Skip to content

Commit

Permalink
Fix RadioDialog view's selection method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Apr 27, 2023
1 parent 6082394 commit 730a2dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,12 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
public void onItemSelected(int dialogId, int selectedIndex) {
switch (dialogId) {
case 0:
if (!getResources().getConfiguration().getLocales().get(0).getLanguage().equals(Arrays.asList(getResources().getStringArray(R.array.locale_code)).get(selectedIndex))) {
Prefs.putString(APP_LANGUAGE, Arrays.asList(getResources().getStringArray(R.array.locale_code)).get(selectedIndex));
restartApplication(requireActivity());
}
Prefs.putString(APP_LANGUAGE, Arrays.asList(getResources().getStringArray(R.array.locale_code)).get(selectedIndex));
restartApplication(requireActivity());
break;
case 1:
if (selectedIndex != Prefs.getInt(APP_THEME, 2)) {
Prefs.putInt(APP_THEME, selectedIndex);
restartApplication(requireActivity());
}
Prefs.putInt(APP_THEME, selectedIndex);
restartApplication(requireActivity());
break;
case 2:
Prefs.putInt(FORCE_APPLY_XPOSED_CHOICE, selectedIndex == 2 ? -1 : selectedIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public void show(int title, int items, TextView output) {
radioGroup.addView(radioButton);
}

((RadioButton) radioGroup.getChildAt(selectedIndex)).setChecked(true);

radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
selectedIndex = checkedId;
dialog.hide();
Expand All @@ -66,8 +68,6 @@ public void show(int title, int items, TextView output) {
}
});

((RadioButton) radioGroup.getChildAt(selectedIndex)).setChecked(true);

dialog.create();
dialog.show();

Expand Down

0 comments on commit 730a2dd

Please sign in to comment.