Move themes to settings, Fix reloading after clear

This commit is contained in:
Ender's Games 2018-09-26 09:03:36 -04:00
parent 4b0d1092c1
commit bf71799798
8 changed files with 121 additions and 30 deletions

View File

@ -396,7 +396,7 @@ public class MainActivity extends AppCompatActivity implements
super.onPostCreate(savedInstanceState);
}
private void restartActivity() {
public void recreateActivity() {
this.recreate();
OptionsFragment optionsFrag = new OptionsFragment();
getSupportFragmentManager()
@ -539,17 +539,6 @@ public class MainActivity extends AppCompatActivity implements
generateErrorLog();
drawer.closeDrawer(GravityCompat.START);
return true;
case R.id.theme_menu:
int app_theme = mPrefs.getInt(Config.pref_app_theme, 0);
if (app_theme == 7) {
mPrefs.edit().putInt(Config.pref_app_theme, 0).apply();
restartActivity();
} else {
mPrefs.edit().putInt(Config.pref_app_theme, 7).apply();
restartActivity();
}
drawer.closeDrawer(GravityCompat.START);
return true;
default:
drawer.closeDrawer(GravityCompat.START);

View File

@ -69,6 +69,7 @@ public class OptionsFragment extends Fragment {
// Container Activity must implement this interface
public interface OnClickListener {
void recreateActivity();
void onMainBrowseSelected(String path_entry, boolean games, String query);
void launchBIOSdetection();
}
@ -129,7 +130,6 @@ public class OptionsFragment extends Fragment {
app.getConfigurationPrefs(mPrefs);
// Generate the menu options and fill in existing settings
Button mainBrowse = (Button) getView().findViewById(R.id.browse_main_path);
mSpnrThemes = (Spinner) getView().findViewById(R.id.pick_button_theme);
new LocateThemes(this).execute(home_directory + "/themes");
@ -181,6 +181,36 @@ public class OptionsFragment extends Fragment {
reios_opt.setChecked(mPrefs.getBoolean(Emulator.pref_usereios, false));
reios_opt.setOnCheckedChangeListener(reios_options);
String[] app_themes = getResources().getStringArray(R.array.themes_app);
Spinner aSpnrThemes = (Spinner) getView().findViewById(R.id.pick_app_theme);
ArrayAdapter<String> themeAdapter = new ArrayAdapter<>(getActivity(),
android.R.layout.simple_spinner_item, app_themes);
themeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
aSpnrThemes.setAdapter(themeAdapter);
int app_theme = mPrefs.getInt(Config.pref_app_theme, 0);
if (app_theme == 7) {
aSpnrThemes.setSelection(themeAdapter.getPosition("Dream"), true);
} else {
aSpnrThemes.setSelection(app_theme, true);
}
aSpnrThemes.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
String theme = String.valueOf(parentView.getItemAtPosition(position));
if (theme.equals("Dream")) {
mPrefs.edit().putInt(Config.pref_app_theme, 7).apply();
mCallback.recreateActivity();
} else {
mPrefs.edit().putInt(Config.pref_app_theme, 0).apply();
mCallback.recreateActivity();
}
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
}
});
OnCheckedChangeListener details_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
@ -573,7 +603,7 @@ public class OptionsFragment extends Fragment {
@Override
protected List<File> doInBackground(String... paths) {
File storage = new File(paths[0]);
String[] mediaTypes = options.get().getResources().getStringArray(R.array.themes);
String[] mediaTypes = options.get().getResources().getStringArray(R.array.themes_ext);
FilenameFilter[] filter = new FilenameFilter[mediaTypes.length];
int i = 0;
for (final String type : mediaTypes) {
@ -706,7 +736,23 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Config.pref_renderdepth).apply();
mPrefs.edit().remove(Config.pref_button_theme).apply();
getActivity().finish();
Emulator.usereios = false;
Emulator.nativeact = false;
Emulator.dynarecopt = true;
Emulator.unstableopt = false;
Emulator.cable = 3;
Emulator.dcregion = 3;
Emulator.broadcast = 4;
Emulator.limitfps = true;
Emulator.mipmaps = true;
Emulator.widescreen = false;
Emulator.frameskip = 0;
Emulator.pvrrender = false;
Emulator.syncedrender = false;
Emulator.bootdisk = null;
Emulator.nosound = false;
mCallback.recreateActivity();
}
private void showToastMessage(String message, int duration) {

View File

@ -124,11 +124,11 @@
android:orientation="vertical" >
<TextView
android:id="@+id/button_theme_label"
android:id="@+id/app_theme_label"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/button_theme" />
android:text="@string/app_theme" />
<LinearLayout
android:layout_width="match_parent"
@ -136,7 +136,7 @@
android:orientation="horizontal" >
<Spinner
android:id="@+id/pick_button_theme"
android:id="@+id/pick_app_theme"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -180,6 +180,35 @@
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/button_theme_label"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/button_theme" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/pick_button_theme"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
</Spinner>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -124,11 +124,11 @@
android:orientation="vertical" >
<TextView
android:id="@+id/button_theme_label"
android:id="@+id/app_theme_label"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/button_theme" />
android:text="@string/app_theme" />
<LinearLayout
android:layout_width="match_parent"
@ -136,7 +136,7 @@
android:orientation="horizontal" >
<Spinner
android:id="@+id/pick_button_theme"
android:id="@+id/pick_app_theme"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -180,6 +180,35 @@
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/button_theme_label"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/button_theme" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/pick_button_theme"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
</Spinner>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -34,9 +34,5 @@
android:id="@+id/about_menu"
android:icon="@drawable/ic_info_outline"
android:title="@string/about" />
<item
android:id="@+id/theme_menu"
android:title="@string/theme"
android:icon="@android:drawable/ic_menu_view"/>
</menu>

View File

@ -25,7 +25,4 @@
<item android:title="@string/about"
android:id="@+id/about_menu"
android:icon="@mipmap/menu_question" />
<item android:title="@string/theme"
android:id="@+id/theme_menu"
android:icon="@android:drawable/ic_menu_view"/>
</menu>

View File

@ -20,7 +20,12 @@
<item>VGA</item>
</string-array>
<string-array name="themes">
<string-array name="themes_app">
<item>Dark</item>
<item>Dream</item>
</string-array>
<string-array name="themes_ext">
<item>png</item>
<item>jpg</item>
<item>jpeg</item>

View File

@ -7,6 +7,7 @@
<string name="system_path">System Path\n (location of data folder with dc_boot.bin/dc_flash.bin inside)</string>
<string name="browser_path">Default System Path</string>
<string name="games_path">Storage Path\n (location of *.gdi, *.chd or *.cdi images)</string>
<string name="app_theme">Application Theme</string>
<string name="button_theme">Onscreen Button Theme</string>
<string name="bios_selection">Select a BIOS source</string>
@ -145,7 +146,6 @@
<string name="rateme">Rate Me</string>
<string name="messages">Send Logs</string>
<string name="cloud">Cloud VMU</string>
<string name="theme">Switch Theme</string>
<string name="cancel">Cancel</string>
<string name="dismiss">Dismiss</string>