Fix the action bar shows up problem
- Hide the internal action bar. - Refine the Utils.setupEdgeToEdge API. - Rollback the testcases. Bug: 328622648 Fixes: 331308440 Test: atest com.android.settings.UtilsTest SettingsActivityTest Change-Id: I7dfbc93def3e772b57bf06b8276315cee7402a9c
This commit is contained in:
@@ -1385,20 +1385,19 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
* @param activity the Activity need to setup the edge to edge feature.
|
||||
*/
|
||||
public static void setupEdgeToEdge(@NonNull FragmentActivity activity) {
|
||||
if (com.android.window.flags.Flags.enforceEdgeToEdge()) {
|
||||
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);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(activity.findViewById(android.R.id.content),
|
||||
(v, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(
|
||||
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
|
||||
int statusBarHeight = activity.getWindow().getDecorView().getRootWindowInsets()
|
||||
.getInsets(WindowInsetsCompat.Type.statusBars()).top;
|
||||
// Apply the insets paddings to the view.
|
||||
v.setPadding(insets.left, statusBarHeight, 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;
|
||||
});
|
||||
}
|
||||
// Return CONSUMED if you don't want the window insets to keep being
|
||||
// passed down to descendant views.
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
}
|
||||
|
||||
private static FaceManager.RemovalCallback faceManagerRemovalCallback(int userId) {
|
||||
|
@@ -46,6 +46,7 @@ import com.android.settings.Utils;
|
||||
import com.android.settings.core.CategoryMixin.CategoryHandler;
|
||||
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
import com.android.window.flags.Flags;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
@@ -92,8 +93,11 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
||||
Log.w(TAG, "Devices lock task mode pinned.");
|
||||
finish();
|
||||
}
|
||||
Utils.setupEdgeToEdge(this);
|
||||
final long startTime = System.currentTimeMillis();
|
||||
if (Flags.enforceEdgeToEdge()) {
|
||||
Utils.setupEdgeToEdge(this);
|
||||
hideInternalActionBar();
|
||||
}
|
||||
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||
TextAppearanceConfig.setShouldLoadFontSynchronously(true);
|
||||
|
||||
@@ -291,4 +295,18 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
||||
}
|
||||
return intent.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* This internal ActionBar will be appeared automatically when the
|
||||
* Utils.setupEdgeToEdge is invoked.
|
||||
*
|
||||
* @see Utils.setupEdgeToEdge
|
||||
*/
|
||||
private void hideInternalActionBar() {
|
||||
final View actionBarContainer =
|
||||
findViewById(com.android.internal.R.id.action_bar_container);
|
||||
if (actionBarContainer != null) {
|
||||
actionBarContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user