Merge "Settings: Adapt edge-to-edge enforcement" into main am: 9befb6cd8f
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/3142636
Change-Id: Ibfc5f8fb007d93d618c4a0c67e396677329b5728
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/wifi/WifiConfigInfo.java b/src/com/android/settings/wifi/WifiConfigInfo.java
index 0de3063..16a4446 100644
--- a/src/com/android/settings/wifi/WifiConfigInfo.java
+++ b/src/com/android/settings/wifi/WifiConfigInfo.java
@@ -37,6 +37,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ WifiUtils.setupEdgeToEdge(this);
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
setContentView(R.layout.wifi_config_info);
diff --git a/src/com/android/settings/wifi/WifiStatusTest.java b/src/com/android/settings/wifi/WifiStatusTest.java
index b4f3ab6..b9b1d70 100644
--- a/src/com/android/settings/wifi/WifiStatusTest.java
+++ b/src/com/android/settings/wifi/WifiStatusTest.java
@@ -115,6 +115,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ WifiUtils.setupEdgeToEdge(this);
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index 68d8beb..e307bcf 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -16,6 +16,8 @@
package com.android.settings.wifi;
+import android.app.ActionBar;
+import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -32,8 +34,13 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.util.TypedValue;
+import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -308,4 +315,34 @@
public static void setCanShowWifiHotspotCached(Boolean cached) {
sCanShowWifiHotspotCached = cached;
}
+
+ /**
+ * Enable new edge to edge feature.
+ *
+ * @param activity the Activity need to setup the edge to edge feature.
+ */
+ public static void setupEdgeToEdge(@NonNull Activity activity) {
+ final ActionBar actionBar = activity.getActionBar();
+ if (actionBar == null) {
+ return;
+ }
+
+ final TypedValue typedValue = new TypedValue();
+ if (activity.getTheme().resolveAttribute(
+ com.android.internal.R.attr.actionBarSize, typedValue, true)) {
+ ViewCompat.setOnApplyWindowInsetsListener(activity.findViewById(android.R.id.content),
+ (v, windowInsets) -> {
+ Insets insets = windowInsets.getInsets(
+ WindowInsetsCompat.Type.systemBars() |
+ WindowInsetsCompat.Type.ime());
+
+ // Apply the insets paddings to the view.
+ v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
+
+ // Return CONSUMED if you don't want the window insets to keep being
+ // passed down to descendant views.
+ return WindowInsetsCompat.CONSUMED;
+ });
+ }
+ }
}