summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-04-28 00:01:32 (GMT)
committerHyunyoung Song <hyunyoungs@google.com>2015-04-28 00:01:32 (GMT)
commitf17a1c9ad99d46a65de797422fd439382114b348 (patch)
tree9a529ce9ed53d39adad050c2a1aff2a61586f756
parentf782fb52581988fb44e9126852221eb260d158a9 (diff)
downloadandroid_packages_apps_Trebuchet-f17a1c9ad99d46a65de797422fd439382114b348.zip
android_packages_apps_Trebuchet-f17a1c9ad99d46a65de797422fd439382114b348.tar.gz
android_packages_apps_Trebuchet-f17a1c9ad99d46a65de797422fd439382114b348.tar.bz2
Widget tray alignment according to UX spec
- Fixing an issue where widget preview is not loaded do to faulty canceling of loading async task when view is detached from the window. b/20338334 Change-Id: I1e3bd6b6cdafda8d1e0a7a0e87c8089100c341a7
-rw-r--r--res/layout/widget_cell.xml8
-rw-r--r--res/layout/widgets_list_row_view.xml33
-rw-r--r--res/values/colors.xml1
-rw-r--r--res/values/dimens.xml8
-rw-r--r--src/com/android/launcher3/widget/WidgetCell.java19
-rw-r--r--src/com/android/launcher3/widget/WidgetsListAdapter.java11
6 files changed, 36 insertions, 44 deletions
diff --git a/res/layout/widget_cell.xml b/res/layout/widget_cell.xml
index 64ddea1..cb1c812 100644
--- a/res/layout/widget_cell.xml
+++ b/res/layout/widget_cell.xml
@@ -17,13 +17,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/widget_preview_container_width"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/widget_cell_height"
android:layout_weight="1"
- android:layout_marginTop="@dimen/widget_preview_padding_top"
- android:layout_marginLeft="8dp"
- android:layout_marginBottom="8dp"
+ android:layout_marginRight="@dimen/widget_row_divider"
android:orientation="vertical"
- android:background="@color/bubble_dark_background"
+ android:background="@color/widgets_cell_color"
android:focusable="true">
<LinearLayout
diff --git a/res/layout/widgets_list_row_view.xml b/res/layout/widgets_list_row_view.xml
index f94d023..12f6401 100644
--- a/res/layout/widgets_list_row_view.xml
+++ b/res/layout/widgets_list_row_view.xml
@@ -20,7 +20,6 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
- android:background="@drawable/focusable_view_bg"
android:descendantFocusability="afterDescendants">
<!-- Section info -->
@@ -29,24 +28,23 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
- android:background="@drawable/focusable_view_bg"
android:descendantFocusability="afterDescendants">
<ImageView
android:id="@+id/section_image"
- android:layout_width="@dimen/widget_section_height"
android:layout_height="@dimen/widget_section_height"
- android:paddingLeft="@dimen/widget_section_icon_padding"
- android:paddingRight="@dimen/widget_section_icon_padding"
- android:paddingTop="@dimen/widget_section_icon_padding"
- android:paddingBottom="@dimen/widget_section_icon_padding"
+ android:layout_width="@dimen/widget_section_icon_width"
+ android:paddingLeft="@dimen/widget_section_icon_horizontal_padding"
+ android:paddingRight="@dimen/widget_section_icon_horizontal_padding"
+ android:paddingTop="@dimen/widget_section_icon_vertical_padding"
+ android:paddingBottom="@dimen/widget_section_icon_vertical_padding"
android:background="@color/widget_text_panel"
/>
<TextView
android:id="@+id/section"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_section_height"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
+ android:paddingEnd="@dimen/widget_preview_label_horizontal_padding"
+ android:paddingRight="@dimen/widget_preview_label_horizontal_padding"
android:singleLine="true"
android:ellipsize="end"
android:gravity="start|center_vertical"
@@ -57,31 +55,24 @@
</LinearLayout>
<!-- Widget list -->
- <RelativeLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
+ android:background="@color/widgets_cell_color"
>
- <!-- TODO(hyunyoungs): replace the indicator with actual assets. -->
- <FrameLayout
- android:id="@+id/scrollable_indicator"
- android:layout_gravity="center_vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/ic_pageindicator_default"
- android:visibility="invisible"
- />
<HorizontalScrollView
android:id="@+id/widgets_scroll_container"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_cell_height"
- android:paddingLeft="40dp"
+ android:layout_marginLeft="@dimen/widget_row_padding"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/widgets_cell_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="horizontal" />
+ android:orientation="horizontal"
+ android:background="@color/widget_text_panel"/>
</HorizontalScrollView>
</RelativeLayout>
</LinearLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3a06bd9..58a4d4c 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -42,4 +42,5 @@
<!-- Widgetss view -->
<color name="widgets_view_section_text_color">#009688</color>
+ <color name="widgets_cell_color">#263238</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index da11082..a57ae89 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -86,12 +86,16 @@
<dimen name="widget_preview_label_horizontal_padding">8dp</dimen>
<dimen name="widget_preview_horizontal_padding">8dp</dimen>
- <dimen name="widget_section_height">52dp</dimen>
- <dimen name="widget_section_icon_padding">8dp</dimen>
+ <dimen name="widget_section_height">56dp</dimen>
+ <dimen name="widget_section_icon_width">72dp</dimen>
+ <dimen name="widget_section_icon_vertical_padding">8dp</dimen>
+ <dimen name="widget_section_icon_horizontal_padding">16dp</dimen>
<!-- Equation: widget_preview_size + 2 * widget_preview_padding_horizontal -->
<dimen name="widget_preview_container_width">136dp</dimen>
<dimen name="widget_cell_height">150dp</dimen>
+ <dimen name="widget_row_padding">8dp</dimen>
+ <dimen name="widget_row_divider">1dp</dimen>
<!-- Padding applied to shortcut previews -->
<dimen name="shortcut_preview_padding_left">0dp</dimen>
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 0bc7333..7c7d982 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -48,7 +48,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
private static final String TAG = "WidgetCell";
private static final boolean DEBUG = false;
- private static final int FADE_IN_DURATION_MS = 70;
+ private static final int FADE_IN_DURATION_MS = 90;
private int mPresetPreviewSize;
private ImageView mWidgetImage;
@@ -104,6 +104,8 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetImage.setImageDrawable(null);
mWidgetName.setText(null);
mWidgetDims.setText(null);
+
+ cancelLoader(false);
}
/**
@@ -140,16 +142,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
mWidgetPreviewLoader = loader;
}
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- deletePreview(false);
-
- if (DEBUG) {
- Log.d(TAG, String.format("[tag=%s] onDetachedFromWindow", getTagToString()));
- }
- }
-
public int[] getPreviewSize() {
int[] maxSize = new int[2];
maxSize[0] = mPresetPreviewSize;
@@ -219,10 +211,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
return Math.min(size[0], info.spanX * cellWidth);
}
-
- private void deletePreview(boolean recycleImage) {
- mWidgetImage.setImageDrawable(null);
-
+ private void cancelLoader(boolean recycleImage) {
if (mActiveRequest != null) {
mActiveRequest.cancel(recycleImage);
mActiveRequest = null;
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index f6ab21e..a5b2aff 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -127,7 +127,6 @@ 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);
- widget.reset();
if (getWidgetPreviewLoader() == null) {
return;
}
@@ -159,6 +158,16 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
}
@Override
+ public void onViewRecycled(WidgetsRowViewHolder holder) {
+ ViewGroup row = ((ViewGroup) holder.getContent().findViewById(R.id.widgets_cell_list));
+
+ for (int i = 0; i < row.getChildCount(); i++) {
+ WidgetCell widget = (WidgetCell) row.getChildAt(i);
+ widget.reset();
+ }
+ }
+
+ @Override
public long getItemId(int pos) {
return pos;
}