From 5e457e95683241501846d0d0403533a293307a88 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 25 Nov 2021 14:16:05 +0100 Subject: ensure advanced settings subtitle is shown after orientation change or after moving back from sub fragment --- .../base/fragments/NavigationDrawerFragment.java | 1 - .../leap/bitmaskclient/base/fragments/SettingsFragment.java | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java index e9881094..cc3ecca6 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java @@ -275,7 +275,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen advancedSettings.setOnClickListener(v -> { closeDrawer(); Fragment fragment = new SettingsFragment(); - setActionBarTitle(advanced_settings); fragmentManager.replace(R.id.main_container, fragment, MainActivity.TAG); }); } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java index 7157d1cc..ae2a1052 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java @@ -10,6 +10,9 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -30,6 +33,7 @@ import se.leap.bitmaskclient.firewall.FirewallManager; import static android.content.Context.MODE_PRIVATE; import static android.view.View.GONE; import static android.view.View.VISIBLE; +import static se.leap.bitmaskclient.R.string.advanced_settings; import static se.leap.bitmaskclient.base.MainActivity.ACTION_SHOW_VPN_FRAGMENT; import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES; @@ -70,6 +74,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh initUseSnowflakeEntry(view); initFirewallEntry(view); initTetheringEntry(view); + setActionBarTitle(advanced_settings); return view; } @@ -242,4 +247,12 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh initFirewallEntry(getView()); } } + + private void setActionBarTitle(@StringRes int stringId) { + ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); + if (actionBar != null) { + actionBar.setSubtitle(stringId); + } + } + } -- cgit v1.2.3