Re-theme Launcher3 components (#4068)

There were some themes that were remove during the 14 and 13 merge. This commit attempt to fix it.

---------

Co-authored-by: John Andrew Camu <werdna.jac@gmail.com>
This commit is contained in:
SuperDragonXD
2024-02-11 09:00:46 +08:00
committed by GitHub
parent f1f8c1c6f4
commit f686b13f8b
12 changed files with 122 additions and 56 deletions

View File

@@ -11,7 +11,7 @@ object ColorStateListTokens {
intArrayOf(),
)
val colors = intArrayOf(
ColorTokens.TextColorPrimary.resolveColor(context, scheme, uiColorMode),
ColorTokens.TextColorPrimaryInverse.resolveColor(context, scheme, uiColorMode),
ColorTokens.TextColorSecondary.resolveColor(context, scheme, uiColorMode),
)
ColorStateList(states, colors)

View File

@@ -67,7 +67,7 @@ object ColorTokens {
@JvmField val AllAppsScrimColor = ColorBackground
@JvmField val AllAppsTabBackgroundSelected = DayNightColorToken(Accent1_100, Accent2_100)
@JvmField val AllAppsTabBackgroundSelected = DayNightColorToken(Accent1_500, Accent2_500)
@JvmField val FocusHighlight = DayNightColorToken(Neutral1_0, Neutral1_700)
@@ -119,6 +119,8 @@ object ColorTokens {
@JvmField val WorkspaceAccentColor = DarkTextColorToken(Accent1_100, Accent2_600)
@JvmField val WidgetListRowColor = DayNightColorToken(Neutral1_10, Neutral2_800)
val SwitchThumbOn = Accent1_100
val SwitchThumbOff = DayNightColorToken(Neutral2_300, Neutral1_400)
val SwitchThumbDisabled = DayNightColorToken(Neutral2_100, Neutral1_700)

View File

@@ -75,9 +75,55 @@ object DrawableTokens {
val WidgetsBottomSheetBackground = ResourceDrawableToken<GradientDrawable>(R.drawable.bg_rounded_corner_bottom_sheet)
.setColor(ColorTokens.Surface)
@JvmField
val WidgetsListBackground = NewDrawable { context, scheme, uiColorMode ->
val list = StateListDrawable()
list.setEnterFadeDuration(100)
val unselected = AppCompatResources.getDrawable(
context,
R.drawable.bg_widgets_header,
)
unselected?.setTint(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
val selected = AppCompatResources.getDrawable(
context,
R.drawable.bg_widgets_header,
)
selected?.setTint(ColorTokens.WidgetListRowColor.resolveColor(context, scheme, uiColorMode))
list.addState(intArrayOf(-android.R.attr.state_selected), unselected)
list.addState(intArrayOf(android.R.attr.state_selected), selected)
list
}
@JvmField
val WidgetsContentBackground = NewDrawable { context, scheme, uiColorMode ->
val list = StateListDrawable()
list.setEnterFadeDuration(100)
val unselected = AppCompatResources.getDrawable(
context,
R.drawable.bg_widgets_content,
)
unselected?.setTint(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
val selected = AppCompatResources.getDrawable(
context,
R.drawable.bg_widgets_content,
)
selected?.setTint(ColorTokens.WidgetListRowColor.resolveColor(context, scheme, uiColorMode))
list.addState(intArrayOf(-android.R.attr.state_selected), unselected)
list.addState(intArrayOf(android.R.attr.state_selected), selected)
list
}
@JvmField
val WidgetsRecommendationBackground = ResourceDrawableToken<GradientDrawable>(R.drawable.widgets_surface_background)
.setColor(ColorTokens.Surface)
.setColor(ColorTokens.WidgetListRowColor)
@JvmField
val WidgetResizeFrame = ResourceDrawableToken<GradientDrawable>(R.drawable.widget_resize_frame)
@@ -106,6 +152,16 @@ object DrawableTokens {
list
}
@JvmField
val AllAppsTabsMaskDrawable = NewDrawable { context, scheme, uiColorMode ->
val mask = GradientDrawable()
val radius = context.resources.getDimension(R.dimen.all_apps_header_pill_corner_radius)
mask.cornerRadius = radius
mask.setColor(ColorTokens.FocusHighlight.resolveColor(context, scheme, uiColorMode))
mask
}
@JvmField
val WorkAppsToggleBackground = NewDrawable { context, scheme, uiColorMode ->
val list = StateListDrawable()
@@ -127,6 +183,7 @@ object DrawableTokens {
list
}
@JvmField val WorkCard = ResourceDrawableToken<GradientDrawable>(R.drawable.work_card)
@JvmField
val WorkCard = ResourceDrawableToken<GradientDrawable>(R.drawable.work_card)
.setColor(ColorTokens.Surface)
}

View File

@@ -14,7 +14,7 @@
limitations under the License.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/accent_ripple_color">
android:color="?android:colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/widgets_cell_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">
<!-- Section info -->
<com.android.launcher3.BubbleTextView
android:id="@+id/section"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_section_height"
android:background="?android:attr/colorPrimary"
android:drawablePadding="@dimen/widget_section_horizontal_padding"
android:focusable="true"
android:gravity="start|center_vertical"
android:paddingBottom="@dimen/widget_section_vertical_padding"
android:paddingLeft="@dimen/widget_section_horizontal_padding"
android:paddingRight="@dimen/widget_section_horizontal_padding"
android:paddingTop="@dimen/widget_section_vertical_padding"
android:singleLine="true"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp"
android:textAlignment="viewStart"
launcher:iconDisplay="widget_section"
launcher:iconSizeOverride="@dimen/widget_section_icon_size"
launcher:layoutHorizontal="true" />
<include layout="@layout/widgets_table_container" />
</LinearLayout>

View File

@@ -99,6 +99,7 @@ import java.util.stream.Stream;
import app.lawnchair.allapps.LawnchairAlphabeticalAppsList;
import app.lawnchair.font.FontManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.ui.StretchRecyclerViewContainer;
/**
@@ -207,10 +208,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mActivityContext = ActivityContext.lookupContext(context);
mAllAppsStore = new AllAppsStore<>(mActivityContext);
mScrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
mScrimColor = ColorTokens.AllAppsScrimColor.resolveColor(context);
mHeaderThreshold = getResources().getDimensionPixelSize(
R.dimen.dynamic_grid_cell_border_spacing);
mHeaderProtectionColor = Themes.getAttrColor(context, R.attr.allappsHeaderProtectionColor);
mHeaderProtectionColor = ColorTokens.AllAppsHeaderProtectionColor.resolveColor(context);
mWorkManager = new WorkProfileManager(
mActivityContext.getSystemService(UserManager.class),

View File

@@ -87,6 +87,7 @@ public class WorkEduCard extends FrameLayout implements
TextView title = findViewById(R.id.work_apps_paused_title);
title.setText(R.string.work_profile_edu_work_apps);
title.setTextColor(ColorTokens.TextColorPrimary.resolveColor(getContext()));
findViewById(R.id.wrapper).setBackground(DrawableTokens.WorkCard.resolve(getContext()));
}
@Override

View File

@@ -29,6 +29,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.view.ViewCompat;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAppState;
@@ -41,6 +42,10 @@ import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.model.WidgetsListHeaderEntry;
import app.lawnchair.font.FontManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.theme.drawable.DrawableTokens;
/**
* A UI represents a header of an app shown in the full widgets tray.
*
@@ -87,6 +92,14 @@ public final class WidgetsListHeader extends LinearLayout implements ItemInfoUpd
mAppIcon = findViewById(R.id.app_icon);
mTitle = findViewById(R.id.app_title);
mSubtitle = findViewById(R.id.app_subtitle);
var mContent = ViewCompat.requireViewById(this, R.id.widgets_list_header);
mContent.setBackground(DrawableTokens.WidgetsListBackground.resolve(getContext()));
FontManager fontManager = FontManager.INSTANCE.get(getContext());
fontManager.setCustomFont(mTitle, R.id.font_body_medium);
fontManager.setCustomFont(mTitle, R.id.font_body);
setAccessibilityDelegate(new AccessibilityDelegate() {
@Override

View File

@@ -21,6 +21,11 @@ import android.widget.TableLayout;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.view.ViewCompat;
import com.android.launcher3.R;
import app.lawnchair.theme.drawable.DrawableTokens;
/**
* Extension of {@link TableLayout} to support the drawable states used by
@@ -46,6 +51,14 @@ public class WidgetsListTableView extends TableLayout {
refreshDrawableState();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
var mContent = ViewCompat.requireViewById(this, R.id.widgets_table);
mContent.setBackground(DrawableTokens.WidgetsContentBackground.resolve(getContext()));
}
@Override
protected int[] onCreateDrawableState(int extraSpace) {
if (mListDrawableState == null) return super.onCreateDrawableState(extraSpace);

View File

@@ -29,6 +29,7 @@ import android.widget.TableLayout;
import android.widget.TableRow;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -40,6 +41,8 @@ import com.android.launcher3.widget.util.WidgetSizes;
import java.util.ArrayList;
import java.util.List;
import app.lawnchair.theme.drawable.DrawableTokens;
/** A {@link TableLayout} for showing recommended widgets. */
public final class WidgetsRecommendationTableLayout extends TableLayout {
private static final String TAG = "WidgetsRecommendationTableLayout";
@@ -77,6 +80,14 @@ public final class WidgetsRecommendationTableLayout extends TableLayout {
mWidgetCellOnClickListener = widgetCellOnClickListener;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
var mContent = ViewCompat.requireViewById(this, R.id.recommended_widget_table);
mContent.setBackground(DrawableTokens.WidgetsRecommendationBackground.resolve(getContext()));
}
/**
* Sets a list of recommended widgets that would like to be displayed in this table within the
* desired {@code recommendationTableMaxHeight}.

View File

@@ -28,6 +28,8 @@ import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.R;
import com.android.launcher3.popup.PopupDataProvider;
import app.lawnchair.font.FontManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.theme.drawable.DrawableTokens;
/**
@@ -70,6 +72,9 @@ public class LauncherWidgetsSearchBar extends LinearLayout implements WidgetsSea
mEditText = findViewById(R.id.widgets_search_bar_edit_text);
mCancelButton = findViewById(R.id.widgets_search_cancel_button);
setBackground(DrawableTokens.BgWidgetsSearchbox.resolve(getContext()));
FontManager fontManager = FontManager.INSTANCE.get(getContext());
fontManager.setCustomFont(mEditText, R.id.font_body_medium);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.android.launcher3.workprofile;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.content.res.TypedArray;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
@@ -54,6 +55,17 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
@Override
protected void onFinishInflate() {
super.onFinishInflate();
FontManager fontManager = FontManager.INSTANCE.get(getContext());
for (int i = 0; i < getChildCount(); i++) {
Button tab = (Button) getChildAt(i);
tab.setAllCaps(false);
RippleDrawable background = (RippleDrawable) tab.getBackground();
background.setDrawableByLayerId(android.R.id.mask, DrawableTokens.AllAppsTabsMaskDrawable.resolve(getContext()));
tab.setBackground(DrawableTokens.AllAppsTabsBackground.resolve(getContext()));
tab.setTextColor(ColorStateListTokens.AllAppsTabText.resolve(getContext()));
fontManager.setCustomFont(tab, R.id.font_body_medium);
}
}
/**