Merge "Defining the base state of the Launcher theme, in case the platform has different defaults" into ub-launcher3-burnaby-polish
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 6392123..82f33d1 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -100,12 +100,8 @@
<attr name="y" format="string" />
<attr name="spanX" format="string" />
<attr name="spanY" format="string" />
- <!--
- Temporarily disabling attr format definitions to prevent conflicts with support libs.
- Re-enable it once AAPT starts supporting multiple definitions of same attr.
<attr name="icon" format="reference" />
<attr name="title" format="reference" />
- -->
<attr name="uri" format="string" />
</declare-styleable>
@@ -119,7 +115,7 @@
</declare-styleable>
<declare-styleable name="PreloadIconDrawable">
- <attr name="ringBackground" format="reference" />
+ <attr name="background" format="reference" />
<attr name="ringOutset" format="dimension" />
<attr name="indicatorSize" format="dimension" />
</declare-styleable>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2b13159..4eee130 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -84,13 +84,13 @@
<style name="DropTargetButton" parent="DropTargetButtonBase" />
<style name="PreloadIcon">
- <item name="ringBackground">@drawable/virtual_preload</item>
+ <item name="background">@drawable/virtual_preload</item>
<item name="indicatorSize">4dp</item>
<item name="ringOutset">4dp</item>
</style>
<style name="PreloadIcon.Folder">
- <item name="ringBackground">@drawable/virtual_preload_folder</item>
+ <item name="background">@drawable/virtual_preload_folder</item>
<item name="indicatorSize">4dp</item>
<item name="ringOutset">4dp</item>
</style>
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index 85d8658..1c02904 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -231,26 +231,30 @@
int actualIconSize = (int) Math.min(iconSize, grid.iconSizePx);
- // Recreate the setup text.
- mSetupTextLayout = new StaticLayout(
- getResources().getText(R.string.gadget_setup_text), mPaint, availableWidth,
- Layout.Alignment.ALIGN_CENTER, 1, 0, true);
- int textHeight = mSetupTextLayout.getHeight();
+ // Icon top when we do not draw the text
+ int iconTop = (getHeight() - actualIconSize) / 2;
+ mSetupTextLayout = null;
- // Extra icon size due to the setting icon
- float minHeightWithText = textHeight + actualIconSize * settingIconScaleFactor
- + grid.iconDrawablePaddingPx;
+ if (availableWidth > 0) {
+ // Recreate the setup text.
+ mSetupTextLayout = new StaticLayout(
+ getResources().getText(R.string.gadget_setup_text), mPaint, availableWidth,
+ Layout.Alignment.ALIGN_CENTER, 1, 0, true);
+ int textHeight = mSetupTextLayout.getHeight();
- int iconTop;
- if (minHeightWithText < availableHeight) {
- // We can draw the text as well
- iconTop = (getHeight() - textHeight -
- grid.iconDrawablePaddingPx - actualIconSize) / 2;
+ // Extra icon size due to the setting icon
+ float minHeightWithText = textHeight + actualIconSize * settingIconScaleFactor
+ + grid.iconDrawablePaddingPx;
- } else {
- // The text will not fit. Only draw the icons.
- iconTop = (getHeight() - actualIconSize) / 2;
- mSetupTextLayout = null;
+ if (minHeightWithText < availableHeight) {
+ // We can draw the text as well
+ iconTop = (getHeight() - textHeight -
+ grid.iconDrawablePaddingPx - actualIconSize) / 2;
+
+ } else {
+ // We can't draw the text. Let the iconTop be same as before.
+ mSetupTextLayout = null;
+ }
}
mRect.set(0, 0, actualIconSize, actualIconSize);
diff --git a/src/com/android/launcher3/PreloadIconDrawable.java b/src/com/android/launcher3/PreloadIconDrawable.java
index a31ae0b..908c8b9 100644
--- a/src/com/android/launcher3/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/PreloadIconDrawable.java
@@ -60,7 +60,7 @@
public void applyPreloaderTheme(Theme t) {
TypedArray ta = t.obtainStyledAttributes(R.styleable.PreloadIconDrawable);
- mBgDrawable = ta.getDrawable(R.styleable.PreloadIconDrawable_ringBackground);
+ mBgDrawable = ta.getDrawable(R.styleable.PreloadIconDrawable_background);
mBgDrawable.setFilterBitmap(true);
mPaint.setStrokeWidth(ta.getDimension(R.styleable.PreloadIconDrawable_indicatorSize, 0));
mRingOutset = ta.getDimensionPixelSize(R.styleable.PreloadIconDrawable_ringOutset, 0);
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 0173eb7..03410ed 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -55,9 +55,6 @@
private static final String TAG = "WidgetsContainerView";
private static final boolean LOGD = false;
- /* Coefficient multiplied to the screen height for preloading widgets. */
- private static final int PRELOAD_SCREEN_HEIGHT_MULTIPLE = 1;
-
/* Global instances that are used inside this container. */
@Thunk Launcher mLauncher;
private DragController mDragController;
@@ -97,16 +94,7 @@
super.onFinishInflate();
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
mRecyclerView.setAdapter(mAdapter);
-
- // This extends the layout space so that preloading happen for the {@link RecyclerView}
- mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) {
- @Override
- protected int getExtraLayoutSpace(State state) {
- DeviceProfile grid = mLauncher.getDeviceProfile();
- return super.getExtraLayoutSpace(state)
- + grid.availableHeightPx * PRELOAD_SCREEN_HEIGHT_MULTIPLE;
- }
- });
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
//