| 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 |
3f7a4363
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedLibrary;
|
| 39 |
|
|
|
| 40 |
d7f0c07d
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedScreen;
|
| 41 |
a59f38d6
|
Leszek Koltunski
|
import org.distorted.messaging.RubikInAppMessanging;
|
| 42 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectControl;
|
| 43 |
3f7a4363
|
Leszek Koltunski
|
import org.distorted.objectlib.main.TwistyObject;
|
| 44 |
2afc6754
|
Leszek Koltunski
|
import org.distorted.objectlib.effects.BaseEffect;
|
| 45 |
3f7a4363
|
Leszek Koltunski
|
|
| 46 |
2d9fc972
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogError;
|
| 47 |
b1e9596b
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogPrivacy;
|
| 48 |
acabdd83
|
Leszek Koltunski
|
import org.distorted.external.RubikScores;
|
| 49 |
|
|
import org.distorted.external.RubikNetwork;
|
| 50 |
d433b50e
|
Leszek Koltunski
|
import org.distorted.objects.RubikObject;
|
| 51 |
|
|
import org.distorted.objects.RubikObjectList;
|
| 52 |
c7238c67
|
Leszek Koltunski
|
import org.distorted.purchase.PurchaseActivity;
|
| 53 |
2e3488f6
|
Leszek Koltunski
|
import org.distorted.screens.RubikScreenSolving;
|
| 54 |
fcd5b990
|
Leszek Koltunski
|
import org.distorted.screens.ScreenList;
|
| 55 |
|
|
import org.distorted.screens.RubikScreenPlay;
|
| 56 |
eaf87d1d
|
Leszek Koltunski
|
import org.distorted.tutorials.TutorialActivity;
|
| 57 |
211b48f2
|
Leszek Koltunski
|
|
| 58 |
09cf2a36
|
Leszek Koltunski
|
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
|
| 59 |
|
|
|
| 60 |
0c52af30
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 61 |
|
|
|
| 62 |
e019c70b
|
Leszek Koltunski
|
public class RubikActivity extends AppCompatActivity
|
| 63 |
0c52af30
|
Leszek Koltunski
|
{
|
| 64 |
a474ccde
|
Leszek Koltunski
|
public static final boolean SHOW_DOWNLOADED_DEBUG = false;
|
| 65 |
6142069a
|
Leszek Koltunski
|
public static final boolean SHOW_SOLVED_DEBUG = true;
|
| 66 |
e847c553
|
Leszek Koltunski
|
|
| 67 |
054fbee1
|
Leszek Koltunski
|
public static final float PADDING = 0.01f;
|
| 68 |
c651024f
|
Leszek Koltunski
|
public static final float SMALL_MARGIN = 0.004f;
|
| 69 |
|
|
public static final float MEDIUM_MARGIN = 0.015f;
|
| 70 |
054fbee1
|
Leszek Koltunski
|
public static final float LARGE_MARGIN = 0.025f;
|
| 71 |
a88b947f
|
Leszek Koltunski
|
public static final float POPUP_PADDING = 0.045f;
|
| 72 |
054fbee1
|
Leszek Koltunski
|
public static final float BUTTON_TEXT_SIZE = 0.05f;
|
| 73 |
|
|
public static final float TITLE_TEXT_SIZE = 0.06f;
|
| 74 |
7ea57482
|
Leszek Koltunski
|
public static final float SOLVER_BMP_H_SIZE = 0.11f;
|
| 75 |
|
|
public static final float SOLVER_BMP_V_SIZE = 0.06f;
|
| 76 |
5de2c572
|
Leszek Koltunski
|
public static final float PATTERN_GROUP_TEXT = 0.03f;
|
| 77 |
|
|
public static final float PATTERN_CHILD_TEXT = 0.02f;
|
| 78 |
362807f0
|
Leszek Koltunski
|
public static final float SCORES_LEVEL_TEXT = 0.035f;
|
| 79 |
|
|
public static final float SCORES_ITEM_TEXT = 0.030f;
|
| 80 |
ef1f3e34
|
Leszek Koltunski
|
public static final float TUTORIAL_ITEM_TEXT = 0.100f;
|
| 81 |
eb376d3a
|
Leszek Koltunski
|
public static final float DIALOG_BUTTON_SIZE = 0.06f;
|
| 82 |
|
|
public static final float MENU_BIG_TEXT_SIZE = 0.05f;
|
| 83 |
3c27ff9e
|
Leszek Koltunski
|
public static final float MENU_MAIN_TEXT_SIZE = 0.047f;
|
| 84 |
eb376d3a
|
Leszek Koltunski
|
public static final float MENU_MED_TEXT_SIZE = 0.04f;
|
| 85 |
|
|
public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
|
| 86 |
6e3fcb91
|
Leszek Koltunski
|
public static final float TAB_WIDTH = 0.100f;
|
| 87 |
|
|
public static final float TAB_HEIGHT = 0.100f;
|
| 88 |
fad10885
|
Leszek Koltunski
|
public static final float MENU_BUTTON_HEIGHT = 0.115f;
|
| 89 |
e3c74c0f
|
Leszek Koltunski
|
|
| 90 |
af7b68e6
|
Leszek Koltunski
|
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
| 91 |
ffd68f35
|
Leszek Koltunski
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
| 92 |
|
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
| 93 |
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
| 94 |
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
| 95 |
|
|
|
| 96 |
1237d25d
|
Leszek Koltunski
|
private static final int ACTIVITY_NUMBER = 0;
|
| 97 |
598de3ee
|
Leszek Koltunski
|
private static final float RATIO_BAR = 0.10f;
|
| 98 |
1071fb69
|
Leszek Koltunski
|
private static final float RATIO_INSET= 0.09f;
|
| 99 |
598de3ee
|
Leszek Koltunski
|
|
| 100 |
972f9eae
|
Leszek Koltunski
|
private static final String KEY_PLAY = "movesController_play";
|
| 101 |
|
|
private static final String KEY_SOLV = "movesController_solv";
|
| 102 |
|
|
|
| 103 |
c3ffcf58
|
Leszek Koltunski
|
private boolean mJustStarted;
|
| 104 |
1b3cbd5b
|
Leszek Koltunski
|
private FirebaseAnalytics mFirebaseAnalytics;
|
| 105 |
f6a9c538
|
Leszek Koltunski
|
private static int mScreenWidth, mScreenHeight;
|
| 106 |
b1e9596b
|
Leszek Koltunski
|
private boolean mPolicyAccepted, mIsChinese;
|
| 107 |
0254cfd7
|
Leszek Koltunski
|
private int mCurrentApiVersion;
|
| 108 |
598de3ee
|
Leszek Koltunski
|
private int mHeightUpperBar, mHeightLowerBar;
|
| 109 |
c3ffcf58
|
Leszek Koltunski
|
|
| 110 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 111 |
|
|
|
| 112 |
0c52af30
|
Leszek Koltunski
|
@Override
|
| 113 |
34747dd1
|
Leszek Koltunski
|
protected void onCreate(Bundle savedState)
|
| 114 |
0c52af30
|
Leszek Koltunski
|
{
|
| 115 |
34747dd1
|
Leszek Koltunski
|
super.onCreate(savedState);
|
| 116 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onCreate(ACTIVITY_NUMBER);
|
| 117 |
d7de3072
|
Leszek Koltunski
|
|
| 118 |
dd874ae8
|
Leszek Koltunski
|
setTheme(R.style.MaterialThemeNoActionBar);
|
| 119 |
1cbcc6bf
|
Leszek Koltunski
|
setContentView(R.layout.main);
|
| 120 |
c3ffcf58
|
Leszek Koltunski
|
|
| 121 |
|
|
mJustStarted = true;
|
| 122 |
1b3cbd5b
|
Leszek Koltunski
|
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
|
| 123 |
51853bf2
|
Leszek Koltunski
|
mIsChinese = localeIsChinese();
|
| 124 |
e3c74c0f
|
Leszek Koltunski
|
|
| 125 |
|
|
DisplayMetrics displaymetrics = new DisplayMetrics();
|
| 126 |
7fe59aa5
|
Leszek Koltunski
|
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
|
| 127 |
88fb92ba
|
Leszek Koltunski
|
mScreenWidth =displaymetrics.widthPixels;
|
| 128 |
|
|
mScreenHeight=displaymetrics.heightPixels;
|
| 129 |
7fe59aa5
|
Leszek Koltunski
|
|
| 130 |
0254cfd7
|
Leszek Koltunski
|
hideNavigationBar();
|
| 131 |
e8f6670f
|
Leszek Koltunski
|
cutoutHack();
|
| 132 |
598de3ee
|
Leszek Koltunski
|
computeBarHeights();
|
| 133 |
a59f38d6
|
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 |
8badfe2a
|
Leszek Koltunski
|
unblockEverything();
|
| 263 |
6142069a
|
Leszek Koltunski
|
restoreMoves(preferences);
|
| 264 |
2e3488f6
|
Leszek Koltunski
|
|
| 265 |
c3ffcf58
|
Leszek Koltunski
|
if( mJustStarted )
|
| 266 |
|
|
{
|
| 267 |
|
|
mJustStarted = false;
|
| 268 |
82ce8e64
|
Leszek Koltunski
|
RubikScores scores = RubikScores.getInstance();
|
| 269 |
|
|
scores.incrementNumRuns();
|
| 270 |
|
|
scores.setCountry(this);
|
| 271 |
f12e4de9
|
Leszek Koltunski
|
RubikObjectList.restoreMeshState(preferences);
|
| 272 |
c3ffcf58
|
Leszek Koltunski
|
}
|
| 273 |
|
|
|
| 274 |
400ff34d
|
Leszek Koltunski
|
int object = RubikObjectList.getCurrObject();
|
| 275 |
b20e89d2
|
Leszek Koltunski
|
changeIfDifferent(object,view.getObjectControl());
|
| 276 |
51853bf2
|
Leszek Koltunski
|
|
| 277 |
b1e9596b
|
Leszek Koltunski
|
if( mIsChinese && !mPolicyAccepted ) PrivacyPolicy();
|
| 278 |
0c52af30
|
Leszek Koltunski
|
}
|
| 279 |
|
|
|
| 280 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 281 |
|
|
|
| 282 |
|
|
@Override
|
| 283 |
|
|
protected void onDestroy()
|
| 284 |
|
|
{
|
| 285 |
1237d25d
|
Leszek Koltunski
|
DistortedLibrary.onDestroy(ACTIVITY_NUMBER);
|
| 286 |
0c52af30
|
Leszek Koltunski
|
super.onDestroy();
|
| 287 |
|
|
}
|
| 288 |
|
|
|
| 289 |
4c9947bd
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 290 |
|
|
|
| 291 |
b20e89d2
|
Leszek Koltunski
|
private String getAppVers()
|
| 292 |
4c9947bd
|
Leszek Koltunski
|
{
|
| 293 |
b20e89d2
|
Leszek Koltunski
|
try
|
| 294 |
|
|
{
|
| 295 |
|
|
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
|
| 296 |
|
|
return pInfo.versionName;
|
| 297 |
|
|
}
|
| 298 |
|
|
catch (PackageManager.NameNotFoundException e)
|
| 299 |
|
|
{
|
| 300 |
|
|
return "unknown";
|
| 301 |
|
|
}
|
| 302 |
4c9947bd
|
Leszek Koltunski
|
}
|
| 303 |
|
|
|
| 304 |
33499c56
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 305 |
|
|
|
| 306 |
|
|
private void savePreferences()
|
| 307 |
|
|
{
|
| 308 |
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
| 309 |
|
|
SharedPreferences.Editor editor = preferences.edit();
|
| 310 |
|
|
|
| 311 |
b1e9596b
|
Leszek Koltunski
|
editor.putBoolean("policyAccepted", mPolicyAccepted);
|
| 312 |
4c9947bd
|
Leszek Koltunski
|
editor.putString("appVersion", getAppVers() );
|
| 313 |
b1e9596b
|
Leszek Koltunski
|
|
| 314 |
211b48f2
|
Leszek Koltunski
|
for (int i=0; i<BaseEffect.Type.LENGTH; i++)
|
| 315 |
33499c56
|
Leszek Koltunski
|
{
|
| 316 |
|
|
BaseEffect.Type.getType(i).savePreferences(editor);
|
| 317 |
|
|
}
|
| 318 |
|
|
|
| 319 |
fcd5b990
|
Leszek Koltunski
|
for (int i = 0; i< ScreenList.LENGTH; i++)
|
| 320 |
211b48f2
|
Leszek Koltunski
|
{
|
| 321 |
f5da732a
|
Leszek Koltunski
|
ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
|
| 322 |
211b48f2
|
Leszek Koltunski
|
}
|
| 323 |
33499c56
|
Leszek Koltunski
|
|
| 324 |
400ff34d
|
Leszek Koltunski
|
RubikObjectList.savePreferences(editor);
|
| 325 |
f12e4de9
|
Leszek Koltunski
|
RubikObjectList.saveMeshState(editor);
|
| 326 |
fcd5b990
|
Leszek Koltunski
|
ScreenList.savePreferences(editor);
|
| 327 |
0333d81e
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 328 |
2afc6754
|
Leszek Koltunski
|
view.getObjectControl().savePreferences(editor);
|
| 329 |
0333d81e
|
Leszek Koltunski
|
|
| 330 |
2e3488f6
|
Leszek Koltunski
|
ScreenList curr = ScreenList.getCurrentScreen();
|
| 331 |
|
|
|
| 332 |
|
|
if( curr==ScreenList.PLAY )
|
| 333 |
|
|
{
|
| 334 |
|
|
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
| 335 |
972f9eae
|
Leszek Koltunski
|
play.saveMovePreferences(KEY_PLAY,editor);
|
| 336 |
2e3488f6
|
Leszek Koltunski
|
}
|
| 337 |
|
|
if( curr==ScreenList.SOLV )
|
| 338 |
|
|
{
|
| 339 |
|
|
RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
|
| 340 |
972f9eae
|
Leszek Koltunski
|
solv.saveMovePreferences(KEY_SOLV,editor);
|
| 341 |
2e3488f6
|
Leszek Koltunski
|
}
|
| 342 |
|
|
|
| 343 |
7480fbab
|
Leszek Koltunski
|
boolean success = editor.commit();
|
| 344 |
|
|
if( !success ) android.util.Log.e("D", "Failed to save preferences");
|
| 345 |
33499c56
|
Leszek Koltunski
|
}
|
| 346 |
|
|
|
| 347 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 348 |
|
|
|
| 349 |
6142069a
|
Leszek Koltunski
|
private void restorePreferences(SharedPreferences preferences, boolean justStarted)
|
| 350 |
33499c56
|
Leszek Koltunski
|
{
|
| 351 |
b1e9596b
|
Leszek Koltunski
|
mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
|
| 352 |
4c9947bd
|
Leszek Koltunski
|
String oldVersion = preferences.getString("appVersion","");
|
| 353 |
b1e9596b
|
Leszek Koltunski
|
|
| 354 |
7480fbab
|
Leszek Koltunski
|
RubikObjectList.restorePreferences(this,preferences,justStarted);
|
| 355 |
526a5906
|
Leszek Koltunski
|
|
| 356 |
03423c67
|
Leszek Koltunski
|
for (int i=0; i<BaseEffect.Type.LENGTH; i++)
|
| 357 |
4235de9b
|
Leszek Koltunski
|
{
|
| 358 |
33499c56
|
Leszek Koltunski
|
BaseEffect.Type.getType(i).restorePreferences(preferences);
|
| 359 |
4235de9b
|
Leszek Koltunski
|
}
|
| 360 |
33499c56
|
Leszek Koltunski
|
|
| 361 |
03423c67
|
Leszek Koltunski
|
for (int i=0; i<ScreenList.LENGTH; i++)
|
| 362 |
211b48f2
|
Leszek Koltunski
|
{
|
| 363 |
f5da732a
|
Leszek Koltunski
|
ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
|
| 364 |
211b48f2
|
Leszek Koltunski
|
}
|
| 365 |
33499c56
|
Leszek Koltunski
|
|
| 366 |
6142069a
|
Leszek Koltunski
|
// this needs to be after the above ScreenList.restore as that restores the Records which we need here
|
| 367 |
|
|
if( justStarted ) RubikObjectList.setObjectFreeState();
|
| 368 |
|
|
|
| 369 |
fcd5b990
|
Leszek Koltunski
|
ScreenList.restorePreferences(preferences);
|
| 370 |
0333d81e
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 371 |
4c9947bd
|
Leszek Koltunski
|
|
| 372 |
|
|
// Versions <= 1.8.6 did not save their 'appVersion' to preferences, therefore in their
|
| 373 |
|
|
// case the 'mOldVersion' - version of the app which saved the preferences on the last
|
| 374 |
|
|
// go - is empty.
|
| 375 |
|
|
// Between versions 1.8.6 and 1.9.0, the order of the cubits in TwistyCube has changed.
|
| 376 |
|
|
// If someone has scrambled the cube with v. 1.8.6, then upgraded to 1.9.0 and re-started
|
| 377 |
|
|
// the app, because of the different order of the cubits - his cube would be messed up.
|
| 378 |
|
|
// So in such case, i.e. on fresh upgrade from version<=1.8.6 to version>=1.9.0, do not
|
| 379 |
|
|
// restore the object scrambling.
|
| 380 |
|
|
|
| 381 |
|
|
if( !oldVersion.equals("") )
|
| 382 |
|
|
{
|
| 383 |
|
|
view.getObjectControl().restorePreferences(preferences);
|
| 384 |
|
|
}
|
| 385 |
ee4e7896
|
Leszek Koltunski
|
|
| 386 |
|
|
RubikScores scores = RubikScores.getInstance();
|
| 387 |
|
|
|
| 388 |
|
|
if( scores.isVerified() )
|
| 389 |
|
|
{
|
| 390 |
|
|
FirebaseAnalytics analytics = getAnalytics();
|
| 391 |
|
|
analytics.setUserId(scores.getName());
|
| 392 |
|
|
}
|
| 393 |
00fcfefa
|
Leszek Koltunski
|
|
| 394 |
|
|
// all old users upgrading from version <1.11.4, where there was no concept of 'stars',
|
| 395 |
|
|
// get all the stars they have earned
|
| 396 |
|
|
int numStars = scores.getNumStars();
|
| 397 |
|
|
|
| 398 |
|
|
if( numStars==0 && upgradingFromVersionWithNoStars(oldVersion) )
|
| 399 |
|
|
{
|
| 400 |
|
|
scores.correctNumStars();
|
| 401 |
|
|
}
|
| 402 |
|
|
}
|
| 403 |
|
|
|
| 404 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 405 |
|
|
|
| 406 |
|
|
private boolean upgradingFromVersionWithNoStars(String version)
|
| 407 |
|
|
{
|
| 408 |
|
|
if( version!=null )
|
| 409 |
|
|
{
|
| 410 |
|
|
try
|
| 411 |
|
|
{
|
| 412 |
|
|
int dot = version.indexOf('.',2);
|
| 413 |
|
|
|
| 414 |
|
|
if( dot>2 )
|
| 415 |
|
|
{
|
| 416 |
|
|
String middle = version.substring(2,dot);
|
| 417 |
|
|
int middleInt = Integer.parseInt(middle);
|
| 418 |
|
|
|
| 419 |
|
|
if( middleInt<11 ) return true;
|
| 420 |
|
|
if( middleInt==11 )
|
| 421 |
|
|
{
|
| 422 |
|
|
String end = version.substring(dot+1);
|
| 423 |
|
|
int endInt = Integer.parseInt(end);
|
| 424 |
|
|
return endInt<4;
|
| 425 |
|
|
}
|
| 426 |
|
|
}
|
| 427 |
|
|
}
|
| 428 |
|
|
catch(Exception ignored) {}
|
| 429 |
|
|
}
|
| 430 |
|
|
|
| 431 |
|
|
return false;
|
| 432 |
f3e12931
|
Leszek Koltunski
|
}
|
| 433 |
|
|
|
| 434 |
2e3488f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 435 |
|
|
|
| 436 |
6142069a
|
Leszek Koltunski
|
private void restoreMoves(SharedPreferences preferences)
|
| 437 |
2e3488f6
|
Leszek Koltunski
|
{
|
| 438 |
|
|
ScreenList curr = ScreenList.getCurrentScreen();
|
| 439 |
|
|
|
| 440 |
|
|
if( curr==ScreenList.PLAY )
|
| 441 |
|
|
{
|
| 442 |
|
|
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
| 443 |
972f9eae
|
Leszek Koltunski
|
play.restoreMovePreferences(this,KEY_PLAY,preferences);
|
| 444 |
2e3488f6
|
Leszek Koltunski
|
}
|
| 445 |
|
|
if( curr==ScreenList.SOLV )
|
| 446 |
|
|
{
|
| 447 |
|
|
RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
|
| 448 |
972f9eae
|
Leszek Koltunski
|
solv.restoreMovePreferences(this,KEY_SOLV,preferences);
|
| 449 |
2e3488f6
|
Leszek Koltunski
|
}
|
| 450 |
|
|
}
|
| 451 |
|
|
|
| 452 |
b1e9596b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 453 |
|
|
|
| 454 |
|
|
private void PrivacyPolicy()
|
| 455 |
|
|
{
|
| 456 |
|
|
RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
|
| 457 |
|
|
priDiag.show(getSupportFragmentManager(), null);
|
| 458 |
|
|
}
|
| 459 |
|
|
|
| 460 |
2d9fc972
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 461 |
|
|
|
| 462 |
e7e0a94d
|
Leszek Koltunski
|
void OpenGLError()
|
| 463 |
2d9fc972
|
Leszek Koltunski
|
{
|
| 464 |
|
|
RubikDialogError errDiag = new RubikDialogError();
|
| 465 |
|
|
errDiag.show(getSupportFragmentManager(), null);
|
| 466 |
|
|
}
|
| 467 |
|
|
|
| 468 |
34747dd1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 469 |
47ba5ddc
|
Leszek Koltunski
|
// PUBLIC API
|
| 470 |
1b3cbd5b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 471 |
|
|
|
| 472 |
|
|
public FirebaseAnalytics getAnalytics()
|
| 473 |
|
|
{
|
| 474 |
|
|
return mFirebaseAnalytics;
|
| 475 |
|
|
}
|
| 476 |
|
|
|
| 477 |
598de3ee
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 478 |
|
|
|
| 479 |
|
|
public int getHeightUpperBar()
|
| 480 |
|
|
{
|
| 481 |
|
|
return mHeightUpperBar;
|
| 482 |
|
|
}
|
| 483 |
|
|
|
| 484 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 485 |
|
|
|
| 486 |
|
|
public int getHeightLowerBar()
|
| 487 |
|
|
{
|
| 488 |
|
|
return mHeightLowerBar;
|
| 489 |
|
|
}
|
| 490 |
|
|
|
| 491 |
a6d3b158
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 492 |
|
|
|
| 493 |
9c2f0c91
|
Leszek Koltunski
|
public TwistyObject getObject()
|
| 494 |
aa171dee
|
Leszek Koltunski
|
{
|
| 495 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 496 |
2afc6754
|
Leszek Koltunski
|
return view.getObjectControl().getObject();
|
| 497 |
8becce57
|
Leszek Koltunski
|
}
|
| 498 |
|
|
|
| 499 |
d7f0c07d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 500 |
|
|
|
| 501 |
|
|
public DistortedScreen getScreen()
|
| 502 |
|
|
{
|
| 503 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 504 |
|
|
return view.getRenderer().getScreen();
|
| 505 |
|
|
}
|
| 506 |
|
|
|
| 507 |
f8eece7d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 508 |
|
|
|
| 509 |
2afc6754
|
Leszek Koltunski
|
public ObjectControl getControl()
|
| 510 |
f8eece7d
|
Leszek Koltunski
|
{
|
| 511 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 512 |
2afc6754
|
Leszek Koltunski
|
return view.getObjectControl();
|
| 513 |
f8eece7d
|
Leszek Koltunski
|
}
|
| 514 |
|
|
|
| 515 |
8becce57
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 516 |
|
|
|
| 517 |
8ba7aeb1
|
Leszek Koltunski
|
public int getScreenWidthInPixels()
|
| 518 |
8becce57
|
Leszek Koltunski
|
{
|
| 519 |
8ba7aeb1
|
Leszek Koltunski
|
return mScreenWidth;
|
| 520 |
|
|
}
|
| 521 |
|
|
|
| 522 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 523 |
|
|
|
| 524 |
|
|
public int getScreenHeightInPixels()
|
| 525 |
|
|
{
|
| 526 |
|
|
return mScreenHeight;
|
| 527 |
aa171dee
|
Leszek Koltunski
|
}
|
| 528 |
|
|
|
| 529 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 530 |
|
|
|
| 531 |
d433b50e
|
Leszek Koltunski
|
public void changeObject(int newObject, boolean reportChange)
|
| 532 |
769d7b9f
|
Leszek Koltunski
|
{
|
| 533 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 534 |
2afc6754
|
Leszek Koltunski
|
ObjectControl control = view.getObjectControl();
|
| 535 |
b20e89d2
|
Leszek Koltunski
|
TwistyObject oldObject = control.getObject();
|
| 536 |
|
|
changeIfDifferent(newObject,control);
|
| 537 |
7eae2d49
|
Leszek Koltunski
|
|
| 538 |
b20e89d2
|
Leszek Koltunski
|
if( reportChange && oldObject!=null )
|
| 539 |
7eae2d49
|
Leszek Koltunski
|
{
|
| 540 |
d433b50e
|
Leszek Koltunski
|
RubikObject robject = RubikObjectList.getObject(newObject);
|
| 541 |
84d746d7
|
Leszek Koltunski
|
String newName = robject==null ? "NULL" : robject.getUpperName();
|
| 542 |
b20e89d2
|
Leszek Koltunski
|
float fps = view.getRenderer().getFPS();
|
| 543 |
|
|
fps = (int)(fps+0.5f);
|
| 544 |
|
|
StringBuilder name = new StringBuilder();
|
| 545 |
|
|
name.append(oldObject.getShortName());
|
| 546 |
|
|
name.append(' ');
|
| 547 |
|
|
name.append(fps);
|
| 548 |
|
|
name.append(" --> ");
|
| 549 |
d433b50e
|
Leszek Koltunski
|
name.append(newName);
|
| 550 |
b20e89d2
|
Leszek Koltunski
|
|
| 551 |
|
|
if( BuildConfig.DEBUG )
|
| 552 |
03822c33
|
Leszek Koltunski
|
{
|
| 553 |
b20e89d2
|
Leszek Koltunski
|
android.util.Log.e("rubik", name.toString());
|
| 554 |
|
|
}
|
| 555 |
|
|
else
|
| 556 |
|
|
{
|
| 557 |
|
|
FirebaseAnalytics analytics = getAnalytics();
|
| 558 |
03822c33
|
Leszek Koltunski
|
|
| 559 |
b20e89d2
|
Leszek Koltunski
|
if( analytics!=null )
|
| 560 |
|
|
{
|
| 561 |
|
|
Bundle bundle = new Bundle();
|
| 562 |
|
|
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
|
| 563 |
|
|
analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
|
| 564 |
7eae2d49
|
Leszek Koltunski
|
}
|
| 565 |
|
|
}
|
| 566 |
|
|
}
|
| 567 |
b20e89d2
|
Leszek Koltunski
|
}
|
| 568 |
|
|
|
| 569 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 570 |
7eae2d49
|
Leszek Koltunski
|
|
| 571 |
d433b50e
|
Leszek Koltunski
|
public void changeIfDifferent(int ordinal, ObjectControl control)
|
| 572 |
b20e89d2
|
Leszek Koltunski
|
{
|
| 573 |
09cf2a36
|
Leszek Koltunski
|
RubikObject object = RubikObjectList.getObject(ordinal);
|
| 574 |
|
|
int meshState = object!=null ? object.getMeshState() : MESH_NICE;
|
| 575 |
7cb8d4b0
|
Leszek Koltunski
|
int iconMode = TwistyObject.MODE_NORM;
|
| 576 |
314e9ff0
|
Leszek Koltunski
|
InputStream jsonStream = object==null ? null : object.getObjectStream(this);
|
| 577 |
|
|
InputStream meshStream = object==null ? null : object.getMeshStream(this);
|
| 578 |
aec421fd
|
Leszek Koltunski
|
String name = object==null ? "NULL" : object.getUpperName();
|
| 579 |
09cf2a36
|
Leszek Koltunski
|
|
| 580 |
7cb8d4b0
|
Leszek Koltunski
|
control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
|
| 581 |
2e8ec627
|
Leszek Koltunski
|
}
|
| 582 |
|
|
|
| 583 |
f6a9c538
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 584 |
|
|
|
| 585 |
|
|
public static int getDrawableSize()
|
| 586 |
|
|
{
|
| 587 |
|
|
if( mScreenHeight<1000 )
|
| 588 |
|
|
{
|
| 589 |
|
|
return 0;
|
| 590 |
|
|
}
|
| 591 |
|
|
if( mScreenHeight<1600 )
|
| 592 |
|
|
{
|
| 593 |
|
|
return 1;
|
| 594 |
|
|
}
|
| 595 |
31a9f38d
|
Leszek Koltunski
|
if( mScreenHeight<1900 )
|
| 596 |
|
|
{
|
| 597 |
|
|
return 2;
|
| 598 |
|
|
}
|
| 599 |
f6a9c538
|
Leszek Koltunski
|
|
| 600 |
31a9f38d
|
Leszek Koltunski
|
return 3;
|
| 601 |
f6a9c538
|
Leszek Koltunski
|
}
|
| 602 |
|
|
|
| 603 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 604 |
|
|
|
| 605 |
31a9f38d
|
Leszek Koltunski
|
public static int getDrawable(int small, int medium, int big, int huge)
|
| 606 |
f6a9c538
|
Leszek Koltunski
|
{
|
| 607 |
|
|
int size = getDrawableSize();
|
| 608 |
|
|
|
| 609 |
|
|
switch(size)
|
| 610 |
|
|
{
|
| 611 |
|
|
case 0 : return small;
|
| 612 |
|
|
case 1 : return medium;
|
| 613 |
31a9f38d
|
Leszek Koltunski
|
case 2 : return big;
|
| 614 |
|
|
default: return huge;
|
| 615 |
f6a9c538
|
Leszek Koltunski
|
}
|
| 616 |
|
|
}
|
| 617 |
|
|
|
| 618 |
b1e9596b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 619 |
|
|
|
| 620 |
|
|
public void acceptPrivacy()
|
| 621 |
|
|
{
|
| 622 |
|
|
mPolicyAccepted = true;
|
| 623 |
|
|
}
|
| 624 |
|
|
|
| 625 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 626 |
|
|
|
| 627 |
|
|
public void declinePrivacy()
|
| 628 |
|
|
{
|
| 629 |
|
|
finish();
|
| 630 |
|
|
}
|
| 631 |
|
|
|
| 632 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 633 |
|
|
|
| 634 |
|
|
public static boolean localeIsChinese()
|
| 635 |
|
|
{
|
| 636 |
|
|
String language;
|
| 637 |
|
|
|
| 638 |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
| 639 |
|
|
{
|
| 640 |
|
|
language= LocaleList.getDefault().get(0).getLanguage();
|
| 641 |
|
|
}
|
| 642 |
|
|
else
|
| 643 |
|
|
{
|
| 644 |
|
|
language= Locale.getDefault().getLanguage();
|
| 645 |
|
|
}
|
| 646 |
|
|
|
| 647 |
|
|
return language.equals("zh");
|
| 648 |
|
|
}
|
| 649 |
|
|
|
| 650 |
769d7b9f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 651 |
|
|
|
| 652 |
|
|
public boolean isVertical()
|
| 653 |
|
|
{
|
| 654 |
|
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 655 |
|
|
return view.isVertical();
|
| 656 |
|
|
}
|
| 657 |
46405bb4
|
Leszek Koltunski
|
|
| 658 |
f5da732a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 659 |
|
|
|
| 660 |
809c3432
|
Leszek Koltunski
|
public void blockEverything(int place)
|
| 661 |
f5da732a
|
Leszek Koltunski
|
{
|
| 662 |
2afc6754
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 663 |
|
|
ObjectControl control = view.getObjectControl();
|
| 664 |
|
|
control.blockEverything(place);
|
| 665 |
8badfe2a
|
Leszek Koltunski
|
|
| 666 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
| 667 |
|
|
play.setLockState(this);
|
| 668 |
f5da732a
|
Leszek Koltunski
|
}
|
| 669 |
|
|
|
| 670 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 671 |
|
|
|
| 672 |
|
|
public void unblockEverything()
|
| 673 |
|
|
{
|
| 674 |
2afc6754
|
Leszek Koltunski
|
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
| 675 |
|
|
ObjectControl control = view.getObjectControl();
|
| 676 |
|
|
control.unblockEverything();
|
| 677 |
8badfe2a
|
Leszek Koltunski
|
|
| 678 |
|
|
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
|
| 679 |
|
|
play.setLockState(this);
|
| 680 |
f5da732a
|
Leszek Koltunski
|
}
|
| 681 |
|
|
|
| 682 |
b6468abb
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 683 |
|
|
|
| 684 |
d433b50e
|
Leszek Koltunski
|
public void switchTutorial(String url, int objectOrdinal)
|
| 685 |
b6468abb
|
Leszek Koltunski
|
{
|
| 686 |
9530f6b0
|
Leszek Koltunski
|
Intent intent = new Intent(this, TutorialActivity.class);
|
| 687 |
|
|
intent.putExtra("url", url);
|
| 688 |
|
|
intent.putExtra("obj", objectOrdinal);
|
| 689 |
|
|
startActivity(intent);
|
| 690 |
b6468abb
|
Leszek Koltunski
|
}
|
| 691 |
1237d25d
|
Leszek Koltunski
|
|
| 692 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 693 |
|
|
|
| 694 |
d433b50e
|
Leszek Koltunski
|
public void switchConfig(int objectOrdinal)
|
| 695 |
1237d25d
|
Leszek Koltunski
|
{
|
| 696 |
9530f6b0
|
Leszek Koltunski
|
Intent intent = new Intent(this, ConfigActivity.class);
|
| 697 |
|
|
intent.putExtra("obj", objectOrdinal);
|
| 698 |
|
|
startActivity(intent);
|
| 699 |
|
|
}
|
| 700 |
|
|
|
| 701 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 702 |
|
|
|
| 703 |
|
|
public void switchToBandagedCreator()
|
| 704 |
|
|
{
|
| 705 |
|
|
Intent intent = new Intent(this, BandagedCreatorActivity.class);
|
| 706 |
|
|
startActivity(intent);
|
| 707 |
1237d25d
|
Leszek Koltunski
|
}
|
| 708 |
41a5dd89
|
Leszek Koltunski
|
|
| 709 |
c7238c67
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 710 |
|
|
|
| 711 |
|
|
public void switchToPurchase(int objectOrdinal)
|
| 712 |
|
|
{
|
| 713 |
|
|
Intent intent = new Intent(this, PurchaseActivity.class);
|
| 714 |
|
|
intent.putExtra("obj", objectOrdinal);
|
| 715 |
|
|
startActivity(intent);
|
| 716 |
|
|
}
|
| 717 |
|
|
|
| 718 |
41a5dd89
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 719 |
|
|
|
| 720 |
|
|
public void reloadObject(String shortName)
|
| 721 |
|
|
{
|
| 722 |
|
|
TwistyObject currObject = getObject();
|
| 723 |
03423c67
|
Leszek Koltunski
|
String name = currObject==null ? "" : currObject.getShortName();
|
| 724 |
41a5dd89
|
Leszek Koltunski
|
|
| 725 |
5e048300
|
Leszek Koltunski
|
if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
|
| 726 |
41a5dd89
|
Leszek Koltunski
|
{
|
| 727 |
|
|
RubikObject object = RubikObjectList.getObject(name);
|
| 728 |
|
|
|
| 729 |
|
|
if( object!=null )
|
| 730 |
|
|
{
|
| 731 |
|
|
int meshState = object.getMeshState();
|
| 732 |
|
|
int iconMode = TwistyObject.MODE_NORM;
|
| 733 |
|
|
InputStream jsonStream = object.getObjectStream(this);
|
| 734 |
|
|
InputStream meshStream = object.getMeshStream(this);
|
| 735 |
|
|
ObjectControl control = getControl();
|
| 736 |
|
|
control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
|
| 737 |
|
|
}
|
| 738 |
|
|
}
|
| 739 |
|
|
}
|
| 740 |
0c52af30
|
Leszek Koltunski
|
}
|