am 8eb50959: Add the ability to replace all wallpapers with overlay resources.
Merge commit '8eb509596bb011ca058f811fbc16602b7846c441' * commit '8eb509596bb011ca058f811fbc16602b7846c441': Add the ability to replace all wallpapers with overlay resources.
This commit is contained in:
commit
f30a1ddf34
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
* Copyright (C) 2009 Google Inc.
|
||||
*
|
||||
* 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>
|
||||
<string-array name="wallpapers">
|
||||
<item>wallpaper_lake</item>
|
||||
<item>wallpaper_sunset</item>
|
||||
<item>wallpaper_beach</item>
|
||||
<item>wallpaper_snow_leopard</item>
|
||||
<item>wallpaper_path</item>
|
||||
<item>wallpaper_sunrise</item>
|
||||
<item>wallpaper_mountain</item>
|
||||
<item>wallpaper_road</item>
|
||||
<item>wallpaper_jellyfish</item>
|
||||
<item>wallpaper_zanzibar</item>
|
||||
<item>wallpaper_blue</item>
|
||||
<item>wallpaper_grey</item>
|
||||
<item>wallpaper_green</item>
|
||||
<item>wallpaper_pink</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -37,45 +37,10 @@ import android.widget.ImageView;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class WallpaperChooser extends Activity implements AdapterView.OnItemSelectedListener,
|
||||
OnClickListener {
|
||||
|
||||
private static final Integer[] THUMB_IDS = {
|
||||
R.drawable.wallpaper_lake_small,
|
||||
R.drawable.wallpaper_sunset_small,
|
||||
R.drawable.wallpaper_beach_small,
|
||||
R.drawable.wallpaper_snow_leopard_small,
|
||||
R.drawable.wallpaper_path_small,
|
||||
R.drawable.wallpaper_sunrise_small,
|
||||
R.drawable.wallpaper_mountain_small,
|
||||
R.drawable.wallpaper_road_small,
|
||||
R.drawable.wallpaper_jellyfish_small,
|
||||
R.drawable.wallpaper_zanzibar_small,
|
||||
R.drawable.wallpaper_blue_small,
|
||||
R.drawable.wallpaper_grey_small,
|
||||
R.drawable.wallpaper_green_small,
|
||||
R.drawable.wallpaper_pink_small,
|
||||
};
|
||||
|
||||
private static final Integer[] IMAGE_IDS = {
|
||||
R.drawable.wallpaper_lake,
|
||||
R.drawable.wallpaper_sunset,
|
||||
R.drawable.wallpaper_beach,
|
||||
R.drawable.wallpaper_snow_leopard,
|
||||
R.drawable.wallpaper_path,
|
||||
R.drawable.wallpaper_sunrise,
|
||||
R.drawable.wallpaper_mountain,
|
||||
R.drawable.wallpaper_road,
|
||||
R.drawable.wallpaper_jellyfish,
|
||||
R.drawable.wallpaper_zanzibar,
|
||||
R.drawable.wallpaper_blue,
|
||||
R.drawable.wallpaper_grey,
|
||||
R.drawable.wallpaper_green,
|
||||
R.drawable.wallpaper_pink,
|
||||
};
|
||||
|
||||
private Gallery mGallery;
|
||||
private ImageView mImageView;
|
||||
private boolean mIsWallpaperSet;
|
||||
|
@ -111,17 +76,18 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele
|
|||
}
|
||||
|
||||
private void findWallpapers() {
|
||||
mThumbs = new ArrayList<Integer>(THUMB_IDS.length + 4);
|
||||
Collections.addAll(mThumbs, THUMB_IDS);
|
||||
|
||||
mImages = new ArrayList<Integer>(IMAGE_IDS.length + 4);
|
||||
Collections.addAll(mImages, IMAGE_IDS);
|
||||
mThumbs = new ArrayList<Integer>(24);
|
||||
mImages = new ArrayList<Integer>(24);
|
||||
|
||||
final Resources resources = getResources();
|
||||
|
||||
final String[] extras = resources.getStringArray(R.array.extra_wallpapers);
|
||||
final String packageName = getApplication().getPackageName();
|
||||
|
||||
addWallpapers(resources, packageName, R.array.wallpapers);
|
||||
addWallpapers(resources, packageName, R.array.extra_wallpapers);
|
||||
}
|
||||
|
||||
private void addWallpapers(Resources resources, String packageName, int list) {
|
||||
final String[] extras = resources.getStringArray(list);
|
||||
for (String extra : extras) {
|
||||
int res = resources.getIdentifier(extra, "drawable", packageName);
|
||||
if (res != 0) {
|
||||
|
@ -170,8 +136,7 @@ public class WallpaperChooser extends Activity implements AdapterView.OnItemSele
|
|||
|
||||
mIsWallpaperSet = true;
|
||||
try {
|
||||
WallpaperManager wpm = (WallpaperManager)getSystemService(
|
||||
WALLPAPER_SERVICE);
|
||||
WallpaperManager wpm = (WallpaperManager)getSystemService(WALLPAPER_SERVICE);
|
||||
wpm.setResource(mImages.get(position));
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
|
|
Loading…
Reference in New Issue