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
</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"
--- /dev/null
+<?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>
--- /dev/null
+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)
\ No newline at end of file
--- /dev/null
+<?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>
--- /dev/null
+<?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>
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);
}
}
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);
}
}
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;
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);
}
}
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) {
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();
}
mAnim.cancel();
}
mWallpaperStrip.setVisibility(View.VISIBLE);
- mAnim = new LauncherViewPropertyAnimator(mWallpaperStrip);
+ mAnim = mWallpaperStrip.animate();
mAnim.alpha(1f)
.setDuration(150)
.setInterpolator(new DecelerateInterpolator(0.75f));
}
}
- public boolean enableRotation() {
- return super.enableRotation() || Launcher.sForceEnableRotation;
- }
-
protected Bitmap getThumbnailOfLastPhoto() {
Cursor cursor = MediaStore.Images.Media.query(getContentResolver(),
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
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);
+ }
}
}
protected ComponentName getWallpaperPickerComponent() {
- return new ComponentName(getPackageName(), WallpaperPickerActivity.class.getName());
+ return new ComponentName(getPackageName(), LauncherWallpaperPickerActivity.class.getName());
}
/**
--- /dev/null
+/*
+ * 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);
+ }
+}
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.
*/
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)
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;
}
# 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