Theme work profile (#3748)

* Theme work profile

* Improved close action in workedu
This commit is contained in:
John Andrew Camu
2023-11-20 19:45:28 +08:00
committed by GitHub
parent 71e6b28755
commit 30d3b8722b
8 changed files with 112 additions and 59 deletions

View File

@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/textColorPrimary">
<path
android:fillColor="@android:color/black"
android:pathData="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
</vector>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.
-->
<com.android.launcher3.allapps.WorkEduCard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/work_edu_card_margin"
android:paddingBottom="@dimen/work_edu_card_bottom_margin"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/work_card"
android:layout_gravity="center_horizontal"
android:paddingEnd="@dimen/work_card_margin"
android:paddingStart="@dimen/work_card_margin"
android:paddingTop="@dimen/work_card_margin"
android:id="@+id/wrapper">
<TextView
style="@style/PrimaryHeadline"
android:textColor="?android:attr/textColorPrimary"
android:id="@+id/work_apps_paused_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/work_card_margin"
android:layout_marginEnd="@dimen/work_card_margin"
android:text="@string/work_profile_edu_work_apps"
android:textDirection="locale"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/padded_rounded_button_height"
android:orientation="horizontal">
<FrameLayout
android:layout_width="@dimen/rounded_button_width"
android:layout_height="@dimen/rounded_button_width"
android:layout_alignParentEnd="true"
android:padding="@dimen/rounded_button_padding">
<ImageView
android:id="@+id/action_btn"
android:layout_width="@dimen/x_icon_size"
android:layout_height="@dimen/x_icon_size"
android:layout_gravity="center"
android:contentDescription="@string/accessibility_close"
android:src="@drawable/ic_close" />
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
</com.android.launcher3.allapps.WorkEduCard>

View File

@@ -88,18 +88,17 @@ object DrawableTokens {
val list = StateListDrawable()
list.setEnterFadeDuration(100)
val cornerRadius = context.resources
.getDimensionPixelSize(R.dimen.all_apps_header_pill_corner_radius).toFloat()
val unselected = AppCompatResources.getDrawable(
context,
R.drawable.all_apps_tabs_background,
)
unselected?.setTint(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
val unselected = GradientDrawable()
unselected.shape = GradientDrawable.RECTANGLE
unselected.cornerRadius = cornerRadius
unselected.setColor(ColorTokens.Surface.resolveColor(context, scheme, uiColorMode))
val selected = GradientDrawable()
selected.shape = GradientDrawable.RECTANGLE
selected.cornerRadius = cornerRadius
selected.setColor(ColorTokens.AllAppsTabBackgroundSelected.resolveColor(context, scheme, uiColorMode))
val selected = AppCompatResources.getDrawable(
context,
R.drawable.all_apps_tabs_background,
)
selected?.setTint(ColorTokens.AllAppsTabBackgroundSelected.resolveColor(context, scheme, uiColorMode))
list.addState(intArrayOf(-android.R.attr.state_selected), unselected)
list.addState(intArrayOf(android.R.attr.state_selected), selected)

View File

@@ -1034,13 +1034,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
private void setDeviceManagementResources() {
if (mActivityContext.getStringCache() != null) {
Button personalTab = findViewById(R.id.tab_personal);
personalTab.setText(mActivityContext.getStringCache().allAppsPersonalTab);
Button personalTab = findViewById(R.id.tab_personal);
personalTab.setText(R.string.all_apps_personal_tab);
Button workTab = findViewById(R.id.tab_work);
workTab.setText(mActivityContext.getStringCache().allAppsWorkTab);
}
Button workTab = findViewById(R.id.tab_work);
workTab.setText(R.string.all_apps_work_tab);
}
protected boolean shouldShowTabs() {

View File

@@ -83,18 +83,10 @@ public class WorkEduCard extends FrameLayout implements
@Override
protected void onFinishInflate() {
super.onFinishInflate();
Button button = ViewCompat.requireViewById(this, R.id.action_btn);
button.setOnClickListener(this);
button.setAllCaps(false);
FontManager.INSTANCE.get(getContext()).setCustomFont(button, R.id.font_button);
StringCache cache = mActivityContext.getStringCache();
if (cache != null) {
TextView title = findViewById(R.id.work_apps_paused_title);
title.setText(cache.workProfileEdu);
title.setTextColor(ColorTokens.TextColorPrimary.resolveColor(getContext()));
}
findViewById(R.id.action_btn).setOnClickListener(this);
TextView title = findViewById(R.id.work_apps_paused_title);
title.setText(R.string.work_profile_edu_work_apps);
title.setTextColor(ColorTokens.TextColorPrimary.resolveColor(getContext()));
}
@Override

View File

@@ -82,9 +82,6 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
public WorkModeSwitch(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if(mTextView != null){
FontManager.INSTANCE.get(context).overrideFont(mTextView, attrs);
}
mScrollThreshold = Utilities.dpToPx(SCROLL_THRESHOLD_DP);
mActivityContext = ActivityContext.lookupContext(getContext());
mStatsLogManager = mActivityContext.getStatsLogManager();
@@ -95,6 +92,7 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
super.onFinishInflate();
mIcon = findViewById(R.id.work_icon);
mTextView = findViewById(R.id.pause_text);
FontManager.INSTANCE.get(getContext()).setCustomFont(mTextView, R.id.font_body_medium);
setSelected(true);
if (Utilities.ATLEAST_R) {
@@ -109,10 +107,7 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
setInsets(grid.getInsets());
setInsets(mActivityContext.getDeviceProfile().getInsets());
StringCache cache = mActivityContext.getStringCache();
if (cache != null) {
mTextView.setText(cache.workProfilePauseButton);
}
mTextView.setText(R.string.work_apps_pause_btn_text);
mIcon.setColorFilter(mTextView.getCurrentTextColor());
getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);

View File

@@ -41,8 +41,6 @@ import app.lawnchair.theme.color.ColorTokens;
public class WorkPausedCard extends LinearLayout implements View.OnClickListener {
private final ActivityContext mActivityContext;
private Button mBtn;
public WorkPausedCard(Context context) {
this(context, null, 0);
}
@@ -59,27 +57,24 @@ public class WorkPausedCard extends LinearLayout implements View.OnClickListener
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mBtn = findViewById(R.id.enable_work_apps);
mBtn.setOnClickListener(this);
mBtn.setAllCaps(false);
FontManager.INSTANCE.get(getContext()).setCustomFont(mBtn, R.id.font_button);
StringCache cache = mActivityContext.getStringCache();
if (cache != null) {
setWorkProfilePausedResources(cache);
}
setWorkProfilePausedResources();
}
private void setWorkProfilePausedResources(StringCache cache) {
private void setWorkProfilePausedResources() {
TextView title = findViewById(R.id.work_apps_paused_title);
title.setText(cache.workProfilePausedTitle);
title.setText(R.string.work_apps_paused_title);
title.setTextColor(ColorTokens.TextColorPrimary.resolveColor(getContext()));
FontManager.INSTANCE.get(getContext()).setCustomFont(title, R.id.font_heading);
TextView body = findViewById(R.id.work_apps_paused_content);
body.setText(cache.workProfilePausedDescription);
body.setText(R.string.work_apps_paused_body);
body.setTextColor(ColorTokens.TextColorPrimary.resolveColor(getContext()));
FontManager.INSTANCE.get(getContext()).setCustomFont(title, R.id.font_body_medium);
TextView button = findViewById(R.id.enable_work_apps);
button.setText(cache.workProfileEnableButton);
Button button = findViewById(R.id.enable_work_apps);
button.setText(R.string.work_apps_enable_btn_text);
FontManager.INSTANCE.get(getContext()).setCustomFont(title, R.id.font_button);
button.setOnClickListener(this);
}
@Override

View File

@@ -360,13 +360,11 @@ public class WidgetsFullSheet extends BaseWidgetSheet
}
private void setDeviceManagementResources() {
if (mActivityContext.getStringCache() != null) {
Button personalTab = findViewById(R.id.tab_personal);
personalTab.setText(mActivityContext.getStringCache().widgetsPersonalTab);
Button personalTab = findViewById(R.id.tab_personal);
personalTab.setText(R.string.all_apps_personal_tab);
Button workTab = findViewById(R.id.tab_work);
workTab.setText(mActivityContext.getStringCache().widgetsWorkTab);
}
Button workTab = findViewById(R.id.tab_work);
workTab.setText(R.string.all_apps_work_tab);
}
@Override