Skip to content

Commit

Permalink
Merge pull request #10608 from t895/theme-refactor
Browse files Browse the repository at this point in the history
Android: Modernize theming system
  • Loading branch information
JosJuice authored May 8, 2022
2 parents 67ee78b + 9b7c5a4 commit 31232f8
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 145 deletions.
18 changes: 9 additions & 9 deletions Source/Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<activity
android:name=".ui.main.MainActivity"
android:exported="true"
android:theme="@style/DolphinBase">
android:theme="@style/Theme.Dolphin.Main">

<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->
<intent-filter>
Expand All @@ -62,7 +62,7 @@
<activity
android:name=".ui.main.TvMainActivity"
android:exported="true"
android:theme="@style/DolphinTvBase">
android:theme="@style/Theme.Dolphin.TV">

<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->
<intent-filter>
Expand All @@ -76,26 +76,26 @@
android:name=".features.settings.ui.SettingsActivity"
android:exported="false"
android:configChanges="orientation|screenSize"
android:theme="@style/DolphinSettingsBase"
android:theme="@style/Theme.Dolphin.Settings"
android:label="@string/settings"/>

<activity
android:name=".features.cheats.ui.CheatsActivity"
android:exported="false"
android:theme="@style/DolphinSettingsBase"
android:theme="@style/Theme.Dolphin.Settings"
android:label="@string/cheats"/>

<activity
android:name=".activities.EmulationActivity"
android:exported="false"
android:theme="@style/DolphinEmulationBase"
android:theme="@style/Theme.Dolphin.Main.Emulation"
android:preferMinimalPostProcessing="true"/>

<activity
android:name=".activities.CustomFilePickerActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/FilePickerTheme">
android:theme="@style/Theme.Dolphin.FilePicker">

<intent-filter>
<action android:name="android.intent.action.GET_CONTENT"/>
Expand All @@ -119,18 +119,18 @@
<activity
android:name=".activities.ConvertActivity"
android:exported="false"
android:theme="@style/DolphinBase" />
android:theme="@style/Theme.Dolphin.Main" />

<activity
android:name=".activities.UserDataActivity"
android:exported="false"
android:label="@string/user_data_submenu"
android:theme="@style/DolphinSettingsBase" />
android:theme="@style/Theme.Dolphin.Settings" />

<activity
android:name=".features.riivolution.ui.RiivolutionBootActivity"
android:exported="false"
android:theme="@style/DolphinBase" />
android:theme="@style/Theme.Dolphin.Main" />

<service
android:name=".services.SyncChannelJobService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static void performLaunchChecks(FragmentActivity activity,
}
else
{
AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(R.string.unavailable_paths);
builder.setPositiveButton(R.string.yes, (dialogInterface, i) ->
SettingsActivity.launch(activity, MenuTag.CONFIG_PATHS));
Expand Down Expand Up @@ -807,7 +807,7 @@ public boolean dispatchKeyEvent(KeyEvent event)

private void toggleControls()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_toggle_controls);
if (!NativeLibrary.IsEmulatingWii() || mPreferences.getInt("wiiController", 3) == 0)
{
Expand Down Expand Up @@ -869,7 +869,7 @@ else if (mPreferences.getInt("wiiController", 3) == 4)

public void chooseDoubleTapButton()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);

int currentController =
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUK);
Expand Down Expand Up @@ -955,7 +955,7 @@ public void onStopTrackingTouch(SeekBar seekBar)
});
valueOpacity.setText(seekbarOpacity.getProgress() + "%");

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_control_adjustments);
builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
Expand All @@ -977,7 +977,7 @@ public void onStopTrackingTouch(SeekBar seekBar)
private void chooseController()
{
final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_choose_controller);
builder.setSingleChoiceItems(R.array.controllersEntries,
mPreferences.getInt("wiiController", 3),
Expand All @@ -999,7 +999,7 @@ private void chooseController()

private void showMotionControlsOptions()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_motion_controls);
builder.setSingleChoiceItems(R.array.motionControlsEntries,
IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings),
Expand All @@ -1019,7 +1019,7 @@ private void showMotionControlsOptions()

private void setIRMode()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_ir_mode);
builder.setSingleChoiceItems(R.array.irModeEntries,
IntSetting.MAIN_IR_MODE.getInt(mSettings),
Expand Down Expand Up @@ -1129,7 +1129,7 @@ private void setIRSensitivity()
}
});

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.emulation_ir_sensitivity));
builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
Expand Down Expand Up @@ -1162,7 +1162,7 @@ private void setIRSensitivity()

private void resetOverlay()
{
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
mEmulationFragment.resetInputOverlay())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data)
{
Uri uri = data.getData();

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setMessage(R.string.user_data_import_warning);
builder.setNegativeButton(R.string.no, (dialog, i) -> dialog.dismiss());
Expand Down Expand Up @@ -148,7 +148,7 @@ private void openFileManager()
{
// Activity not found. Perhaps it was removed by the OEM, or by some new Android version
// that didn't exist at the time of writing. Not much we can do other than tell the user
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setMessage(R.string.user_data_open_system_file_manager_failed)
.setPositiveButton(R.string.ok, null)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
boolean isWarning = requireArguments().getBoolean(ARG_IS_WARNING);
setCancelable(false);

AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity,
R.style.DolphinDialogBase)
AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity)
.setTitle(title)
.setMessage(message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
{
GameFile gameFile = GameFileCacheManager.addOrGet(getArguments().getString(ARG_GAME_PATH));

AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater()
.inflate(R.layout.dialog_game_details, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
itemsBuilder.add(R.string.properties_clear_game_settings, (dialog, i) ->
clearGameSettingsWithConfirmation(gameId));

AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
itemsBuilder.applyToBuilder(builder);
builder.setTitle(requireContext()
.getString(R.string.preferences_game_properties_with_game_id, gameId));
Expand All @@ -127,7 +126,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)

private void clearGameSettingsWithConfirmation(String gameId)
{
new AlertDialog.Builder(requireContext(), R.style.DolphinDialogBase)
new AlertDialog.Builder(requireContext())
.setTitle(R.string.properties_clear_game_settings)
.setMessage(R.string.properties_clear_game_settings_confirmation)
.setPositiveButton(R.string.yes, (dialog, i) -> clearGameSettings(gameId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void clearEditErrors()
private void onDeleteClicked(View view)
{
AlertDialog.Builder builder =
new AlertDialog.Builder(requireContext(), R.style.DolphinDialogBase);
new AlertDialog.Builder(requireContext());
builder.setMessage(getString(R.string.cheats_delete_confirmation, mCheat.getName()));
builder.setPositiveButton(R.string.yes, (dialog, i) -> mViewModel.deleteSelectedCheat());
builder.setNegativeButton(R.string.no, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public Settings loadGameSpecificSettings()

public void downloadGeckoCodes()
{
AlertDialog progressDialog = new AlertDialog.Builder(this, R.style.DolphinDialogBase).create();
AlertDialog progressDialog = new AlertDialog.Builder(this).create();
progressDialog.setTitle(R.string.cheats_downloading);
progressDialog.setCancelable(false);
progressDialog.show();
Expand All @@ -206,14 +206,14 @@ public void downloadGeckoCodes()

if (codes == null)
{
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setMessage(getString(R.string.cheats_download_failed))
.setPositiveButton(R.string.ok, null)
.show();
}
else if (codes.length == 0)
{
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setMessage(getString(R.string.cheats_download_empty))
.setPositiveButton(R.string.ok, null)
.show();
Expand All @@ -223,7 +223,7 @@ else if (codes.length == 0)
int cheatsAdded = mViewModel.addDownloadedGeckoCodes(codes);
String message = getString(R.string.cheats_download_succeeded, codes.length, cheatsAdded);

new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton(R.string.ok, null)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void hideLoading()
@Override
public void showGameIniJunkDeletionQuestion()
{
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
new AlertDialog.Builder(this)
.setTitle(getString(R.string.game_ini_junk_title))
.setMessage(getString(R.string.game_ini_junk_question))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public void onSingleChoiceClick(SingleChoiceSetting item, int position)

int value = getSelectionForSingleChoiceValue(item);

AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), value, this);
Expand All @@ -209,8 +208,7 @@ public void onStringSingleChoiceClick(StringSingleChoiceSetting item, int positi
mClickedItem = item;
mClickedPosition = position;

AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(getSettings()),
Expand All @@ -227,8 +225,7 @@ public void onSingleChoiceDynamicDescriptionsClick(SingleChoiceSettingDynamicDes

int value = getSelectionForSingleChoiceDynamicDescriptionsValue(item);

AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

builder.setTitle(item.getName());
builder.setSingleChoiceItems(item.getChoicesId(), value, this);
Expand All @@ -242,8 +239,7 @@ public void onSliderClick(SliderSetting item, int position)
mClickedPosition = position;
mSeekbarMinValue = item.getMin();
mSeekbarProgress = item.getSelectedValue(getSettings());
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity());

LayoutInflater inflater = LayoutInflater.from(mView.getActivity());
View view = inflater.inflate(R.layout.dialog_seekbar, null);
Expand Down Expand Up @@ -303,7 +299,7 @@ public void onFilePickerDirectoryClick(SettingsItem item, int position)

if (!PermissionsHandler.isExternalStorageLegacy())
{
AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setMessage(R.string.path_not_changeable_scoped_storage);
builder.setPositiveButton(R.string.ok, (dialog, i) -> dialog.dismiss());
builder.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onClick(View clicked)

if (alertTextID > 0)
{
AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase)
AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
.setTitle(mItem.getName())
.setMessage(alertTextID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public boolean onLongClick(View clicked)

Context context = clicked.getContext();

AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DolphinDialogBase)
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setMessage(R.string.setting_clear_confirm);

builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState)
R.string.japan), getString(R.string.korea), getString(R.string.united_states)};
int checkedItem = -1;

return new AlertDialog.Builder(requireContext(), R.style.DolphinDialogBase)
return new AlertDialog.Builder(requireContext())
.setTitle(R.string.region_select_title)
.setSingleChoiceItems(items, checkedItem, (dialog, which) ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SystemMenuNotInstalledDialogFragment extends DialogFragment
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
return new AlertDialog.Builder(requireContext(), R.style.DolphinDialogBase)
return new AlertDialog.Builder(requireContext())
.setTitle(R.string.system_menu_not_installed_title)
.setMessage(R.string.system_menu_not_installed_message)
.setPositiveButton(R.string.yes, (dialog, which) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
throw new IllegalStateException("Unexpected value: " + mResult);
}

return new AlertDialog.Builder(requireContext(), R.style.DolphinDialogBase)
return new AlertDialog.Builder(requireContext())
.setTitle(title)
.setMessage(message)
.setPositiveButton(R.string.ok, (dialog, which) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private Runnable addAreYouSureDialog(Runnable action, @StringRes int warning_tex
return () ->
{
Context context = requireContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(warning_text)
.setPositiveButton(R.string.yes, (dialog, i) -> action.run())
.setNegativeButton(R.string.no, null);
Expand Down Expand Up @@ -459,7 +459,7 @@ private void convert(String outPath)
{
progressDialog.dismiss();

AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DolphinDialogBase);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (success)
{
builder.setMessage(R.string.convert_success_message)
Expand Down
Loading

0 comments on commit 31232f8

Please sign in to comment.