android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
- <LinearLayout android:id="@+id/third_party_wallpaper_list"
+ <LinearLayout android:id="@+id/wallpaper_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
- <LinearLayout android:id="@+id/wallpaper_list"
+ <LinearLayout android:id="@+id/live_wallpaper_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
- <LinearLayout android:id="@+id/live_wallpaper_list"
+ <LinearLayout android:id="@+id/third_party_wallpaper_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
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"
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"
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"/>
<!-- 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>
return INSTANCE;
}
+ public static LauncherAppState getInstanceNoCreate() {
+ return INSTANCE;
+ }
+
public Context getContext() {
return sContext;
}
import java.util.Set;
import java.util.zip.CRC32;
-import static android.graphics.Bitmap.CompressFormat.WEBP;
-
/**
* Persist the launcher home state across calamities.
*/
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 = {
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;
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();
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 {
/** 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. */
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);
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;
}
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;
}
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;
}
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;
private final LayoutInflater mInflater;
private final PackageManager mPackageManager;
+ private final int mIconSize;
private List<ThirdPartyWallpaperTile> mThirdPartyWallpaperPickers =
new ArrayList<ThirdPartyWallpaperTile>();
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);
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;
}
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;
}
}
// 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);
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();
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);