23 |
23 |
|
24 |
24 |
import android.content.Intent;
|
25 |
25 |
import android.content.SharedPreferences;
|
|
26 |
import android.content.pm.PackageInfo;
|
|
27 |
import android.content.pm.PackageManager;
|
26 |
28 |
import android.os.Build;
|
27 |
29 |
import android.os.Bundle;
|
28 |
30 |
import android.os.LocaleList;
|
... | ... | |
263 |
265 |
super.onDestroy();
|
264 |
266 |
}
|
265 |
267 |
|
|
268 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
269 |
|
|
270 |
private String getAppVers()
|
|
271 |
{
|
|
272 |
try
|
|
273 |
{
|
|
274 |
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
|
|
275 |
return pInfo.versionName;
|
|
276 |
}
|
|
277 |
catch (PackageManager.NameNotFoundException e)
|
|
278 |
{
|
|
279 |
return "unknown";
|
|
280 |
}
|
|
281 |
}
|
|
282 |
|
266 |
283 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
267 |
284 |
|
268 |
285 |
private void savePreferences()
|
... | ... | |
271 |
288 |
SharedPreferences.Editor editor = preferences.edit();
|
272 |
289 |
|
273 |
290 |
editor.putBoolean("policyAccepted", mPolicyAccepted);
|
|
291 |
editor.putString("appVersion", getAppVers() );
|
274 |
292 |
|
275 |
293 |
for (int i=0; i<BaseEffect.Type.LENGTH; i++)
|
276 |
294 |
{
|
... | ... | |
296 |
314 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
297 |
315 |
|
298 |
316 |
mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
|
|
317 |
String oldVersion = preferences.getString("appVersion","");
|
299 |
318 |
|
300 |
319 |
for (int i=0; i< BaseEffect.Type.LENGTH; i++)
|
301 |
320 |
{
|
... | ... | |
310 |
329 |
ScreenList.restorePreferences(preferences);
|
311 |
330 |
|
312 |
331 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
|
313 |
|
view.getObjectControl().restorePreferences(preferences);
|
|
332 |
|
|
333 |
// Versions <= 1.8.6 did not save their 'appVersion' to preferences, therefore in their
|
|
334 |
// case the 'mOldVersion' - version of the app which saved the preferences on the last
|
|
335 |
// go - is empty.
|
|
336 |
// Between versions 1.8.6 and 1.9.0, the order of the cubits in TwistyCube has changed.
|
|
337 |
// If someone has scrambled the cube with v. 1.8.6, then upgraded to 1.9.0 and re-started
|
|
338 |
// the app, because of the different order of the cubits - his cube would be messed up.
|
|
339 |
// So in such case, i.e. on fresh upgrade from version<=1.8.6 to version>=1.9.0, do not
|
|
340 |
// restore the object scrambling.
|
|
341 |
|
|
342 |
if( !oldVersion.equals("") )
|
|
343 |
{
|
|
344 |
view.getObjectControl().restorePreferences(preferences);
|
|
345 |
}
|
314 |
346 |
|
315 |
347 |
RubikScores scores = RubikScores.getInstance();
|
316 |
348 |
|
1. Do not restore object scrambling if we freshly upgraded from some version older than 1.9.0
2. Bugfix for a recently introduced crasher in the Play screen.