mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Re-open DisplayFragment after changing theme
This commit is contained in:
@@ -31,6 +31,7 @@ import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.briar.android.BriarApplication.ENTRY_ACTIVITY;
|
||||
import static org.briarproject.briar.android.navdrawer.NavDrawerActivity.SIGN_OUT_URI;
|
||||
import static org.briarproject.briar.android.settings.SettingsActivity.EXTRA_THEME_CHANGE;
|
||||
|
||||
@NotNullByDefault
|
||||
public class DisplayFragment extends PreferenceFragmentCompat {
|
||||
@@ -131,8 +132,8 @@ public class DisplayFragment extends PreferenceFragmentCompat {
|
||||
intent.setFlags(FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
// bring this activity back to the foreground
|
||||
// TODO maybe tell the activity here to relaunch this fragment?
|
||||
intent = new Intent(getActivity(), activity.getClass());
|
||||
intent.putExtra(EXTRA_THEME_CHANGE, true);
|
||||
startActivity(intent);
|
||||
activity.finish();
|
||||
return true;
|
||||
|
||||
@@ -23,6 +23,8 @@ import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCal
|
||||
public class SettingsActivity extends BriarActivity
|
||||
implements OnPreferenceStartFragmentCallback {
|
||||
|
||||
static final String EXTRA_THEME_CHANGE = "themeChange";
|
||||
|
||||
@Override
|
||||
public void injectActivity(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
@@ -38,6 +40,14 @@ public class SettingsActivity extends BriarActivity
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// show display fragment after theme change
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (bundle == null && extras != null &&
|
||||
extras.getBoolean(EXTRA_THEME_CHANGE, false)) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
showNextFragment(fragmentManager, new DisplayFragment());
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_settings);
|
||||
}
|
||||
|
||||
@@ -59,14 +69,18 @@ public class SettingsActivity extends BriarActivity
|
||||
.instantiate(getClassLoader(), pref.getFragment());
|
||||
fragment.setTargetFragment(caller, 0);
|
||||
// Replace the existing Fragment with the new Fragment
|
||||
showNextFragment(fragmentManager, fragment);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showNextFragment(FragmentManager fragmentManager, Fragment f) {
|
||||
fragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.step_next_in,
|
||||
R.anim.step_previous_out, R.anim.step_previous_in,
|
||||
R.anim.step_next_out)
|
||||
.replace(R.id.fragmentContainer, fragment)
|
||||
.replace(R.id.fragmentContainer, f)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user