From 766ec49e8d941fc69a01ae8235c6424d98105c43 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 20 Apr 2023 16:07:27 -0400 Subject: [PATCH] Fix channel panel UI on 3 button nav devices Test: edit panel on 3 button & gesture nav devices Fixes: 278710039 Change-Id: I45b7e7c942578c4f49be8a0d193893cf872ff36e --- res/layout/notification_channel_panel.xml | 1 + .../app/ChannelPanelActivity.java | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/res/layout/notification_channel_panel.xml b/res/layout/notification_channel_panel.xml index 14e10cc94f5..7e944ac7e74 100644 --- a/res/layout/notification_channel_panel.xml +++ b/res/layout/notification_channel_panel.xml @@ -19,6 +19,7 @@ android:layout_height="@dimen/notif_channel_panel_max_height" android:maxHeight="@dimen/notif_channel_panel_max_height" android:background="@drawable/settings_panel_background" + android:fitsSystemWindows="true" android:orientation="vertical" android:layout_width="match_parent"> diff --git a/src/com/android/settings/notification/app/ChannelPanelActivity.java b/src/com/android/settings/notification/app/ChannelPanelActivity.java index 9889183d4d7..dda1c65869c 100644 --- a/src/com/android/settings/notification/app/ChannelPanelActivity.java +++ b/src/com/android/settings/notification/app/ChannelPanelActivity.java @@ -28,10 +28,13 @@ import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import com.android.settings.R; +import com.android.settings.Utils; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin; @@ -99,7 +102,7 @@ public class ChannelPanelActivity extends FragmentActivity { findViewById(R.id.done).setOnClickListener(v -> finish()); findViewById(R.id.see_more).setOnClickListener(v -> launchFullSettings()); - + setupNavigationBar(); mPanelFragment = callingIntent.hasExtra(Settings.EXTRA_CONVERSATION_ID) ? new ConversationNotificationSettings() : new ChannelNotificationSettings(); @@ -107,4 +110,27 @@ public class ChannelPanelActivity extends FragmentActivity { fragmentManager.beginTransaction().replace( android.R.id.list_container, mPanelFragment).commit(); } + + /** + * Adjust bottom edge and color. + */ + private void setupNavigationBar() { + // Extend the panel all the way to the bottom of the screen, as opposed to sitting on top of + // the navigation bar. + ViewCompat.setOnApplyWindowInsetsListener(getWindow().getDecorView(), + (v, windowInsets) -> { + v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), 0); + return windowInsets; // propagate down to panel layout root element + }); + + // When using 3-button navigation in light mode, the system picks white navigation buttons + // which are not sufficiently contrasted from the panel background. + WindowInsetsControllerCompat windowInsetsController = + ViewCompat.getWindowInsetsController(getWindow().getDecorView()); + + if (windowInsetsController != null) { + boolean forceNavigationButtonsDark = !Utils.isNightMode(this); + windowInsetsController.setAppearanceLightNavigationBars(forceNavigationButtonsDark); + } + } }