am 76c9d31c: Revert "adding set wallpaper sample code in ApiDemos."
Merge commit '76c9d31ce383cf1f4ef89dd1dae4f751fbb73b9a' into eclair-mr2 * commit '76c9d31ce383cf1f4ef89dd1dae4f751fbb73b9a': Revert "adding set wallpaper sample code in ApiDemos."
This commit is contained in:
committed by
Android Git Automerger
commit
aecf2c6581
@@ -27,7 +27,6 @@
|
|||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
|
||||||
|
|
||||||
<!-- We will request access to the camera, saying we require a camera
|
<!-- We will request access to the camera, saying we require a camera
|
||||||
of some sort but not one with autofocus capability. -->
|
of some sort but not one with autofocus capability. -->
|
||||||
@@ -188,14 +187,6 @@
|
|||||||
<activity android:name=".app.ReorderThree" />
|
<activity android:name=".app.ReorderThree" />
|
||||||
<activity android:name=".app.ReorderFour" />
|
<activity android:name=".app.ReorderFour" />
|
||||||
|
|
||||||
<activity android:name=".app.SetWallpaperActivity"
|
|
||||||
android:label="@string/activity_setwallpaper">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<!-- Intent Samples -->
|
<!-- Intent Samples -->
|
||||||
|
|
||||||
<activity android:name=".app.Intents" android:label="@string/activity_intents">
|
<activity android:name=".app.Intents" android:label="@string/activity_intents">
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/imageview" />
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent">
|
|
||||||
<Button
|
|
||||||
android:id="@+id/randomize"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Randomize"
|
|
||||||
android:layout_gravity="bottom" />
|
|
||||||
<Button
|
|
||||||
android:id="@+id/setwallpaper"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Set Wallpaper"
|
|
||||||
android:layout_gravity="bottom" />
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
customized dialog, here with an ugly frame.</string>
|
customized dialog, here with an ugly frame.</string>
|
||||||
|
|
||||||
<string name="activity_wallpaper">App/Activity/Wallpaper</string>
|
<string name="activity_wallpaper">App/Activity/Wallpaper</string>
|
||||||
<string name="activity_setwallpaper">App/Activity/SetWallpaper</string>
|
|
||||||
|
|
||||||
<string name="activity_translucent">App/Activity/Translucent</string>
|
<string name="activity_translucent">App/Activity/Translucent</string>
|
||||||
<string name="translucent_background">Example of how you can make an
|
<string name="translucent_background">Example of how you can make an
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2009 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.example.android.apis.app;
|
|
||||||
|
|
||||||
// Need the following import to get access to the app resources, since this
|
|
||||||
// class is in a sub-package.
|
|
||||||
import com.example.android.apis.R;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.WallpaperManager;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h3>SetWallpaper Activity</h3>
|
|
||||||
*
|
|
||||||
* <p>This demonstrates the how to write an activity that gets the current system wallpaper,
|
|
||||||
* modifies it and sets the modified bitmap as system wallpaper.</p>
|
|
||||||
*/
|
|
||||||
public class SetWallpaperActivity extends Activity {
|
|
||||||
/**
|
|
||||||
* Initialization of the Activity after it is first created. Must at least
|
|
||||||
* call {@link android.app.Activity#setContentView setContentView()} to
|
|
||||||
* describe what is to be displayed in the screen.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
// Be sure to call the super class.
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
// See assets/res/layout/wallpaper2.xml for this
|
|
||||||
// view layout definition, which is being set here as
|
|
||||||
// the content of our screen.
|
|
||||||
setContentView(R.layout.wallpaper_2);
|
|
||||||
final WallpaperManager mWallpaperManager = WallpaperManager.getInstance(this);
|
|
||||||
final BitmapDrawable mWallpaperDrawable = (BitmapDrawable) mWallpaperManager.getDrawable();
|
|
||||||
final ImageView imageView = (ImageView) findViewById(R.id.imageview);
|
|
||||||
imageView.setDrawingCacheEnabled(true);
|
|
||||||
imageView.setImageDrawable(mWallpaperDrawable);
|
|
||||||
|
|
||||||
Button randomize = (Button) findViewById(R.id.randomize);
|
|
||||||
randomize.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
int mColor = (int) Math.floor(Math.random() * mColors.length);
|
|
||||||
mWallpaperDrawable.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);
|
|
||||||
imageView.setImageDrawable(mWallpaperDrawable);
|
|
||||||
imageView.invalidate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button setWallpaper = (Button) findViewById(R.id.setwallpaper);
|
|
||||||
setWallpaper.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
try {
|
|
||||||
mWallpaperManager.setBitmap(imageView.getDrawingCache());
|
|
||||||
finish();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
final private int[] mColors =
|
|
||||||
{Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN,
|
|
||||||
Color.YELLOW, Color.WHITE};
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user