diff --git a/WallpaperPicker/res/values/config.xml b/WallpaperPicker/res/values/config.xml index 1b24190735..71580b5b07 100644 --- a/WallpaperPicker/res/values/config.xml +++ b/WallpaperPicker/res/values/config.xml @@ -15,4 +15,7 @@ --> false + + false diff --git a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java index 58add7022d..44bfdf1f9d 100644 --- a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java +++ b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java @@ -85,6 +85,9 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { } public SavedWallpaperImages(Activity context) { + // We used to store the saved images in the cache directory, but that meant they'd get + // deleted sometimes-- move them to the data directory + ImageDb.moveFromCacheDirectoryIfNecessary(context); mDb = new ImageDb(context); mContext = context; mLayoutInflater = context.getLayoutInflater(); @@ -215,11 +218,20 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { Context mContext; public ImageDb(Context context) { - super(context, new File(context.getCacheDir(), DB_NAME).getPath(), null, DB_VERSION); + super(context, context.getDatabasePath(DB_NAME).getPath(), null, DB_VERSION); // Store the context for later use mContext = context; } + public static void moveFromCacheDirectoryIfNecessary(Context context) { + // We used to store the saved images in the cache directory, but that meant they'd get + // deleted sometimes-- move them to the data directory + File oldSavedImagesFile = new File(context.getCacheDir(), ImageDb.DB_NAME); + File savedImagesFile = context.getDatabasePath(ImageDb.DB_NAME); + if (oldSavedImagesFile.exists()) { + oldSavedImagesFile.renameTo(savedImagesFile); + } + } @Override public void onCreate(SQLiteDatabase database) { database.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java index b3ef073091..ee7b819512 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java @@ -330,10 +330,10 @@ public class WallpaperCropActivity extends Activity { protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) { + boolean centerCrop = getResources().getBoolean(R.bool.center_crop); // Get the crop boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; - Display d = getWindowManager().getDefaultDisplay(); Point displaySize = new Point(); @@ -358,15 +358,25 @@ public class WallpaperCropActivity extends Activity { // ADJUST CROP WIDTH // Extend the crop all the way to the right, for parallax // (or all the way to the left, in RTL) - float extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; + float extraSpace; + if (centerCrop) { + extraSpace = 2f * Math.min(rotatedInSize[0] - cropRect.right, cropRect.left); + } else { + extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; + } // Cap the amount of extra width float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width(); extraSpace = Math.min(extraSpace, maxExtraSpace); - if (ltr) { - cropRect.right += extraSpace; + if (centerCrop) { + cropRect.left -= extraSpace / 2f; + cropRect.right += extraSpace / 2f; } else { - cropRect.left -= extraSpace; + if (ltr) { + cropRect.right += extraSpace; + } else { + cropRect.left -= extraSpace; + } } // ADJUST CROP HEIGHT diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index d3c779fe4b..c54e4779c1 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -85,6 +85,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public static final int PICK_WALLPAPER_THIRD_PARTY_ACTIVITY = 6; public static final int PICK_LIVE_WALLPAPER = 7; private static final String TEMP_WALLPAPER_TILES = "TEMP_WALLPAPER_TILES"; + private static final String SELECTED_INDEX = "SELECTED_INDEX"; private static final String OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME = "default_thumb.jpg"; private static final String DEFAULT_WALLPAPER_THUMBNAIL_FILENAME = "default_thumb2.jpg"; @@ -103,6 +104,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { ArrayList mTempWallpaperTiles = new ArrayList(); private SavedWallpaperImages mSavedImages; private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch; + private int mSelectedIndex; public static abstract class WallpaperTileInfo { protected View mView; @@ -148,7 +150,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public void run() { if (mBitmapSource != null && mBitmapSource.getLoadingState() == BitmapSource.State.LOADED) { - mView.setVisibility(View.VISIBLE); a.selectTile(mView); } else { ViewGroup parent = (ViewGroup) mView.getParent(); @@ -430,8 +431,9 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if ((right - left) > 0 && (bottom - top) > 0) { - if (mWallpapersView.getChildCount() > 0) { - mThumbnailOnClickListener.onClick(mWallpapersView.getChildAt(0)); + if (mSelectedIndex >= 0 && mSelectedIndex < mWallpapersView.getChildCount()) { + mThumbnailOnClickListener.onClick( + mWallpapersView.getChildAt(mSelectedIndex)); } v.removeOnLayoutChangeListener(this); } @@ -551,6 +553,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } mSelectedTile = v; v.setSelected(true); + mSelectedIndex = mWallpapersView.indexOfChild(v); // TODO: Remove this once the accessibility framework and // services have better support for selection state. v.announceForAccessibility( @@ -601,13 +604,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { protected void onSaveInstanceState(Bundle outState) { outState.putParcelableArrayList(TEMP_WALLPAPER_TILES, mTempWallpaperTiles); + outState.putInt(SELECTED_INDEX, mSelectedIndex); } protected void onRestoreInstanceState(Bundle savedInstanceState) { ArrayList uris = savedInstanceState.getParcelableArrayList(TEMP_WALLPAPER_TILES); for (Uri uri : uris) { - addTemporaryWallpaperTile(uri); + addTemporaryWallpaperTile(uri, true); } + mSelectedIndex = savedInstanceState.getInt(SELECTED_INDEX, 0); } private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter, @@ -711,7 +716,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } } - private void addTemporaryWallpaperTile(final Uri uri) { + private void addTemporaryWallpaperTile(final Uri uri, boolean fromRestore) { mTempWallpaperTiles.add(uri); // Add a tile for the image picked from Gallery final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater(). @@ -735,6 +740,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { image.setImageBitmap(thumb); Drawable thumbDrawable = image.getDrawable(); thumbDrawable.setDither(true); + pickedImageThumbnail.setVisibility(View.VISIBLE); } else { Log.e(TAG, "Error loading thumbnail for uri=" + uri); } @@ -747,14 +753,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { addLongPressHandler(pickedImageThumbnail); updateTileIndices(); pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener); - mThumbnailOnClickListener.onClick(pickedImageThumbnail); + if (!fromRestore) { + mThumbnailOnClickListener.onClick(pickedImageThumbnail); + } } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) { if (data != null && data.getData() != null) { Uri uri = data.getData(); - addTemporaryWallpaperTile(uri); + addTemporaryWallpaperTile(uri, false); } } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) { setResult(RESULT_OK); diff --git a/res/drawable-hdpi/screenpanel_hover.9.png b/res/drawable-hdpi/screenpanel_hover.9.png index 3321fc9255..0fed7c9d8d 100644 Binary files a/res/drawable-hdpi/screenpanel_hover.9.png and b/res/drawable-hdpi/screenpanel_hover.9.png differ diff --git a/res/drawable-mdpi/screenpanel_hover.9.png b/res/drawable-mdpi/screenpanel_hover.9.png index dd7740665d..7dd885860f 100644 Binary files a/res/drawable-mdpi/screenpanel_hover.9.png and b/res/drawable-mdpi/screenpanel_hover.9.png differ diff --git a/res/drawable-xhdpi/screenpanel_hover.9.png b/res/drawable-xhdpi/screenpanel_hover.9.png index a44dc113fb..251bf20855 100644 Binary files a/res/drawable-xhdpi/screenpanel_hover.9.png and b/res/drawable-xhdpi/screenpanel_hover.9.png differ diff --git a/res/drawable-xxhdpi/screenpanel_hover.9.png b/res/drawable-xxhdpi/screenpanel_hover.9.png index 1ab18da6a2..e8b36d8f14 100644 Binary files a/res/drawable-xxhdpi/screenpanel_hover.9.png and b/res/drawable-xxhdpi/screenpanel_hover.9.png differ diff --git a/res/layout-land/folder_cling.xml b/res/layout-land/folder_cling.xml index 86286d71ba..5dd372973a 100644 --- a/res/layout-land/folder_cling.xml +++ b/res/layout-land/folder_cling.xml @@ -16,7 +16,7 @@ + launcher:drawIdentifier="folder_landscape"> @@ -59,6 +60,6 @@ android:id="@+id/cling_dismiss" android:layout_marginBottom="15dp" android:layout_marginEnd="20dp" - android:layout_gravity="bottom|end" + android:layout_gravity="bottom|right" android:onClick="dismissFolderCling" /> diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index abb19f4bb0..7791609252 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -45,8 +45,8 @@ android:layout_gravity="end" /> + android:id="@+id/search_drop_target_bar" + layout="@layout/search_drop_target_bar" /> + + - - + android:layout_width="400dp" + android:layout_height="wrap_content" + android:layout_gravity="end|center_vertical" + android:paddingEnd="60dp" + android:orientation="vertical"> + android:orientation="horizontal"> + android:layout_gravity="center_vertical" + android:src="@drawable/cling_arrow_end" /> -