Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 410f699c authored by SongFerng Wang's avatar SongFerng Wang Committed by Automerger Merge Worker
Browse files

Merge "Settings: Adapt edge-to-edge enforcement" into main am: 9befb6cd am: e910d895

parents 9503f42e e910d895
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class WifiConfigInfo extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WifiUtils.setupEdgeToEdge(this);

        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        setContentView(R.layout.wifi_config_info);
+1 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public class WifiStatusTest extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WifiUtils.setupEdgeToEdge(this);

        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);

+37 −0
Original line number Diff line number Diff line
@@ -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.os.UserManager;
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 class WifiUtils extends com.android.settingslib.wifi.WifiUtils {
    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;
                    });
        }
    }
}