Update Settings title in subscreens

This commit is contained in:
xynngh 2020-10-18 01:11:41 +04:00
parent cdfbf146f0
commit dd05446dee
2 changed files with 17 additions and 8 deletions

View File

@ -15,7 +15,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceFragmentCompat;
@ -90,12 +89,14 @@ public class SettingsActivity extends AppCompatActivity
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey()); args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
fragment.setArguments(args); fragment.setArguments(args);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); getSupportFragmentManager()
ft.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, .beginTransaction()
R.anim.enter_from_left, R.anim.exit_to_right); .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left,
ft.replace(R.id.settings, fragment, preferenceScreen.getKey()); R.anim.enter_from_left, R.anim.exit_to_right)
ft.addToBackStack(preferenceScreen.getKey()); .replace(R.id.settings, fragment, preferenceScreen.getKey())
ft.commit(); .addToBackStack(preferenceScreen.getKey())
.commit();
return true; return true;
} }
@ -144,6 +145,13 @@ public class SettingsActivity extends AppCompatActivity
private final UpdateScheduler updateScheduler = UpdateScheduler.get(App.getInstance()); private final UpdateScheduler updateScheduler = UpdateScheduler.get(App.getInstance());
@Override
public void onStart() {
super.onStart();
requireActivity().setTitle(getPreferenceScreen().getTitle());
}
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getPreferenceManager().setStorageDeviceProtected(); getPreferenceManager().setStorageDeviceProtected();

View File

@ -1,4 +1,5 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
app:title="@string/title_settings_activity">
<PreferenceCategory app:title="@string/settings_category_main"> <PreferenceCategory app:title="@string/settings_category_main">
<SwitchPreferenceCompat <SwitchPreferenceCompat