merge from eclair

This commit is contained in:
Jean-Baptiste Queru
2009-11-15 12:05:38 -08:00
3240 changed files with 153711 additions and 72942 deletions

View File

@@ -24,15 +24,24 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- We will request access to the camera, saying we require a camera
of some sort but not one with autofocus capability. -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application android:name="ApiDemosApplication"
android:label="@string/activity_sample_code"
android:icon="@drawable/app_sample_code" >
<!-- This is how we can request a library but still allow the app
to be installed if it doesn't exist. -->
<uses-library android:name="com.example.will.never.exist" android:required="false" />
<activity android:name="ApiDemos">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -72,6 +81,15 @@
</intent-filter>
</activity>
<activity android:name=".app.WallpaperActivity"
android:label="@string/activity_wallpaper"
android:theme="@style/Theme.Wallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".app.TranslucentActivity"
android:label="@string/activity_translucent"
android:theme="@style/Theme.Translucent">
@@ -90,6 +108,13 @@
</intent-filter>
</activity>
<activity android:name=".app.Animation" android:label="@string/activity_animation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".app.SaveRestoreState"
android:label="@string/activity_save_restore"
android:windowSoftInputMode="stateVisible|adjustResize">
@@ -1562,6 +1587,13 @@
</intent-filter>
</activity>
<activity android:name=".graphics.ColorFilters" android:label="Graphics/ColorFilters">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".graphics.CreateBitmap" android:label="Graphics/CreateBitmap">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@@ -1,11 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-4

View File

@@ -16,4 +16,5 @@
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="100" />
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime" />

View File

@@ -15,5 +15,6 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="150" />
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>

View File

@@ -15,5 +15,6 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="150" />
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 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.
*/
-->
<!-- Special window zoom animation: this is the element that enters the screen,
it starts at 200% and scales down. Goes with zoom_exit.xml. -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 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.
*/
-->
<!-- Special window zoom animation: this is the element that exits the
screen, it is forced above the entering element and starts at its
normal size (filling the screen) and scales down while fading out.
This goes with zoom_enter.xml. -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 686 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<!-- Demonstrates starting and stopping a local service.
See corresponding Java code com.android.sdk.app.LocalSerice.java. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip"
android:text="@string/activity_animation_msg"/>
<Button android:id="@+id/fade_animation"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/activity_animation_fade">
<requestFocus />
</Button>
<Button android:id="@+id/zoom_animation"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/activity_animation_zoom">
</Button>
</LinearLayout>

View File

@@ -43,5 +43,15 @@
android:text="@string/start3_service">
</Button>
<Button android:id="@+id/startfail"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/startfail_service">
</Button>
<Button android:id="@+id/kill"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/kill_process">
</Button>
</LinearLayout>

View File

@@ -38,6 +38,8 @@
custom Theme.Dialog theme to make an activity that looks like a
customized dialog, here with an ugly frame.</string>
<string name="activity_wallpaper">App/Activity/Wallpaper</string>
<string name="activity_translucent">App/Activity/Translucent</string>
<string name="translucent_background">Example of how you can make an
activity have a translucent background, compositing over
@@ -45,6 +47,11 @@
<string name="activity_translucent_blur">App/Activity/Translucent Blur</string>
<string name="activity_animation">App/Activity/Animation</string>
<string name="activity_animation_msg">Press a button to launch an activity with a custom animation.</string>
<string name="activity_animation_fade">Fade in</string>
<string name="activity_animation_zoom">Zoom in</string>
<string name="activity_save_restore">App/Activity/Save &amp; Restore State</string>
<string name="save_restore_msg">Demonstration of saving and restoring activity state in onSaveInstanceState() and onCreate().</string>
<string name="saves_state">This text field saves its state:</string>
@@ -115,9 +122,6 @@
<string name="remote_service_disconnected">Disconnected from remote service</string>
<string name="remote_call_failed">Failure calling remote service</string>
<string name="service_arguments_started">"Started with arguments: "</string>
<string name="service_arguments_stopped">Finished arguments,
stopping.</string>
<string name="service_start_arguments_label">Sample Service Start Arguments
</string>
@@ -128,10 +132,13 @@
service can be started with arguments, and run until all arguments are
processed.
</string>
<string name="start1_service">Start with \"One\"</string>
<string name="start2_service">Start with \"Two\"</string>
<string name="start3_service">Start with \"Three\"</string>
<string name="start1_service">Start \"One\" no redeliver</string>
<string name="start2_service">Start \"Two\" no redeliver</string>
<string name="start3_service">Start \"Three\" w/redeliver</string>
<string name="startfail_service">Start failed delivery</string>
<string name="service_created">Service created.</string>
<string name="service_destroyed">Service destroyed.</string>
<string name="one_shot_received">The one-shot alarm has gone off</string>
<string name="repeating_received">The repeating alarm has gone off</string>
@@ -363,8 +370,8 @@
<string name="summary_my_preference">This is a custom counter preference</string>
<string name="title_advanced_toggle_preference">Haunted preference</string>
<string name="summary_on_advanced_toggle_preference">I'm on! :)</string>
<string name="summary_off_advanced_toggle_preference">I'm off! :(</string>
<string name="summary_on_advanced_toggle_preference">I\'m on! :)</string>
<string name="summary_off_advanced_toggle_preference">I\'m off! :(</string>
<string name="title_parent_preference">Parent toggle</string>
<string name="summary_parent_preference">This is visually a parent</string>
@@ -633,13 +640,13 @@
using the Java programming language and run on Dalvik, a custom virtual
machine designed for embedded use which runs on top of a Linux kernel.
If you want to know how to develop applications for Android, you're in the
If you want to know how to develop applications for Android, you\'re in the
right place. This site provides a variety of documentation that will help you
learn about Android and develop mobile applications for the platform.
An early look at the the Android SDK is also available. It includes sample
projects with source code, development tools, an emulator, and of course all
the libraries you'll need to build an Android application. What would it take
the libraries you\'ll need to build an Android application. What would it take
to build a better mobile phone?
</string>
<string name="spinner_1_color">Color:</string>

View File

@@ -37,9 +37,16 @@
<item name="android:windowBackground">@drawable/filled_box</item>
</style>
<!-- A theme that has a wallpaper background. Here we explicitly specify
that this theme is to inherit from the system's wallpaper theme,
which sets up various attributes correctly. -->
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper">
<item name="android:colorForeground">#fff</item>
</style>
<!-- A theme that has a translucent background. Here we explicitly specify
that this theme is to inherit from the system's translucent theme,
which sets up various attributes correctly.. -->
which sets up various attributes correctly. -->
<style name="Theme.Translucent" parent="android:style/Theme.Translucent">
<item name="android:windowBackground">@drawable/translucent_background</item>
<item name="android:windowNoTitle">true</item>

View File

@@ -0,0 +1,78 @@
/*
* 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 com.example.android.apis.view.Controls1;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/**
* <p>Example of explicitly starting and stopping the {@link LocalService}.
* This demonstrates the implementation of a service that runs in the same
* process as the rest of the application, which is explicitly started and stopped
* as desired.</p>
*/
public class Animation extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animation);
// Watch for button clicks.
Button button = (Button)findViewById(R.id.fade_animation);
button.setOnClickListener(mFadeListener);
button = (Button)findViewById(R.id.zoom_animation);
button.setOnClickListener(mZoomListener);
}
private OnClickListener mFadeListener = new OnClickListener() {
public void onClick(View v) {
// Request the next activity transition (here starting a new one).
startActivity(new Intent(Animation.this, Controls1.class));
// Supply a custom animation. This one will just fade the new
// activity on top. Note that we need to also supply an animation
// (here just doing nothing for the same amount of time) for the
// old activity to prevent it from going away too soon.
overridePendingTransition(R.anim.fade, R.anim.hold);
}
};
private OnClickListener mZoomListener = new OnClickListener() {
public void onClick(View v) {
// Request the next activity transition (here starting a new one).
startActivity(new Intent(Animation.this, Controls1.class));
// This is a more complicated animation, involving transformations
// on both this (exit) and the new (enter) activity. Note how for
// the duration of the animation we force the exiting activity
// to be Z-ordered on top (even though it really isn't) to achieve
// the effect we want.
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
}
};
}

View File

@@ -24,6 +24,7 @@ import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.util.Log;
import android.widget.Toast;
// Need the following import to get access to the app resources, since this
@@ -63,6 +64,14 @@ public class LocalService extends Service {
showNotification();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("LocalService", "Received start id " + startId + ": " + intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
@Override
public void onDestroy() {
// Cancel the persistent notification.

View File

@@ -27,6 +27,7 @@ import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.util.Log;
import android.widget.Toast;
@@ -41,9 +42,12 @@ import com.example.android.apis.R;
* happen in the service. This is generally how background services should
* interact with the user, rather than doing something more disruptive such as
* calling startActivity().
*
* <p>For applications targeting Android 1.5 or beyond, you may want consider
* using the android.app.IntentService class, which takes care of all the
* work of creating the extra thread and dispatching commands to it.
*/
public class ServiceStartArguments extends Service
{
public class ServiceStartArguments extends Service {
private NotificationManager mNM;
private Intent mInvokeIntent;
private volatile Looper mServiceLooper;
@@ -58,16 +62,22 @@ public class ServiceStartArguments extends Service
public void handleMessage(Message msg)
{
Bundle arguments = (Bundle)msg.obj;
String txt = getResources()
.getString(R.string.service_arguments_started);
txt = txt + arguments.getString("name");
Log.i("ServiceStartArguments", "Message: " + msg + ", " + txt);
String txt = arguments.getString("name");
Log.i("ServiceStartArguments", "Message: " + msg + ", "
+ arguments.getString("name"));
showNotification();
if ((msg.arg2&Service.START_FLAG_REDELIVERY) == 0) {
txt = "New cmd #" + msg.arg1 + ": " + txt;
} else {
txt = "Re-delivered #" + msg.arg1 + ": " + txt;
}
showNotification(txt);
// Normally we would do some work here... for our sample, we will
// just sleep for 10 seconds.
// Normally we would do some work here... for our sample, we will
// just sleep for 5 seconds.
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
@@ -78,6 +88,8 @@ public class ServiceStartArguments extends Service
}
}
hideNotification();
Log.i("ServiceStartArguments", "Done with #" + msg.arg1);
stopSelf(msg.arg1);
}
@@ -88,14 +100,19 @@ public class ServiceStartArguments extends Service
public void onCreate() {
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Toast.makeText(this, R.string.service_created,
Toast.LENGTH_SHORT).show();
// This is who should be launched if the user selects our persistent
// notification.
mInvokeIntent = new Intent(this, ServiceStartArgumentsController.class);
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block.
HandlerThread thread = new HandlerThread("ServiceStartArguments");
// main thread, which we don't want to block. We also make it
// background priority so CPU-intensive work will not disrupt our UI.
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
@@ -103,25 +120,45 @@ public class ServiceStartArguments extends Service
}
@Override
public void onStart(Intent intent, int startId) {
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("ServiceStartArguments",
"Starting #" + startId + ": " + intent.getExtras());
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
msg.arg2 = flags;
msg.obj = intent.getExtras();
mServiceHandler.sendMessage(msg);
Log.i("ServiceStartArguments", "Sending: " + msg);
// For the start fail button, we will simulate the process dying
// for some reason in onStartCommand().
if (intent.getBooleanExtra("fail", false)) {
// Don't do this if we are in a retry... the system will
// eventually give up if we keep crashing.
if ((flags&START_FLAG_RETRY) == 0) {
// Since the process hasn't finished handling the command,
// it will be restarted with the command again, regardless of
// whether we return START_REDELIVER_INTENT.
Process.killProcess(Process.myPid());
}
}
// Normally we would consistently return one kind of result...
// however, here we will select between these two, so you can see
// how they impact the behavior. Try killing the process while it
// is in the middle of executing the different commands.
return intent.getBooleanExtra("redeliver", false)
? START_REDELIVER_INTENT : START_NOT_STICKY;
}
@Override
public void onDestroy() {
mServiceLooper.quit();
// Cancel the persistent notification.
mNM.cancel(R.string.service_arguments_started);
hideNotification();
// Tell the user we stopped.
Toast.makeText(ServiceStartArguments.this, R.string.service_arguments_stopped,
Toast.makeText(ServiceStartArguments.this, R.string.service_destroyed,
Toast.LENGTH_SHORT).show();
}
@@ -133,10 +170,7 @@ public class ServiceStartArguments extends Service
/**
* Show a notification while this service is running.
*/
private void showNotification() {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.service_arguments_started);
private void showNotification(String text) {
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.stat_sample, text,
System.currentTimeMillis());
@@ -149,9 +183,16 @@ public class ServiceStartArguments extends Service
notification.setLatestEventInfo(this, getText(R.string.service_start_arguments_label),
text, contentIntent);
// We show this for as long as our service is processing a command.
notification.flags |= Notification.FLAG_ONGOING_EVENT;
// Send the notification.
// We use a string id because it is a unique number. We use it later to cancel.
mNM.notify(R.string.service_arguments_started, notification);
mNM.notify(R.string.service_created, notification);
}
private void hideNotification() {
mNM.cancel(R.string.service_created);
}
}

View File

@@ -21,14 +21,13 @@ package com.example.android.apis.app;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Process;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.example.android.apis.R;
import java.util.HashMap;
/**
* Example of explicitly starting the {@link ServiceStartArguments}.
*/
@@ -46,26 +45,51 @@ public class ServiceStartArgumentsController extends Activity {
button.setOnClickListener(mStart2Listener);
button = (Button)findViewById(R.id.start3);
button.setOnClickListener(mStart3Listener);
button = (Button)findViewById(R.id.startfail);
button.setOnClickListener(mStartFailListener);
button = (Button)findViewById(R.id.kill);
button.setOnClickListener(mKillListener);
}
private OnClickListener mStart1Listener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(ServiceStartArgumentsController.this,
ServiceStartArguments.class).putExtra("name", "One"));
ServiceStartArguments.class)
.putExtra("name", "One"));
}
};
private OnClickListener mStart2Listener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(ServiceStartArgumentsController.this,
ServiceStartArguments.class).putExtra("name", "Two"));
ServiceStartArguments.class)
.putExtra("name", "Two"));
}
};
private OnClickListener mStart3Listener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(ServiceStartArgumentsController.this,
ServiceStartArguments.class).putExtra("name", "Three"));
ServiceStartArguments.class)
.putExtra("name", "Three")
.putExtra("redeliver", true));
}
};
private OnClickListener mStartFailListener = new OnClickListener() {
public void onClick(View v) {
startService(new Intent(ServiceStartArgumentsController.this,
ServiceStartArguments.class)
.putExtra("name", "Failure")
.putExtra("fail", true));
}
};
private OnClickListener mKillListener = new OnClickListener() {
public void onClick(View v) {
// This is to simulate the service being killed while it is
// running in the background.
Process.killProcess(Process.myPid());
}
};
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2007 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 android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
/**
* <h3>Wallpaper Activity</h3>
*
* <p>This demonstrates the how to write an activity that has the system
* wallpaper behind it.</p>
*/
public class WallpaperActivity 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/any/layout/translucent_background.xml for this
// view layout definition, which is being set here as
// the content of our screen.
setContentView(R.layout.translucent_background);
}
}

View File

@@ -0,0 +1,184 @@
/*
* 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.graphics;
import com.example.android.apis.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.*;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.*;
public class ColorFilters extends GraphicsActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
private Activity mActivity;
private Drawable mDrawable;
private Drawable[] mDrawables;
private Paint mPaint;
private Paint mPaint2;
private float mPaintTextOffset;
private int[] mColors;
private PorterDuff.Mode[] mModes;
private int mModeIndex;
private static void addToTheRight(Drawable curr, Drawable prev) {
Rect r = prev.getBounds();
int x = r.right + 12;
int center = (r.top + r.bottom) >> 1;
int h = curr.getIntrinsicHeight();
int y = center - (h >> 1);
curr.setBounds(x, y, x + curr.getIntrinsicWidth(), y + h);
}
public SampleView(Activity activity) {
super(activity);
mActivity = activity;
Context context = activity;
setFocusable(true);
mDrawable = context.getResources().getDrawable(R.drawable.btn_default_normal);
mDrawable.setBounds(0, 0, 150, 48);
mDrawable.setDither(true);
int[] resIDs = new int[] {
R.drawable.btn_circle_normal,
R.drawable.btn_check_off,
R.drawable.btn_check_on
};
mDrawables = new Drawable[resIDs.length];
Drawable prev = mDrawable;
for (int i = 0; i < resIDs.length; i++) {
mDrawables[i] = context.getResources().getDrawable(resIDs[i]);
mDrawables[i].setDither(true);
addToTheRight(mDrawables[i], prev);
prev = mDrawables[i];
}
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextSize(16);
mPaint.setTextAlign(Paint.Align.CENTER);
mPaint2 = new Paint(mPaint);
mPaint2.setAlpha(64);
Paint.FontMetrics fm = mPaint.getFontMetrics();
mPaintTextOffset = (fm.descent + fm.ascent) * 0.5f;
mColors = new int[] {
0,
0xCC0000FF,
0x880000FF,
0x440000FF,
0xFFCCCCFF,
0xFF8888FF,
0xFF4444FF,
};
mModes = new PorterDuff.Mode[] {
PorterDuff.Mode.SRC_ATOP,
PorterDuff.Mode.MULTIPLY,
};
mModeIndex = 0;
updateTitle();
}
private void swapPaintColors() {
if (mPaint.getColor() == 0xFF000000) {
mPaint.setColor(0xFFFFFFFF);
mPaint2.setColor(0xFF000000);
} else {
mPaint.setColor(0xFF000000);
mPaint2.setColor(0xFFFFFFFF);
}
mPaint2.setAlpha(64);
}
private void updateTitle() {
mActivity.setTitle(mModes[mModeIndex].toString());
}
private void drawSample(Canvas canvas, ColorFilter filter) {
Rect r = mDrawable.getBounds();
float x = (r.left + r.right) * 0.5f;
float y = (r.top + r.bottom) * 0.5f - mPaintTextOffset;
mDrawable.setColorFilter(filter);
mDrawable.draw(canvas);
canvas.drawText("Label", x+1, y+1, mPaint2);
canvas.drawText("Label", x, y, mPaint);
for (Drawable dr : mDrawables) {
dr.setColorFilter(filter);
dr.draw(canvas);
}
}
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
canvas.translate(8, 12);
for (int color : mColors) {
ColorFilter filter;
if (color == 0) {
filter = null;
} else {
filter = new PorterDuffColorFilter(color,
mModes[mModeIndex]);
}
drawSample(canvas, filter);
canvas.translate(0, 55);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
// update mode every other time we change paint colors
if (mPaint.getColor() == 0xFFFFFFFF) {
mModeIndex = (mModeIndex + 1) % mModes.length;
updateTitle();
}
swapPaintColors();
invalidate();
break;
}
return true;
}
}
}

View File

@@ -64,29 +64,6 @@ class CubeRenderer implements GLSurfaceView.Renderer {
mAngle += 1.2f;
}
public int[] getConfigSpec() {
if (mTranslucentBackground) {
// We want a depth buffer and an alpha buffer
int[] configSpec = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_NONE
};
return configSpec;
} else {
// We want a depth buffer, don't care about the
// details of the color buffer.
int[] configSpec = {
EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_NONE
};
return configSpec;
}
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);

View File

@@ -134,16 +134,6 @@ class TouchSurfaceView extends GLSurfaceView {
mCube.draw(gl);
}
public int[] getConfigSpec() {
// We want a depth buffer, don't care about the
// details of the color buffer.
int[] configSpec = {
EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_NONE
};
return configSpec;
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);

View File

@@ -50,16 +50,6 @@ public class SpriteTextRenderer implements GLSurfaceView.Renderer{
mLabelPaint.setARGB(0xff, 0x00, 0x00, 0x00);
}
public int[] getConfigSpec() {
// We don't need a depth buffer, and don't care about our
// color depth.
int[] configSpec = {
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_NONE
};
return configSpec;
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
/*
* By default, OpenGL enables features that improve quality

View File

@@ -0,0 +1 @@
tested.project.dir=..