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