Merge "Import translations. DO NOT MERGE" into jb-ub-now-kermit
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 5874c80..bf670d4 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -36,8 +36,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
- launcher:defaultScreen="@integer/config_workspaceDefaultScreen"
- launcher:pageIndicator="@id/page_indicator" />
+ launcher:defaultScreen="@integer/config_workspaceDefaultScreen" />
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout-port/first_run_cling.xml b/res/layout-port/first_run_cling.xml
index 4830e5d..ac3939c 100644
--- a/res/layout-port/first_run_cling.xml
+++ b/res/layout-port/first_run_cling.xml
@@ -39,16 +39,14 @@
android:layout_marginBottom="10dp"
android:text="@string/first_run_cling_title"
android:textColor="#FFFFFFFF"
- android:textSize="30sp"
android:gravity="center" />
<TextView
- style="@style/ClingAltTitleText"
+ style="@style/ClingAltText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/first_run_cling_description"
android:textColor="#80000000"
- android:textSize="16sp"
android:gravity="center" />
</LinearLayout>
<TextView
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 49e6b6a..2b3cf81 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -35,7 +35,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
launcher:defaultScreen="@integer/config_workspaceDefaultScreen"
- launcher:pageIndicator="@id/page_indicator">
+ launcher:pageIndicator="@+id/page_indicator">
</com.android.launcher3.Workspace>
<include layout="@layout/hotseat"
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 11a938f..eae216e 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -56,13 +56,12 @@
android:id="@+id/apps_customize_pane_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_offset"
launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
launcher:maxGap="@dimen/workspace_max_gap"
- launcher:pageIndicator="@+id/page_indicator" />
+ launcher:pageIndicator="@+id/apps_customize_page_indicator" />
<FrameLayout
android:id="@+id/animation_buffer"
android:layout_width="match_parent"
@@ -70,12 +69,11 @@
android:background="#FF000000"
android:visibility="gone" />
<include
- android:id="@+id/page_indicator"
+ android:id="@+id/apps_customize_page_indicator"
layout="@layout/page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|center_horizontal"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_margin" />
+ android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
</LinearLayout>
</com.android.launcher3.AppsCustomizeTabHost>
diff --git a/res/values-en/dimens.xml b/res/values-en/dimens.xml
new file mode 100644
index 0000000..01d4693
--- /dev/null
+++ b/res/values-en/dimens.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<resources>
+<!-- Cling -->
+ <dimen name="cling_title_text_size">22sp</dimen>
+ <dimen name="cling_text_size">16sp</dimen>
+ <dimen name="cling_alt_title_text_size">30sp</dimen>
+ <dimen name="cling_alt_text_size">16sp</dimen>
+ <dimen name="cling_hint_text_size">18sp</dimen>
+</resources>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 7f5594d..f9ca01b 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -15,12 +15,6 @@
-->
<resources>
-<!-- AppsCustomize -->
- <dimen name="apps_customize_pageLayoutWidthGap">36dp</dimen>
- <dimen name="apps_customize_pageLayoutHeightGap">8dp</dimen>
- <dimen name="apps_customize_pageLayoutPaddingTop">20dp</dimen>
- <dimen name="apps_customize_pageLayoutPaddingBottom">14dp</dimen>
-
<!-- QSB -->
<dimen name="toolbar_button_vertical_padding">12dip</dimen>
<dimen name="toolbar_button_horizontal_padding">20dip</dimen>
diff --git a/res/values/config.xml b/res/values/config.xml
index 4978281..1a83556 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -1,4 +1,10 @@
<resources>
+<!-- Dynamic Grid -->
+ <integer name="config_dynamic_grid_max_long_edge_cell_count">6</integer>
+ <integer name="config_dynamic_grid_max_short_edge_cell_count">5</integer>
+ <integer name="config_dynamic_grid_min_edge_cell_count">3</integer>
+
+<!-- Miscellaneous -->
<bool name="config_largeHeap">false</bool>
<bool name="is_tablet">false</bool>
<bool name="is_large_tablet">false</bool>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d87fb14..740393e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -21,6 +21,7 @@
<dimen name="dynamic_grid_search_bar_height">48dp</dimen>
<dimen name="dynamic_grid_page_indicator_height">24dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
+ <dimen name="dynamic_grid_all_apps_cell_padding">18dp</dimen>
<dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen>
<!-- Wallpaper picker -->
@@ -38,6 +39,12 @@
<add-resource type="dimen" name="custom_cling_margin_top" />
<add-resource type="dimen" name="custom_cling_margin_right" />
<add-resource type="dimen" name="custom_cling_margin_left" />
+
+ <dimen name="cling_title_text_size">20sp</dimen>
+ <dimen name="cling_text_size">14sp</dimen>
+ <dimen name="cling_alt_title_text_size">24sp</dimen>
+ <dimen name="cling_alt_text_size">16sp</dimen>
+ <dimen name="cling_hint_text_size">14sp</dimen>
<!-- Workspace -->
<dimen name="workspace_max_gap">16dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 39e55d8..8226915 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -52,27 +52,33 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginBottom">5dp</item>
- <item name="android:textSize">22sp</item>
+ <item name="android:textSize">@dimen/cling_title_text_size</item>
<item name="android:textColor">#ffffff</item>
<item name="android:fontFamily">sans-serif-condensed</item>
</style>
- <style name="ClingAltTitleText">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:textSize">24sp</item>
- <item name="android:textColor">#49C0EC</item>
- </style>
<style name="ClingText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:textSize">16sp</item>
+ <item name="android:textSize">@dimen/cling_text_size</item>
<item name="android:textColor">#80000000</item>
<item name="android:lineSpacingMultiplier">1.1</item>
</style>
+ <style name="ClingAltTitleText">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">@dimen/cling_alt_title_text_size</item>
+ <item name="android:textColor">#49C0EC</item>
+ </style>
+ <style name="ClingAltText">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">@dimen/cling_alt_text_size</item>
+ <item name="android:textColor">#49C0EC</item>
+ </style>
<style name="ClingHintText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:textSize">18sp</item>
+ <item name="android:textSize">@dimen/cling_hint_text_size</item>
<item name="android:textColor">#80ffffff</item>
<item name="android:fontFamily">sans-serif-condensed</item>
</style>
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 25cd9f2..d9ca157 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -187,6 +187,7 @@
private PagedViewCellLayout mWidgetSpacingLayout;
private int mNumAppsPages;
private int mNumWidgetPages;
+ private Rect mAllAppsPadding = new Rect();
// Relating to the scroll and overscroll effects
Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f);
@@ -293,6 +294,13 @@
grid.edgeMarginPx, 2 * grid.edgeMarginPx);
}
+ void setAllAppsPadding(Rect r) {
+ mAllAppsPadding.set(r);
+ }
+ void setWidgetsPageIndicatorPadding(int pageIndicatorHeight) {
+ mPageLayoutPaddingBottom = pageIndicatorHeight;
+ }
+
/** Returns the item index of the center item on this page so that we can restore to this
* item index when we rotate. */
private int getMiddleComponentIndexOnCurrentPage() {
@@ -995,6 +1003,8 @@
int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
layout.setMinimumWidth(getPageContentWidth());
layout.measure(widthSpec, heightSpec);
+ layout.setPadding(mAllAppsPadding.left, mAllAppsPadding.top, mAllAppsPadding.right,
+ mAllAppsPadding.bottom);
setVisibilityOnChildren(layout, View.VISIBLE);
}
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index ccbac2c..9b3b193 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -91,6 +91,11 @@
int iconDrawablePaddingPx;
int cellWidthPx;
int cellHeightPx;
+ int allAppsIconSizePx;
+ int allAppsIconTextSizePx;
+ int allAppsCellWidthPx;
+ int allAppsCellHeightPx;
+ int allAppsCellPaddingPx;
int folderBackgroundOffset;
int folderIconSizePx;
int folderCellWidthPx;
@@ -151,6 +156,8 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
defaultPageSpacingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
+ allAppsCellPaddingPx =
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_all_apps_cell_padding);
// Interpolate the rows
for (DeviceProfile p : profiles) {
@@ -177,6 +184,8 @@
points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconSize));
}
iconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
+ // AllApps uses the original non-scaled icon size
+ allAppsIconSizePx = DynamicGrid.pxFromDp(iconSize, dm);
// Interpolate the icon text size
points.clear();
@@ -186,6 +195,8 @@
iconTextSize = invDistWeightedInterpolate(minWidth, minHeight, points);
iconDrawablePaddingOriginalPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
+ // AllApps uses the original non-scaled icon text size
+ allAppsIconTextSizePx = DynamicGrid.pxFromDp(iconTextSize, dm);
// Interpolate the hotseat icon size
points.clear();
@@ -309,14 +320,23 @@
CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
int pageIndicatorOffset =
resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
- if (isLandscape) {
- allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
- (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
- } else {
- allAppsNumRows = (int) numRows + 1;
- }
- allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /
- (iconSizePx + 2 * edgeMarginPx);
+ allAppsCellWidthPx = allAppsIconSizePx;
+ allAppsCellHeightPx = allAppsIconSizePx + drawablePadding + iconTextSizePx;
+ int maxLongEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_max_long_edge_cell_count);
+ int maxShortEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_max_short_edge_cell_count);
+ int minEdgeCellCount =
+ resources.getInteger(R.integer.config_dynamic_grid_min_edge_cell_count);
+ int maxRows = (isLandscape ? maxShortEdgeCellCount : maxLongEdgeCellCount);
+ int maxCols = (isLandscape ? maxLongEdgeCellCount : maxShortEdgeCellCount);
+
+ allAppsNumRows = (availableHeightPx - pageIndicatorHeightPx) /
+ (allAppsCellHeightPx + allAppsCellPaddingPx);
+ allAppsNumRows = Math.max(minEdgeCellCount, Math.min(maxRows, allAppsNumRows));
+ allAppsNumCols = (availableWidthPx) /
+ (allAppsCellWidthPx + allAppsCellPaddingPx);
+ allAppsNumCols = Math.max(minEdgeCellCount, Math.min(maxCols, allAppsNumCols));
}
void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx,
@@ -580,6 +600,45 @@
pageIndicator.setLayoutParams(lp);
}
}
+
+ AppsCustomizeTabHost host = (AppsCustomizeTabHost)
+ launcher.findViewById(R.id.apps_customize_pane);
+ if (host != null) {
+ // Center the all apps page indicator
+ int pageIndicatorHeight = (int) (pageIndicatorHeightPx * Math.min(1f,
+ (allAppsIconSizePx / DynamicGrid.DEFAULT_ICON_SIZE_PX)));
+ pageIndicator = host.findViewById(R.id.apps_customize_page_indicator);
+ if (pageIndicator != null) {
+ lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
+ lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
+ lp.width = LayoutParams.WRAP_CONTENT;
+ lp.height = pageIndicatorHeight;
+ pageIndicator.setLayoutParams(lp);
+ }
+
+ AppsCustomizePagedView pagedView = (AppsCustomizePagedView)
+ host.findViewById(R.id.apps_customize_pane_content);
+ padding = new Rect();
+ if (pagedView != null) {
+ // Constrain the dimensions of all apps so that it does not span the full width
+ int paddingLR = (availableWidthPx - (allAppsCellWidthPx * allAppsNumCols)) /
+ (2 * (allAppsNumCols + 1));
+ int paddingTB = (availableHeightPx - (allAppsCellHeightPx * allAppsNumRows)) /
+ (2 * (allAppsNumRows + 1));
+ paddingLR = Math.min(paddingLR, (int)((paddingLR + paddingTB) * 0.75f));
+ paddingTB = Math.min(paddingTB, (int)((paddingLR + paddingTB) * 0.75f));
+ int maxAllAppsWidth = (allAppsNumCols * (allAppsCellWidthPx + 2 * paddingLR));
+ int gridPaddingLR = (availableWidthPx - maxAllAppsWidth) / 2;
+ if (gridPaddingLR > (allAppsCellWidthPx / 4)) {
+ padding.left = padding.right = gridPaddingLR;
+ }
+ // The icons are centered, so we can't just offset by the page indicator height
+ // because the empty space will actually be pageIndicatorHeight + paddingTB
+ padding.bottom = Math.max(0, pageIndicatorHeight - paddingTB);
+ pagedView.setAllAppsPadding(padding);
+ pagedView.setWidgetsPageIndicatorPadding(pageIndicatorHeight);
+ }
+ }
}
}
@@ -591,6 +650,10 @@
private float mMinWidth;
private float mMinHeight;
+ // This is a static that we use for the default icon size on a 4/5-inch phone
+ static float DEFAULT_ICON_SIZE_DP = 60;
+ static float DEFAULT_ICON_SIZE_PX = 0;
+
public static float dpiFromPx(int size, DisplayMetrics metrics){
float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
return (size / densityRatio);
@@ -612,6 +675,7 @@
ArrayList<DeviceProfile> deviceProfiles =
new ArrayList<DeviceProfile>();
boolean hasAA = !AppsCustomizePagedView.DISABLE_ALL_APPS;
+ DEFAULT_ICON_SIZE_PX = pxFromDp(DEFAULT_ICON_SIZE_DP, dm);
// Our phone profiles include the bar sizes in each orientation
deviceProfiles.add(new DeviceProfile("Super Short Stubby",
255, 300, 2, 3, 48, 13, (hasAA ? 5 : 4), 48));
@@ -624,7 +688,7 @@
deviceProfiles.add(new DeviceProfile("Nexus S",
296, 491.33f, 4, 4, 48, 13, (hasAA ? 5 : 4), 48));
deviceProfiles.add(new DeviceProfile("Nexus 4",
- 359, 518, 4, 4, 60, 13, (hasAA ? 5 : 4), 56));
+ 359, 518, 4, 4, DEFAULT_ICON_SIZE_DP, 13, (hasAA ? 5 : 4), 56));
// The tablet profile is odd in that the landscape orientation
// also includes the nav bar on the side
deviceProfiles.add(new DeviceProfile("Nexus 7",
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3290d8e..0637b24 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -181,6 +181,8 @@
private static final String RUNTIME_STATE_PENDING_ADD_SPAN_Y = "launcher.add_span_y";
// Type: parcelable
private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_INFO = "launcher.add_widget_info";
+ // Type: parcelable
+ private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id";
private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon";
private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME =
@@ -227,6 +229,7 @@
private ItemInfo mPendingAddInfo = new ItemInfo();
private AppWidgetProviderInfo mPendingAddWidgetInfo;
+ private int mPendingAddWidgetId = -1;
private int[] mTmpAddItemCellCoordinates = new int[2];
@@ -704,6 +707,8 @@
final int requestCode, final int resultCode, final Intent data) {
// Reset the startActivity waiting flag
mWaitingForResult = false;
+ int pendingAddWidgetId = mPendingAddWidgetId;
+ mPendingAddWidgetId = -1;
Runnable exitSpringLoaded = new Runnable() {
@Override
@@ -737,11 +742,18 @@
// We have special handling for widgets
if (isWidgetDrop) {
- final int appWidgetId = data != null ?
- data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
+ final int appWidgetId;
+ int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1)
+ : -1;
+ if (widgetId < 0) {
+ appWidgetId = pendingAddWidgetId;
+ } else {
+ appWidgetId = widgetId;
+ }
+
final int result;
final Runnable onComplete;
- if (appWidgetId < 0) {
+ if (appWidgetId < 0 || resultCode == RESULT_CANCELED) {
Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not returned from the \\" +
"widget configuration activity.");
result = RESULT_CANCELED;
@@ -819,6 +831,7 @@
}
};
} else if (resultCode == RESULT_CANCELED) {
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
animationType = Workspace.CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION;
}
if (mDragLayer.getAnimatedView() != null) {
@@ -1122,6 +1135,7 @@
mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
+ mPendingAddWidgetId = savedState.getInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID);
mWaitingForResult = true;
mRestoring = true;
}
@@ -1746,6 +1760,7 @@
outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX);
outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY);
outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo);
+ outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId);
}
if (mFolderInfo != null && mWaitingForResult) {
@@ -1929,6 +1944,7 @@
delay) {
if (appWidgetInfo.configure != null) {
mPendingAddWidgetInfo = appWidgetInfo;
+ mPendingAddWidgetId = appWidgetId;
// Launch over to configure widget, if needed
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
@@ -4122,6 +4138,9 @@
if (grid.isTablet()) {
return false;
}
+ if (grid.isLandscape) {
+ return false;
+ }
// disable clings when running in a test harness
if(ActivityManager.isRunningInTestHarness()) return false;
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 46c861b..8181bea 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -152,6 +152,8 @@
protected int mTouchState = TOUCH_STATE_REST;
protected boolean mForceScreenScrolled = false;
+ private boolean mScrollAbortedFromIntercept = false;
+
protected OnLongClickListener mLongClickListener;
@@ -1368,6 +1370,7 @@
final boolean finishedScrolling = (mScroller.isFinished() || xDist < mTouchSlop);
if (finishedScrolling) {
mTouchState = TOUCH_STATE_REST;
+ mScrollAbortedFromIntercept = true;
abortScrollerAnimation(false);
} else {
if (isTouchPointInViewportWithBuffer((int) mDownMotionX, (int) mDownMotionY)) {
@@ -1395,6 +1398,9 @@
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
+ if (mScrollAbortedFromIntercept) {
+ snapToDestination();
+ }
resetTouchState();
break;
@@ -1871,15 +1877,6 @@
snapToPageWithVelocity(finalPage, velocityX);
} else {
snapToDestination();
- } } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
- // at this point we have not moved beyond the touch slop
- // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
- // we can just page
- int nextPage = Math.max(0, mCurrentPage - 1);
- if (nextPage != mCurrentPage) {
- snapToPage(nextPage);
- } else {
- snapToDestination();
}
} else {
if (!mScroller.isFinished()) {
@@ -1894,6 +1891,16 @@
getScrollY(), vX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
invalidate();
}
+ } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
+ // at this point we have not moved beyond the touch slop
+ // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
+ // we can just page
+ int nextPage = Math.max(0, mCurrentPage - 1);
+ if (nextPage != mCurrentPage) {
+ snapToPage(nextPage);
+ } else {
+ snapToDestination();
+ }
} else if (mTouchState == TOUCH_STATE_NEXT_PAGE) {
// at this point we have not moved beyond the touch slop
// (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
@@ -1965,6 +1972,7 @@
releaseVelocityTracker();
endReordering();
mCancelTap = false;
+ mScrollAbortedFromIntercept = false;
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
}
diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java
index 865c0b2..f7cb997 100644
--- a/src/com/android/launcher3/PagedViewIcon.java
+++ b/src/com/android/launcher3/PagedViewIcon.java
@@ -20,7 +20,7 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Region;
-import android.graphics.Region.Op;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
@@ -62,7 +62,7 @@
// Ensure we are using the right text size
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
+ setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
}
public void applyFromApplicationInfo(AppInfo info, boolean scaleUp,
@@ -72,8 +72,9 @@
mIcon = info.iconBitmap;
mPressedCallback = cb;
- setCompoundDrawables(null, Utilities.createIconDrawable(mIcon),
- null, null);
+ Drawable icon = Utilities.createIconDrawable(mIcon);
+ icon.setBounds(0, 0, grid.allAppsIconSizePx, grid.allAppsIconSizePx);
+ setCompoundDrawables(null, icon, null, null);
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
setText(info.title);
setTag(info);
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
index 435dbda..18e7c86 100644
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ b/src/com/android/launcher3/SearchDropTargetBar.java
@@ -71,10 +71,10 @@
mDeleteDropTarget.setLauncher(launcher);
mQSBSearchBar = launcher.getQsbBar();
if (mEnableDropDownDropTargets) {
- mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "translationY", 0,
+ mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "translationY", 0f,
-mBarHeight);
} else {
- mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
+ mQSBSearchBarAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
}
setupAnimation(mQSBSearchBarAnim, mQSBSearchBar);
}
@@ -117,12 +117,12 @@
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
mBarHeight = grid.searchBarSpaceHeightPx;
mDropTargetBar.setTranslationY(-mBarHeight);
- mDropTargetBarAnim = LauncherAnimUtils.ofFloat(mDropTargetBar, "translationY",
+ mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, "translationY",
-mBarHeight, 0f);
} else {
mDropTargetBar.setAlpha(0f);
- mDropTargetBarAnim = LauncherAnimUtils.ofFloat(mDropTargetBar, "alpha", 0f, 1f);
+ mDropTargetBarAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f, 1f);
}
setupAnimation(mDropTargetBarAnim, mDropTargetBar);
}
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index 07b4f6f..7e1ad6d 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -4,6 +4,7 @@
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -100,6 +101,7 @@
public class WidgetPreviewLoader {
static final String TAG = "WidgetPreviewLoader";
+ static final String ANDROID_INCREMENTAL_VERSION_NAME_KEY = "android.incremental.version";
private int mPreviewBitmapWidth;
private int mPreviewBitmapHeight;
@@ -147,6 +149,20 @@
mDb = app.getWidgetPreviewCacheDb();
mLoadedPreviews = new HashMap<String, WeakReference<Bitmap>>();
mUnusedBitmaps = new ArrayList<SoftReference<Bitmap>>();
+
+ SharedPreferences sp = context.getSharedPreferences(
+ LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE);
+ final String lastVersionName = sp.getString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, null);
+ final String versionName = android.os.Build.VERSION.INCREMENTAL;
+ if (!versionName.equals(lastVersionName)) {
+ // clear all the previews whenever the system version changes, to ensure that previews
+ // are up-to-date for any apps that might have been updated with the system
+ clearDb();
+
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName);
+ editor.commit();
+ }
}
public void setPreviewSize(int previewWidth, int previewHeight,
@@ -334,6 +350,12 @@
db.insert(CacheDb.TABLE_NAME, null, values);
}
+ private void clearDb() {
+ SQLiteDatabase db = mDb.getWritableDatabase();
+ // Delete everything
+ db.delete(CacheDb.TABLE_NAME, null, null);
+ }
+
public static void removePackageFromDb(final CacheDb cacheDb, final String packageName) {
synchronized(sInvalidPackages) {
sInvalidPackages.add(packageName);