Loading WallpaperPicker/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,7 @@ --> <resources> <bool name="allow_rotation">false</bool> <!-- Specifies whether to expand the cropped area on both sides (rather than just to one side) --> <bool name="center_crop">false</bool> </resources> WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java +13 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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 + " (" + Loading WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +15 −5 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -358,16 +358,26 @@ 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 (centerCrop) { cropRect.left -= extraSpace / 2f; cropRect.right += extraSpace / 2f; } else { if (ltr) { cropRect.right += extraSpace; } else { cropRect.left -= extraSpace; } } // ADJUST CROP HEIGHT if (isPortrait) { Loading WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +15 −7 Original line number Diff line number Diff line Loading @@ -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"; Loading @@ -103,6 +104,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { ArrayList<Uri> mTempWallpaperTiles = new ArrayList<Uri>(); private SavedWallpaperImages mSavedImages; private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch; private int mSelectedIndex; public static abstract class WallpaperTileInfo { protected View mView; Loading Loading @@ -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(); Loading Loading @@ -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); } Loading Loading @@ -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( Loading Loading @@ -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<Uri> 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, Loading Loading @@ -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(). Loading @@ -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); } Loading @@ -747,14 +753,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { addLongPressHandler(pickedImageThumbnail); updateTileIndices(); pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener); 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); Loading res/drawable-hdpi/screenpanel_hover.9.png −93 B (1.07 KiB) Loading image diff... Loading
WallpaperPicker/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,7 @@ --> <resources> <bool name="allow_rotation">false</bool> <!-- Specifies whether to expand the cropped area on both sides (rather than just to one side) --> <bool name="center_crop">false</bool> </resources>
WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java +13 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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 + " (" + Loading
WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +15 −5 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -358,16 +358,26 @@ 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 (centerCrop) { cropRect.left -= extraSpace / 2f; cropRect.right += extraSpace / 2f; } else { if (ltr) { cropRect.right += extraSpace; } else { cropRect.left -= extraSpace; } } // ADJUST CROP HEIGHT if (isPortrait) { Loading
WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +15 −7 Original line number Diff line number Diff line Loading @@ -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"; Loading @@ -103,6 +104,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { ArrayList<Uri> mTempWallpaperTiles = new ArrayList<Uri>(); private SavedWallpaperImages mSavedImages; private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch; private int mSelectedIndex; public static abstract class WallpaperTileInfo { protected View mView; Loading Loading @@ -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(); Loading Loading @@ -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); } Loading Loading @@ -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( Loading Loading @@ -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<Uri> 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, Loading Loading @@ -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(). Loading @@ -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); } Loading @@ -747,14 +753,16 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { addLongPressHandler(pickedImageThumbnail); updateTileIndices(); pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener); 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); Loading