Updating widget tray theme

Using standard theme attributes rather than custom color codes, so
that it plays nice with system theme changes.

Bug: 34819119
Bug: 34897402
Bug: 21446746
Change-Id: I265fba3ceae8873650fd09e4704838d313155e83
This commit is contained in:
Sunny Goyal committed 2017-02-09 10:16:22 -08:00
1 parent db7b82960a
commit d5d5e22715
17 files changed
+68 -93

No files matched your search

-22
View File
@@ -1,22 +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.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/quantum_panel_shape_dark"
android:insetBottom="@dimen/quantum_panel_outer_padding"
android:insetLeft="@dimen/quantum_panel_outer_padding"
android:insetRight="@dimen/quantum_panel_outer_padding"
android:insetTop="@dimen/quantum_panel_outer_padding" />
@@ -16,7 +16,6 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/colorSecondary" />
<corners
android:radius="2dp" />
<solid android:color="?android:attr/colorPrimary" />
<corners android:radius="2dp" />
</shape>
@@ -22,10 +22,10 @@
android:layout_height="match_parent">
<TextView
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="4dp"
android:paddingBottom="20dp"
android:text="@string/add_item_request_drag_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -33,7 +33,7 @@
<FrameLayout
android:theme="@style/WidgetContainerTheme"
android:layout_width="match_parent"
android:background="?android:attr/colorPrimary"
android:background="?android:attr/colorPrimaryDark"
android:layout_height="wrap_content">
<include
+1 -1
View File
@@ -55,7 +55,7 @@
android:focusable="true"
android:paddingStart="@dimen/container_fastscroll_thumb_max_width"
android:paddingEnd="@dimen/container_fastscroll_thumb_max_width"
android:theme="@style/CustomOverscroll.Light" />
android:theme="@style/AllAppsOverscroll" />
<!-- Fast scroller popup -->
<TextView
+3 -2
View File
@@ -19,9 +19,10 @@
android:layout_height="match_parent"
android:gravity="center"
android:elevation="2dp"
android:padding="4dp"
android:theme="@style/WidgetContainerTheme"
android:background="@drawable/quantum_panel_dark"
android:background="@drawable/round_rect_primary"
android:textAppearance="?android:attr/textAppearanceMediumInverse"
android:textColor="@color/widgets_view_item_text_color"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/gadget_error_text"
/>
+5 -7
View File
@@ -20,7 +20,7 @@
android:layout_weight="1"
android:orientation="vertical"
android:focusable="true"
android:background="?android:attr/colorPrimary"
android:background="?android:attr/colorPrimaryDark"
android:gravity="center_horizontal">
<LinearLayout
@@ -42,10 +42,9 @@
android:fadingEdge="horizontal"
android:fontFamily="sans-serif-condensed"
android:gravity="start"
android:shadowColor="#B0000000"
android:shadowRadius="2.0"
android:singleLine="true"
android:textColor="@color/widgets_view_item_text_color"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp" />
<!-- The original dimensions of the widget (can't be the same text as above due to different
@@ -56,11 +55,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:textColor="@color/widgets_view_item_text_color"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
android:fontFamily="sans-serif-condensed"
android:shadowRadius="2.0"
android:shadowColor="#B0000000" />
android:alpha="0.8" />
</LinearLayout>
<!-- The image of the widget. This view does not support padding. Any placement adjustment
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
<!-- Copyright (C) 2017 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.
@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="@dimen/widget_row_divider" />
<solid android:color="?attr/colorSecondary" />
</shape>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/widget_row_divider"
android:layout_height="match_parent"
android:background="?android:attr/colorPrimary" />
+4 -6
View File
@@ -19,7 +19,6 @@
android:id="@+id/widgets_cell_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">
@@ -30,7 +29,7 @@
android:id="@+id/section"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_section_height"
android:background="?attr/colorSecondary"
android:background="?android:attr/colorPrimary"
android:drawablePadding="@dimen/widget_section_horizontal_padding"
android:ellipsize="end"
android:focusable="true"
@@ -51,9 +50,9 @@
<HorizontalScrollView
android:id="@+id/widgets_scroll_container"
android:theme="@style/CustomOverscroll.Dark"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimaryDark"
android:scrollbars="none">
<LinearLayout
android:id="@+id/widgets_cell_list"
@@ -62,7 +61,6 @@
android:paddingStart="@dimen/widget_row_padding"
android:paddingEnd="0dp"
android:orientation="horizontal"
android:divider="@drawable/widgets_row_divider"
android:showDividers="middle"/>
android:showDividers="none"/>
</HorizontalScrollView>
</LinearLayout>
+1 -2
View File
@@ -23,7 +23,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
launcher:revealBackground="@drawable/quantum_panel_shape_dark"
launcher:revealBackground="@drawable/round_rect_primary"
android:theme="@style/WidgetContainerTheme">
<View
@@ -45,7 +45,6 @@
<com.android.launcher3.widget.WidgetsRecyclerView
android:id="@+id/widgets_list_view"
android:theme="@style/CustomOverscroll.Dark"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2016 The Android Open Source Project
* Copyright (C) 2017 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.
@@ -19,6 +19,6 @@
<resources>
<!-- Theme for the widget container. -->
<style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="colorSecondary">?android:attr/colorSecondary</item>
<item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
</style>
</resources>
-3
View File
@@ -80,9 +80,6 @@
<attr name="hideParentOnDisable" format="boolean" />
</declare-styleable>
<!-- Fallback attr for pre-API 25 support -->
<attr name="colorSecondary" format="reference|color" />
<declare-styleable name="InvariantDeviceProfile">
<attr name="name" format="string" />
<attr name="minWidthDps" format="float" />
-6
View File
@@ -45,11 +45,5 @@
<color name="spring_loaded_panel_color">#40FFFFFF</color>
<color name="spring_loaded_highlighted_panel_border_color">#FFF</color>
<!-- Widgets view -->
<color name="widgets_view_item_text_color">#3B3B3B</color>
<!-- Used as a fallback since colorSecondary doesn't exist pre-API 25 -->
<color name="fallback_secondary_color">#FF37474F</color>
<color name="notification_icon_default_color">#757575</color> <!-- Gray 600 -->
</resources>
+4 -8
View File
@@ -46,20 +46,16 @@
<!-- Theme for the widget container. Overridden on API 25. -->
<style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="colorSecondary">@color/fallback_secondary_color</item>
<item name="android:colorEdgeEffect">@color/workspace_edge_effect_color</item>
<item name="android:textColorPrimary">?android:attr/textColorPrimaryInverse</item>
<item name="android:textColorSecondary">?android:attr/textColorSecondaryInverse</item>
</style>
<!-- Overscroll effect -->
<style name="CustomOverscroll" />
<style name="CustomOverscroll.Light" parent="@android:style/Theme.DeviceDefault.Light">
<style name="AllAppsOverscroll" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:colorEdgeEffect">@color/folder_edge_effect_color</item>
</style>
<style name="CustomOverscroll.Dark">
<item name="android:colorEdgeEffect">@color/workspace_edge_effect_color</item>
</style>
<!-- Different icons -->
<style name="Icon">
<item name="android:layout_width">match_parent</item>
+4 -3
View File
@@ -45,6 +45,7 @@ import android.os.UserHandle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextThemeWrapper;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
@@ -132,9 +133,9 @@ public class IconCache {
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color);
TypedArray ta = context.obtainStyledAttributes(new int[]{R.attr.colorSecondary});
mPackageBgColor = ta.getColor(0, 0);
ta.recycle();
mPackageBgColor = Utilities.getAttrColor(
new ContextThemeWrapper(context, R.style.WidgetContainerTheme),
android.R.attr.colorPrimary);
mLowResOptions = new BitmapFactory.Options();
// Always prefer RGB_565 config for low res. If the bitmap has transparency, it will
// automatically be loaded as ALPHA_8888.
@@ -69,10 +69,10 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView
mDisabledForSafeMode = disabledForSafeMode;
mPaint = new TextPaint();
mPaint.setColor(0xFFFFFFFF);
mPaint.setColor(Utilities.getAttrColor(getContext(), android.R.attr.textColorPrimary));
mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
setBackgroundResource(R.drawable.quantum_panel_dark);
setBackgroundResource(R.drawable.round_rect_primary);
setWillNotDraw(false);
setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
+5 -1
View File
@@ -608,7 +608,11 @@ public final class Utilities {
}
public static int getColorAccent(Context context) {
TypedArray ta = context.obtainStyledAttributes(new int[]{android.R.attr.colorAccent});
return getAttrColor(context, android.R.attr.colorAccent);
}
public static int getAttrColor(Context context, int attr) {
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
int colorAccent = ta.getColor(0, 0);
ta.recycle();
return colorAccent;
@@ -113,20 +113,27 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
// Add more views.
// if there are too many, hide them.
int diff = infoList.size() - row.getChildCount();
int expectedChildCount = infoList.size() + Math.max(0, infoList.size() - 1);
int childCount = row.getChildCount();
if (diff > 0) {
for (int i = 0; i < diff; i++) {
WidgetCell widget = (WidgetCell) mLayoutInflater.inflate(
R.layout.widget_cell, row, false);
if (expectedChildCount > childCount) {
for (int i = childCount ; i < expectedChildCount; i++) {
if ((i & 1) == 1) {
// Add a divider for odd index
mLayoutInflater.inflate(R.layout.widget_list_divider, row);
} else {
// Add cell for even index
WidgetCell widget = (WidgetCell) mLayoutInflater.inflate(
R.layout.widget_cell, row, false);
// set up touch.
widget.setOnClickListener(mIconClickListener);
widget.setOnLongClickListener(mIconLongClickListener);
row.addView(widget);
// set up touch.
widget.setOnClickListener(mIconClickListener);
widget.setOnLongClickListener(mIconLongClickListener);
row.addView(widget);
}
}
} else if (diff < 0) {
for (int i=infoList.size() ; i < row.getChildCount(); i++) {
} else if (expectedChildCount < childCount) {
for (int i = expectedChildCount ; i < childCount; i++) {
row.getChildAt(i).setVisibility(View.GONE);
}
}
@@ -136,10 +143,14 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
// Bind the view in the widget horizontal tray region.
for (int i=0; i < infoList.size(); i++) {
WidgetCell widget = (WidgetCell) row.getChildAt(i);
WidgetCell widget = (WidgetCell) row.getChildAt(2*i);
widget.applyFromCellItem(infoList.get(i), mWidgetPreviewLoader);
widget.ensurePreview();
widget.setVisibility(View.VISIBLE);
if (i > 0) {
row.getChildAt(2*i - 1).setVisibility(View.VISIBLE);
}
}
}
@@ -151,11 +162,10 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
ViewGroup container = (ViewGroup) mLayoutInflater.inflate(
R.layout.widgets_list_row_view, parent, false);
LinearLayout cellList = (LinearLayout) container.findViewById(R.id.widgets_cell_list);
// if the end padding is 0, then container view (horizontal scroll view) doesn't respect
// the end of the linear layout width + the start padding and doesn't allow scrolling.
cellList.setPaddingRelative(mIndent, 0, 1, 0);
container.findViewById(R.id.widgets_cell_list).setPaddingRelative(mIndent, 0, 1, 0);
return new WidgetsRowViewHolder(container);
}
@@ -163,7 +173,7 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
@Override
public void onViewRecycled(WidgetsRowViewHolder holder) {
int total = holder.cellContainer.getChildCount();
for (int i = 0; i < total; i++) {
for (int i = 0; i < total; i+=2) {
WidgetCell widget = (WidgetCell) holder.cellContainer.getChildAt(i);
widget.clear();
}