summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2011-06-21 13:03:34 -0700
committerAmith Yamasani <yamasani@google.com>2011-06-22 11:29:38 -0700
commit6be594922fac988f3b350718df8e9df3ef25b97e (patch)
tree7352b5679222d26d849eb15bb5694defc81baa79
parent2a451abcc0d81d249840ca755d54ae829002d27e (diff)
downloadandroid_packages_apps_Trebuchet-6be594922fac988f3b350718df8e9df3ef25b97e.tar.gz
android_packages_apps_Trebuchet-6be594922fac988f3b350718df8e9df3ef25b97e.tar.bz2
android_packages_apps_Trebuchet-6be594922fac988f3b350718df8e9df3ef25b97e.zip
A fullscreen wallpaper chooser for all screen sizes.
The wallpaper preview covers the whole screen, with background protection for the gallery items and button. Change-Id: Ice31c4fea6503d1a59b59d6fbffb5e4a28eb2143
-rw-r--r--AndroidManifest.xml3
-rw-r--r--res/drawable/wallpaper_gallery_background.xml20
-rw-r--r--res/layout-large/wallpaper_chooser.xml51
-rw-r--r--res/layout-large/wallpaper_chooser_base.xml23
-rw-r--r--res/layout/wallpaper_chooser.xml36
-rw-r--r--res/values-large/styles.xml11
-rw-r--r--res/values/styles.xml8
-rw-r--r--src/com/android/launcher2/WallpaperChooser.java2
-rw-r--r--src/com/android/launcher2/WallpaperChooserDialogFragment.java84
9 files changed, 109 insertions, 129 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d9404a7bc..feba679f9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -85,10 +85,9 @@
<activity
android:name="com.android.launcher2.WallpaperChooser"
- style="@style/config_orientation"
+ style="@style/Theme.WallpaperPicker"
android:label="@string/pick_wallpaper"
android:icon="@drawable/ic_launcher_wallpaper"
- android:theme="@style/Theme.WallpaperPicker"
android:finishOnCloseSystemDialogs="true">
<intent-filter>
<action android:name="android.intent.action.SET_WALLPAPER" />
diff --git a/res/drawable/wallpaper_gallery_background.xml b/res/drawable/wallpaper_gallery_background.xml
new file mode 100644
index 000000000..271c1dfb8
--- /dev/null
+++ b/res/drawable/wallpaper_gallery_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient android:startColor="#0000" android:endColor="#D0000000"
+ android:angle="270"/>
+</shape> \ No newline at end of file
diff --git a/res/layout-large/wallpaper_chooser.xml b/res/layout-large/wallpaper_chooser.xml
deleted file mode 100644
index b48dbd9ad..000000000
--- a/res/layout-large/wallpaper_chooser.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 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.
-*/
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/wallpaper_list"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="24dp"
- android:paddingRight="24dp"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:gravity="center">
- <GridView
- android:id="@+id/gallery"
- android:layout_width="636dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:numColumns="3"
- android:stretchMode="none"
- android:columnWidth="@dimen/live_wallpaper_column_width"
- android:verticalSpacing="0dp"
- android:horizontalSpacing="0dp"
- android:drawSelectorOnTop="false" />
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
-
- android:gravity="center"
- android:visibility="gone"
-
- android:text="@string/wallpaper_chooser_empty"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-</FrameLayout> \ No newline at end of file
diff --git a/res/layout-large/wallpaper_chooser_base.xml b/res/layout-large/wallpaper_chooser_base.xml
deleted file mode 100644
index ba5ac5304..000000000
--- a/res/layout-large/wallpaper_chooser_base.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 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.
-*/
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
diff --git a/res/layout/wallpaper_chooser.xml b/res/layout/wallpaper_chooser.xml
index 92a6596ee..c0a5fdf9e 100644
--- a/res/layout/wallpaper_chooser.xml
+++ b/res/layout/wallpaper_chooser.xml
@@ -18,26 +18,26 @@
*/
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
- <ImageView android:id="@+id/wallpaper"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0"
- android:scaleType="fitCenter" />
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:background="@drawable/wallpaper_gallery_background">
- <Gallery android:id="@+id/gallery"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <Button android:id="@+id/set"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/wallpaper_instructions"
- android:layout_gravity="center_horizontal" />
-
-</LinearLayout>
+ <Gallery android:id="@+id/gallery"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <Button android:id="@+id/set"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/wallpaper_instructions"
+ android:layout_gravity="center_horizontal" />
+ </LinearLayout>
+</RelativeLayout>
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
index 7e19e89fa..f44bfa58a 100644
--- a/res/values-large/styles.xml
+++ b/res/values-large/styles.xml
@@ -18,9 +18,6 @@
-->
<resources>
- <style name="Theme.WallpaperPicker" parent="@*android:Theme.Holo.Dialog.NoFrame">
- </style>
-
<style name="Theme" parent="android:Theme.Holo">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionModeOverlay">true</item>
@@ -30,6 +27,10 @@
<item name="android:windowShowWallpaper">true</item>
</style>
+ <style name="Theme.WallpaperPicker">
+ <item name="android:screenOrientation">unspecified</item>
+ </style>
+
<style name="WorkspaceIcon.Portrait">
<item name="android:drawablePadding">2dip</item>
<item name="android:paddingTop">0dip</item>
@@ -83,8 +84,4 @@
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:textSize">16sp</item>
</style>
-
- <style name="config_orientation">
- <item name="@android:screenOrientation">unspecified</item>
- </style>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 3c0ae8d46..0449b9349 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -18,8 +18,8 @@
-->
<resources>
- <style name="Theme.WallpaperPicker" parent="android:Theme">
- <item name="android:windowNoTitle">true</item>
+ <style name="Theme.WallpaperPicker">
+ <item name="android:screenOrientation">nosensor</item>
</style>
<style name="Theme.Base" parent="android:Theme.Wallpaper">
@@ -155,8 +155,4 @@
<item name="android:layout_marginRight">4dip</item>
<item name="android:background">@drawable/hotseat_bg_right</item>
</style>
-
- <style name="config_orientation">
- <item name="@android:screenOrientation">nosensor</item>
- </style>
</resources>
diff --git a/src/com/android/launcher2/WallpaperChooser.java b/src/com/android/launcher2/WallpaperChooser.java
index 2311d1e9a..8a9d92f4a 100644
--- a/src/com/android/launcher2/WallpaperChooser.java
+++ b/src/com/android/launcher2/WallpaperChooser.java
@@ -33,6 +33,8 @@ public class WallpaperChooser extends Activity {
Fragment fragmentView =
getFragmentManager().findFragmentById(R.id.wallpaper_chooser_fragment);
+ // TODO: The following code is currently not exercised. Leaving it here in case it
+ // needs to be revived again.
if (fragmentView == null) {
/* When the screen is XLarge, the fragment is not included in the layout, so show it
* as a dialog
diff --git a/src/com/android/launcher2/WallpaperChooserDialogFragment.java b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
index 4f133324c..c9e21f2da 100644
--- a/src/com/android/launcher2/WallpaperChooserDialogFragment.java
+++ b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
@@ -15,8 +15,6 @@
*/
package com.android.launcher2;
-import com.android.launcher.R;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -27,14 +25,17 @@ import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
@@ -44,6 +45,8 @@ import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
+import com.android.launcher.R;
+
import java.io.IOException;
import java.util.ArrayList;
@@ -55,12 +58,12 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
+ "WallpaperChooserDialogFragment.EMBEDDED_KEY";
private boolean mEmbedded;
- private ImageView mImageView = null;
private Bitmap mBitmap = null;
private ArrayList<Integer> mThumbs;
private ArrayList<Integer> mImages;
private WallpaperLoader mLoader;
+ private WallpaperDrawable mWallpaperDrawable = new WallpaperDrawable();
public static WallpaperChooserDialogFragment newInstance() {
WallpaperChooserDialogFragment fragment = new WallpaperChooserDialogFragment();
@@ -113,6 +116,9 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
public Dialog onCreateDialog(Bundle savedInstanceState) {
findWallpapers();
+ // TODO: The following code is not exercised right now and may be removed
+ // if the dialog version is not needed.
+ /*
final View v = getActivity().getLayoutInflater().inflate(
R.layout.wallpaper_chooser, null, false);
@@ -122,13 +128,15 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
final int viewInset =
getResources().getDimensionPixelSize(R.dimen.alert_dialog_content_inset);
-
+
FrameLayout wallPaperList = (FrameLayout) v.findViewById(R.id.wallpaper_list);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setNegativeButton(R.string.wallpaper_cancel, null);
builder.setTitle(R.string.wallpaper_dialog_title);
- builder.setView(wallPaperList, viewInset, viewInset, viewInset, viewInset);
- return builder.create();
+ builder.setView(wallPaperList,
+ viewInset, viewInset, viewInset, viewInset); return builder.create();
+ */
+ return null;
}
@Override
@@ -142,6 +150,7 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
*/
if (mEmbedded) {
View view = inflater.inflate(R.layout.wallpaper_chooser, container, false);
+ view.setBackgroundDrawable(mWallpaperDrawable);
final Gallery gallery = (Gallery) view.findViewById(R.id.gallery);
gallery.setCallbackDuringFling(false);
@@ -155,7 +164,6 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
selectWallpaper(gallery.getSelectedItemPosition());
}
});
- mImageView = (ImageView) view.findViewById(R.id.wallpaper);
return view;
}
return null;
@@ -299,20 +307,9 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
mBitmap.recycle();
}
- // This should always be the case, but check anyways
- final ImageView view = mImageView;
- if (view != null) {
- view.setImageBitmap(b);
-
- mBitmap = b;
-
- final Drawable drawable = view.getDrawable();
- drawable.setFilterBitmap(true);
- drawable.setDither(true);
-
- view.postInvalidate();
- }
-
+ mBitmap = b;
+ mWallpaperDrawable.setBitmap(b);
+ getView().postInvalidate();
mLoader = null;
} else {
b.recycle();
@@ -324,4 +321,47 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
super.cancel(true);
}
}
+
+ /**
+ * Custom drawable that centers the bitmap fed to it.
+ */
+ static class WallpaperDrawable extends Drawable {
+
+ Bitmap mBitmap;
+ int mIntrinsicWidth;
+ int mIntrinsicHeight;
+
+ /* package */void setBitmap(Bitmap bitmap) {
+ mBitmap = bitmap;
+ if (mBitmap == null)
+ return;
+ mIntrinsicWidth = mBitmap.getWidth();
+ mIntrinsicHeight = mBitmap.getHeight();
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ if (mBitmap == null) return;
+ int width = canvas.getWidth();
+ int height = canvas.getHeight();
+ int x = (width - mIntrinsicWidth) / 2;
+ int y = (height - mIntrinsicHeight) / 2;
+ canvas.drawBitmap(mBitmap, x, y, null);
+ }
+
+ @Override
+ public int getOpacity() {
+ return android.graphics.PixelFormat.OPAQUE;
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ // Ignore
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter cf) {
+ // Ignore
+ }
+ }
} \ No newline at end of file