OSDN Git Service

Update styling of tile to pick image as wallpaper
authorMichael Jurka <mikejurka@google.com>
Tue, 17 Sep 2013 22:45:45 +0000 (00:45 +0200)
committerMichael Jurka <mikejurka@google.com>
Tue, 17 Sep 2013 22:45:45 +0000 (00:45 +0200)
Bug: 10743257

res/drawable-hdpi/ic_images.png [new file with mode: 0644]
res/drawable-mdpi/ic_images.png [new file with mode: 0644]
res/drawable-xhdpi/ic_images.png [new file with mode: 0644]
res/drawable-xxhdpi/ic_images.png [new file with mode: 0644]
res/layout/wallpaper_picker_gallery_item.xml
res/values/strings.xml
src/com/android/launcher3/WallpaperPickerActivity.java

diff --git a/res/drawable-hdpi/ic_images.png b/res/drawable-hdpi/ic_images.png
new file mode 100644 (file)
index 0000000..0003c6c
Binary files /dev/null and b/res/drawable-hdpi/ic_images.png differ
diff --git a/res/drawable-mdpi/ic_images.png b/res/drawable-mdpi/ic_images.png
new file mode 100644 (file)
index 0000000..aabc123
Binary files /dev/null and b/res/drawable-mdpi/ic_images.png differ
diff --git a/res/drawable-xhdpi/ic_images.png b/res/drawable-xhdpi/ic_images.png
new file mode 100644 (file)
index 0000000..3f21faf
Binary files /dev/null and b/res/drawable-xhdpi/ic_images.png differ
diff --git a/res/drawable-xxhdpi/ic_images.png b/res/drawable-xxhdpi/ic_images.png
new file mode 100644 (file)
index 0000000..d00db9a
Binary files /dev/null and b/res/drawable-xxhdpi/ic_images.png differ
index 7f30f80..ecfba60 100644 (file)
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="#66000000"
-        android:scaleType="fitXY" />
+        android:scaleType="centerCrop" />
     <TextView
         android:id="@+id/wallpaper_item_label"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
+        android:text="@string/pick_image"
+        android:drawableTop="@drawable/ic_images"
+        android:drawablePadding="4dp"
         android:textColor="#FFFFFFFF"/>
 </com.android.launcher3.CheckableFrameLayout>
index e04902a..6b9b070 100644 (file)
@@ -41,8 +41,8 @@
 
     <!-- Label on button to delete wallpaper(s) -->
     <string name="wallpaper_delete">Delete</string>
-    <!-- Label on button in Wallpaper Picker that launches Gallery app -->
-    <string name="gallery">Gallery</string>
+    <!-- Label on button in Wallpaper Picker to pick an image -->
+    <string name="pick_image">Pick image</string>
     <!-- Option in "Select wallpaper from" dialog box -->
     <string name="pick_wallpaper">Wallpapers</string>
     <!-- Title of activity for cropping wallpapers -->
index fe7525a..d980967 100644 (file)
@@ -26,6 +26,7 @@ import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
+import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -34,6 +35,7 @@ import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LevelListDrawable;
 import android.net.Uri;
 import android.os.Bundle;
+import android.provider.MediaStore;
 import android.util.Log;
 import android.util.Pair;
 import android.view.ActionMode;
@@ -52,7 +54,6 @@ import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ListAdapter;
 import android.widget.SpinnerAdapter;
-import android.widget.TextView;
 
 import com.android.photos.BitmapRegionTileSource;
 
@@ -214,12 +215,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
         FrameLayout galleryThumbnail = (FrameLayout) getLayoutInflater().
                 inflate(R.layout.wallpaper_picker_gallery_item, mWallpapersView, false);
         setWallpaperItemPaddingToZero(galleryThumbnail);
-
-        TextView galleryLabel =
-                (TextView) galleryThumbnail.findViewById(R.id.wallpaper_item_label);
-        galleryLabel.setText(R.string.gallery);
         mWallpapersView.addView(galleryThumbnail, 0);
 
+        // Make its background the last photo taken on external storage
+        Bitmap lastPhoto = getThumbnailOfLastPhoto();
+        if (lastPhoto != null) {
+            ImageView galleryThumbnailBg =
+                    (ImageView) galleryThumbnail.findViewById(R.id.wallpaper_image);
+            galleryThumbnailBg.setImageBitmap(getThumbnailOfLastPhoto());
+        }
+
         ThumbnailMetaData meta = new ThumbnailMetaData();
         meta.mLaunchesGallery = true;
         galleryThumbnail.setTag(meta);
@@ -322,7 +327,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
                     for (View v : viewsToRemove) {
                         mWallpapersView.removeView(v);
                     }
-                    ///xxxxx DESTROYING
                     mode.finish(); // Action picked, so close the CAB
                     return true;
                 } else {
@@ -343,6 +347,23 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
             }
         };
     }
+
+    protected Bitmap getThumbnailOfLastPhoto() {
+        Cursor cursor = MediaStore.Images.Media.query(getContentResolver(),
+                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+                new String[] { MediaStore.Images.ImageColumns._ID,
+                    MediaStore.Images.ImageColumns.DATE_TAKEN},
+                null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC LIMIT 1");
+        Bitmap thumb = null;
+        if (cursor.moveToNext()) {
+            int id = cursor.getInt(0);
+            thumb = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(),
+                    id, MediaStore.Images.Thumbnails.MINI_KIND, null);
+        }
+        cursor.close();
+        return thumb;
+    }
+    
     protected void onSaveInstanceState(Bundle outState) {
         outState.putParcelableArrayList(TEMP_WALLPAPER_TILES, mTempWallpaperTiles);
     }