Merge "Fixing issue with numerous empty screens showing when adding a shortcut to a clear workspace. (Bug 10785413)" into jb-ub-now-indigo-rose
diff --git a/res/layout/wallpaper_picker.xml b/res/layout/wallpaper_picker.xml
index fd66a57..c91cc7e 100644
--- a/res/layout/wallpaper_picker.xml
+++ b/res/layout/wallpaper_picker.xml
@@ -55,10 +55,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
- <LinearLayout android:id="@+id/third_party_wallpaper_list"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal" />
<LinearLayout android:id="@+id/wallpaper_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -67,6 +63,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
+ <LinearLayout android:id="@+id/third_party_wallpaper_list"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" />
</LinearLayout>
</HorizontalScrollView>
<View
diff --git a/res/layout/wallpaper_picker_gallery_item.xml b/res/layout/wallpaper_picker_image_picker_item.xml
similarity index 95%
rename from res/layout/wallpaper_picker_gallery_item.xml
rename to res/layout/wallpaper_picker_image_picker_item.xml
index d14ab3e..ae3c43d 100644
--- a/res/layout/wallpaper_picker_gallery_item.xml
+++ b/res/layout/wallpaper_picker_image_picker_item.xml
@@ -32,6 +32,8 @@
android:id="@+id/wallpaper_item_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:gravity="center"
android:layout_gravity="center"
android:text="@string/pick_image"
android:drawableTop="@drawable/ic_images"
diff --git a/res/layout/live_wallpaper_picker_item.xml b/res/layout/wallpaper_picker_live_wallpaper_item.xml
similarity index 90%
rename from res/layout/live_wallpaper_picker_item.xml
rename to res/layout/wallpaper_picker_live_wallpaper_item.xml
index 29aa12c..29fdb1b 100644
--- a/res/layout/live_wallpaper_picker_item.xml
+++ b/res/layout/wallpaper_picker_live_wallpaper_item.xml
@@ -31,14 +31,16 @@
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/wallpaper_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="@dimen/wallpaperItemIconSize"
+ android:layout_height="@dimen/wallpaperItemIconSize"
android:layout_gravity="center"
android:visibility="gone" />
<TextView
android:id="@+id/wallpaper_item_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="marquee"
android:gravity="center"
android:padding="4dp"
android:layout_gravity="bottom"
diff --git a/res/layout/third_party_wallpaper_picker_item.xml b/res/layout/wallpaper_picker_third_party_item.xml
similarity index 95%
rename from res/layout/third_party_wallpaper_picker_item.xml
rename to res/layout/wallpaper_picker_third_party_item.xml
index c2aeade..68661bc 100644
--- a/res/layout/third_party_wallpaper_picker_item.xml
+++ b/res/layout/wallpaper_picker_third_party_item.xml
@@ -32,6 +32,8 @@
android:id="@+id/wallpaper_item_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:gravity="center"
android:layout_gravity="center"
android:drawablePadding="4dp"
android:textColor="@android:color/white"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2910b7c..b4b2367 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -24,6 +24,7 @@
<!-- Wallpaper picker -->
<dimen name="wallpaperThumbnailWidth">106.5dp</dimen>
<dimen name="wallpaperThumbnailHeight">94.5dp</dimen>
+ <dimen name="wallpaperItemIconSize">32dp</dimen>
<!-- Cling -->
<dimen name="clingPunchThroughGraphicCenterRadius">94dp</dimen>
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 7da1c2a..8b34ffb 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -54,6 +54,10 @@
return INSTANCE;
}
+ public static LauncherAppState getInstanceNoCreate() {
+ return INSTANCE;
+ }
+
public Context getContext() {
return sContext;
}
diff --git a/src/com/android/launcher3/LauncherBackupAgent.java b/src/com/android/launcher3/LauncherBackupAgent.java
index 7cffe7b..f40238c 100644
--- a/src/com/android/launcher3/LauncherBackupAgent.java
+++ b/src/com/android/launcher3/LauncherBackupAgent.java
@@ -61,8 +61,6 @@
import java.util.Set;
import java.util.zip.CRC32;
-import static android.graphics.Bitmap.CompressFormat.WEBP;
-
/**
* Persist the launcher home state across calamities.
*/
@@ -81,6 +79,9 @@
public static final int IMAGE_COMPRESSION_QUALITY = 75;
+ private static final Bitmap.CompressFormat IMAGE_FORMAT =
+ android.graphics.Bitmap.CompressFormat.PNG;
+
private static BackupManager sBackupManager;
private static final String[] FAVORITE_PROJECTION = {
@@ -407,8 +408,13 @@
private void backupIcons(Journal in, BackupDataOutput data, Journal out,
ArrayList<Key> keys) throws IOException {
// persist icons that haven't been persisted yet
+ final LauncherAppState app = LauncherAppState.getInstanceNoCreate();
+ if (app == null) {
+ dataChanged(this); // try again later
+ if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying icon backup");
+ return;
+ }
final ContentResolver cr = getContentResolver();
- final LauncherAppState app = LauncherAppState.getInstance();
final IconCache iconCache = app.getIconCache();
final int dpi = getResources().getDisplayMetrics().densityDpi;
@@ -519,10 +525,15 @@
private void backupWidgets(Journal in, BackupDataOutput data, Journal out,
ArrayList<Key> keys) throws IOException {
// persist static widget info that hasn't been persisted yet
+ final LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
+ if (appState == null) {
+ dataChanged(this); // try again later
+ if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying widget backup");
+ return;
+ }
final ContentResolver cr = getContentResolver();
- final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(this);
final WidgetPreviewLoader previewLoader = new WidgetPreviewLoader(this);
- final LauncherAppState appState = LauncherAppState.getInstance();
+ final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(this);
final IconCache iconCache = appState.getIconCache();
final int dpi = getResources().getDisplayMetrics().densityDpi;
final DeviceProfile profile = appState.getDynamicGrid().getDeviceProfile();
@@ -567,6 +578,7 @@
previewLoader.setPreviewSize(spanX * profile.cellWidthPx,
spanY * profile.cellHeightPx, widgetSpacingLayout);
byte[] blob = packWidget(dpi, previewLoader, iconCache, provider);
+ keys.add(key);
writeRowToBackup(key, blob, out, data);
} else {
@@ -643,7 +655,7 @@
/** keys need to be strings, serialize and encode. */
private String keyToBackupKey(Key key) {
- return Base64.encodeToString(Key.toByteArray(key), Base64.NO_WRAP | Base64.NO_PADDING);
+ return Base64.encodeToString(Key.toByteArray(key), Base64.NO_WRAP);
}
/** keys need to be strings, decode and parse. */
@@ -775,7 +787,7 @@
Resource res = new Resource();
res.dpi = dpi;
ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (icon.compress(WEBP, IMAGE_COMPRESSION_QUALITY, os)) {
+ if (icon.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
res.data = os.toByteArray();
}
return writeCheckedBytes(res);
@@ -802,7 +814,7 @@
Drawable fullResIcon = iconCache.getFullResIcon(provider.getPackageName(), info.icon);
Bitmap icon = Utilities.createIconBitmap(fullResIcon, this);
ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (icon.compress(WEBP, IMAGE_COMPRESSION_QUALITY, os)) {
+ if (icon.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
widget.icon.data = os.toByteArray();
widget.icon.dpi = dpi;
}
@@ -811,7 +823,7 @@
widget.preview = new Resource();
Bitmap preview = previewLoader.generateWidgetPreview(info, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (preview.compress(WEBP, IMAGE_COMPRESSION_QUALITY, os)) {
+ if (preview.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
widget.preview.data = os.toByteArray();
widget.preview.dpi = dpi;
}
diff --git a/src/com/android/launcher3/LiveWallpaperListAdapter.java b/src/com/android/launcher3/LiveWallpaperListAdapter.java
index e9e5e79..4b59794 100644
--- a/src/com/android/launcher3/LiveWallpaperListAdapter.java
+++ b/src/com/android/launcher3/LiveWallpaperListAdapter.java
@@ -85,7 +85,7 @@
View view;
if (convertView == null) {
- view = mInflater.inflate(R.layout.live_wallpaper_picker_item, parent, false);
+ view = mInflater.inflate(R.layout.wallpaper_picker_live_wallpaper_item, parent, false);
} else {
view = convertView;
}
diff --git a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java b/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java
index 70ef7c3..494694c 100644
--- a/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java
+++ b/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java
@@ -22,6 +22,8 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +40,7 @@
private final LayoutInflater mInflater;
private final PackageManager mPackageManager;
+ private final int mIconSize;
private List<ThirdPartyWallpaperTile> mThirdPartyWallpaperPickers =
new ArrayList<ThirdPartyWallpaperTile>();
@@ -61,6 +64,7 @@
public ThirdPartyWallpaperPickerListAdapter(Context context) {
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mPackageManager = context.getPackageManager();
+ mIconSize = context.getResources().getDimensionPixelSize(R.dimen.wallpaperItemIconSize);
final PackageManager pm = mPackageManager;
final Intent pickWallpaperIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
@@ -117,7 +121,7 @@
View view;
if (convertView == null) {
- view = mInflater.inflate(R.layout.third_party_wallpaper_picker_item, parent, false);
+ view = mInflater.inflate(R.layout.wallpaper_picker_third_party_item, parent, false);
} else {
view = convertView;
}
@@ -127,8 +131,9 @@
ResolveInfo info = mThirdPartyWallpaperPickers.get(position).mResolveInfo;
TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label);
label.setText(info.loadLabel(mPackageManager));
- label.setCompoundDrawablesWithIntrinsicBounds(
- null, info.loadIcon(mPackageManager), null, null);
+ Drawable icon = info.loadIcon(mPackageManager);
+ icon.setBounds(new Rect(0, 0, mIconSize, mIconSize));
+ label.setCompoundDrawables(null, icon, null, null);
return view;
}
}
diff --git a/src/com/android/launcher3/WallpaperPickerActivity.java b/src/com/android/launcher3/WallpaperPickerActivity.java
index 12e69d3..9702a3a 100644
--- a/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -295,7 +295,7 @@
// Add a tile for the Gallery
LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list);
FrameLayout galleryThumbnail = (FrameLayout) getLayoutInflater().
- inflate(R.layout.wallpaper_picker_gallery_item, masterWallpaperList, false);
+ inflate(R.layout.wallpaper_picker_image_picker_item, masterWallpaperList, false);
setWallpaperItemPaddingToZero(galleryThumbnail);
masterWallpaperList.addView(galleryThumbnail, 0);
@@ -554,8 +554,10 @@
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) {
- Uri uri = data.getData();
- addTemporaryWallpaperTile(uri);
+ if (data != null && data.getData() != null) {
+ Uri uri = data.getData();
+ addTemporaryWallpaperTile(uri);
+ }
} else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
setResult(RESULT_OK);
finish();
diff --git a/util/com/android/launcher3/DecoderRing.java b/util/com/android/launcher3/DecoderRing.java
index cde845e..b7349fe 100644
--- a/util/com/android/launcher3/DecoderRing.java
+++ b/util/com/android/launcher3/DecoderRing.java
@@ -100,7 +100,7 @@
if (type == Key.class) {
Key key = new Key();
try {
- MessageNano.mergeFrom(key, byteStream.toByteArray());
+ key = Key.parseFrom(byteStream.toByteArray());
} catch (InvalidProtocolBufferNanoException e) {
System.err.println("failed to parse proto: " + e);
System.exit(1);