am 7ad868b8: Create separate project for Wallpaper Picker

* commit '7ad868b86e45d6f58c186d2731ab2beb84643757':
  Create separate project for Wallpaper Picker
This commit is contained in:
Michael Jurka
2013-12-13 04:25:57 -08:00
committed by Android Git Automerger
100 changed files with 122 additions and 27 deletions
+2 -2
View File
@@ -26,10 +26,10 @@ LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
$(call all-java-files-under, wallpaper_picker_src) \
$(call all-java-files-under, WallpaperPicker/src) \
$(call all-renderscript-files-under, src) \
$(call all-proto-files-under, protos)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/wallpaper_picker_res $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/WallpaperPicker/res $(LOCAL_PATH)/res
LOCAL_AAPT_FLAGS := --auto-add-overlay
+1 -1
View File
@@ -104,7 +104,7 @@
</activity>
<activity
android:name="com.android.launcher3.WallpaperPickerActivity"
android:name="com.android.launcher3.LauncherWallpaperPickerActivity"
android:theme="@style/Theme.WallpaperCropper"
android:label="@string/pick_wallpaper"
android:icon="@mipmap/ic_launcher_wallpaper"
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.launcher3"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
</manifest>
+4
View File
@@ -0,0 +1,4 @@
This project contains the wallpaper picker for Launcher3. It's in a separate
folder to organize the code separately from the rest of the launcher, and has
a manifest so that a separate Eclipse project can exist for the wallpaper
picker (necessary to have the Eclipse build work)

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 159 B

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 148 B

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 142 B

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 159 B

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 174 B

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 167 B

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 164 B

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<resources>
<bool name="allow_rotation">true</bool>
</resources>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<resources>
<bool name="allow_rotation">false</bool>
</resources>
@@ -123,8 +123,7 @@ public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter
preview.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
mInfo.getComponent());
a.onLiveWallpaperPickerLaunch();
Utilities.startActivityForResultSafely(
a, preview, WallpaperPickerActivity.PICK_LIVE_WALLPAPER);
a.startActivityForResultSafely(preview, WallpaperPickerActivity.PICK_LIVE_WALLPAPER);
}
}
@@ -56,8 +56,8 @@ public class ThirdPartyWallpaperPickerListAdapter extends BaseAdapter implements
mResolveInfo.activityInfo.packageName, mResolveInfo.activityInfo.name);
Intent launchIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
launchIntent.setComponent(itemComponentName);
Utilities.startActivityForResultSafely(
a, launchIntent, WallpaperPickerActivity.PICK_WALLPAPER_THIRD_PARTY_ACTIVITY);
a.startActivityForResultSafely(
launchIntent, WallpaperPickerActivity.PICK_WALLPAPER_THIRD_PARTY_ACTIVITY);
}
}
@@ -57,6 +57,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.animation.AccelerateInterpolator;
@@ -125,7 +126,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
public void onClick(WallpaperPickerActivity a) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Utilities.startActivityForResultSafely(a, intent, IMAGE_PICK);
a.startActivityForResultSafely(intent, IMAGE_PICK);
}
}
@@ -278,7 +279,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
mCropView = (CropView) findViewById(R.id.cropView);
mWallpaperStrip = findViewById(R.id.wallpaper_strip);
mCropView.setTouchCallback(new CropView.TouchCallback() {
LauncherViewPropertyAnimator mAnim;
ViewPropertyAnimator mAnim;
@Override
public void onTouchDown() {
if (mAnim != null) {
@@ -287,17 +288,14 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
if (mWallpaperStrip.getAlpha() == 1f) {
mIgnoreNextTap = true;
}
mAnim = new LauncherViewPropertyAnimator(mWallpaperStrip);
mAnim = mWallpaperStrip.animate();
mAnim.alpha(0f)
.setDuration(150)
.addListener(new Animator.AnimatorListener() {
public void onAnimationStart(Animator animator) { }
public void onAnimationEnd(Animator animator) {
mWallpaperStrip.setVisibility(View.INVISIBLE);
}
public void onAnimationCancel(Animator animator) { }
public void onAnimationRepeat(Animator animator) { }
});
.setDuration(150)
.withEndAction(new Runnable() {
public void run() {
mWallpaperStrip.setVisibility(View.INVISIBLE);
}
});
mAnim.setInterpolator(new AccelerateInterpolator(0.75f));
mAnim.start();
}
@@ -314,7 +312,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
mAnim.cancel();
}
mWallpaperStrip.setVisibility(View.VISIBLE);
mAnim = new LauncherViewPropertyAnimator(mWallpaperStrip);
mAnim = mWallpaperStrip.animate();
mAnim.alpha(1f)
.setDuration(150)
.setInterpolator(new DecelerateInterpolator(0.75f));
@@ -576,10 +574,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
}
}
public boolean enableRotation() {
return super.enableRotation() || Launcher.sForceEnableRotation;
}
protected Bitmap getThumbnailOfLastPhoto() {
Cursor cursor = MediaStore.Images.Media.query(getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
@@ -1001,4 +995,10 @@ 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);
}
}
+1 -1
View File
@@ -2174,7 +2174,7 @@ public class Launcher extends Activity
}
protected ComponentName getWallpaperPickerComponent() {
return new ComponentName(getPackageName(), WallpaperPickerActivity.class.getName());
return new ComponentName(getPackageName(), LauncherWallpaperPickerActivity.class.getName());
}
/**
@@ -0,0 +1,30 @@
/*
* 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;
import android.content.Intent;
public class LauncherWallpaperPickerActivity extends WallpaperPickerActivity {
@Override
public void startActivityForResultSafely(Intent intent, int requestCode) {
Utilities.startActivityForResultSafely(this, intent, requestCode);
}
@Override
public boolean enableRotation() {
return Utilities.isRotationEnabled(this);
}
}
+16
View File
@@ -65,6 +65,12 @@ public final class Utilities {
static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
static int sColorIndex = 0;
// To turn on these properties, type
// adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate";
public static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
/**
* Returns a FastBitmapDrawable with the icon, accurately sized.
*/
@@ -82,6 +88,16 @@ public final class Utilities {
icon.setBounds(0, 0, sIconTextureWidth, sIconTextureHeight);
}
private static boolean isPropertyEnabled(String propertyName) {
return Log.isLoggable(propertyName, Log.VERBOSE);
}
public static boolean isRotationEnabled(Context c) {
boolean enableRotation = sForceEnableRotation ||
c.getResources().getBoolean(R.bool.allow_rotation);
return enableRotation;
}
/**
* Returns a bitmap suitable for the all apps view. Used to convert pre-ICS
* icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size)
+1 -1
View File
@@ -1232,7 +1232,7 @@ public class Workspace extends SmoothPagedView
String spKey = WallpaperCropActivity.getSharedPreferencesKey();
SharedPreferences sp =
mLauncher.getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
WallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(),
LauncherWallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(),
sp, mLauncher.getWindowManager(), mWallpaperManager);
return null;
}
+1 -1
View File
@@ -5,7 +5,7 @@
# necessary so do this with care
import os
import sys
src_dir = "wallpaper_picker_src/"
src_dir = "WallpaperPicker/src/"
files = """
src/android/util/Pools.java
com/android/gallery3d/util/IntArray.java