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

Commit 749acbbe authored by Edgar Wang's avatar Edgar Wang Committed by Android (Google) Code Review
Browse files

Merge "[Expressive design] handle page launched by SuW" into main

parents 633f8ba7 04ee8f37
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.appcompat.app.AppCompatActivity;

import com.android.settingslib.collapsingtoolbar.widget.ScrollableToolbarItemLayout;
import com.android.settingslib.widget.SettingsThemeHelper;
import com.android.settingslib.widget.SetupWizardHelper;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -90,6 +91,10 @@ public class CollapsingToolbarAppCompatActivity extends AppCompatActivity implem

        View view = getToolbarDelegate().onCreateView(getLayoutInflater(), null, this);
        super.setContentView(view);

        if (SetupWizardHelper.isAnySetupWizard(getIntent())) {
            findViewById(R.id.content_parent).setFitsSystemWindows(false);
        }
    }

    @Override
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.fragment.app.FragmentActivity;

import com.android.settingslib.collapsingtoolbar.widget.ScrollableToolbarItemLayout;
import com.android.settingslib.widget.SettingsThemeHelper;
import com.android.settingslib.widget.SetupWizardHelper;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
@@ -82,6 +83,10 @@ public class CollapsingToolbarBaseActivity extends FragmentActivity implements

        View view = getToolbarDelegate().onCreateView(getLayoutInflater(), null, this);
        super.setContentView(view);

        if (SetupWizardHelper.isAnySetupWizard(getIntent())) {
            findViewById(R.id.content_parent).setFitsSystemWindows(false);
        }
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.android.settingslib.widget.SetupWizardHelper;

/**
 * Util class for edge to edge.
 */
@@ -42,6 +44,10 @@ public class EdgeToEdgeUtils {
            return;
        }

        if (SetupWizardHelper.isAnySetupWizard(activity.getIntent())) {
            return;
        }

        EdgeToEdge.enable(activity);

        ViewCompat.setOnApplyWindowInsetsListener(activity.findViewById(android.R.id.content),
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib.widget

import android.content.Intent
import android.os.Build

object SetupWizardHelper {

    private const val EXTRA_IS_SETUP_FLOW = "isSetupFlow"
    private const val EXTRA_IS_FIRST_RUN = "firstRun"
    private const val EXTRA_IS_PRE_DEFERRED_SETUP = "preDeferredSetup"
    private const val EXTRA_IS_DEFERRED_SETUP = "deferredSetup"

    /**
     * Checks if the current context is within any setup wizard flow.
     *
     * On Android Q and above, it checks for the presence of the [EXTRA_IS_SETUP_FLOW] intent extra.
     * On older versions, it checks for the presence of specific extras indicating initial,
     * pre-deferred, or deferred setup ([EXTRA_IS_FIRST_RUN], [EXTRA_IS_PRE_DEFERRED_SETUP],
     * [EXTRA_IS_DEFERRED_SETUP]).
     *
     * @param intent The intent to check.
     * @return True if within any setup wizard flow, false otherwise.
     */
    @JvmStatic
    fun isAnySetupWizard(intent: Intent?): Boolean {
        if (intent == null) {
            return false
        }

        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            intent.getBooleanExtra(EXTRA_IS_SETUP_FLOW, false)
        } else {
            isLegacySetupWizard(intent)
        }
    }

    private fun isLegacySetupWizard(intent: Intent): Boolean {
        return intent.run {
            getBooleanExtra(EXTRA_IS_FIRST_RUN, false) ||
                    getBooleanExtra(EXTRA_IS_PRE_DEFERRED_SETUP, false) ||
                    getBooleanExtra(EXTRA_IS_DEFERRED_SETUP, false)
        }
    }
}
 No newline at end of file