1111import android .content .Intent ;
1212import android .content .ServiceConnection ;
1313import android .content .SharedPreferences ;
14- import android .content .SharedPreferences .Editor ;
14+ import org .ncmud .mudwammer .data .AppStateKeys ;
15+ import org .ncmud .mudwammer .data .AppStateStore ;
1516import android .content .pm .ApplicationInfo ;
1617import android .content .pm .PackageManager ;
1718import android .content .pm .PackageManager .NameNotFoundException ;
@@ -426,8 +427,7 @@ public void onClick(View v) {
426427 // if(mode == LAUNCH_MODE.TEST) {
427428 if (ConfigurationLoader .isTestMode (this )) {
428429 int readver =
429- this .getSharedPreferences ("TEST_VERSION_DOWHATSNEW" , Context .MODE_PRIVATE )
430- .getInt ("TEST_VERSION" , 0 );
430+ AppStateStore .getInt (this , AppStateKeys .INSTANCE .getTEST_VERSION (), 0 );
431431 int testVersion = 0 ;
432432 try {
433433 testVersion =
@@ -442,11 +442,7 @@ public void onClick(View v) {
442442
443443 if (testVersion != readver ) {
444444 dowhatsnew = true ;
445- SharedPreferences .Editor edit =
446- this .getSharedPreferences ("TEST_VERSION_DOWHATSNEW" , Context .MODE_PRIVATE )
447- .edit ();
448- edit .putInt ("TEST_VERSION" , testVersion );
449- edit .apply ();
445+ AppStateStore .putInt (this , AppStateKeys .INSTANCE .getTEST_VERSION (), testVersion );
450446 }
451447 }
452448
@@ -628,11 +624,8 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
628624 // titleBarHeight += statusBarHeight;
629625 // }
630626
631- SharedPreferences pref = Launcher .this .getSharedPreferences ("STATUS_BAR_HEIGHT" , 0 );
632- Editor e = pref .edit ();
633- e .putInt ("STATUS_BAR_HEIGHT" , statusBarHeight );
634- e .putInt ("TITLE_BAR_HEIGHT" , titleBarHeight );
635- e .apply ();
627+ AppStateStore .putInt (Launcher .this , AppStateKeys .INSTANCE .getSTATUS_BAR_HEIGHT (), statusBarHeight );
628+ AppStateStore .putInt (Launcher .this , AppStateKeys .INSTANCE .getTITLE_BAR_HEIGHT (), titleBarHeight );
636629
637630 MudConnection muc = apdapter .getItem (arg2 );
638631
@@ -1247,29 +1240,6 @@ public void onClick(DialogInterface dialog, int which) {
12471240 }
12481241
12491242 private void DoNewStartup () {
1250- Pattern invalidchars = Pattern .compile ("\\ W" );
1251- Matcher replacebadchars = invalidchars .matcher (launch .getDisplayName ());
1252- String prefsname = replacebadchars .replaceAll ("" ) + ".PREFS" ;
1253- // prefsname = prefsname.replaceAll("/", "");
1254-
1255- SharedPreferences sprefs = Launcher .this .getSharedPreferences (prefsname , 0 );
1256- // servicestarted = prefs.getBoolean("CONNECTED", false);
1257- // finishStart = prefs.getBoolean("FINISHSTART", true);
1258- SharedPreferences .Editor editor = sprefs .edit ();
1259- editor .putBoolean ("CONNECTED" , false );
1260- editor .putBoolean ("FINISHSTART" , true );
1261- editor .apply ();
1262- // Log.e("LAUNCHER","SERVICE NOT STARTED, AM RESETTING THE INITIALIZER BOOLS IN " +
1263- // prefsname);
1264-
1265- // Launcher.this.startActivity(the_intent);
1266- // SharedPreferences sprefs = Launcher.this.getSharedPreferences(prefsname,0);
1267- // SharedPreferences.Editor editor = sprefs.edit();
1268- // editor.putBoolean("CONNECTED", false);
1269- // editor.putBoolean("FINISHSTART", true);
1270- editor .apply ();
1271-
1272- // launch = muc;
12731243 DoFinalStartup ();
12741244 }
12751245
@@ -1304,12 +1274,6 @@ private void DoFinalStartup() {
13041274 // Log.e("LAUNCHER","SERVICE NOT STARTED, AM RESETTING THE INITIALIZER BOOLS IN " +
13051275 // prefsname);
13061276
1307- SharedPreferences prefs = Launcher .this .getSharedPreferences ("SERVICE_INFO" , 0 );
1308- Editor edit = prefs .edit ();
1309-
1310- edit .putString ("SETTINGS_PATH" , launch .getDisplayName ());
1311- edit .apply ();
1312-
13131277 // this.unbindService(connectionChecker);
13141278
13151279 Launcher .this .startActivity (the_intent );
@@ -1991,10 +1955,6 @@ public void handleMessage(Message msg) {
19911955 if (outer == null ) return ;
19921956 switch (msg .what ) {
19931957 case MESSAGE_USERNAME :
1994- SharedPreferences .Editor edit =
1995- outer .getSharedPreferences ("TEST_USER" , Context .MODE_PRIVATE ).edit ();
1996- edit .putString ("USER_NAME" , (String ) msg .obj );
1997- edit .apply ();
19981958 break ;
19991959 case MESSAGE_WHATSNEW :
20001960 break ;
0 commit comments