Add live wallpapers and third-party pickers to bottom strip
Bug: 10742727 Bug: 10805463 Change-Id: I961344b34fff3b183380caf3508d23b05c1ca26c
This commit is contained in:
parent
437dec39ee
commit
998e4ff3dc
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<com.android.launcher3.CheckableFrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="@dimen/wallpaperThumbnailWidth"
|
||||||
|
android:layout_height="@dimen/wallpaperThumbnailHeight"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="@drawable/wallpaper_tile_fg"
|
||||||
|
android:foreground="@drawable/wallpaper_tile_fg">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/wallpaper_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@android:color/black"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/wallpaper_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/wallpaper_item_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="@color/wallpaper_picker_translucent_gray"
|
||||||
|
android:textColor="@android:color/white"/>
|
||||||
|
</com.android.launcher3.CheckableFrameLayout>
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2008 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<com.android.launcher3.CheckableFrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="@dimen/wallpaperThumbnailWidth"
|
||||||
|
android:layout_height="@dimen/wallpaperThumbnailHeight"
|
||||||
|
android:focusable="true"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="@drawable/wallpaper_tile_fg"
|
||||||
|
android:foreground="@drawable/wallpaper_tile_fg">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/wallpaper_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/wallpaper_picker_translucent_gray"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/wallpaper_item_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:drawablePadding="4dp"
|
||||||
|
android:textColor="@android:color/white"/>
|
||||||
|
</com.android.launcher3.CheckableFrameLayout>
|
|
@ -50,10 +50,23 @@
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
<LinearLayout android:id="@+id/wallpaper_list"
|
<LinearLayout android:id="@+id/master_wallpaper_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal" />
|
android:orientation="horizontal" >
|
||||||
|
<LinearLayout android:id="@+id/third_party_wallpaper_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" />
|
||||||
|
<LinearLayout android:id="@+id/wallpaper_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" />
|
||||||
|
<LinearLayout android:id="@+id/live_wallpaper_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" />
|
||||||
|
</LinearLayout>
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
android:id="@+id/wallpaper_image"
|
android:id="@+id/wallpaper_image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#66000000"
|
android:background="@color/wallpaper_picker_translucent_gray"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wallpaper_item_label"
|
android:id="@+id/wallpaper_item_label"
|
||||||
|
@ -36,5 +36,5 @@
|
||||||
android:text="@string/pick_image"
|
android:text="@string/pick_image"
|
||||||
android:drawableTop="@drawable/ic_images"
|
android:drawableTop="@drawable/ic_images"
|
||||||
android:drawablePadding="4dp"
|
android:drawablePadding="4dp"
|
||||||
android:textColor="#FFFFFFFF"/>
|
android:textColor="@android:color/white"/>
|
||||||
</com.android.launcher3.CheckableFrameLayout>
|
</com.android.launcher3.CheckableFrameLayout>
|
||||||
|
|
|
@ -32,4 +32,5 @@
|
||||||
<color name="workspace_icon_text_color">#FFF</color>
|
<color name="workspace_icon_text_color">#FFF</color>
|
||||||
|
|
||||||
<color name="apps_customize_icon_text_color">#FFF</color>
|
<color name="apps_customize_icon_text_color">#FFF</color>
|
||||||
|
<color name="wallpaper_picker_translucent_gray">#66000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,237 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.app.WallpaperInfo;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.service.wallpaper.WallpaperService;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter {
|
||||||
|
private static final String LOG_TAG = "LiveWallpaperListAdapter";
|
||||||
|
|
||||||
|
private final LayoutInflater mInflater;
|
||||||
|
private final PackageManager mPackageManager;
|
||||||
|
|
||||||
|
private List<LiveWallpaperInfo> mWallpapers;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public LiveWallpaperListAdapter(Context context) {
|
||||||
|
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mPackageManager = context.getPackageManager();
|
||||||
|
|
||||||
|
List<ResolveInfo> list = mPackageManager.queryIntentServices(
|
||||||
|
new Intent(WallpaperService.SERVICE_INTERFACE),
|
||||||
|
PackageManager.GET_META_DATA);
|
||||||
|
|
||||||
|
mWallpapers = generatePlaceholderViews(list.size());
|
||||||
|
|
||||||
|
new LiveWallpaperEnumerator(context).execute(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LiveWallpaperInfo> generatePlaceholderViews(int amount) {
|
||||||
|
ArrayList<LiveWallpaperInfo> list = new ArrayList<LiveWallpaperInfo>(amount);
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
LiveWallpaperInfo info = new LiveWallpaperInfo();
|
||||||
|
list.add(info);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
if (mWallpapers == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return mWallpapers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return mWallpapers.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view;
|
||||||
|
|
||||||
|
if (convertView == null) {
|
||||||
|
view = mInflater.inflate(R.layout.live_wallpaper_picker_item, parent, false);
|
||||||
|
} else {
|
||||||
|
view = convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view);
|
||||||
|
|
||||||
|
LiveWallpaperInfo wallpaperInfo = mWallpapers.get(position);
|
||||||
|
ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image);
|
||||||
|
ImageView icon = (ImageView) view.findViewById(R.id.wallpaper_icon);
|
||||||
|
if (wallpaperInfo.thumbnail != null) {
|
||||||
|
image.setImageDrawable(wallpaperInfo.thumbnail);
|
||||||
|
icon.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
icon.setImageDrawable(wallpaperInfo.info.loadIcon(mPackageManager));
|
||||||
|
icon.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label);
|
||||||
|
label.setText(wallpaperInfo.info.loadLabel(mPackageManager));
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LiveWallpaperInfo {
|
||||||
|
public Drawable thumbnail;
|
||||||
|
public WallpaperInfo info;
|
||||||
|
public Intent intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LiveWallpaperEnumerator extends
|
||||||
|
AsyncTask<List<ResolveInfo>, LiveWallpaperInfo, Void> {
|
||||||
|
private Context mContext;
|
||||||
|
private int mWallpaperPosition;
|
||||||
|
|
||||||
|
public LiveWallpaperEnumerator(Context context) {
|
||||||
|
super();
|
||||||
|
mContext = context;
|
||||||
|
mWallpaperPosition = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(List<ResolveInfo>... params) {
|
||||||
|
final PackageManager packageManager = mContext.getPackageManager();
|
||||||
|
|
||||||
|
List<ResolveInfo> list = params[0];
|
||||||
|
|
||||||
|
Collections.sort(list, new Comparator<ResolveInfo>() {
|
||||||
|
final Collator mCollator;
|
||||||
|
|
||||||
|
{
|
||||||
|
mCollator = Collator.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(ResolveInfo info1, ResolveInfo info2) {
|
||||||
|
return mCollator.compare(info1.loadLabel(packageManager),
|
||||||
|
info2.loadLabel(packageManager));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (ResolveInfo resolveInfo : list) {
|
||||||
|
WallpaperInfo info = null;
|
||||||
|
try {
|
||||||
|
info = new WallpaperInfo(mContext, resolveInfo);
|
||||||
|
} catch (XmlPullParserException e) {
|
||||||
|
Log.w(LOG_TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e);
|
||||||
|
continue;
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(LOG_TAG, "Skipping wallpaper " + resolveInfo.serviceInfo, e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveWallpaperInfo wallpaper = new LiveWallpaperInfo();
|
||||||
|
wallpaper.intent = new Intent(WallpaperService.SERVICE_INTERFACE);
|
||||||
|
wallpaper.intent.setClassName(info.getPackageName(), info.getServiceName());
|
||||||
|
wallpaper.info = info;
|
||||||
|
|
||||||
|
Drawable thumb = info.loadThumbnail(packageManager);
|
||||||
|
// TODO: generate a default thumb
|
||||||
|
/*
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
|
Canvas canvas = new Canvas();
|
||||||
|
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
|
||||||
|
paint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
BitmapDrawable galleryIcon = (BitmapDrawable) res.getDrawable(
|
||||||
|
R.drawable.livewallpaper_placeholder);
|
||||||
|
if (thumb == null) {
|
||||||
|
int thumbWidth = res.getDimensionPixelSize(
|
||||||
|
R.dimen.live_wallpaper_thumbnail_width);
|
||||||
|
int thumbHeight = res.getDimensionPixelSize(
|
||||||
|
R.dimen.live_wallpaper_thumbnail_height);
|
||||||
|
|
||||||
|
Bitmap thumbnail = Bitmap.createBitmap(thumbWidth, thumbHeight,
|
||||||
|
Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
|
paint.setColor(res.getColor(R.color.live_wallpaper_thumbnail_background));
|
||||||
|
canvas.setBitmap(thumbnail);
|
||||||
|
canvas.drawPaint(paint);
|
||||||
|
|
||||||
|
galleryIcon.setBounds(0, 0, thumbWidth, thumbHeight);
|
||||||
|
galleryIcon.setGravity(Gravity.CENTER);
|
||||||
|
galleryIcon.draw(canvas);
|
||||||
|
|
||||||
|
String title = info.loadLabel(packageManager).toString();
|
||||||
|
|
||||||
|
paint.setColor(res.getColor(R.color.live_wallpaper_thumbnail_text_color));
|
||||||
|
paint.setTextSize(
|
||||||
|
res.getDimensionPixelSize(R.dimen.live_wallpaper_thumbnail_text_size));
|
||||||
|
|
||||||
|
canvas.drawText(title, (int) (thumbWidth * 0.5),
|
||||||
|
thumbHeight - res.getDimensionPixelSize(
|
||||||
|
R.dimen.live_wallpaper_thumbnail_text_offset), paint);
|
||||||
|
|
||||||
|
thumb = new BitmapDrawable(res, thumbnail);
|
||||||
|
}*/
|
||||||
|
wallpaper.thumbnail = thumb;
|
||||||
|
publishProgress(wallpaper);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(LiveWallpaperInfo...infos) {
|
||||||
|
for (LiveWallpaperInfo info : infos) {
|
||||||
|
info.thumbnail.setDither(true);
|
||||||
|
if (mWallpaperPosition < mWallpapers.size()) {
|
||||||
|
mWallpapers.set(mWallpaperPosition, info);
|
||||||
|
} else {
|
||||||
|
mWallpapers.add(info);
|
||||||
|
}
|
||||||
|
mWallpaperPosition++;
|
||||||
|
if (mWallpaperPosition == getCount()) {
|
||||||
|
LiveWallpaperListAdapter.this.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ThirdPartyWallpaperPickerListAdapter extends BaseAdapter implements ListAdapter {
|
||||||
|
private static final String LOG_TAG = "LiveWallpaperListAdapter";
|
||||||
|
|
||||||
|
private final LayoutInflater mInflater;
|
||||||
|
private final PackageManager mPackageManager;
|
||||||
|
|
||||||
|
private List<ResolveInfo> mThirdPartyWallpaperPickers = new ArrayList<ResolveInfo>();
|
||||||
|
|
||||||
|
public ThirdPartyWallpaperPickerListAdapter(Context context) {
|
||||||
|
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mPackageManager = context.getPackageManager();
|
||||||
|
final PackageManager pm = mPackageManager;
|
||||||
|
|
||||||
|
final Intent pickWallpaperIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
|
||||||
|
final List<ResolveInfo> apps =
|
||||||
|
pm.queryIntentActivities(pickWallpaperIntent, 0);
|
||||||
|
|
||||||
|
// Get list of image picker intents
|
||||||
|
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
pickImageIntent.setType("image/*");
|
||||||
|
final List<ResolveInfo> imagePickerActivities =
|
||||||
|
pm.queryIntentActivities(pickImageIntent, 0);
|
||||||
|
final ComponentName[] imageActivities = new ComponentName[imagePickerActivities.size()];
|
||||||
|
for (int i = 0; i < imagePickerActivities.size(); i++) {
|
||||||
|
ActivityInfo activityInfo = imagePickerActivities.get(i).activityInfo;
|
||||||
|
imageActivities[i] = new ComponentName(activityInfo.packageName, activityInfo.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
outerLoop:
|
||||||
|
for (ResolveInfo info : apps) {
|
||||||
|
final ComponentName itemComponentName =
|
||||||
|
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
||||||
|
final String itemPackageName = itemComponentName.getPackageName();
|
||||||
|
// Exclude anything from our own package, and the old Launcher,
|
||||||
|
// and live wallpaper picker
|
||||||
|
if (itemPackageName.equals(context.getPackageName()) ||
|
||||||
|
itemPackageName.equals("com.android.launcher") ||
|
||||||
|
itemPackageName.equals("com.android.wallpaper.livepicker")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Exclude any package that already responds to the image picker intent
|
||||||
|
for (ResolveInfo imagePickerActivityInfo : imagePickerActivities) {
|
||||||
|
if (itemPackageName.equals(
|
||||||
|
imagePickerActivityInfo.activityInfo.packageName)) {
|
||||||
|
continue outerLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mThirdPartyWallpaperPickers.add(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return mThirdPartyWallpaperPickers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return mThirdPartyWallpaperPickers.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view;
|
||||||
|
|
||||||
|
if (convertView == null) {
|
||||||
|
view = mInflater.inflate(R.layout.third_party_wallpaper_picker_item, parent, false);
|
||||||
|
} else {
|
||||||
|
view = convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view);
|
||||||
|
|
||||||
|
ResolveInfo info = mThirdPartyWallpaperPickers.get(position);
|
||||||
|
TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label);
|
||||||
|
label.setText(info.loadLabel(mPackageManager));
|
||||||
|
label.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
null, info.loadIcon(mPackageManager), null, null);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ package com.android.launcher3;
|
||||||
import android.animation.LayoutTransition;
|
import android.animation.LayoutTransition;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.WallpaperInfo;
|
||||||
|
import android.app.WallpaperManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
@ -27,8 +29,10 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.database.DataSetObserver;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -66,6 +70,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
|
|
||||||
private static final int IMAGE_PICK = 5;
|
private static final int IMAGE_PICK = 5;
|
||||||
private static final int PICK_WALLPAPER_THIRD_PARTY_ACTIVITY = 6;
|
private static final int PICK_WALLPAPER_THIRD_PARTY_ACTIVITY = 6;
|
||||||
|
private static final int PICK_LIVE_WALLPAPER = 7;
|
||||||
private static final String TEMP_WALLPAPER_TILES = "TEMP_WALLPAPER_TILES";
|
private static final String TEMP_WALLPAPER_TILES = "TEMP_WALLPAPER_TILES";
|
||||||
|
|
||||||
private ArrayList<Drawable> mBundledWallpaperThumbs;
|
private ArrayList<Drawable> mBundledWallpaperThumbs;
|
||||||
|
@ -85,12 +90,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
|
|
||||||
ArrayList<Uri> mTempWallpaperTiles = new ArrayList<Uri>();
|
ArrayList<Uri> mTempWallpaperTiles = new ArrayList<Uri>();
|
||||||
private SavedWallpaperImages mSavedImages;
|
private SavedWallpaperImages mSavedImages;
|
||||||
|
private WallpaperInfo mLiveWallpaperInfoOnPickerLaunch;
|
||||||
|
|
||||||
private static class ThumbnailMetaData {
|
private static class ThumbnailMetaData {
|
||||||
public boolean mLaunchesGallery;
|
public TileType mTileType;
|
||||||
public Uri mWallpaperUri;
|
public Uri mWallpaperUri;
|
||||||
public int mSavedWallpaperDbId;
|
public int mSavedWallpaperDbId;
|
||||||
public int mWallpaperResId;
|
public int mWallpaperResId;
|
||||||
|
public LiveWallpaperListAdapter.LiveWallpaperInfo mLiveWallpaperInfo;
|
||||||
|
public ResolveInfo mThirdPartyWallpaperPickerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by onCreate; this is subclassed to overwrite WallpaperCropActivity
|
// called by onCreate; this is subclassed to overwrite WallpaperCropActivity
|
||||||
|
@ -142,29 +150,38 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
ThumbnailMetaData meta = (ThumbnailMetaData) v.getTag();
|
ThumbnailMetaData meta = (ThumbnailMetaData) v.getTag();
|
||||||
|
if (meta.mTileType == TileType.WALLPAPER_RESOURCE ||
|
||||||
if (!meta.mLaunchesGallery) {
|
meta.mTileType == TileType.SAVED_WALLPAPER ||
|
||||||
|
meta.mTileType == TileType.WALLPAPER_URI) {
|
||||||
mSelectedThumb = v;
|
mSelectedThumb = v;
|
||||||
v.setSelected(true);
|
v.setSelected(true);
|
||||||
}
|
}
|
||||||
|
if (meta.mTileType == TileType.PICK_IMAGE) {
|
||||||
if (meta.mLaunchesGallery) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
intent.setType("image/*");
|
intent.setType("image/*");
|
||||||
Utilities.startActivityForResultSafely(
|
Utilities.startActivityForResultSafely(
|
||||||
WallpaperPickerActivity.this, intent, IMAGE_PICK);
|
WallpaperPickerActivity.this, intent, IMAGE_PICK);
|
||||||
} else if (meta.mWallpaperUri != null) {
|
} else if (meta.mTileType == TileType.WALLPAPER_URI) {
|
||||||
mCropView.setTileSource(new BitmapRegionTileSource(WallpaperPickerActivity.this,
|
mCropView.setTileSource(new BitmapRegionTileSource(WallpaperPickerActivity.this,
|
||||||
meta.mWallpaperUri, 1024, 0), null);
|
meta.mWallpaperUri, 1024, 0), null);
|
||||||
mCropView.setTouchEnabled(true);
|
mCropView.setTouchEnabled(true);
|
||||||
} else if (meta.mSavedWallpaperDbId != 0) {
|
} else if (meta.mTileType == TileType.SAVED_WALLPAPER) {
|
||||||
String imageFilename = mSavedImages.getImageFilename(meta.mSavedWallpaperDbId);
|
String imageFilename = mSavedImages.getImageFilename(meta.mSavedWallpaperDbId);
|
||||||
File file = new File(getFilesDir(), imageFilename);
|
File file = new File(getFilesDir(), imageFilename);
|
||||||
mCropView.setTileSource(new BitmapRegionTileSource(WallpaperPickerActivity.this,
|
mCropView.setTileSource(new BitmapRegionTileSource(WallpaperPickerActivity.this,
|
||||||
file.getAbsolutePath(), 1024, 0), null);
|
file.getAbsolutePath(), 1024, 0), null);
|
||||||
mCropView.moveToLeft();
|
mCropView.moveToLeft();
|
||||||
mCropView.setTouchEnabled(false);
|
mCropView.setTouchEnabled(false);
|
||||||
} else if (meta.mWallpaperResId != 0) {
|
} else if (meta.mTileType == TileType.LIVE_WALLPAPER) {
|
||||||
|
Intent preview = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
|
||||||
|
preview.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
|
||||||
|
meta.mLiveWallpaperInfo.info.getComponent());
|
||||||
|
WallpaperManager wm =
|
||||||
|
WallpaperManager.getInstance(WallpaperPickerActivity.this);
|
||||||
|
mLiveWallpaperInfoOnPickerLaunch = wm.getWallpaperInfo();
|
||||||
|
Utilities.startActivityForResultSafely(WallpaperPickerActivity.this,
|
||||||
|
preview, PICK_LIVE_WALLPAPER);
|
||||||
|
} else if (meta.mTileType == TileType.WALLPAPER_RESOURCE) {
|
||||||
BitmapRegionTileSource source = new BitmapRegionTileSource(mWallpaperResources,
|
BitmapRegionTileSource source = new BitmapRegionTileSource(mWallpaperResources,
|
||||||
WallpaperPickerActivity.this, meta.mWallpaperResId, 1024, 0);
|
WallpaperPickerActivity.this, meta.mWallpaperResId, 1024, 0);
|
||||||
mCropView.setTileSource(source, null);
|
mCropView.setTileSource(source, null);
|
||||||
|
@ -175,6 +192,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
wallpaperSize.x, wallpaperSize.y, false);
|
wallpaperSize.x, wallpaperSize.y, false);
|
||||||
mCropView.setScale(wallpaperSize.x / crop.width());
|
mCropView.setScale(wallpaperSize.x / crop.width());
|
||||||
mCropView.setTouchEnabled(false);
|
mCropView.setTouchEnabled(false);
|
||||||
|
} else if (meta.mTileType == TileType.THIRD_PARTY_WALLPAPER_PICKER) {
|
||||||
|
ResolveInfo info = meta.mThirdPartyWallpaperPickerInfo;
|
||||||
|
|
||||||
|
final ComponentName itemComponentName = new ComponentName(
|
||||||
|
info.activityInfo.packageName, info.activityInfo.name);
|
||||||
|
Intent launchIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
|
||||||
|
launchIntent.setComponent(itemComponentName);
|
||||||
|
Utilities.startActivityForResultSafely(WallpaperPickerActivity.this,
|
||||||
|
launchIntent, PICK_WALLPAPER_THIRD_PARTY_ACTIVITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -202,7 +228,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
findBundledWallpapers();
|
findBundledWallpapers();
|
||||||
mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);
|
mWallpapersView = (LinearLayout) findViewById(R.id.wallpaper_list);
|
||||||
ImageAdapter ia = new ImageAdapter(this, mBundledWallpaperThumbs);
|
ImageAdapter ia = new ImageAdapter(this, mBundledWallpaperThumbs);
|
||||||
populateWallpapersFromAdapter(mWallpapersView, ia, mBundledWallpaperResIds, true, false);
|
populateWallpapersFromAdapter(
|
||||||
|
mWallpapersView, ia, mBundledWallpaperResIds, TileType.WALLPAPER_RESOURCE, false, true);
|
||||||
|
|
||||||
// Populate the saved wallpapers
|
// Populate the saved wallpapers
|
||||||
mSavedImages = new SavedWallpaperImages(this);
|
mSavedImages = new SavedWallpaperImages(this);
|
||||||
|
@ -210,13 +237,34 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
ArrayList<Drawable> savedWallpaperThumbs = mSavedImages.getThumbnails();
|
ArrayList<Drawable> savedWallpaperThumbs = mSavedImages.getThumbnails();
|
||||||
ArrayList<Integer > savedWallpaperIds = mSavedImages.getImageIds();
|
ArrayList<Integer > savedWallpaperIds = mSavedImages.getImageIds();
|
||||||
ia = new ImageAdapter(this, savedWallpaperThumbs);
|
ia = new ImageAdapter(this, savedWallpaperThumbs);
|
||||||
populateWallpapersFromAdapter(mWallpapersView, ia, savedWallpaperIds, false, true);
|
populateWallpapersFromAdapter(
|
||||||
|
mWallpapersView, ia, savedWallpaperIds, TileType.SAVED_WALLPAPER, true, true);
|
||||||
|
|
||||||
|
// Populate the live wallpapers
|
||||||
|
final LinearLayout liveWallpapersView = (LinearLayout) findViewById(R.id.live_wallpaper_list);
|
||||||
|
final LiveWallpaperListAdapter a = new LiveWallpaperListAdapter(this);
|
||||||
|
a.registerDataSetObserver(new DataSetObserver() {
|
||||||
|
public void onChanged() {
|
||||||
|
liveWallpapersView.removeAllViews();
|
||||||
|
populateWallpapersFromAdapter(
|
||||||
|
liveWallpapersView, a, null, TileType.LIVE_WALLPAPER, false, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Populate the third-party wallpaper pickers
|
||||||
|
final LinearLayout thirdPartyWallpapersView =
|
||||||
|
(LinearLayout) findViewById(R.id.third_party_wallpaper_list);
|
||||||
|
final ThirdPartyWallpaperPickerListAdapter ta =
|
||||||
|
new ThirdPartyWallpaperPickerListAdapter(this);
|
||||||
|
populateWallpapersFromAdapter(thirdPartyWallpapersView, ta, null,
|
||||||
|
TileType.THIRD_PARTY_WALLPAPER_PICKER, false, false);
|
||||||
|
|
||||||
// Add a tile for the Gallery
|
// Add a tile for the Gallery
|
||||||
|
LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list);
|
||||||
FrameLayout galleryThumbnail = (FrameLayout) getLayoutInflater().
|
FrameLayout galleryThumbnail = (FrameLayout) getLayoutInflater().
|
||||||
inflate(R.layout.wallpaper_picker_gallery_item, mWallpapersView, false);
|
inflate(R.layout.wallpaper_picker_gallery_item, masterWallpaperList, false);
|
||||||
setWallpaperItemPaddingToZero(galleryThumbnail);
|
setWallpaperItemPaddingToZero(galleryThumbnail);
|
||||||
mWallpapersView.addView(galleryThumbnail, 0);
|
masterWallpaperList.addView(galleryThumbnail, 0);
|
||||||
|
|
||||||
// Make its background the last photo taken on external storage
|
// Make its background the last photo taken on external storage
|
||||||
Bitmap lastPhoto = getThumbnailOfLastPhoto();
|
Bitmap lastPhoto = getThumbnailOfLastPhoto();
|
||||||
|
@ -224,10 +272,12 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
ImageView galleryThumbnailBg =
|
ImageView galleryThumbnailBg =
|
||||||
(ImageView) galleryThumbnail.findViewById(R.id.wallpaper_image);
|
(ImageView) galleryThumbnail.findViewById(R.id.wallpaper_image);
|
||||||
galleryThumbnailBg.setImageBitmap(getThumbnailOfLastPhoto());
|
galleryThumbnailBg.setImageBitmap(getThumbnailOfLastPhoto());
|
||||||
|
int colorOverlay = getResources().getColor(R.color.wallpaper_picker_translucent_gray);
|
||||||
|
galleryThumbnailBg.setColorFilter(colorOverlay, PorterDuff.Mode.SRC_ATOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThumbnailMetaData meta = new ThumbnailMetaData();
|
ThumbnailMetaData meta = new ThumbnailMetaData();
|
||||||
meta.mLaunchesGallery = true;
|
meta.mTileType = TileType.PICK_IMAGE;
|
||||||
galleryThumbnail.setTag(meta);
|
galleryThumbnail.setTag(meta);
|
||||||
galleryThumbnail.setOnClickListener(mThumbnailOnClickListener);
|
galleryThumbnail.setOnClickListener(mThumbnailOnClickListener);
|
||||||
|
|
||||||
|
@ -247,7 +297,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ThumbnailMetaData meta = (ThumbnailMetaData) mSelectedThumb.getTag();
|
ThumbnailMetaData meta = (ThumbnailMetaData) mSelectedThumb.getTag();
|
||||||
if (meta.mLaunchesGallery) {
|
if (meta.mTileType == TileType.PICK_IMAGE) {
|
||||||
// shouldn't be selected, but do nothing
|
// shouldn't be selected, but do nothing
|
||||||
} else if (meta.mWallpaperUri != null) {
|
} else if (meta.mWallpaperUri != null) {
|
||||||
boolean finishActivityWhenDone = true;
|
boolean finishActivityWhenDone = true;
|
||||||
|
@ -385,24 +435,39 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateWallpapersFromAdapter(ViewGroup parent, ImageAdapter ia,
|
private enum TileType {
|
||||||
ArrayList<Integer> imageIds, boolean imagesAreResources, boolean addLongPressHandler) {
|
PICK_IMAGE,
|
||||||
for (int i = 0; i < ia.getCount(); i++) {
|
WALLPAPER_RESOURCE,
|
||||||
FrameLayout thumbnail = (FrameLayout) ia.getView(i, null, parent);
|
WALLPAPER_URI,
|
||||||
|
SAVED_WALLPAPER,
|
||||||
|
LIVE_WALLPAPER,
|
||||||
|
THIRD_PARTY_WALLPAPER_PICKER
|
||||||
|
};
|
||||||
|
|
||||||
|
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
|
||||||
|
ArrayList<Integer> imageIds, TileType tileType, boolean addLongPressHandler, boolean selectFirstTile) {
|
||||||
|
for (int i = 0; i < adapter.getCount(); i++) {
|
||||||
|
FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
|
||||||
parent.addView(thumbnail, i);
|
parent.addView(thumbnail, i);
|
||||||
|
|
||||||
ThumbnailMetaData meta = new ThumbnailMetaData();
|
ThumbnailMetaData meta = new ThumbnailMetaData();
|
||||||
if (imagesAreResources) {
|
meta.mTileType = tileType;
|
||||||
|
if (tileType == TileType.WALLPAPER_RESOURCE) {
|
||||||
meta.mWallpaperResId = imageIds.get(i);
|
meta.mWallpaperResId = imageIds.get(i);
|
||||||
} else {
|
} else if (tileType == TileType.SAVED_WALLPAPER) {
|
||||||
meta.mSavedWallpaperDbId = imageIds.get(i);
|
meta.mSavedWallpaperDbId = imageIds.get(i);
|
||||||
|
} else if (tileType == TileType.LIVE_WALLPAPER) {
|
||||||
|
meta.mLiveWallpaperInfo =
|
||||||
|
(LiveWallpaperListAdapter.LiveWallpaperInfo) adapter.getItem(i);
|
||||||
|
} else if (tileType == TileType.THIRD_PARTY_WALLPAPER_PICKER) {
|
||||||
|
meta.mThirdPartyWallpaperPickerInfo = (ResolveInfo) adapter.getItem(i);
|
||||||
}
|
}
|
||||||
thumbnail.setTag(meta);
|
thumbnail.setTag(meta);
|
||||||
if (addLongPressHandler) {
|
if (addLongPressHandler) {
|
||||||
addLongPressHandler(thumbnail);
|
addLongPressHandler(thumbnail);
|
||||||
}
|
}
|
||||||
thumbnail.setOnClickListener(mThumbnailOnClickListener);
|
thumbnail.setOnClickListener(mThumbnailOnClickListener);
|
||||||
if (i == 0) {
|
if (i == 0 && selectFirstTile) {
|
||||||
mThumbnailOnClickListener.onClick(thumbnail);
|
mThumbnailOnClickListener.onClick(thumbnail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,9 +517,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Error loading thumbnail for uri=" + uri);
|
Log.e(TAG, "Error loading thumbnail for uri=" + uri);
|
||||||
}
|
}
|
||||||
mWallpapersView.addView(pickedImageThumbnail, 1);
|
mWallpapersView.addView(pickedImageThumbnail, 0);
|
||||||
|
|
||||||
ThumbnailMetaData meta = new ThumbnailMetaData();
|
ThumbnailMetaData meta = new ThumbnailMetaData();
|
||||||
|
meta.mTileType = TileType.WALLPAPER_URI;
|
||||||
meta.mWallpaperUri = uri;
|
meta.mWallpaperUri = uri;
|
||||||
pickedImageThumbnail.setTag(meta);
|
pickedImageThumbnail.setTag(meta);
|
||||||
pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
|
pickedImageThumbnail.setOnClickListener(mThumbnailOnClickListener);
|
||||||
|
@ -466,13 +532,24 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
addTemporaryWallpaperTile(uri);
|
addTemporaryWallpaperTile(uri);
|
||||||
} else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
|
} else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
|
||||||
// No result code is returned; just return
|
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
finish();
|
finish();
|
||||||
|
} else if (requestCode == PICK_LIVE_WALLPAPER) {
|
||||||
|
WallpaperManager wm = WallpaperManager.getInstance(this);
|
||||||
|
final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch;
|
||||||
|
WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo();
|
||||||
|
// Try to figure out if a live wallpaper was set;
|
||||||
|
if (newLiveWallpaper != null &&
|
||||||
|
(oldLiveWallpaper == null ||
|
||||||
|
!oldLiveWallpaper.getComponent().equals(newLiveWallpaper.getComponent()))) {
|
||||||
|
// Return if a live wallpaper was set
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setWallpaperItemPaddingToZero(FrameLayout frameLayout) {
|
static void setWallpaperItemPaddingToZero(FrameLayout frameLayout) {
|
||||||
frameLayout.setPadding(0, 0, 0, 0);
|
frameLayout.setPadding(0, 0, 0, 0);
|
||||||
frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground()));
|
frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground()));
|
||||||
}
|
}
|
||||||
|
@ -481,68 +558,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
|
||||||
v.setOnLongClickListener(mLongClickListener);
|
v.setOnLongClickListener(mLongClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
|
||||||
if (item.getIntent() == null) {
|
|
||||||
return super.onMenuItemSelected(featureId, item);
|
|
||||||
} else {
|
|
||||||
Utilities.startActivityForResultSafely(
|
|
||||||
this, item.getIntent(), PICK_WALLPAPER_THIRD_PARTY_ACTIVITY);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
final Intent pickWallpaperIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
|
|
||||||
final PackageManager pm = getPackageManager();
|
|
||||||
final List<ResolveInfo> apps =
|
|
||||||
pm.queryIntentActivities(pickWallpaperIntent, 0);
|
|
||||||
|
|
||||||
SubMenu sub = menu.addSubMenu("Other\u2026"); // TODO: what's the better way to do this?
|
|
||||||
sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
|
|
||||||
|
|
||||||
// Get list of image picker intents
|
|
||||||
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
||||||
pickImageIntent.setType("image/*");
|
|
||||||
final List<ResolveInfo> imagePickerActivities =
|
|
||||||
pm.queryIntentActivities(pickImageIntent, 0);
|
|
||||||
final ComponentName[] imageActivities = new ComponentName[imagePickerActivities.size()];
|
|
||||||
for (int i = 0; i < imagePickerActivities.size(); i++) {
|
|
||||||
ActivityInfo activityInfo = imagePickerActivities.get(i).activityInfo;
|
|
||||||
imageActivities[i] = new ComponentName(activityInfo.packageName, activityInfo.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
outerLoop:
|
|
||||||
for (ResolveInfo info : apps) {
|
|
||||||
final ComponentName itemComponentName =
|
|
||||||
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
|
||||||
final String itemPackageName = itemComponentName.getPackageName();
|
|
||||||
// Exclude anything from our own package, and the old Launcher
|
|
||||||
if (itemPackageName.equals(getPackageName()) ||
|
|
||||||
itemPackageName.equals("com.android.launcher")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Exclude any package that already responds to the image picker intent
|
|
||||||
for (ResolveInfo imagePickerActivityInfo : imagePickerActivities) {
|
|
||||||
if (itemPackageName.equals(
|
|
||||||
imagePickerActivityInfo.activityInfo.packageName)) {
|
|
||||||
continue outerLoop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MenuItem mi = sub.add(info.loadLabel(pm));
|
|
||||||
Intent launchIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
|
|
||||||
launchIntent.setComponent(itemComponentName);
|
|
||||||
mi.setIntent(launchIntent);
|
|
||||||
Drawable icon = info.loadIcon(pm);
|
|
||||||
if (icon != null) {
|
|
||||||
mi.setIcon(icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findBundledWallpapers() {
|
private void findBundledWallpapers() {
|
||||||
mBundledWallpaperThumbs = new ArrayList<Drawable>(24);
|
mBundledWallpaperThumbs = new ArrayList<Drawable>(24);
|
||||||
mBundledWallpaperResIds = new ArrayList<Integer>(24);
|
mBundledWallpaperResIds = new ArrayList<Integer>(24);
|
||||||
|
|
Loading…
Reference in New Issue