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

Commit b14a68ad authored by Ben Reich's avatar Ben Reich
Browse files

Introduce a new DocumentsDefaultM3Theme behind a flag

This theme will serve as the entry point for the material 3 uplift.
It also parents at the Theme.Material3.DynamicColors theme and applies
DynamicColors to the current activity when available.

Currently the theme is a copy paste from the existing theme with the
parent updated. Subsequent CLs will repoint the style references to
their corresponding M3 variants or remove them entirely if the
underlying theme is WAI.

Bug: 377771410
Test: m DocumentsUIGoogle && adb install DocumentsUIGoogle.apk
Flag: com.android.documentsui.flags.use_material3

Change-Id: Ib0ab7ed89f879304ebd475e316b5d1f16d3ee889
parent c444e086
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -77,6 +77,36 @@
        <item name="android:itemTextAppearance">@style/MenuItemTextAppearance</item>
    </style>

    <!-- Theme used for Material 3 uplift, hidden behind the use_material3 flag. -->
    <style name="DocumentsDefaultM3Theme" parent="@style/Theme.Material3.DynamicColors.DayNight.NoActionBar">

        <!-- This only used by support lib, not allow to overlay -->
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>

        <!-- For material design widget, chips, buttons, not support attr-->
        <item name="colorPrimary">@color/primary</item>
        <item name="colorAccent">@color/primary</item>

        <!-- TODO need to solve the error handle in GridItemThumbnail -->
        <item name="gridItemTint">@color/item_doc_grid_tint</item>

        <item name="actionBarTheme">@style/ActionBarTheme</item>
        <item name="actionModeStyle">@style/ActionModeStyle</item>
        <item name="actionOverflowButtonStyle">@style/OverflowButtonStyle</item>
        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item>
        <item name="alertDialogTheme">@style/AlertDialogTheme</item>
        <item name="autoCompleteTextViewStyle">@style/AutoCompleteTextViewStyle</item>
        <item name="bottomSheetDialogTheme">@style/BottomSheetDialogStyle</item>
        <item name="materialButtonStyle">@style/MaterialButton</item>
        <item name="materialButtonOutlinedStyle">@style/MaterialOutlinedButton</item>
        <item name="materialCardViewStyle">@style/CardViewStyle</item>
        <item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
        <item name="queryBackground">@color/menu_search_background</item>
        <item name="snackbarButtonStyle">@style/SnackbarButtonStyle</item>
        <item name="android:itemTextAppearance">@style/MenuItemTextAppearance</item>
    </style>

    <style name="TabTheme" parent="@android:style/Theme.DeviceDefault.DayNight">
        <item name="colorPrimary">@color/edge_effect</item>
    </style>
+9 −2
Original line number Diff line number Diff line
@@ -19,6 +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 android.content.Context;
import android.content.Intent;
@@ -78,6 +79,7 @@ import com.android.documentsui.sorting.SortModel;
import com.android.modules.utils.build.SdkLevel;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.color.DynamicColors;

import java.util.ArrayList;
import java.util.Date;
@@ -178,8 +180,13 @@ public abstract class BaseActivity

        // ToDo Create tool to check resource version before applyStyle for the theme
        // If version code is not match, we should reset overlay package to default,
        // in case Activity continueusly encounter resource not found exception
        // in case Activity continuously encounter resource not found exception.
        if (useMaterial3() && SdkLevel.isAtLeastS()) {
            getTheme().applyStyle(R.style.DocumentsDefaultM3Theme, false);
            DynamicColors.applyToActivityIfAvailable(this);
        } else {
            getTheme().applyStyle(R.style.DocumentsDefaultTheme, false);
        }

        super.onCreate(savedInstanceState);