mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Revert commits d2f4294a & 7c618e01
This commit is contained in:
@@ -353,7 +353,6 @@ dependencies {
|
||||
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
|
||||
implementation 'com.github.ChickenHook:RestrictionBypass:2.2'
|
||||
implementation 'dev.rikka.tools.refine:runtime:3.1.1'
|
||||
implementation 'dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0'
|
||||
|
||||
implementation "androidx.compose.ui:ui:$compose_version"
|
||||
implementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
|
||||
@@ -66,9 +66,4 @@
|
||||
<declare-styleable name="FallbackSearchInputView">
|
||||
<attr name="customFontType" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ResourceTokenOverride">
|
||||
<attr name="android:background" />
|
||||
<attr name="android:src" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
@@ -1,14 +1,43 @@
|
||||
package app.lawnchair
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import app.lawnchair.font.FontManager
|
||||
import app.lawnchair.theme.ResourceTokenApplier
|
||||
import rikka.layoutinflater.view.LayoutInflaterFactory
|
||||
import com.android.launcher3.BubbleTextView
|
||||
import com.android.launcher3.views.DoubleShadowBubbleTextView
|
||||
|
||||
class LawnchairLayoutFactory(context: Context) : LayoutInflaterFactory() {
|
||||
class LawnchairLayoutFactory(context: Context) : LayoutInflater.Factory2 {
|
||||
|
||||
init {
|
||||
addOnViewCreatedListener(FontManager.INSTANCE.get(context).onViewCreatedListener)
|
||||
addOnViewCreatedListener(ResourceTokenApplier)
|
||||
private val fontManager by lazy { FontManager.INSTANCE.get(context) }
|
||||
private val constructorMap = mapOf<String, (Context, AttributeSet) -> View>(
|
||||
"Button" to ::Button,
|
||||
"TextView" to ::TextView,
|
||||
BubbleTextView::class.java.name to ::BubbleTextView,
|
||||
DoubleShadowBubbleTextView::class.java.name to ::DoubleShadowBubbleTextView,
|
||||
)
|
||||
|
||||
override fun onCreateView(
|
||||
parent: View?,
|
||||
name: String,
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
): View? {
|
||||
val view = constructorMap[name]?.let { it(context, attrs) }
|
||||
if (view is TextView) {
|
||||
try {
|
||||
fontManager.overrideFont(view, attrs)
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
|
||||
return onCreateView(null, name, context, attrs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import app.lawnchair.util.runOnMainThread
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.MainThreadInitializedObject
|
||||
import kotlinx.coroutines.launch
|
||||
import rikka.layoutinflater.view.LayoutInflaterFactory.OnViewCreatedListener
|
||||
|
||||
class FontManager private constructor(private val context: Context) {
|
||||
|
||||
@@ -21,11 +20,6 @@ class FontManager private constructor(private val context: Context) {
|
||||
|
||||
private val specMap = createFontMap()
|
||||
|
||||
val onViewCreatedListener = OnViewCreatedListener { view, _, _, _, attrs ->
|
||||
if (view !is TextView) return@OnViewCreatedListener
|
||||
overrideFont(view, attrs)
|
||||
}
|
||||
|
||||
private fun createFontMap(): Map<Int, FontSpec> {
|
||||
val sansSerif = Typeface.SANS_SERIF
|
||||
val sansSerifMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package app.lawnchair.theme
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import app.lawnchair.theme.drawable.DrawableTokens
|
||||
import com.android.launcher3.R
|
||||
import rikka.layoutinflater.view.LayoutInflaterFactory.OnViewCreatedListener
|
||||
|
||||
object ResourceTokenApplier : OnViewCreatedListener {
|
||||
|
||||
override fun onViewCreated(view: View, parent: View?, name: String, context: Context, attrs: AttributeSet) {
|
||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.ResourceTokenOverride)
|
||||
for (i in 0 until ta.indexCount) {
|
||||
when (val attr = ta.getIndex(i)) {
|
||||
R.styleable.ResourceTokenOverride_android_background -> {
|
||||
val resId = ta.getResourceId(attr, 0)
|
||||
val drawable = resolveDrawable(resId, context) ?: continue
|
||||
view.background = drawable
|
||||
}
|
||||
R.styleable.ResourceTokenOverride_android_src -> {
|
||||
if (view !is ImageView) continue
|
||||
val resId = ta.getResourceId(attr, 0)
|
||||
val drawable = resolveDrawable(resId, context) ?: continue
|
||||
view.setImageDrawable(drawable)
|
||||
}
|
||||
}
|
||||
}
|
||||
ta.recycle()
|
||||
}
|
||||
|
||||
private fun resolveDrawable(resId: Int, context: Context): Drawable? {
|
||||
return DrawableTokens.drawableMapping[resId]?.resolve(context)
|
||||
}
|
||||
}
|
||||
@@ -8,53 +8,28 @@ import com.android.launcher3.R
|
||||
|
||||
object DrawableTokens {
|
||||
|
||||
private val privateDrawableMapping = mutableMapOf<Int, DrawableToken<*>>()
|
||||
val drawableMapping: Map<Int, DrawableToken<*>> get() = privateDrawableMapping
|
||||
|
||||
@JvmField
|
||||
val BgCellLayout = ResourceDrawableToken<Drawable>(R.drawable.bg_celllayout)
|
||||
.setTint(ColorTokens.ColorAccent)
|
||||
|
||||
init {
|
||||
addDrawableMapping<RippleDrawable>(R.drawable.bg_overview_clear_all_button) {
|
||||
it.mutate { context, scheme, uiColorMode ->
|
||||
val background = getDrawable(0) as GradientDrawable
|
||||
background.setColor(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
|
||||
}
|
||||
@JvmField
|
||||
val BgOverviewClearAllButton = ResourceDrawableToken<RippleDrawable>(R.drawable.bg_overview_clear_all_button)
|
||||
.mutate { context, scheme, uiColorMode ->
|
||||
val background = getDrawable(0) as GradientDrawable
|
||||
background.setColor(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.bg_widgets_full_sheet) {
|
||||
it.setColor(ColorTokens.ColorBackground)
|
||||
}
|
||||
@JvmField
|
||||
val BgWidgetsFullSheet = ResourceDrawableToken<GradientDrawable>(R.drawable.bg_widgets_full_sheet)
|
||||
.setColor(ColorTokens.ColorBackground)
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.bg_widgets_searchbox) {
|
||||
it.setColor(ColorTokens.Surface)
|
||||
}
|
||||
@JvmField
|
||||
val BgWidgetsSearchbox = ResourceDrawableToken<GradientDrawable>(R.drawable.bg_widgets_searchbox)
|
||||
.setColor(ColorTokens.Surface)
|
||||
|
||||
addDrawableMapping<Drawable>(R.drawable.drop_target_background) {
|
||||
it.setTint(ColorTokens.WorkspaceAccentColor)
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.task_menu_item_bg) {
|
||||
it.setColor(ColorTokens.ColorPrimary)
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.bg_rounded_corner_bottom_sheet) {
|
||||
it.setColor(ColorTokens.Surface)
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.widgets_recommendation_background) {
|
||||
it.setColor(ColorTokens.Surface)
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.widget_resize_frame) {
|
||||
it.setTint(ColorTokens.WorkspaceAccentColor)
|
||||
}
|
||||
|
||||
addDrawableMapping<GradientDrawable>(R.drawable.work_card) {
|
||||
it.setColor(ColorTokens.Surface)
|
||||
}
|
||||
}
|
||||
@JvmField
|
||||
val DropTargetBackground = ResourceDrawableToken<Drawable>(R.drawable.drop_target_background)
|
||||
.setTint(ColorTokens.WorkspaceAccentColor)
|
||||
|
||||
@JvmField
|
||||
val MiddleItemPrimary = ResourceDrawableToken<GradientDrawable>(R.drawable.middle_item_primary)
|
||||
@@ -88,6 +63,22 @@ object DrawableTokens {
|
||||
val SingleItemPrimary = ResourceDrawableToken<GradientDrawable>(R.drawable.single_item_primary)
|
||||
.setColor(ColorTokens.PopupColorPrimary)
|
||||
|
||||
@JvmField
|
||||
val TaskMenuItemBg = ResourceDrawableToken<GradientDrawable>(R.drawable.task_menu_item_bg)
|
||||
.setColor(ColorTokens.ColorPrimary)
|
||||
|
||||
@JvmField
|
||||
val WidgetsBottomSheetBackground = ResourceDrawableToken<GradientDrawable>(R.drawable.bg_rounded_corner_bottom_sheet)
|
||||
.setColor(ColorTokens.Surface)
|
||||
|
||||
@JvmField
|
||||
val WidgetsRecommendationBackground = ResourceDrawableToken<GradientDrawable>(R.drawable.widgets_recommendation_background)
|
||||
.setColor(ColorTokens.Surface)
|
||||
|
||||
@JvmField
|
||||
val WidgetResizeFrame = ResourceDrawableToken<GradientDrawable>(R.drawable.widget_resize_frame)
|
||||
.setTint(ColorTokens.WorkspaceAccentColor)
|
||||
|
||||
@JvmField
|
||||
val AllAppsTabsBackground = NewDrawable { context, scheme, uiColorMode ->
|
||||
val list = StateListDrawable()
|
||||
@@ -129,11 +120,6 @@ object DrawableTokens {
|
||||
list
|
||||
}
|
||||
|
||||
private fun <T : Drawable> addDrawableMapping(
|
||||
resId: Int,
|
||||
customizer: (DrawableToken<T>) -> DrawableToken<*> = { it }
|
||||
) {
|
||||
val token = customizer(ResourceDrawableToken(resId))
|
||||
privateDrawableMapping[resId] = token
|
||||
}
|
||||
@JvmField val WorkCard = ResourceDrawableToken<GradientDrawable>(R.drawable.work_card)
|
||||
.setColor(ColorTokens.Surface)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
|
||||
import app.lawnchair.font.FontManager;
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
public class ClearAllButton extends Button {
|
||||
|
||||
public static final FloatProperty<ClearAllButton> VISIBILITY_ALPHA =
|
||||
@@ -75,6 +78,8 @@ public class ClearAllButton extends Button {
|
||||
super(context, attrs);
|
||||
mIsRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
|
||||
mActivity = StatefulActivity.fromContext(context);
|
||||
FontManager.INSTANCE.get(context).overrideFont(this, attrs);
|
||||
setBackground(DrawableTokens.BgOverviewClearAllButton.resolve(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,6 +56,8 @@ import com.android.quickstep.TaskUtils;
|
||||
import com.android.quickstep.util.TaskCornerRadius;
|
||||
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
|
||||
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
/**
|
||||
* Contains options for a recent task when long-pressing its icon.
|
||||
*/
|
||||
@@ -91,6 +93,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mTaskName = findViewById(R.id.task_name);
|
||||
mTaskName.setBackground(DrawableTokens.TaskMenuItemBg.resolve(getContext()));
|
||||
mOptionLayout = findViewById(R.id.menu_option_layout);
|
||||
}
|
||||
|
||||
@@ -256,6 +259,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
|
||||
menuOption.onClick(view);
|
||||
}
|
||||
});
|
||||
menuOptionView.setBackground(DrawableTokens.TaskMenuItemBg.resolve(mActivity));
|
||||
mOptionLayout.addView(menuOptionView);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="@dimen/work_card_padding_horizontal"
|
||||
android:paddingVertical="@dimen/work_card_padding_horizontal"
|
||||
android:background="@drawable/work_card"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:id="@+id/wrapper">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import static android.appwidget.AppWidgetHostView.getDefaultPaddingForWidget;
|
||||
|
||||
import static com.android.launcher3.CellLayout.SPRING_LOADED_PROGRESS;
|
||||
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_HEIGHT;
|
||||
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_WIDTH;
|
||||
@@ -45,6 +46,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.lawnchair.theme.color.ColorTokens;
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
public class AppWidgetResizeFrame extends AbstractFloatingView implements View.OnKeyListener {
|
||||
private static final int SNAP_DURATION = 150;
|
||||
@@ -207,9 +209,10 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
DragLayer dl = launcher.getDragLayer();
|
||||
AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater()
|
||||
.inflate(R.layout.app_widget_resize_frame, dl, false);
|
||||
ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
|
||||
imageView.setImageDrawable(DrawableTokens.WidgetResizeFrame.resolve(launcher));
|
||||
if (widget.hasEnforcedCornerRadius()) {
|
||||
float enforcedCornerRadius = widget.getEnforcedCornerRadius();
|
||||
ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
|
||||
Drawable d = imageView.getDrawable();
|
||||
if (d instanceof GradientDrawable) {
|
||||
GradientDrawable gd = (GradientDrawable) d.mutate();
|
||||
|
||||
@@ -43,6 +43,8 @@ import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.Themes;
|
||||
|
||||
import app.lawnchair.theme.color.ColorTokens;
|
||||
import app.lawnchair.theme.drawable.DrawableToken;
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
/**
|
||||
* Implements a DropTarget.
|
||||
@@ -100,6 +102,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
super.onFinishInflate();
|
||||
mText = getText();
|
||||
setContentDescription(mText);
|
||||
setBackground(DrawableTokens.DropTargetBackground.resolve(getContext()));
|
||||
setTextColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
button.setAllCaps(false);
|
||||
FontManager.INSTANCE.get(getContext()).setCustomFont(button, R.id.font_button);
|
||||
|
||||
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
|
||||
LinearLayout wrapper = ViewCompat.requireViewById(this, R.id.wrapper);
|
||||
wrapper.setBackground(DrawableTokens.WorkCard.resolve(getContext()));
|
||||
MarginLayoutParams lp = ((MarginLayoutParams) wrapper.getLayoutParams());
|
||||
lp.width = mLauncher.getAppsView().getActiveRecyclerView().getTabWidth();
|
||||
|
||||
TextView title = ViewCompat.requireViewById(this, R.id.work_apps_paused_title);
|
||||
|
||||
@@ -45,6 +45,8 @@ import com.android.launcher3.widget.util.WidgetsTableUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
/**
|
||||
* Bottom sheet for the "Widgets" system shortcut in the long-press popup.
|
||||
*/
|
||||
@@ -119,6 +121,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mContent = findViewById(R.id.widgets_bottom_sheet);
|
||||
mContent.setBackground(DrawableTokens.WidgetsBottomSheetBackground.resolve(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,8 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpaceView;
|
||||
import com.android.launcher3.widget.picker.search.WidgetsSearchBar;
|
||||
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
/**
|
||||
* A controller which measures & updates {@link WidgetsFullSheet}'s views padding, margin and
|
||||
* vertical displacement upon scrolling.
|
||||
@@ -82,6 +84,8 @@ final class SearchAndRecommendationsScrollController implements
|
||||
mSearchBar = mContainer.findViewById(R.id.widgets_search_bar);
|
||||
mHeaderTitle = mContainer.findViewById(R.id.title);
|
||||
mRecommendedWidgetsTable = mContainer.findViewById(R.id.recommended_widget_table);
|
||||
mRecommendedWidgetsTable.setBackground(
|
||||
DrawableTokens.WidgetsRecommendationBackground.resolve(mContainer.getContext()));
|
||||
mTabBar = mContainer.findViewById(R.id.tabs);
|
||||
|
||||
mContainer.setSearchAndRecommendationScrollController(this);
|
||||
|
||||
@@ -186,6 +186,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mContent = findViewById(R.id.container);
|
||||
mContent.setBackground(DrawableTokens.BgWidgetsFullSheet.resolve(getContext()));
|
||||
|
||||
View collapseHandle = findViewById(R.id.collapse_handle);
|
||||
collapseHandle.setBackgroundColor(ColorTokens.TextColorSecondary.resolveColor(getContext()));
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.android.launcher3.ExtendedEditText;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.popup.PopupDataProvider;
|
||||
|
||||
import app.lawnchair.theme.drawable.DrawableTokens;
|
||||
|
||||
/**
|
||||
* View for a search bar with an edit text with a cancel button.
|
||||
*/
|
||||
@@ -67,6 +69,7 @@ public class LauncherWidgetsSearchBar extends LinearLayout implements WidgetsSea
|
||||
super.onFinishInflate();
|
||||
mEditText = findViewById(R.id.widgets_search_bar_edit_text);
|
||||
mCancelButton = findViewById(R.id.widgets_search_cancel_button);
|
||||
setBackground(DrawableTokens.BgWidgetsSearchbox.resolve(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user