Fix edge to edge issue on Blocked Numbers edit screen.
Fixes: 397097211
Flag: NONE UX only fix.
Test: Manual
Change-Id: I40e7222672e2eb7bab865e63cc68301fb531bdb1
diff --git a/src/com/android/server/telecom/settings/BlockedNumbersActivity.java b/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
index edc8da6..801ec49 100644
--- a/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
+++ b/src/com/android/server/telecom/settings/BlockedNumbersActivity.java
@@ -18,6 +18,7 @@
import android.annotation.Nullable;
import android.app.ActionBar;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
@@ -54,6 +55,10 @@
import android.widget.TextView;
import android.widget.Toast;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.telecom.R;
import com.android.server.telecom.flags.FeatureFlags;
@@ -109,6 +114,7 @@
// set the talkback voice prompt to "Back" instead of "Navigate Up"
actionBar.setHomeActionContentDescription(R.string.back);
}
+ setupEdgeToEdge(this);
if (!BlockedNumberContract.canCurrentUserBlockNumbers(this)) {
TextView nonPrimaryUserText = (TextView) findViewById(R.id.non_primary_user);
@@ -358,4 +364,23 @@
}
mAddButton.setEnabled(true);
}
+
+ /**
+ * Given an activity, configure the activity to adjust for edge to edge restrictions.
+ * @param activity the activity.
+ */
+ public static void setupEdgeToEdge(Activity activity) {
+ 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;
+ });
+ }
}
\ No newline at end of file