mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-27 09:13:53 +01:00
Switch theme without user obstruction
This commit is contained in:
parent
b233f4dcb7
commit
30381ca09a
@ -76,6 +76,7 @@ public class MainActivity extends CastEnabledActivity {
|
|||||||
private LockableBottomSheetBehavior sheetBehavior;
|
private LockableBottomSheetBehavior sheetBehavior;
|
||||||
private long lastBackButtonPressTime = 0;
|
private long lastBackButtonPressTime = 0;
|
||||||
private RecyclerView.RecycledViewPool recycledViewPool = new RecyclerView.RecycledViewPool();
|
private RecyclerView.RecycledViewPool recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
|
private int lastTheme = 0;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static Intent getIntentToOpenFeed(@NonNull Context context, long feedId) {
|
public static Intent getIntentToOpenFeed(@NonNull Context context, long feedId) {
|
||||||
@ -87,7 +88,8 @@ public class MainActivity extends CastEnabledActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
setTheme(UserPreferences.getNoTitleTheme());
|
lastTheme = UserPreferences.getNoTitleTheme();
|
||||||
|
setTheme(lastTheme);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
StorageUtils.checkStorageAvailability(this);
|
StorageUtils.checkStorageAvailability(this);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
@ -323,11 +325,12 @@ public class MainActivity extends CastEnabledActivity {
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
RatingDialog.init(this);
|
RatingDialog.init(this);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (lastTheme != UserPreferences.getNoTitleTheme()) {
|
||||||
protected void onPause() {
|
// Nav drawer is empty for half a second after recreating. Don't confuse users with that.
|
||||||
super.onPause();
|
drawerLayout.closeDrawer(navDrawer);
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,8 @@ import de.danoeh.antennapod.fragment.preferences.UserInterfacePreferencesFragmen
|
|||||||
* PreferenceController.
|
* PreferenceController.
|
||||||
*/
|
*/
|
||||||
public class PreferenceActivity extends AppCompatActivity implements SearchPreferenceResultListener {
|
public class PreferenceActivity extends AppCompatActivity implements SearchPreferenceResultListener {
|
||||||
|
private static final String FRAGMENT_TAG = "tag_preferences";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setTheme(UserPreferences.getTheme());
|
setTheme(UserPreferences.getTheme());
|
||||||
@ -44,8 +46,11 @@ public class PreferenceActivity extends AppCompatActivity implements SearchPrefe
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
setContentView(root);
|
setContentView(root);
|
||||||
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.content, new MainPreferencesFragment()).commit();
|
if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.content, new MainPreferencesFragment(), FRAGMENT_TAG)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PreferenceFragmentCompat getPreferenceScreen(int screen) {
|
private PreferenceFragmentCompat getPreferenceScreen(int screen) {
|
||||||
|
@ -35,11 +35,7 @@ public class UserInterfacePreferencesFragment extends PreferenceFragmentCompat {
|
|||||||
findPreference(UserPreferences.PREF_THEME)
|
findPreference(UserPreferences.PREF_THEME)
|
||||||
.setOnPreferenceChangeListener(
|
.setOnPreferenceChangeListener(
|
||||||
(preference, newValue) -> {
|
(preference, newValue) -> {
|
||||||
Intent i = new Intent(getActivity(), MainActivity.class);
|
getActivity().recreate();
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
|
|
||||||
| Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
getActivity().finish();
|
|
||||||
startActivity(i);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user