1 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
fdec60a3
|
Leszek Koltunski
|
// This file is part of Magic Cube. //
|
5 |
0c52af30
|
Leszek Koltunski
|
// //
|
6 |
296219b4
|
Leszek Koltunski
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
1f9772f3
|
Leszek Koltunski
|
package org.distorted.main;
|
11 |
0c52af30
|
Leszek Koltunski
|
|
12 |
b20e89d2
|
Leszek Koltunski
|
import java.io.InputStream;
|
13 |
2afc6754
|
Leszek Koltunski
|
import java.util.Locale;
|
14 |
|
|
|
15 |
b6468abb
|
Leszek Koltunski
|
import android.content.Intent;
|
16 |
33499c56
|
Leszek Koltunski
|
import android.content.SharedPreferences;
|
17 |
4c9947bd
|
Leszek Koltunski
|
import android.content.pm.PackageInfo;
|
18 |
|
|
import android.content.pm.PackageManager;
|
19 |
b1e9596b
|
Leszek Koltunski
|
import android.os.Build;
|
20 |
0c52af30
|
Leszek Koltunski
|
import android.os.Bundle;
|
21 |
b1e9596b
|
Leszek Koltunski
|
import android.os.LocaleList;
|
22 |
33499c56
|
Leszek Koltunski
|
import android.preference.PreferenceManager;
|
23 |
e3c74c0f
|
Leszek Koltunski
|
|
24 |
|
|
import android.util.DisplayMetrics;
|
25 |
fd0b901a
|
Leszek Koltunski
|
import android.view.DisplayCutout;
|
26 |
0254cfd7
|
Leszek Koltunski
|
import android.view.View;
|
27 |
1cb36646
|
Leszek Koltunski
|
import android.view.ViewGroup;
|
28 |
c9556e1e
|
Leszek Koltunski
|
import android.view.WindowManager;
|
29 |
1cb36646
|
Leszek Koltunski
|
import android.widget.LinearLayout;
|
30 |
0c52af30
|
Leszek Koltunski
|
|
31 |
e019c70b
|
Leszek Koltunski
|
import androidx.appcompat.app.AppCompatActivity;
|
32 |
|
|
|
33 |
1b3cbd5b
|
Leszek Koltunski
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
34 |
a59f38d6
|
Leszek Koltunski
|
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
|
35 |
1b3cbd5b
|
Leszek Koltunski
|
|
36 |
1237d25d
|
Leszek Koltunski
|
import org.distorted.config.ConfigActivity;
|
37 |
9530f6b0
|
Leszek Koltunski
|
import org.distorted.bandaged.BandagedCreatorActivity;
|
38 |
45831b78
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogStarsExplain;
|
39 |
3f7a4363
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedLibrary;
|
40 |
|
|
|
41 |
d7f0c07d
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedScreen;
|
42 |
a59f38d6
|
Leszek Koltunski
|
import org.distorted.messaging.RubikInAppMessanging;
|
43 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
44 |
3f7a4363
|
Leszek Koltunski
|
import org.distorted.objectlib.main.TwistyObject;
|
45 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.effects.BaseEffect;
|
46 |
3f7a4363
|
Leszek Koltunski
|
|
47 |
2d9fc972
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogError;
|
48 |
b1e9596b
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogPrivacy;
|
49 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikScores;
|
50 |
|
|
import org.distorted.external.RubikNetwork;
|
51 |
d433b50e
|
Leszek Koltunski
|
import org.distorted.objects.RubikObject;
|
52 |
|
|
import org.distorted.objects.RubikObjectList;
|
53 |
c7238c67
|
Leszek Koltunski
|
import org.distorted.purchase.PurchaseActivity;
|
54 |
2e3488f6
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenSolving;
|
55 |
fcd5b990
|
Leszek Koltunski
|
import org.distorted.screens.ScreenList;
|
56 |
|
|
import org.distorted.screens.RubikScreenPlay;
|
57 |
eaf87d1d
|
Leszek Koltunski
|
import org.distorted.tutorials.TutorialActivity;
|
58 |
211b48f2
|
Leszek Koltunski
|
|
59 |
09cf2a36
|
Leszek Koltunski
|
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
|
60 |
|
|
|
61 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
|
63 |
e019c70b
|
Leszek Koltunski
|
public class RubikActivity extends AppCompatActivity
|
64 |
0c52af30
|
Leszek Koltunski
|
{
|
65 |
a474ccde
|
Leszek Koltunski
|
public static final boolean SHOW_DOWNLOADED_DEBUG = false;
|
66 |
82c02259
|
Leszek Koltunski
|
public static final boolean SHOW_IAP_DEBUG = true;
|
67 |
a01e5cdc
|
Leszek Koltunski
|
public static final boolean USE_IAP = false;
|
68 |
e847c553
|
Leszek Koltunski
|
|
69 |
054fbee1
|
Leszek Koltunski
|
public static final float PADDING = 0.01f;
|
70 |
c651024f
|
Leszek Koltunski
|
public static final float SMALL_MARGIN = 0.004f;
|
71 |
|
|
public static final float MEDIUM_MARGIN = 0.015f;
|
72 |
054fbee1
|
Leszek Koltunski
|
public static final float LARGE_MARGIN = 0.025f;
|
73 |
a88b947f
|
Leszek Koltunski
|
public static final float POPUP_PADDING = 0.045f;
|
74 |
054fbee1
|
Leszek Koltunski
|
public static final float BUTTON_TEXT_SIZE = 0.05f;
|
75 |
|
|
public static final float TITLE_TEXT_SIZE = 0.06f;
|
76 |
7ea57482
|
Leszek Koltunski
|
public static final float SOLVER_BMP_H_SIZE = 0.11f;
|
77 |
|
|
public static final float SOLVER_BMP_V_SIZE = 0.06f;
|
78 |
5de2c572
|
Leszek Koltunski
|
public static final float PATTERN_GROUP_TEXT = 0.03f;
|
79 |
|
|
public static final float PATTERN_CHILD_TEXT = 0.02f;
|
80 |
362807f0
|
Leszek Koltunski
|
public static final float SCORES_LEVEL_TEXT = 0.035f;
|
81 |
|
|
public static final float SCORES_ITEM_TEXT = 0.030f;
|
82 |
ef1f3e34
|
Leszek Koltunski
|
public static final float TUTORIAL_ITEM_TEXT = 0.100f;
|
83 |
eb376d3a
|
Leszek Koltunski
|
public static final float DIALOG_BUTTON_SIZE = 0.06f;
|
84 |
|
|
public static final float MENU_BIG_TEXT_SIZE = 0.05f;
|
85 |
3c27ff9e
|
Leszek Koltunski
|
public static final float MENU_MAIN_TEXT_SIZE = 0.047f;
|
86 |
eb376d3a
|
Leszek Koltunski
|
public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
|
87 |
6e3fcb91
|
Leszek Koltunski
|
public static final float TAB_WIDTH = 0.100f;
|
88 |
|
|
public static final float TAB_HEIGHT = 0.100f;
|
89 |
fad10885
|
Leszek Koltunski
|
public static final float MENU_BUTTON_HEIGHT = 0.115f;
|
90 |
e3c74c0f
|
Leszek Koltunski
|
|
91 |
af7b68e6
|
Leszek Koltunski
|
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
92 |
ffd68f35
|
Leszek Koltunski
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
93 |
|
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
94 |
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
95 |
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
96 |
|
|
|
97 |
1237d25d
|
Leszek Koltunski
|
private static final int ACTIVITY_NUMBER = 0;
|
98 |
598de3ee
|
Leszek Koltunski
|
private static final float RATIO_BAR = 0.10f;
|
99 |
1071fb69
|
Leszek Koltunski
|
private static final float RATIO_INSET= 0.09f;
|
100 |
598de3ee
|
Leszek Koltunski
|
|
101 |
972f9eae
|
Leszek Koltunski
|
private static final String KEY_PLAY = "movesController_play";
|
102 |
|
|
private static final String KEY_SOLV = "movesController_solv";
|
103 |
|
|
|
104 |
c3ffcf58
|
Leszek Koltunski
|
private boolean mJustStarted;
|
105 |
1b3cbd5b
|
Leszek Koltunski
|
private FirebaseAnalytics mFirebaseAnalytics;
|
106 |
f6a9c538
|
Leszek Koltunski
|
private static int mScreenWidth, mScreenHeight;
|
107 |
b1e9596b
|
Leszek Koltunski
|
private boolean mPolicyAccepted, mIsChinese;
|
108 |
0254cfd7
|
Leszek Koltunski
|
private int mCurrentApiVersion;
|
109 |
598de3ee
|
Leszek Koltunski
|
private int mHeightUpperBar, mHeightLowerBar;
|
110 |
e9e744f7
|
Leszek Koltunski
|
private int mOldVersion1, mOldVersion2, mOldVersion3;
|
111 |
d05e7629
|
Leszek Koltunski
|
private String mOldVersion, mCurrVersion;
|
112 |
c3ffcf58
|
Leszek Koltunski
|
|
113 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
|
|
|
115 |
0c52af30
|
Leszek Koltunski
|
@Override
|
116 |
34747dd1
|
Leszek Koltunski
|
protected void onCreate(Bundle savedState)
|
117 |
0c52af30
|
Leszek Koltunski
|
{
|
118 |
34747dd1
|
Leszek Koltunski
|
super.onCreate(savedState);
|
119 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onCreate(ACTIVITY_NUMBER);
|
120 |
d7de3072
|
Leszek Koltunski
|
|
121 |
dd874ae8
|
Leszek Koltunski
|
setTheme(R.style.MaterialThemeNoActionBar);
|
122 |
1cbcc6bf
|
Leszek Koltunski
|
setContentView(R.layout.main);
|
123 |
c3ffcf58
|
Leszek Koltunski
|
|
124 |
|
|
mJustStarted = true;
|
125 |
1b3cbd5b
|
Leszek Koltunski
|
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
126 |
51853bf2
|
Leszek Koltunski
|
mIsChinese = localeIsChinese();
|
127 |
e3c74c0f
|
Leszek Koltunski
|
|
128 |
|
|
DisplayMetrics displaymetrics = new DisplayMetrics();
|
129 |
7fe59aa5
|
Leszek Koltunski
|
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
|
130 |
88fb92ba
|
Leszek Koltunski
|
mScreenWidth =displaymetrics.widthPixels;
|
131 |
|
|
mScreenHeight=displaymetrics.heightPixels;
|
132 |
7fe59aa5
|
Leszek Koltunski
|
|
133 |
0254cfd7
|
Leszek Koltunski
|
hideNavigationBar();
|
134 |
e8f6670f
|
Leszek Koltunski
|
cutoutHack();
|
135 |
598de3ee
|
Leszek Koltunski
|
computeBarHeights();
|
136 |
a59f38d6
|
Leszek Koltunski
|
|
137 |
e9e744f7
|
Leszek Koltunski
|
mCurrVersion = getAppVers();
|
138 |
|
|
|
139 |
83018ac4
|
Leszek Koltunski
|
Thread thread = new Thread()
|
140 |
|
|
{
|
141 |
|
|
public void run()
|
142 |
|
|
{
|
143 |
|
|
RubikInAppMessanging listener = new RubikInAppMessanging();
|
144 |
|
|
FirebaseInAppMessaging.getInstance().addClickListener(listener);
|
145 |
|
|
}
|
146 |
|
|
};
|
147 |
|
|
|
148 |
|
|
thread.start();
|
149 |
0254cfd7
|
Leszek Koltunski
|
}
|
150 |
|
|
|
151 |
598de3ee
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
152 |
|
|
// this does not include possible insets
|
153 |
|
|
|
154 |
|
|
private void computeBarHeights()
|
155 |
|
|
{
|
156 |
7fe59aa5
|
Leszek Koltunski
|
int barHeight = (int)(mScreenHeight*RATIO_BAR);
|
157 |
598de3ee
|
Leszek Koltunski
|
mHeightLowerBar = barHeight;
|
158 |
|
|
mHeightUpperBar = barHeight;
|
159 |
214e301a
|
Leszek Koltunski
|
|
160 |
|
|
LinearLayout layoutTop = findViewById(R.id.upperBar);
|
161 |
|
|
LinearLayout layoutBot = findViewById(R.id.lowerBar);
|
162 |
|
|
|
163 |
|
|
ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams();
|
164 |
|
|
paramsTop.height = mHeightUpperBar;
|
165 |
|
|
layoutTop.setLayoutParams(paramsTop);
|
166 |
|
|
ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams();
|
167 |
|
|
paramsBot.height = mHeightLowerBar;
|
168 |
|
|
layoutBot.setLayoutParams(paramsBot);
|
169 |
598de3ee
|
Leszek Koltunski
|
}
|
170 |
|
|
|
171 |
0254cfd7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172 |
|
|
|
173 |
|
|
private void hideNavigationBar()
|
174 |
|
|
{
|
175 |
c9556e1e
|
Leszek Koltunski
|
mCurrentApiVersion = Build.VERSION.SDK_INT;
|
176 |
0254cfd7
|
Leszek Koltunski
|
|
177 |
|
|
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT)
|
178 |
|
|
{
|
179 |
|
|
final View decorView = getWindow().getDecorView();
|
180 |
|
|
|
181 |
c9556e1e
|
Leszek Koltunski
|
decorView.setSystemUiVisibility(FLAGS);
|
182 |
|
|
|
183 |
0254cfd7
|
Leszek Koltunski
|
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
|
184 |
|
|
{
|
185 |
|
|
@Override
|
186 |
|
|
public void onSystemUiVisibilityChange(int visibility)
|
187 |
|
|
{
|
188 |
|
|
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
|
189 |
|
|
{
|
190 |
ffd68f35
|
Leszek Koltunski
|
decorView.setSystemUiVisibility(FLAGS);
|
191 |
0254cfd7
|
Leszek Koltunski
|
}
|
192 |
|
|
}
|
193 |
|
|
});
|
194 |
|
|
}
|
195 |
|
|
}
|
196 |
|
|
|
197 |
1cb36646
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
198 |
|
|
|
199 |
|
|
@Override
|
200 |
|
|
public void onAttachedToWindow()
|
201 |
|
|
{
|
202 |
fd0b901a
|
Leszek Koltunski
|
super.onAttachedToWindow();
|
203 |
|
|
|
204 |
e8f6670f
|
Leszek Koltunski
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
205 |
|
|
{
|
206 |
|
|
DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
|
207 |
|
|
int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
|
208 |
|
|
|
209 |
|
|
LinearLayout layoutHid = findViewById(R.id.hiddenBar);
|
210 |
|
|
ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams();
|
211 |
598de3ee
|
Leszek Koltunski
|
paramsHid.height = (int)(insetHeight*RATIO_INSET);
|
212 |
e8f6670f
|
Leszek Koltunski
|
layoutHid.setLayoutParams(paramsHid);
|
213 |
598de3ee
|
Leszek Koltunski
|
mHeightUpperBar += paramsHid.height;
|
214 |
e8f6670f
|
Leszek Koltunski
|
}
|
215 |
1cb36646
|
Leszek Koltunski
|
}
|
216 |
|
|
|
217 |
0254cfd7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218 |
e8f6670f
|
Leszek Koltunski
|
// do not avoid cutouts
|
219 |
c9556e1e
|
Leszek Koltunski
|
|
220 |
e8f6670f
|
Leszek Koltunski
|
private void cutoutHack()
|
221 |
c9556e1e
|
Leszek Koltunski
|
{
|
222 |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
223 |
|
|
{
|
224 |
|
|
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
225 |
|
|
}
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
229 |
0254cfd7
|
Leszek Koltunski
|
|
230 |
|
|
@Override
|
231 |
|
|
public void onWindowFocusChanged(boolean hasFocus)
|
232 |
|
|
{
|
233 |
|
|
super.onWindowFocusChanged(hasFocus);
|
234 |
|
|
|
235 |
|
|
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus)
|
236 |
|
|
{
|
237 |
ffd68f35
|
Leszek Koltunski
|
getWindow().getDecorView().setSystemUiVisibility(FLAGS);
|
238 |
0254cfd7
|
Leszek Koltunski
|
}
|
239 |
|
|
}
|
240 |
|
|
|
241 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
242 |
|
|
|
243 |
|
|
@Override
|
244 |
|
|
protected void onPause()
|
245 |
|
|
{
|
246 |
82f42eeb
|
Leszek Koltunski
|
super.onPause();
|
247 |
4235de9b
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
248 |
0c52af30
|
Leszek Koltunski
|
view.onPause();
|
249 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onPause(ACTIVITY_NUMBER);
|
250 |
6a083c6a
|
Leszek Koltunski
|
RubikNetwork.onPause();
|
251 |
33499c56
|
Leszek Koltunski
|
savePreferences();
|
252 |
0c52af30
|
Leszek Koltunski
|
}
|
253 |
|
|
|
254 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
255 |
|
|
|
256 |
|
|
@Override
|
257 |
|
|
protected void onResume()
|
258 |
|
|
{
|
259 |
|
|
super.onResume();
|
260 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onResume(ACTIVITY_NUMBER);
|
261 |
4235de9b
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
262 |
0c52af30
|
Leszek Koltunski
|
view.onResume();
|
263 |
51853bf2
|
Leszek Koltunski
|
|
264 |
6142069a
|
Leszek Koltunski
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
265 |
|
|
restorePreferences(preferences,mJustStarted);
|
266 |
f5da732a
|
Leszek Koltunski
|
ScreenList.setScreen(this);
|
267 |
8badfe2a
|
Leszek Koltunski
|
unblockEverything();
|
268 |
6142069a
|
Leszek Koltunski
|
restoreMoves(preferences);
|
269 |
2e3488f6
|
Leszek Koltunski
|
|
270 |
c3ffcf58
|
Leszek Koltunski
|
if( mJustStarted )
|
271 |
|
|
{
|
272 |
|
|
mJustStarted = false;
|
273 |
82ce8e64
|
Leszek Koltunski
|
RubikScores scores = RubikScores.getInstance();
|
274 |
|
|
scores.incrementNumRuns();
|
275 |
|
|
scores.setCountry(this);
|
276 |
f12e4de9
|
Leszek Koltunski
|
RubikObjectList.restoreMeshState(preferences);
|
277 |
c3ffcf58
|
Leszek Koltunski
|
}
|
278 |
|
|
|
279 |
400ff34d
|
Leszek Koltunski
|
int object = RubikObjectList.getCurrObject();
|
280 |
b20e89d2
|
Leszek Koltunski
|
changeIfDifferent(object,view.getObjectControl());
|
281 |
51853bf2
|
Leszek Koltunski
|
|
282 |
d05e7629
|
Leszek Koltunski
|
if( mIsChinese && !mPolicyAccepted ) privacyPolicy();
|
283 |
|
|
|
284 |
a01e5cdc
|
Leszek Koltunski
|
if( USE_IAP )
|
285 |
d05e7629
|
Leszek Koltunski
|
{
|
286 |
a01e5cdc
|
Leszek Koltunski
|
if( mOldVersion!=null && !mOldVersion.equals("") && oldVersionLessThan(1,11,5) && !mCurrVersion.equals("1.11.4") )
|
287 |
|
|
{
|
288 |
|
|
explainStars();
|
289 |
|
|
}
|
290 |
|
|
else
|
291 |
|
|
{
|
292 |
|
|
view.setShowStars();
|
293 |
|
|
}
|
294 |
d05e7629
|
Leszek Koltunski
|
}
|
295 |
0c52af30
|
Leszek Koltunski
|
}
|
296 |
d05e7629
|
Leszek Koltunski
|
|
297 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
298 |
|
|
|
299 |
|
|
private void privacyPolicy()
|
300 |
|
|
{
|
301 |
|
|
RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
|
302 |
|
|
priDiag.show(getSupportFragmentManager(), null);
|
303 |
|
|
}
|
304 |
|
|
|
305 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
306 |
|
|
|
307 |
|
|
private void explainStars()
|
308 |
|
|
{
|
309 |
45831b78
|
Leszek Koltunski
|
RubikDialogStarsExplain staDiag = new RubikDialogStarsExplain();
|
310 |
d05e7629
|
Leszek Koltunski
|
staDiag.show(getSupportFragmentManager(), null);
|
311 |
|
|
}
|
312 |
|
|
|
313 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
314 |
|
|
|
315 |
|
|
@Override
|
316 |
|
|
protected void onDestroy()
|
317 |
|
|
{
|
318 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onDestroy(ACTIVITY_NUMBER);
|
319 |
0c52af30
|
Leszek Koltunski
|
super.onDestroy();
|
320 |
|
|
}
|
321 |
|
|
|
322 |
4c9947bd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323 |
|
|
|
324 |
b20e89d2
|
Leszek Koltunski
|
private String getAppVers()
|
325 |
4c9947bd
|
Leszek Koltunski
|
{
|
326 |
b20e89d2
|
Leszek Koltunski
|
try
|
327 |
|
|
{
|
328 |
|
|
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
|
329 |
|
|
return pInfo.versionName;
|
330 |
|
|
}
|
331 |
|
|
catch (PackageManager.NameNotFoundException e)
|
332 |
|
|
{
|
333 |
|
|
return "unknown";
|
334 |
|
|
}
|
335 |
4c9947bd
|
Leszek Koltunski
|
}
|
336 |
|
|
|
337 |
33499c56
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338 |
|
|
|
339 |
|
|
private void savePreferences()
|
340 |
|
|
{
|
341 |
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
342 |
|
|
SharedPreferences.Editor editor = preferences.edit();
|
343 |
|
|
|
344 |
b1e9596b
|
Leszek Koltunski
|
editor.putBoolean("policyAccepted", mPolicyAccepted);
|
345 |
e9e744f7
|
Leszek Koltunski
|
editor.putString("appVersion", mCurrVersion );
|
346 |
b1e9596b
|
Leszek Koltunski
|
|
347 |
211b48f2
|
Leszek Koltunski
|
for (int i=0; i<BaseEffect.Type.LENGTH; i++)
|
348 |
33499c56
|
Leszek Koltunski
|
{
|
349 |
|
|
BaseEffect.Type.getType(i).savePreferences(editor);
|
350 |
|
|
}
|
351 |
|
|
|
352 |
fcd5b990
|
Leszek Koltunski
|
for (int i = 0; i< ScreenList.LENGTH; i++)
|
353 |
211b48f2
|
Leszek Koltunski
|
{
|
354 |
f5da732a
|
Leszek Koltunski
|
ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
|
355 |
211b48f2
|
Leszek Koltunski
|
}
|
356 |
33499c56
|
Leszek Koltunski
|
|
357 |
400ff34d
|
Leszek Koltunski
|
RubikObjectList.savePreferences(editor);
|
358 |
f12e4de9
|
Leszek Koltunski
|
RubikObjectList.saveMeshState(editor);
|
359 |
fcd5b990
|
Leszek Koltunski
|
ScreenList.savePreferences(editor);
|
360 |
0333d81e
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
361 |
2afc6754
|
Leszek Koltunski
|
view.getObjectControl().savePreferences(editor);
|
362 |
0333d81e
|
Leszek Koltunski
|
|
363 |
2e3488f6
|
Leszek Koltunski
|
ScreenList curr = ScreenList.getCurrentScreen();
|
364 |
|
|
|
365 |
|
|
if( curr==ScreenList.PLAY )
|
366 |
|
|
{
|
367 |
|
|
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
368 |
972f9eae
|
Leszek Koltunski
|
play.saveMovePreferences(KEY_PLAY,editor);
|
369 |
2e3488f6
|
Leszek Koltunski
|
}
|
370 |
|
|
if( curr==ScreenList.SOLV )
|
371 |
|
|
{
|
372 |
|
|
RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
|
373 |
972f9eae
|
Leszek Koltunski
|
solv.saveMovePreferences(KEY_SOLV,editor);
|
374 |
2e3488f6
|
Leszek Koltunski
|
}
|
375 |
|
|
|
376 |
7480fbab
|
Leszek Koltunski
|
boolean success = editor.commit();
|
377 |
|
|
if( !success ) android.util.Log.e("D", "Failed to save preferences");
|
378 |
33499c56
|
Leszek Koltunski
|
}
|
379 |
|
|
|
380 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
381 |
|
|
|
382 |
6142069a
|
Leszek Koltunski
|
private void restorePreferences(SharedPreferences preferences, boolean justStarted)
|
383 |
33499c56
|
Leszek Koltunski
|
{
|
384 |
b1e9596b
|
Leszek Koltunski
|
mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
|
385 |
d05e7629
|
Leszek Koltunski
|
mOldVersion = preferences.getString("appVersion","");
|
386 |
|
|
parseOldVersion(mOldVersion);
|
387 |
b1e9596b
|
Leszek Koltunski
|
|
388 |
7480fbab
|
Leszek Koltunski
|
RubikObjectList.restorePreferences(this,preferences,justStarted);
|
389 |
526a5906
|
Leszek Koltunski
|
|
390 |
03423c67
|
Leszek Koltunski
|
for (int i=0; i<BaseEffect.Type.LENGTH; i++)
|
391 |
4235de9b
|
Leszek Koltunski
|
{
|
392 |
33499c56
|
Leszek Koltunski
|
BaseEffect.Type.getType(i).restorePreferences(preferences);
|
393 |
4235de9b
|
Leszek Koltunski
|
}
|
394 |
33499c56
|
Leszek Koltunski
|
|
395 |
03423c67
|
Leszek Koltunski
|
for (int i=0; i<ScreenList.LENGTH; i++)
|
396 |
211b48f2
|
Leszek Koltunski
|
{
|
397 |
f5da732a
|
Leszek Koltunski
|
ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
|
398 |
211b48f2
|
Leszek Koltunski
|
}
|
399 |
33499c56
|
Leszek Koltunski
|
|
400 |
e9e744f7
|
Leszek Koltunski
|
RubikScores scores = RubikScores.getInstance();
|
401 |
|
|
|
402 |
|
|
if( scores.isVerified() )
|
403 |
|
|
{
|
404 |
|
|
FirebaseAnalytics analytics = getAnalytics();
|
405 |
|
|
analytics.setUserId(scores.getName());
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
// all old users upgrading from version <1.11.4, where there was no concept of 'stars',
|
409 |
|
|
// get all the stars they have earned
|
410 |
|
|
int numStars = scores.getNumStars();
|
411 |
|
|
|
412 |
|
|
if( justStarted && numStars==0 && oldVersionLessThan(1,11,4) )
|
413 |
|
|
{
|
414 |
|
|
scores.correctNumStars();
|
415 |
|
|
}
|
416 |
|
|
|
417 |
|
|
// in 1.11.5 we have introduced IAP. When upgrading from something less than 1.11.5 to
|
418 |
|
|
// something at least 1.11.5, mark all solved objects as free.
|
419 |
|
|
// this needs to be after the above ScreenList.getScreen(i).getScreenClass().restorePreferences()
|
420 |
|
|
// as that restores the Records which we need here
|
421 |
|
|
// also needs to be after RubikObjectList.restorePreferences()
|
422 |
|
|
if( USE_IAP && justStarted && oldVersionLessThan(1,11,5) && !mCurrVersion.equals("1.11.4") )
|
423 |
|
|
{
|
424 |
|
|
RubikObjectList.firstUpgradeMarkAllSolvedAsFree();
|
425 |
|
|
}
|
426 |
6142069a
|
Leszek Koltunski
|
|
427 |
fcd5b990
|
Leszek Koltunski
|
ScreenList.restorePreferences(preferences);
|
428 |
4c9947bd
|
Leszek Koltunski
|
|
429 |
|
|
// Versions <= 1.8.6 did not save their 'appVersion' to preferences, therefore in their
|
430 |
|
|
// case the 'mOldVersion' - version of the app which saved the preferences on the last
|
431 |
|
|
// go - is empty.
|
432 |
|
|
// Between versions 1.8.6 and 1.9.0, the order of the cubits in TwistyCube has changed.
|
433 |
|
|
// If someone has scrambled the cube with v. 1.8.6, then upgraded to 1.9.0 and re-started
|
434 |
|
|
// the app, because of the different order of the cubits - his cube would be messed up.
|
435 |
|
|
// So in such case, i.e. on fresh upgrade from version<=1.8.6 to version>=1.9.0, do not
|
436 |
|
|
// restore the object scrambling.
|
437 |
|
|
|
438 |
d05e7629
|
Leszek Koltunski
|
if( !mOldVersion.equals("") )
|
439 |
4c9947bd
|
Leszek Koltunski
|
{
|
440 |
e9e744f7
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
441 |
4c9947bd
|
Leszek Koltunski
|
view.getObjectControl().restorePreferences(preferences);
|
442 |
|
|
}
|
443 |
e9e744f7
|
Leszek Koltunski
|
}
|
444 |
ee4e7896
|
Leszek Koltunski
|
|
445 |
e9e744f7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
446 |
ee4e7896
|
Leszek Koltunski
|
|
447 |
d05e7629
|
Leszek Koltunski
|
private void parseOldVersion(String version)
|
448 |
e9e744f7
|
Leszek Koltunski
|
{
|
449 |
|
|
if( version==null ) return;
|
450 |
00fcfefa
|
Leszek Koltunski
|
|
451 |
e9e744f7
|
Leszek Koltunski
|
try
|
452 |
|
|
{
|
453 |
|
|
String[] parts = version.split("\\.");
|
454 |
00fcfefa
|
Leszek Koltunski
|
|
455 |
e9e744f7
|
Leszek Koltunski
|
if( parts.length==3 )
|
456 |
|
|
{
|
457 |
|
|
mOldVersion1 = Integer.parseInt(parts[0]);
|
458 |
|
|
mOldVersion2 = Integer.parseInt(parts[1]);
|
459 |
|
|
mOldVersion3 = Integer.parseInt(parts[2]);
|
460 |
|
|
}
|
461 |
|
|
}
|
462 |
|
|
catch(Exception ignored)
|
463 |
00fcfefa
|
Leszek Koltunski
|
{
|
464 |
e9e744f7
|
Leszek Koltunski
|
mOldVersion1 = 0;
|
465 |
|
|
mOldVersion2 = 0;
|
466 |
|
|
mOldVersion3 = 0;
|
467 |
00fcfefa
|
Leszek Koltunski
|
}
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
471 |
|
|
|
472 |
e9e744f7
|
Leszek Koltunski
|
private boolean oldVersionLessThan(int v1, int v2, int v3)
|
473 |
00fcfefa
|
Leszek Koltunski
|
{
|
474 |
e9e744f7
|
Leszek Koltunski
|
if( mOldVersion1<v1 ) return true;
|
475 |
|
|
if( mOldVersion1>v1 ) return false;
|
476 |
|
|
if( mOldVersion2<v2 ) return true;
|
477 |
|
|
if( mOldVersion2>v2 ) return false;
|
478 |
|
|
return mOldVersion3<v3;
|
479 |
f3e12931
|
Leszek Koltunski
|
}
|
480 |
|
|
|
481 |
2e3488f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
482 |
|
|
|
483 |
6142069a
|
Leszek Koltunski
|
private void restoreMoves(SharedPreferences preferences)
|
484 |
2e3488f6
|
Leszek Koltunski
|
{
|
485 |
|
|
ScreenList curr = ScreenList.getCurrentScreen();
|
486 |
|
|
|
487 |
|
|
if( curr==ScreenList.PLAY )
|
488 |
|
|
{
|
489 |
|
|
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
490 |
972f9eae
|
Leszek Koltunski
|
play.restoreMovePreferences(this,KEY_PLAY,preferences);
|
491 |
2e3488f6
|
Leszek Koltunski
|
}
|
492 |
|
|
if( curr==ScreenList.SOLV )
|
493 |
|
|
{
|
494 |
|
|
RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
|
495 |
972f9eae
|
Leszek Koltunski
|
solv.restoreMovePreferences(this,KEY_SOLV,preferences);
|
496 |
2e3488f6
|
Leszek Koltunski
|
}
|
497 |
|
|
}
|
498 |
|
|
|
499 |
2d9fc972
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
500 |
|
|
|
501 |
e7e0a94d
|
Leszek Koltunski
|
void OpenGLError()
|
502 |
2d9fc972
|
Leszek Koltunski
|
{
|
503 |
|
|
RubikDialogError errDiag = new RubikDialogError();
|
504 |
|
|
errDiag.show(getSupportFragmentManager(), null);
|
505 |
|
|
}
|
506 |
|
|
|
507 |
34747dd1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
508 |
47ba5ddc
|
Leszek Koltunski
|
// PUBLIC API
|
509 |
1b3cbd5b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
510 |
|
|
|
511 |
|
|
public FirebaseAnalytics getAnalytics()
|
512 |
|
|
{
|
513 |
|
|
return mFirebaseAnalytics;
|
514 |
|
|
}
|
515 |
|
|
|
516 |
598de3ee
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
517 |
|
|
|
518 |
|
|
public int getHeightUpperBar()
|
519 |
|
|
{
|
520 |
|
|
return mHeightUpperBar;
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
524 |
|
|
|
525 |
|
|
public int getHeightLowerBar()
|
526 |
|
|
{
|
527 |
|
|
return mHeightLowerBar;
|
528 |
|
|
}
|
529 |
|
|
|
530 |
a6d3b158
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
531 |
|
|
|
532 |
9c2f0c91
|
Leszek Koltunski
|
public TwistyObject getObject()
|
533 |
aa171dee
|
Leszek Koltunski
|
{
|
534 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
535 |
2afc6754
|
Leszek Koltunski
|
return view.getObjectControl().getObject();
|
536 |
8becce57
|
Leszek Koltunski
|
}
|
537 |
|
|
|
538 |
d7f0c07d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
539 |
|
|
|
540 |
|
|
public DistortedScreen getScreen()
|
541 |
|
|
{
|
542 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
543 |
|
|
return view.getRenderer().getScreen();
|
544 |
|
|
}
|
545 |
|
|
|
546 |
f8eece7d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
547 |
|
|
|
548 |
2afc6754
|
Leszek Koltunski
|
public ObjectControl getControl()
|
549 |
f8eece7d
|
Leszek Koltunski
|
{
|
550 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
551 |
2afc6754
|
Leszek Koltunski
|
return view.getObjectControl();
|
552 |
f8eece7d
|
Leszek Koltunski
|
}
|
553 |
|
|
|
554 |
8becce57
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
555 |
|
|
|
556 |
8ba7aeb1
|
Leszek Koltunski
|
public int getScreenWidthInPixels()
|
557 |
8becce57
|
Leszek Koltunski
|
{
|
558 |
8ba7aeb1
|
Leszek Koltunski
|
return mScreenWidth;
|
559 |
|
|
}
|
560 |
|
|
|
561 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
562 |
|
|
|
563 |
|
|
public int getScreenHeightInPixels()
|
564 |
|
|
{
|
565 |
|
|
return mScreenHeight;
|
566 |
aa171dee
|
Leszek Koltunski
|
}
|
567 |
|
|
|
568 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
569 |
|
|
|
570 |
d433b50e
|
Leszek Koltunski
|
public void changeObject(int newObject, boolean reportChange)
|
571 |
769d7b9f
|
Leszek Koltunski
|
{
|
572 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
573 |
2afc6754
|
Leszek Koltunski
|
ObjectControl control = view.getObjectControl();
|
574 |
b20e89d2
|
Leszek Koltunski
|
TwistyObject oldObject = control.getObject();
|
575 |
|
|
changeIfDifferent(newObject,control);
|
576 |
7eae2d49
|
Leszek Koltunski
|
|
577 |
b20e89d2
|
Leszek Koltunski
|
if( reportChange && oldObject!=null )
|
578 |
7eae2d49
|
Leszek Koltunski
|
{
|
579 |
d433b50e
|
Leszek Koltunski
|
RubikObject robject = RubikObjectList.getObject(newObject);
|
580 |
84d746d7
|
Leszek Koltunski
|
String newName = robject==null ? "NULL" : robject.getUpperName();
|
581 |
b20e89d2
|
Leszek Koltunski
|
float fps = view.getRenderer().getFPS();
|
582 |
|
|
fps = (int)(fps+0.5f);
|
583 |
|
|
StringBuilder name = new StringBuilder();
|
584 |
|
|
name.append(oldObject.getShortName());
|
585 |
|
|
name.append(' ');
|
586 |
|
|
name.append(fps);
|
587 |
|
|
name.append(" --> ");
|
588 |
d433b50e
|
Leszek Koltunski
|
name.append(newName);
|
589 |
b20e89d2
|
Leszek Koltunski
|
|
590 |
|
|
if( BuildConfig.DEBUG )
|
591 |
03822c33
|
Leszek Koltunski
|
{
|
592 |
b20e89d2
|
Leszek Koltunski
|
android.util.Log.e("rubik", name.toString());
|
593 |
|
|
}
|
594 |
|
|
else
|
595 |
|
|
{
|
596 |
|
|
FirebaseAnalytics analytics = getAnalytics();
|
597 |
03822c33
|
Leszek Koltunski
|
|
598 |
b20e89d2
|
Leszek Koltunski
|
if( analytics!=null )
|
599 |
|
|
{
|
600 |
|
|
Bundle bundle = new Bundle();
|
601 |
|
|
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
|
602 |
|
|
analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
|
603 |
7eae2d49
|
Leszek Koltunski
|
}
|
604 |
|
|
}
|
605 |
|
|
}
|
606 |
b20e89d2
|
Leszek Koltunski
|
}
|
607 |
|
|
|
608 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
609 |
7eae2d49
|
Leszek Koltunski
|
|
610 |
d433b50e
|
Leszek Koltunski
|
public void changeIfDifferent(int ordinal, ObjectControl control)
|
611 |
b20e89d2
|
Leszek Koltunski
|
{
|
612 |
09cf2a36
|
Leszek Koltunski
|
RubikObject object = RubikObjectList.getObject(ordinal);
|
613 |
|
|
int meshState = object!=null ? object.getMeshState() : MESH_NICE;
|
614 |
7cb8d4b0
|
Leszek Koltunski
|
int iconMode = TwistyObject.MODE_NORM;
|
615 |
314e9ff0
|
Leszek Koltunski
|
InputStream jsonStream = object==null ? null : object.getObjectStream(this);
|
616 |
|
|
InputStream meshStream = object==null ? null : object.getMeshStream(this);
|
617 |
aec421fd
|
Leszek Koltunski
|
String name = object==null ? "NULL" : object.getUpperName();
|
618 |
09cf2a36
|
Leszek Koltunski
|
|
619 |
7cb8d4b0
|
Leszek Koltunski
|
control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
|
620 |
2e8ec627
|
Leszek Koltunski
|
}
|
621 |
|
|
|
622 |
f6a9c538
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
623 |
|
|
|
624 |
|
|
public static int getDrawableSize()
|
625 |
|
|
{
|
626 |
|
|
if( mScreenHeight<1000 )
|
627 |
|
|
{
|
628 |
|
|
return 0;
|
629 |
|
|
}
|
630 |
|
|
if( mScreenHeight<1600 )
|
631 |
|
|
{
|
632 |
|
|
return 1;
|
633 |
|
|
}
|
634 |
31a9f38d
|
Leszek Koltunski
|
if( mScreenHeight<1900 )
|
635 |
|
|
{
|
636 |
|
|
return 2;
|
637 |
|
|
}
|
638 |
f6a9c538
|
Leszek Koltunski
|
|
639 |
31a9f38d
|
Leszek Koltunski
|
return 3;
|
640 |
f6a9c538
|
Leszek Koltunski
|
}
|
641 |
|
|
|
642 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
643 |
|
|
|
644 |
31a9f38d
|
Leszek Koltunski
|
public static int getDrawable(int small, int medium, int big, int huge)
|
645 |
f6a9c538
|
Leszek Koltunski
|
{
|
646 |
|
|
int size = getDrawableSize();
|
647 |
|
|
|
648 |
|
|
switch(size)
|
649 |
|
|
{
|
650 |
|
|
case 0 : return small;
|
651 |
|
|
case 1 : return medium;
|
652 |
31a9f38d
|
Leszek Koltunski
|
case 2 : return big;
|
653 |
|
|
default: return huge;
|
654 |
f6a9c538
|
Leszek Koltunski
|
}
|
655 |
|
|
}
|
656 |
|
|
|
657 |
b1e9596b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
658 |
|
|
|
659 |
|
|
public void acceptPrivacy()
|
660 |
|
|
{
|
661 |
|
|
mPolicyAccepted = true;
|
662 |
|
|
}
|
663 |
|
|
|
664 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
665 |
|
|
|
666 |
|
|
public void declinePrivacy()
|
667 |
|
|
{
|
668 |
|
|
finish();
|
669 |
|
|
}
|
670 |
|
|
|
671 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
672 |
|
|
|
673 |
|
|
public static boolean localeIsChinese()
|
674 |
|
|
{
|
675 |
|
|
String language;
|
676 |
|
|
|
677 |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
678 |
|
|
{
|
679 |
|
|
language= LocaleList.getDefault().get(0).getLanguage();
|
680 |
|
|
}
|
681 |
|
|
else
|
682 |
|
|
{
|
683 |
|
|
language= Locale.getDefault().getLanguage();
|
684 |
|
|
}
|
685 |
|
|
|
686 |
|
|
return language.equals("zh");
|
687 |
|
|
}
|
688 |
|
|
|
689 |
769d7b9f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
690 |
|
|
|
691 |
|
|
public boolean isVertical()
|
692 |
|
|
{
|
693 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
694 |
|
|
return view.isVertical();
|
695 |
|
|
}
|
696 |
46405bb4
|
Leszek Koltunski
|
|
697 |
f5da732a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
698 |
|
|
|
699 |
809c3432
|
Leszek Koltunski
|
public void blockEverything(int place)
|
700 |
f5da732a
|
Leszek Koltunski
|
{
|
701 |
2afc6754
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
702 |
|
|
ObjectControl control = view.getObjectControl();
|
703 |
|
|
control.blockEverything(place);
|
704 |
8badfe2a
|
Leszek Koltunski
|
|
705 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
706 |
|
|
play.setLockState(this);
|
707 |
f5da732a
|
Leszek Koltunski
|
}
|
708 |
|
|
|
709 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
710 |
|
|
|
711 |
|
|
public void unblockEverything()
|
712 |
|
|
{
|
713 |
2afc6754
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
714 |
|
|
ObjectControl control = view.getObjectControl();
|
715 |
|
|
control.unblockEverything();
|
716 |
8badfe2a
|
Leszek Koltunski
|
|
717 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
718 |
|
|
play.setLockState(this);
|
719 |
f5da732a
|
Leszek Koltunski
|
}
|
720 |
|
|
|
721 |
b6468abb
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
722 |
|
|
|
723 |
d433b50e
|
Leszek Koltunski
|
public void switchTutorial(String url, int objectOrdinal)
|
724 |
b6468abb
|
Leszek Koltunski
|
{
|
725 |
9530f6b0
|
Leszek Koltunski
|
Intent intent = new Intent(this, TutorialActivity.class);
|
726 |
|
|
intent.putExtra("url", url);
|
727 |
|
|
intent.putExtra("obj", objectOrdinal);
|
728 |
|
|
startActivity(intent);
|
729 |
b6468abb
|
Leszek Koltunski
|
}
|
730 |
1237d25d
|
Leszek Koltunski
|
|
731 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
732 |
|
|
|
733 |
d433b50e
|
Leszek Koltunski
|
public void switchConfig(int objectOrdinal)
|
734 |
1237d25d
|
Leszek Koltunski
|
{
|
735 |
9530f6b0
|
Leszek Koltunski
|
Intent intent = new Intent(this, ConfigActivity.class);
|
736 |
|
|
intent.putExtra("obj", objectOrdinal);
|
737 |
|
|
startActivity(intent);
|
738 |
|
|
}
|
739 |
|
|
|
740 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
741 |
|
|
|
742 |
|
|
public void switchToBandagedCreator()
|
743 |
|
|
{
|
744 |
|
|
Intent intent = new Intent(this, BandagedCreatorActivity.class);
|
745 |
|
|
startActivity(intent);
|
746 |
1237d25d
|
Leszek Koltunski
|
}
|
747 |
41a5dd89
|
Leszek Koltunski
|
|
748 |
c7238c67
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
749 |
|
|
|
750 |
|
|
public void switchToPurchase(int objectOrdinal)
|
751 |
|
|
{
|
752 |
|
|
Intent intent = new Intent(this, PurchaseActivity.class);
|
753 |
|
|
intent.putExtra("obj", objectOrdinal);
|
754 |
|
|
startActivity(intent);
|
755 |
|
|
}
|
756 |
|
|
|
757 |
41a5dd89
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
758 |
|
|
|
759 |
|
|
public void reloadObject(String shortName)
|
760 |
|
|
{
|
761 |
|
|
TwistyObject currObject = getObject();
|
762 |
03423c67
|
Leszek Koltunski
|
String name = currObject==null ? "" : currObject.getShortName();
|
763 |
41a5dd89
|
Leszek Koltunski
|
|
764 |
5e048300
|
Leszek Koltunski
|
if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
|
765 |
41a5dd89
|
Leszek Koltunski
|
{
|
766 |
|
|
RubikObject object = RubikObjectList.getObject(name);
|
767 |
|
|
|
768 |
|
|
if( object!=null )
|
769 |
|
|
{
|
770 |
|
|
int meshState = object.getMeshState();
|
771 |
|
|
int iconMode = TwistyObject.MODE_NORM;
|
772 |
|
|
InputStream jsonStream = object.getObjectStream(this);
|
773 |
|
|
InputStream meshStream = object.getMeshStream(this);
|
774 |
|
|
ObjectControl control = getControl();
|
775 |
|
|
control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
|
776 |
|
|
}
|
777 |
|
|
}
|
778 |
|
|
}
|
779 |
0c52af30
|
Leszek Koltunski
|
}
|