summaryrefslogtreecommitdiffstats
path: root/WallpaperPicker/src/com/android/launcher3
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-03-20 17:26:30 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-03-20 18:16:58 -0700
commit6a1e95a3dfb5eb65cc2c682c5ede9e22cc7ff7d9 (patch)
tree90631f1b2ffce2487e58dc501301a17e8c5116fe /WallpaperPicker/src/com/android/launcher3
parent71c3baf5ebc520d5146946e0d7907a5dc12366db (diff)
downloadandroid_packages_apps_Trebuchet-6a1e95a3dfb5eb65cc2c682c5ede9e22cc7ff7d9.tar.gz
android_packages_apps_Trebuchet-6a1e95a3dfb5eb65cc2c682c5ede9e22cc7ff7d9.tar.bz2
android_packages_apps_Trebuchet-6a1e95a3dfb5eb65cc2c682c5ede9e22cc7ff7d9.zip
Removing all dependencies of launcher code on wallpaper-picker
> WallpaperPicker can still depend on launcher code, but not the other way round. Change-Id: I93a07f985c3955c638a68a5fad9c09b184a879b9
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3')
-rw-r--r--WallpaperPicker/src/com/android/launcher3/LauncherWallpaperPickerActivity.java21
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java46
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java12
3 files changed, 37 insertions, 42 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/LauncherWallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/LauncherWallpaperPickerActivity.java
new file mode 100644
index 000000000..091c05462
--- /dev/null
+++ b/WallpaperPicker/src/com/android/launcher3/LauncherWallpaperPickerActivity.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+// TODO: Remove this class
+public class LauncherWallpaperPickerActivity extends WallpaperPickerActivity {
+} \ No newline at end of file
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
index 5b2943a65..c238390e3 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
@@ -38,13 +38,13 @@ import android.os.Message;
import android.util.Log;
import android.view.Display;
import android.view.View;
-import android.view.WindowManager;
import android.widget.Toast;
import com.android.gallery3d.common.BitmapCropTask;
import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.Utils;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.WallpaperUtils;
import com.android.photos.BitmapRegionTileSource;
import com.android.photos.BitmapRegionTileSource.BitmapSource;
import com.android.photos.BitmapRegionTileSource.BitmapSource.InBitmapProvider;
@@ -57,8 +57,8 @@ import java.util.WeakHashMap;
public class WallpaperCropActivity extends Activity implements Handler.Callback {
private static final String LOGTAG = "Launcher3.CropActivity";
- protected static final String WALLPAPER_WIDTH_KEY = "wallpaper.width";
- protected static final String WALLPAPER_HEIGHT_KEY = "wallpaper.height";
+ protected static final String WALLPAPER_WIDTH_KEY = WallpaperUtils.WALLPAPER_WIDTH_KEY;
+ protected static final String WALLPAPER_HEIGHT_KEY = WallpaperUtils.WALLPAPER_HEIGHT_KEY;
/**
* The maximum bitmap size we allow to be returned through the intent.
@@ -68,7 +68,7 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
* array instead of a Bitmap instance to avoid overhead.
*/
public static final int MAX_BMAP_IN_INTENT = 750000;
- public static final float WALLPAPER_SCREENS_SPAN = 2f;
+ public static final float WALLPAPER_SCREENS_SPAN = WallpaperUtils.WALLPAPER_SCREENS_SPAN;
private static final int MSG_LOAD_IMAGE = 1;
@@ -290,10 +290,6 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
return getResources().getBoolean(R.bool.allow_rotation);
}
- public static String getSharedPreferencesKey() {
- return LauncherFiles.WALLPAPER_CROP_PREFERENCES_KEY;
- }
-
protected void setWallpaper(Uri uri, final boolean finishActivityWhenDone) {
int rotation = BitmapUtils.getRotationFromExif(this, uri);
BitmapCropTask cropTask = new BitmapCropTask(
@@ -319,7 +315,7 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
// this device
int rotation = BitmapUtils.getRotationFromExif(res, resId);
Point inSize = mCropView.getSourceDimensions();
- Point outSize = BitmapUtils.getDefaultWallpaperSize(getResources(),
+ Point outSize = WallpaperUtils.getDefaultWallpaperSize(getResources(),
getWindowManager());
RectF crop = Utils.getMaxCropRect(
inSize.x, inSize.y, outSize.x, outSize.y, false);
@@ -352,7 +348,7 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
d.getSize(displaySize);
boolean isPortrait = displaySize.x < displaySize.y;
- Point defaultWallpaperSize = BitmapUtils.getDefaultWallpaperSize(getResources(),
+ Point defaultWallpaperSize = WallpaperUtils.getDefaultWallpaperSize(getResources(),
getWindowManager());
// Get the crop
RectF cropRect = mCropView.getCrop();
@@ -435,7 +431,7 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
}
protected void updateWallpaperDimensions(int width, int height) {
- String spKey = getSharedPreferencesKey();
+ String spKey = LauncherFiles.WALLPAPER_CROP_PREFERENCES_KEY;
SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
SharedPreferences.Editor editor = sp.edit();
if (width != 0 && height != 0) {
@@ -446,36 +442,10 @@ public class WallpaperCropActivity extends Activity implements Handler.Callback
editor.remove(WALLPAPER_HEIGHT_KEY);
}
editor.commit();
-
- suggestWallpaperDimension(getResources(),
+ WallpaperUtils.suggestWallpaperDimension(getResources(),
sp, getWindowManager(), WallpaperManager.getInstance(this), true);
}
- public static void suggestWallpaperDimension(Resources res,
- final SharedPreferences sharedPrefs,
- WindowManager windowManager,
- final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
- final Point defaultWallpaperSize = BitmapUtils.getDefaultWallpaperSize(res, windowManager);
- // If we have saved a wallpaper width/height, use that instead
-
- int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
- int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);
-
- if (savedWidth == -1 || savedHeight == -1) {
- if (!fallBackToDefaults) {
- return;
- } else {
- savedWidth = defaultWallpaperSize.x;
- savedHeight = defaultWallpaperSize.y;
- }
- }
-
- if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
- savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
- wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
- }
- }
-
static class LoadRequest {
BitmapSource src;
boolean touchEnabled;
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index 1364df3ed..152cac4cc 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -71,6 +71,7 @@ import com.android.gallery3d.common.BitmapCropTask;
import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.Utils;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.WallpaperUtils;
import com.android.photos.BitmapRegionTileSource;
import com.android.photos.BitmapRegionTileSource.BitmapSource;
import com.android.photos.views.TiledImageRenderer.TileSource;
@@ -239,7 +240,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
@Override
public float getScale(TileSource src) {
- Point wallpaperSize = BitmapUtils.getDefaultWallpaperSize(
+ Point wallpaperSize = WallpaperUtils.getDefaultWallpaperSize(
a.getResources(), a.getWindowManager());
RectF crop = Utils.getMaxCropRect(
src.getImageWidth(), src.getImageHeight(),
@@ -1109,9 +1110,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
return view;
}
- // In Launcher3, we override this with a method that catches exceptions
- // from starting activities; didn't want to copy and paste code into here
public void startActivityForResultSafely(Intent intent, int requestCode) {
- startActivityForResult(intent, requestCode);
+ Utilities.startActivityForResultSafely(this, intent, requestCode);
+ }
+
+ @Override
+ public boolean enableRotation() {
+ return Utilities.isRotationEnabled(this);
}
}