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

Commit 725f07ab authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Extract flags into their own Util class" into main

parents 4d0d9d44 f5ac84e6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}

ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES}
docsui_checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT} --config_xml ${REPO_ROOT}/packages/apps/DocumentsUI/preupload-checks.xml

preupload-checks.xml

0 → 100644
+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ 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.
  -->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="RegexpSinglelineJava">
            <property name="ignoreComments" value="true" />
            <property name="severity" value="error" />
            <property name="format" value="com.android.documentsui.flags.Flags" />
            <property name="message" value="Please don't use Flags.* directly, instead add the flag to FlagUtils and use that instead." />
        </module>
    </module>
</module>
+4 −4
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.documentsui;
import static com.android.documentsui.base.DocumentInfo.getCursorInt;
import static com.android.documentsui.base.DocumentInfo.getCursorString;
import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.flags.Flags.desktopFileHandling;
import static com.android.documentsui.flags.Flags.useSearchV2Rw;
import static com.android.documentsui.util.FlagUtils.isDesktopFileHandlingFlagEnabled;
import static com.android.documentsui.util.FlagUtils.isUseSearchV2RwFlagEnabled;

import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
@@ -576,7 +576,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
            flags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
        }
        // On desktop users expect files to open in a new window.
        if (desktopFileHandling()) {
        if (isDesktopFileHandlingFlagEnabled()) {
            // The combination of NEW_DOCUMENT and MULTIPLE_TASK allows multiple instances of the
            // same activity to open in separate windows.
            flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
@@ -916,7 +916,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
                mState.stack.changeRoot(mActivity.getCurrentRoot());
            }

            if (useSearchV2Rw()) {
            if (isUseSearchV2RwFlagEnabled()) {
                return onCreateLoaderV2(id, args);
            }
            return onCreateLoaderV1(id, args);
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.documentsui;

import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.flags.Flags.useMaterial3;
import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;

import android.app.Activity;
import android.util.Log;
@@ -138,7 +138,7 @@ public class ActionModeController extends SelectionObserver<String>

        // Re-enable TalkBack for the toolbars, as they are no longer covered by action mode.
        int[] toolbarIds =
                useMaterial3()
                isUseMaterial3FlagEnabled()
                        ? new int[] {R.id.toolbar}
                        : new int[] {R.id.toolbar, R.id.roots_toolbar};
        mScope.accessibilityImportanceSetter.setAccessibilityImportance(
@@ -159,7 +159,7 @@ public class ActionModeController extends SelectionObserver<String>
            // Hide the toolbars if action mode is enabled, so TalkBack doesn't navigate to
            // these controls when using linear navigation.
            int[] toolbarIds =
                    useMaterial3()
                    isUseMaterial3FlagEnabled()
                            ? new int[] {R.id.toolbar}
                            : new int[] {R.id.toolbar, R.id.roots_toolbar};
            mScope.accessibilityImportanceSetter.setAccessibilityImportance(
+12 −12
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.documentsui;
import static com.android.documentsui.base.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.base.State.MODE_GRID;
import static com.android.documentsui.flags.Flags.useMaterial3;
import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;

import android.content.Context;
import android.content.Intent;
@@ -184,7 +184,7 @@ public abstract class BaseActivity
        // in case Activity continuously encounter resource not found exception.
        getTheme().applyStyle(R.style.DocumentsDefaultTheme, false);

        if (useMaterial3() && SdkLevel.isAtLeastS()) {
        if (isUseMaterial3FlagEnabled() && SdkLevel.isAtLeastS()) {
            DynamicColors.applyToActivityIfAvailable(this);
        }

@@ -205,7 +205,7 @@ public abstract class BaseActivity
        mDrawer = DrawerController.create(this, mInjector.config);
        Metrics.logActivityLaunch(mState, intent);

        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            View navRailRoots = findViewById(R.id.nav_rail_container_roots);
            if (navRailRoots != null) {
                // Bind event listener for the burger menu on nav rail.
@@ -369,7 +369,7 @@ public abstract class BaseActivity
            if (roots != null) {
                roots.onSelectedUserChanged();
            }
            if (useMaterial3()) {
            if (isUseMaterial3FlagEnabled()) {
                final RootsFragment navRailRoots =
                        RootsFragment.getNavRail(getSupportFragmentManager());
                if (navRailRoots != null) {
@@ -397,7 +397,7 @@ public abstract class BaseActivity
        });

        mSortController = SortController.create(this, mState.derivedMode, mState.sortModel);
        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            View previewIconPlaceholder = findViewById(R.id.preview_icon_placeholder);
            if (previewIconPlaceholder != null) {
                previewIconPlaceholder.setVisibility(
@@ -454,7 +454,7 @@ public abstract class BaseActivity
        super.onPostCreate(savedInstanceState);

        Runnable finishActionMode =
                (useMaterial3())
                (isUseMaterial3FlagEnabled())
                        ? mNavigator::closeSelectionBar
                        : mInjector.actionModeController::finishActionMode;

@@ -479,7 +479,7 @@ public abstract class BaseActivity

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            // In Material3 the menu is now inflated in the `NavigationViewMenu`. This is currently
            // to allow for us to inflate between the action_menu and the activity menu. Once the
            // Material 3 flag is removed, the menus will be merged and we can rely on this single
@@ -510,7 +510,7 @@ public abstract class BaseActivity
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        // Remove the subMenu when material3 is launched b/379776735.
        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            if (mNavigator != null) {
                mNavigator.updateActionMenu();
            }
@@ -574,7 +574,7 @@ public abstract class BaseActivity
                    insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0);

            // in M3, no additional bottom gap in full screen mode.
            if (!useMaterial3()) {
            if (!isUseMaterial3FlagEnabled()) {
                View saveContainer = findViewById(R.id.container_save);
                saveContainer.setPadding(
                        0, 0, 0, insets.getSystemWindowInsetBottom());
@@ -617,7 +617,7 @@ public abstract class BaseActivity
            return;
        }

        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            mNavigator.closeSelectionBar();
        } else {
            mInjector.actionModeController.finishActionMode();
@@ -759,7 +759,7 @@ public abstract class BaseActivity
        if (roots != null) {
            roots.onCurrentRootChanged();
        }
        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            final RootsFragment navRailRoots =
                    RootsFragment.getNavRail(getSupportFragmentManager());
            if (navRailRoots != null) {
@@ -843,7 +843,7 @@ public abstract class BaseActivity
        mState.derivedMode = mode;

        // Remove the subMenu when material3 is launched b/379776735.
        if (useMaterial3()) {
        if (isUseMaterial3FlagEnabled()) {
            mInjector.menuManager.updateSubMenu(null);
        } else {
            final ActionMenuView subMenuView = findViewById(R.id.sub_menu);
Loading