commit
This commit is contained in:
		| @ -44,6 +44,8 @@ public class MainActivity extends AppCompatActivity { | |||||||
|  |  | ||||||
|     ArrayAdapter<String> starAdapter; |     ArrayAdapter<String> starAdapter; | ||||||
|  |  | ||||||
|  |     Spinner sp; | ||||||
|  |  | ||||||
|     MyHandler handler = new MyHandler(this); |     MyHandler handler = new MyHandler(this); | ||||||
|  |  | ||||||
|     private static final String TAG = "run.evan.gost"; |     private static final String TAG = "run.evan.gost"; | ||||||
| @ -96,7 +98,7 @@ public class MainActivity extends AppCompatActivity { | |||||||
|         appPreferences = getSharedPreferences("app", MODE_PRIVATE); |         appPreferences = getSharedPreferences("app", MODE_PRIVATE); | ||||||
|  |  | ||||||
|  |  | ||||||
|         Spinner sp = findViewById(R.id.spinner); |         sp = findViewById(R.id.spinner); | ||||||
|         starAdapter = new ArrayAdapter<String>(this, R.layout.item_select); |         starAdapter = new ArrayAdapter<String>(this, R.layout.item_select); | ||||||
|         starAdapter.setDropDownViewResource(R.layout.item_dropdown); |         starAdapter.setDropDownViewResource(R.layout.item_dropdown); | ||||||
|         sp.setAdapter(starAdapter); |         sp.setAdapter(starAdapter); | ||||||
| @ -202,6 +204,12 @@ public class MainActivity extends AppCompatActivity { | |||||||
|                 String basedir = getApplication().getApplicationInfo().nativeLibraryDir; |                 String basedir = getApplication().getApplicationInfo().nativeLibraryDir; | ||||||
|                 String config = configEditText.getText().toString(); |                 String config = configEditText.getText().toString(); | ||||||
|  |  | ||||||
|  |                 if (null != sp.getSelectedItem()) { | ||||||
|  |                     String key = sp.getSelectedItem().toString(); | ||||||
|  |                     appPreferences.edit().putString("lastConfig", key).apply(); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |  | ||||||
|                 if (process == null) { |                 if (process == null) { | ||||||
|                     if ("".contains(config)) { |                     if ("".contains(config)) { | ||||||
|                         Toast.makeText(getApplicationContext(), R.string.toast_tip_config_empty, Toast.LENGTH_LONG).show(); |                         Toast.makeText(getApplicationContext(), R.string.toast_tip_config_empty, Toast.LENGTH_LONG).show(); | ||||||
| @ -285,8 +293,19 @@ public class MainActivity extends AppCompatActivity { | |||||||
|     private void reloadConfig() { |     private void reloadConfig() { | ||||||
|         starAdapter.clear(); |         starAdapter.clear(); | ||||||
|         Map<String, ?> all = configPreferences.getAll(); |         Map<String, ?> all = configPreferences.getAll(); | ||||||
|  |         String lastConfig = appPreferences.getString("lastConfig", ""); | ||||||
|  |         int count = 0; | ||||||
|  |         boolean lastValid = false; | ||||||
|         for (String s : all.keySet()) { |         for (String s : all.keySet()) { | ||||||
|             starAdapter.add(s); |             starAdapter.add(s); | ||||||
|  |             if (s.equals(lastConfig)) { | ||||||
|  |                 sp.setSelection(count); | ||||||
|  |                 lastValid = true; | ||||||
|  |             } | ||||||
|  |             count++; | ||||||
|  |         } | ||||||
|  |         if (!lastValid) { | ||||||
|  |             appPreferences.edit().putString("lastConfig", "").apply(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ | |||||||
|             android:id="@+id/textTipConfig" |             android:id="@+id/textTipConfig" | ||||||
|             android:layout_width="match_parent" |             android:layout_width="match_parent" | ||||||
|             android:layout_height="wrap_content" |             android:layout_height="wrap_content" | ||||||
|  |             android:textSize="18sp" | ||||||
|             android:text="@string/text_tip_config" /> |             android:text="@string/text_tip_config" /> | ||||||
|  |  | ||||||
|         <Spinner |         <Spinner | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <TextView xmlns:android="http://schemas.android.com/apk/res/android" | <TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="45dp" |     android:layout_height="40dp" | ||||||
|     android:textColor="@android:color/black" |     android:textColor="@android:color/black" | ||||||
|     android:textSize="14sp" |     android:textSize="18sp" | ||||||
|     android:gravity="center"/> |     android:gravity="center"/> | ||||||
| @ -1,4 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <TextView xmlns:android="http://schemas.android.com/apk/res/android" | <TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="match_parent" /> |     android:layout_height="match_parent" | ||||||
|  |     android:textSize="18sp" | ||||||
|  |     /> | ||||||
		Reference in New Issue
	
	Block a user