diff options
author | Simon Wingrove <simonjw@google.com> | 2023-06-27 14:00:48 +0100 |
---|---|---|
committer | Simon Wingrove <simonjw@google.com> | 2023-06-28 08:16:37 +0100 |
commit | 769ea57ec03edc5b41b3d8b2906075a0cbc5ef17 (patch) | |
tree | d07a7ce48e4ae7193914cc0b5bdddce96a4ca002 /PermissionController/src/com | |
parent | 0ac1ec1039eae88efe5ffede3c30f399cb31e876 (diff) | |
download | Permission-769ea57ec03edc5b41b3d8b2906075a0cbc5ef17.tar.gz |
Implement onConfigurationChanged for Safety Center
Bug: 286814380
Test: manual
Relnote: N/A
Change-Id: Iad2bca0e8e449606740c4fe02c9a828e52f88ae2
Diffstat (limited to 'PermissionController/src/com')
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java index 8f31da828..c012a0264 100644 --- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java +++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java @@ -30,6 +30,7 @@ import static com.android.permissioncontroller.safetycenter.SafetyCenterConstant import android.app.ActionBar; import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.provider.Settings; import android.safetycenter.SafetyCenterManager; @@ -107,7 +108,30 @@ public final class SafetyCenterActivity extends CollapsingToolbarBaseActivity { .commitNow(); } + configureHomeButton(); + } + + @Override + protected void onStart() { + super.onStart(); + maybeRedirectIfDisabled(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + // We don't set configChanges, but small screen size changes may still be delivered here. + super.onConfigurationChanged(newConfig); + configureHomeButton(); + } + + /** Decide whether a home/back button should be shown or not. */ + private void configureHomeButton() { ActionBar actionBar = getActionBar(); + Fragment frag = getSupportFragmentManager().findFragmentById(R.id.content_frame); + if (actionBar == null || frag == null) { + return; + } + // Only the homepage can be considered a "second layer" page as it's the only one that // can be reached from the Settings menu. The other pages are only reachable using // a direct intent (e.g. notification, "first layer") and/or by navigating within Safety @@ -115,19 +139,12 @@ public final class SafetyCenterActivity extends CollapsingToolbarBaseActivity { // Note that the homepage can also be a "first layer" page, but that would only happen // if the activity is not embedded. boolean isSecondLayerPage = frag instanceof SafetyCenterScrollWrapperFragment; - if (actionBar != null - && ActivityEmbeddingUtils.shouldHideNavigateUpButton(this, isSecondLayerPage)) { + if (ActivityEmbeddingUtils.shouldHideNavigateUpButton(this, isSecondLayerPage)) { actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setHomeButtonEnabled(false); } } - @Override - protected void onStart() { - super.onStart(); - maybeRedirectIfDisabled(); - } - private boolean maybeRedirectIfDisabled() { if (mSafetyCenterManager == null || !mSafetyCenterManager.isSafetyCenterEnabled()) { Log.w(TAG, "Safety Center disabled, redirecting to settings page"); |