Merge "Fix flicker of “touch to unlock anytime” toggle" into udc-dev
diff --git a/res/layout/notification_channel_panel.xml b/res/layout/notification_channel_panel.xml
index 14e10cc..7e944ac 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 9889183..dda1c65 100644
--- a/src/com/android/settings/notification/app/ChannelPanelActivity.java
+++ b/src/com/android/settings/notification/app/ChannelPanelActivity.java
@@ -28,10 +28,13 @@
 
 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 @@
 
         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 @@
         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);
+        }
+    }
 }