am 435959e7: am f0f2aba8: Merge "update notepad tutorial to change activity title in NoteEdit class" into froyo
Merge commit '435959e72b623a41ff4384862b924102dd7a1bc6' into gingerbread-plus-aosp
* commit '435959e72b623a41ff4384862b924102dd7a1bc6':
update notepad tutorial to change activity title in NoteEdit class
diff --git a/docs/howto_SDK_git_cygwin.txt b/docs/howto_SDK_git_cygwin.txt
deleted file mode 100644
index 622c592..0000000
--- a/docs/howto_SDK_git_cygwin.txt
+++ /dev/null
@@ -1,189 +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.
-
-
-Subject: How to get the android source code using Cygwin and Git
-Date: 2009/04/27
-Updated: 2009/05/21
-Updated: 2010/03/30
-
-
-Table of content:
- 1- Goals and Requirements
- 2- Getting the code, the simple way
- 3- SSH issues
- 4- Advanced Tricks
-
-
--------------------------
-1- Goals and Requirements
--------------------------
-
-This document explains how to checkout the Android source from the git
-repositories under Windows.
-
-As stated in development/docs/howto_build_SDK.txt, one can't build the whole
-Android source code under Windows. You can only build the SDK tools for
-Windows.
-
-There are a number of caveats in checking out the code from Git under Windows.
-This document tries to explain them.
-
-First you will need to meet the following requirements:
-- You must have Cygwin installed. But wait! You CANNOT use the latest Cygwin 1.7.
- Instead you MUST use the "legacy Cygwin 1.5" that you can find at this page:
-
- http://cygwin.org/win-9x.html
-
- Don't mind the page title, just grab setup-legacy.exe and it will works just fine
- under XP or Vista.
-
-- You must install Cyginw using the "Unix / Binary" mode.
- If you don't do that, git will fail to properly compute some SHA1 keys.
-
-- You need the "git" and "curl" packages to checkout the code.
- If you plan to contribute, you might want to get "gitk" also.
-
- Note: if you want to build the SDK, check the howto_build_SDK.txt file
- for a list of extra required packages.
- The short summary is that you need at least these:
- autoconf, bison, curl, flex, gcc, g++, git, gnupg, make, mingw-zlib, python, unzip, zip
- and you must avoid the "readline" package.
-
-
------------------------------------
-2- Getting the code, the simple way
------------------------------------
-
-Out of the box, "repo" and "git" will work just fine under Cygwin:
-
- $ repo init -u git://android.git.kernel.org/platform/manifest.git
- $ repo sync
-
-And you're done. You can build as explained in howto_build_SDK.txt and ignore
-the rest of this document.
-
-
--------------
-3- SSH issues
--------------
-
-If you maintain your own private repository using an SSH server, you might get
-some "mux/ssh" errors. In this case try this:
-
- $ repo init -u ssh://my.private.ssh.repo/platform/manifest.git
- $ export GIT_SSH=ssh
- $ repo sync
-
-
-------------------
-4- Advanced Tricks
-------------------
-
-There is one remaining issue with the default repo/git options:
-
-If you plan on contributing, you will notice that even after a fresh "repo
-sync" some projects are marked as having modified files. This happens on the
-"bionic" and the "external/iptables" project. The issue is that they have files
-which have the same name yet differ only by their case-sensitivity. Since the
-Windows filesystem is not case-sensitive, this confuses Git.
-
-Solution: we can simply ignore these projects as they are not needed to build
-the Windows SDK.
-
-To do this you just need to create a file .repo/local_manifest.xml that
-provides a list of projects to ignore:
-
-<?xml version="1.0" encoding="UTF-8"?>
-<manifest>
- <remove-project name="platform/external/iptables" />
-</manifest>
-
-The other thing we can do is tell git not to track the files that cause
-problems:
-
- cd bionic
- git update-index --assume-unchanged \
- libc/kernel/common/linux/netfilter/xt_CONNMARK.h \
- libc/kernel/common/linux/netfilter/xt_MARK.h \
- libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h
-
- cd external/tcpdump;
- git update-index --assume-unchanged \
- tests/print-X.new \
- tests/print-XX.new
-
-
-Here's a script that takes care of all these details. It performs the repo
-init, creates the appropriate local_manifest.xml, does a repo sync as
-needed and tell git to ignore the offending files:
-
-------------
-#!/bin/bash
-
-set -e # fail on errors
-
-URL=ssh://android-git.corp.google.com:29418/platform/manifest.git
-BRANCH=donut
-if [ "$1" == "-b" ]; then shift; BRANCH=$1; shift; fi
-
-# repo init if there's no .repo directory
-if [[ ! -d .repo ]]; then
- repo init -u $URL -b $BRANCH
-fi
-
-# create a local_manifest to exclude projects that cause problems under Windows
-# due to the case-insenstivines of the file system.
-L=.repo/local_manifest.xml
-if [[ ! -f $L ]]; then
-
- cat > $L <<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<manifest>
-<remove-project name="platform/external/iptables" />
-</manifest>
-EOF
-fi
-
-# sync using the native ssh client if necessary
-[[ $URL != ${URL/ssh/} ]] && export GIT_SSH=ssh
-repo sync $@
-
-
-# These files cause trouble too, we need to ignore them
-(cd bionic;
-git update-index --assume-unchanged \
- libc/kernel/common/linux/netfilter/xt_CONNMARK.h \
- libc/kernel/common/linux/netfilter/xt_MARK.h \
- libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h
-)
-(cd external/tcpdump;
-git update-index --assume-unchanged \
- tests/print-X.new \
- tests/print-XX.new
-)
-------------
-
-Simply extract this to a "my_sync.sh" file and try the following:
- $ mkdir android_src
- $ cd android_src
- $ chmod +x mysync.sh
- $ ./mysync.sh
-
-
--end-
-
-
-
-
diff --git a/docs/howto_build_SDK.txt b/docs/howto_build_SDK.txt
deleted file mode 100644
index e09440b..0000000
--- a/docs/howto_build_SDK.txt
+++ /dev/null
@@ -1,305 +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.
-
-
-Subject: How to build an Android SDK & ADT Eclipse plugin.
-Date: 2009/03/27
-Updated: 2010/03/30
-
-
-Table of content:
- 0- License
- 1- Foreword
- 2- Building an SDK for MacOS and Linux
- 3- Building an SDK for Windows
- 4- Building an ADT plugin for Eclipse
- 5- Conclusion
-
-
-
-----------
-0- License
-----------
-
- 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.
-
-
-
------------
-1- Foreword
------------
-
-This document explains how to build the Android SDK and the ADT Eclipse plugin.
-
-It is designed for advanced users which are proficient with command-line
-operations and know how to setup the pre-required software.
-
-Basically it's not trivial yet when done right it's not that complicated.
-
-
-
---------------------------------------
-2- Building an SDK for MacOS and Linux
---------------------------------------
-
-First, setup your development environment and get the Android source code from
-git as explained here:
-
- http://source.android.com/download
-
-For example for the cupcake branch:
-
- $ mkdir ~/my-android-git
- $ cd ~/my-android-git
- $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
- $ repo sync
-
-Then once you have all the source, simply build the SDK using:
-
- $ cd ~/my-android-git
- $ . build/envsetup.sh
- $ lunch sdk-eng
- $ make sdk
-
-This will take a while, maybe between 20 minutes and several hours depending on
-your machine. After a while you'll see this in the output:
-
- Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zip
-
-Some options:
-
-- Depending on your machine you can tell 'make' to build more things in
- parallel, e.g. if you have a dual core, use "make -j4 sdk" to build faster.
-
-- You can define "BUILD_NUMBER" to control the build identifier that gets
- incorporated in the resulting archive. The default is to use your username.
- One suggestion is to include the date, e.g.:
-
- $ export BUILD_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
-
- There are certain characters you should avoid in the build number, typically
- everything that might confuse 'make' or your shell. So for example avoid
- punctuation and characters like $ & : / \ < > , and .
-
-
-
-------------------------------
-3- Building an SDK for Windows
-------------------------------
-
-A- SDK pre-requisite
---------------------
-
-First you need to build an SDK for MacOS and Linux. The Windows build works by
-updating an existing MacOS or Linux SDK zip file and replacing the unix
-binaries by Windows binaries.
-
-
-
-B- Cygwin pre-requisite & code checkout
----------------------------------------
-
-You must have Cygwin installed. But wait! You CANNOT use the latest Cygwin 1.7.
-Instead you MUST use the "legacy Cygwin 1.5" that you can find at this page:
-
- http://cygwin.org/win-9x.html
-
-Don't mind the page title, just grab setup-legacy.exe and it will works just fine
-under XP or Vista.
-
-
-Now configure it:
-- When installing Cygwin, set Default Text File Type to Unix/binary, not DOS/text.
- This is really important, otherwise you will get errors when trying to
- checkout code using git.
-- Packages that you must install or not:
- - Required packages: autoconf, bison, curl, flex, gcc, g++, git, gnupg, make,
- mingw-zlib, python, zip, unzip.
- - Suggested extra packages: diffutils, emacs, openssh, rsync, vim, wget.
- - Packages that must not be installed: readline.
-
-Once you installed Cygwin properly, checkout the code from git as you did
-for MacOS or Linux. Make sure to get the same branch, and if possible keep
-it as close to the other one as possible:
-
- $ mkdir ~/my-android-git
- $ cd ~/my-android-git
- $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
- $ repo sync
-
-
-
-C- Building the Windows SDK
----------------------------
-
-Now it's time to build that Windows SDK. You need:
-- The path to the MacOS or Linux SDK zip.
-- A directory where to place the final SDK. It will also hold some temporary
- files.
-- The build number will be extracted from the SDK zip filename, but this will
- only work if that build number has no underscores in it. It is suggested you
- just define SDK_NUMBER (and not BUILD_NUMBER!) on the command line before
- invoking the script.
-
- Note that the "SDK number" is really a free identifier of your choice. It
- doesn't need to be strictly a number. As always it is suggested you avoid
- too much punctuation and special shell/make characters. Underscores cannot
- be used.
-
-
-To summarize, the steps on the command line would be something like this:
-
- $ mkdir ~/mysdk
- $ export SDK_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
- $ cd ~/my-android-git
- $ development/build/tools/make_windows_sdk.sh /path/to/macos/or/linux/sdk.zip ~/mysdk
-
-This will take a while to build some Windows-specific binaries, including the
-emulator, unzip the previous zip, rename & replace things and rezip the final
-Windows SDK zip file. A typical build time should be around 5-10 minutes.
-
-
-
--------------------------------------
-4- Building an ADT plugin for Eclipse
--------------------------------------
-
-Requirements:
-- You can currently only build an ADT plugin for Eclipse under Linux.
-- You must have a working version of Eclipse 3.4 "ganymede" RCP installed.
-- You need X11 to run Eclipse at least once.
-- You need a lot of patience. The trick is to do the initial setup correctly
- once, after it's a piece of cake.
-
-
-
-A- Pre-requisites
------------------
-
-Note for Ubuntu or Debian users: your apt repository probably only has Eclipse
-3.2 available and it's probably not suitable to build plugins in the first
-place. Forget that and install a working 3.4 manually as described below.
-
-- Visit http://www.eclipse.org/downloads/ to grab the
- "Eclipse for RCP/Plug-in Developers (176 MB)" download for Linux.
- 32-bit and 64-bit versions are available, depending on your Linux installation.
-
- Note: we've always used a 32-bit one, so use the 64-bit one at your own risk.
-
- Note: Eclipse comes in various editions. Do yourself a favor and just stick
- to the RCP for building this plugin. For example the J2EE contains too many
- useless features that will get in the way, and the "Java" version lacks some
- plugins you need to build other plugins. Please just use the RCP one.
-
-- Unpack "eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz" in the directory of
- your choice, e.g.:
-
- $ mkdir ~/eclipse-3.4
- $ cd ~/eclipse-3.4
- $ tar xvzf eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz
-
- This will create an "eclipse" directory in the current directory.
-
-- Set ECLIPSE_HOME to that "eclipse" directory:
-
- $ export ECLIPSE_HOME=~/eclipse-3.4/eclipse
-
- Note: it is important you set ECLIPSE_HOME before starting the build.
- Otherwise the build process will try to download and install its own Eclipse
- installation in /buildroot, which is probably limited to root.
-
-- Now, before you can build anything, it is important that you start Eclipse
- *manually* once using the same user that you will use to build later. That's
- because your Eclipse installation is not finished: Eclipse must be run at
- least once to create some files in ~/.eclipse/. So run Eclipse now:
-
- $ ~/eclipse-3.4/eclipse/eclipse &
-
- Wait for it load, create a workspace when requested and then simply quit
- using the File > Quit menu. That's it. You won't need to run it manually
- again.
-
-
-
-B- Building ADT
----------------
-
-Finally, you have Eclipse, it's installed and it created its own config files,
-so now you can build your ADT plugin. To do that you'll change directories to
-your git repository and invoke the build script by giving it a destination
-directory and an optional build number:
-
- $ mkdir ~/mysdk
- $ cd ~/my-android-git # <-- this is where you did your "repo sync"
- $ development/tools/eclipse/scripts/build_server.sh ~/mysdk $USER
-
-The first argument is the destination directory. It must be absolute. Do not
-give a relative destination directory such as "../mysdk". This will make the
-Eclipse build fail with a cryptic message:
-
- BUILD SUCCESSFUL
- Total time: 1 minute 5 seconds
- **** Package in ../mysdk
- Error: Build failed to produce ../mysdk/android-eclipse
- Aborting
-
-The second argument is the build "number". The example used "$USER" but it
-really is a free identifier of your choice. It cannot contain spaces nor
-periods (dashes are ok.) If the build number is missing, a build timestamp will
-be used instead in the filename.
-
-The build should take something like 5-10 minutes.
-
-
-When the build succeeds, you'll see something like this at the end of the
-output:
-
- ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zip
-or
- ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zip
-
-When you load the plugin in Eclipse, its feature and plugin name will look like
-"com.android.ide.eclipse.adt_0.9.0.v200903272328-<buildnumber>.jar". The
-internal plugin ID is always composed of the package, the build timestamp and
-then your own build identifier (a.k.a. the "build number"), if provided. This
-means successive builds with the same build identifier are incremental and
-Eclipse will know how to update to more recent ones.
-
-
-
--------------
-5- Conclusion
--------------
-
-This completes the howto guide on building your own SDK and ADT plugin.
-Feedback is welcome on the public Android Open Source forums:
- http://source.android.com/discuss
-
-If you are upgrading from a pre-cupcake to a cupcake or later SDK please read
-the accompanying document "howto_use_cupcake_sdk.txt".
-
--end-
-
diff --git a/docs/howto_use_cupcake_sdk.txt b/docs/howto_use_cupcake_sdk.txt
deleted file mode 100644
index b131230..0000000
--- a/docs/howto_use_cupcake_sdk.txt
+++ /dev/null
@@ -1,371 +0,0 @@
-Subject: How to build use a Cupcake Android SDK & ADT Eclipse plugin.
-Date: 2009/03/27
-
-
-Table of content:
- 0- License
- 1- Foreword
- 2- Installation steps
- 3- For Eclipse users
- 4- For Ant users
- 5- Targets, AVDs, Emulator changes
- 6- Conclusion
-
-
-
-----------
-0- License
-----------
-
- 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.
-
-
-
------------
-1- Foreword
------------
-
-This explains how to use the "new" SDK provided starting with cupcake.
-The new SDK has as a different structure than the pre-cupcake ones.
-
-This means:
-- The new SDK does not work with older Eclipse plugins (ADT 0.8)
-- The old SDKs (1.0 and 1.1) do NOT work with this Eclipse plugin (ADT 0.9)
-
-
-
-----------------------
-2- Installation steps
-----------------------
-
-First you will need to grab the zip of the SDK for your platform or build it
-yourself. Please refer to the accompanying document "howto_build_SDK.txt" if
-needed.
-
-Unzip the SDK somewhere. We'll call that directory "SDK" in command-line
-examples.
-
-Grab the new ADT Eclipse plugin zip file or build it yourself. Keep it
-somewhere (no need to unzip).
-
-
-
---------------------
-3- For Eclipse users
---------------------
-
-
-Below we'll explain how you can upgrade your Eclipse install to the new plugin.
-If you already have a working Eclipse installation with a pre-0.9 ADT,
-another suggestion is to simply install a new copy of Eclipse and create a
-new empty workspace. This is just a precaution. The update process should
-be otherwise harmless.
-
-
-
-A- Setting up Eclipse
----------------------
-
-- You must have Eclipse 3.3 or 3.4. Eclipse 3.2 is not longer supported.
-
- There are many flavors, or "editions", of Eclipse. To develop, we'd recommend
- the "Java" edition. The "RCP" one is totally suitable too. The J2EE one is
- probably overkill.
-
-
-- If updating an existing Eclipse, use Help > Software Update and please
- uninstall the two features of the previous ADT: the "editors" feature and the
- ADT feature itself.
-
- => If you don't you will get a conflict on editors when installing
- the new one.
-
-- Using Help > Software Update, add a new "archived site", point it to the new
- adt.zip (e.g. android-eclipse-<some-id>.zip), select the "Install" button at
- the top right and restart eclipse as needed.
-
-- After it restarts, please use Window > Preferences > Android and select
- the new SDK folder that you unzipped in paragraph 2.
-
-
-
-B- Updating older projects
---------------------------
-
-If you have pre-0.9 projects in your Eclipse workspace, or if you import them
-from your code repository, these projects will fail to build at first.
-
-First right-click on the project and select "Properties":
-
-- In the properties, open the Android panel and select the platform to use.
- The SDK comes with a 1.5 platform. Select it and close the properties panel.
-- Do a clean build.
-
-
-The new plugin creates a "gen" folder in your project where it puts the R.java
-and all automatically generated AIDL java files. If you get an error such as:
-
- "The type R is already defined"
-
-that means you must check to see if your old R.java or your old auto-generated
-AIDL Java files are still present in the "src" folder. If yes, remove them.
-
-Note: this does not apply to your own hand-crafted parcelable AIDL java files.
-
-Note: if you want to reuse the project with an older Eclipse ADT install,
- simply remove the "gen" folder from the build path of the project.
-
-
-C- New Wizards
---------------
-
-The "New Android Project" wizard has been expanded to use the multi-platform
-capabilities of the new SDK.
-
-There is now a "New XML File" wizard that lets you create skeleton XML resource
-files for your Android projects. This makes it easier to create a new layout, a
-new strings file, etc.
-
-Both wizard are available via File > New... as well as new icons in the main
-icon bar. If you do not see the new icons, you may need to use Window > Reset
-Perspective on your Java perspective.
-
-
-Please see step 5 "Emulator changes" below for important details on how to run
-the emulator.
-
-
-
-----------------
-4- For Ant users
-----------------
-
-
-A- build.xml has changed
-------------------------
-
-You must re-create your build.xml file.
-
-First if you had customized your build.xml, make a copy of it:
-
- $ cd my-project
- $ cp build.xml build.xml.old
-
-
-Then use the new "android" tool to create a new build.xml:
-
- $ SDK/tools/android update project --path /path/to/my-project
-
-or
-
- $ cd my-project
- $ SDK/tools/android update project --path .
-
-
-A "gen" folder will be created the first time you build and your R.java and
-your AIDL Java files will be generated in this "gen" folder. You MUST remove
-the old R.java and old auto-generated AIDL java files manually. (Note: this
-does not apply to your own hand-crafted parcelabe AIDL java files.)
-
-
-B- Where is activitycreator?
-----------------------------
-
-Note that the "activitycreator" tool has been replaced by the new "android"
-tool too. Example of how to create a new Ant project:
-
- $ SDK/tools/android create project --path /path/to/my/project --name ProjectName
- --package com.mycompany.myapp --activity MyActivityClass
- --target 1 --mode activity
-
-
-Please see paragraph 5 below for important details on how to run the emulator
-and the meaning of that "--target 1" parameter.
-
-
-
-----------------------------------
-5- Targets, AVDs, Emulator changes
-----------------------------------
-
-This applies to BOTH Eclipse and Ant users.
-
-One major change with the emulator is that now you must pre-create an "Android
-Virtual Device" (a.k.a "AVD") before you run the emulator.
-
-
-
-A- What is an AVD and why do I need one?
-----------------------------------------
-
-What is an "AVD"? If you forget, just run:
-
- $ SDK/tools/emulator -help-virtual-device
-
- An Android Virtual Device (AVD) models a single virtual device running the
- Android platform that has, at least, its own kernel, system image and data
- partition.
-
-There is a lot more explanation given by the emulator. Please run the help
-command given above to read the rest.
-
-The bottom line is that you can create many emulator configurations, or "AVDs",
-each with their own system image and most important each with their own user
-data and SD card data. Then you tell Eclipse or the emulator which one to use
-to debug or run your applications.
-
-
-Note for Eclipse users: eventually there will be a user interface to do all of
-these operations. For right now, please use the command line interface.
-
-
-B- Listing targets and AVDs
----------------------------
-
-There is a new tool called "android" in the SDK that lets you know which
-"target" and AVDs you can use.
-
-A target is a specific version of Android that you can use. By default the SDK
-comes with an "Android 1.5" target, codenamed "cupcake". In the future there
-will be more versions of Android to use, e.g. "Android 2.0" or specific add-ons
-provided by hardware manufacturers. When you want to run an emulator, you need
-to specify a given flavor of Android: this is the "target".
-
-
-To learn about available targets in your SDK, use this command:
-
- $ SDK/tools/android list targets
-
-This will give you an output such as:
-
- Available Android targets:
- [1] Android 1.5
- API level: 3
- Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
-
-Note the "[1]". Later you will need to reference this as "--target 1" on the
-command line.
-
-
-Similarly you can list the available AVDs:
-
- $ SDK/tools/android list avds
-
-Which might output something as:
-
- Available Android Virtual Devices:
- Name: my_avd
- Path: C:\Users\<username>\.android\avd\my_avd.avd
- Target: Android 1.5 (API level 3)
- Skin: 320x480
- Sdcard: 16M
-
-
-
-C- Creating an AVD
-------------------
-
-To create a configuration:
-
- $ SDK/tools/android create avd --name my_avd_name --target 1
-
-
-where "target 1" is the index of a target listed by "android list targets".
-
-The AVD name is purely an identifier used to refer to the AVD later.
-Since it is used as directory name, please avoid using shell or path specific
-characters.
-
-To learn the various options available when creating an AVD, simply type:
-
- $ SDK/tools/android create avd
-
-The android tool will automatically print an explanation of required arguments.
-
-
-
-D- Invoking an AVD from the command-line
-----------------------------------------
-
-To use this AVD in the emulator from the command-line, type:
-
- $ SDK/tools/emulator @my_avd_name
-
-
-For more options, please consult the emulator help:
-
- $ SDK/tools/emulator -help-virtual-device
-
-
-
-E- Invoking an AVD from Eclipse
--------------------------------
-
-By default Android projects in Eclipse have an "automatic target" mode.
-In this mode, when a project is deployed in debug or run, it checks:
-- If there's one running device or emulator, this is used for deployment.
-- If there's more than one running device or emulator, a "device chooser" is
- shown to let the user select which one to use.
-- If there are no running devices or emulators, ADT looks at available AVDs.
- If one matches the project configuration (e.g. same API level), it is
- automatically used.
-
-Alternatively you can edit the "launch configuration" on your Android project
-in Eclipse by selecting the menu Run > Run Configurations. In the "target" tab
-of the configuration, you can choose:
-
-- Manual or automatic targetting mode.
-
- - Manual means to always present the device chooser.
- - Automatic is the behavior explained above.
-
-- In automatic mode, which AVD is preferred. If none is selected, the first
- suitable is used.
-
-
-F- AVD concurrency
-------------------
-
-You can no longer run several emulators at the same time on the same
-configuration.
-
-Before this used to put the second or more emulators in a transient read-only
-mode that would not save user data.
-
-Now you just need to create as many AVDs as you want to run emulators.
-
-For example if you are working on a client/server application for Android, you
-could create a "client" AVD and a "server" AVD then run them both at once. The
-emulator window will show you the AVD name so that you know which one is which.
-
-Example:
-
- $ SDK/tools/android create avd --name client --target 1 --sdcard 16M --skin HVGA
- $ SDK/tools/android create avd --name server --target 1 --sdcard 32M --skin HVGA-P
- $ SDK/tools/emulator @server &
- $ SDK/tools/emulator @client &
-
-
-
--------------
-6- Conclusion
--------------
-
-This completes the howto guide on how to use the new Cupcake SDK.
-Feedback is welcome on the public Android Open Source forums:
- http://source.android.com/discuss
-
--end-
-
diff --git a/ide/eclipse/.classpath b/ide/eclipse/.classpath
index d355052..a6eca24 100644
--- a/ide/eclipse/.classpath
+++ b/ide/eclipse/.classpath
@@ -10,12 +10,14 @@
<classpathentry kind="src" path="packages/apps/Contacts/src"/>
<classpathentry kind="src" path="packages/apps/DeskClock/src"/>
<classpathentry kind="src" path="packages/apps/Email/src"/>
+ <classpathentry kind="src" path="packages/apps/Gallery3D/src"/>
<classpathentry kind="src" path="packages/apps/HTMLViewer/src"/>
<classpathentry kind="src" path="packages/apps/Launcher2/src"/>
<classpathentry kind="src" path="packages/apps/Mms/src"/>
<classpathentry kind="src" path="packages/apps/PackageInstaller/src"/>
<classpathentry kind="src" path="packages/apps/Phone/src"/>
<classpathentry kind="src" path="packages/apps/QuickSearchBox/src"/>
+ <classpathentry kind="src" path="packages/apps/Provision/src"/>
<classpathentry kind="src" path="packages/apps/Settings/src"/>
<classpathentry kind="src" path="packages/apps/SoundRecorder/src"/>
<classpathentry kind="src" path="packages/apps/Stk/src"/>
diff --git a/pdk/README b/pdk/README
index d9f8996..0acb1eb 100644
--- a/pdk/README
+++ b/pdk/README
@@ -11,7 +11,7 @@
If that doesn't work, go through the instructions on
- http://source.android.com/download again.
+ http://source.android.com/source/download.html again.
2) from the root
diff --git a/pdk/docs/source/git-repo.jd b/pdk/docs/source/git-repo.jd
index ac7fd37..245d7d9 100644
--- a/pdk/docs/source/git-repo.jd
+++ b/pdk/docs/source/git-repo.jd
@@ -288,14 +288,13 @@
Getting started with the Android source code:
<ul>
- <li><a href="http://source.android.com/download">Get source</a></li>
- <li><a href="http://source.android.com/submit-patches/code-style-guide">Code Style Guide</a></li>
+ <li><a href="http://source.android.com/source/download.html">Get source</a></li>
+ <li><a href="http://source.android.com/source/code-style.html">Code Style Guide</a></li>
</ul>
Repo and Git resources:
<ul>
- <li><a href="http://source.android.com/download/using-repo#TOC-Git-and-Repo-cheatsheet">Git and Repo cheat sheet</a></li>
- <li><a href="http://source.android.com/download/using-repo">Using Repo and Git</a></li>
+ <li><a href="http://source.android.com/source/git-repo.html">Using Repo and Git</a></li>
<li>The <a href="http://book.git-scm.com/">Git Community Book</a> maintained by Scott Chacon</li>
<li><a href="http://git.or.cz/gitwiki/FrontPage">GitWiki</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/">Git Manual Page</a></li>
@@ -304,7 +303,7 @@
Documentation on specific tasks:
<ul>
- <li><a href="http://source.android.com/documentation/building-for-dream">Building for an Android Developer Phone</a></li>
+ <li><a href="http://source.android.com/source/building-dream.html">Building for an Android Developer Phone</a></li>
</ul>
-->
diff --git a/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java b/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java
index 78b1fd7..39f24b6 100644
--- a/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java
+++ b/samples/ApiDemos/src/com/example/android/apis/ApiDemos.java
@@ -52,8 +52,8 @@
getListView().setTextFilterEnabled(true);
}
- protected List getData(String prefix) {
- List<Map> myData = new ArrayList<Map>();
+ protected List<Map<String, Object>> getData(String prefix) {
+ List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
@@ -107,10 +107,11 @@
return myData;
}
- private final static Comparator<Map> sDisplayNameComparator = new Comparator<Map>() {
+ private final static Comparator<Map<String, Object>> sDisplayNameComparator =
+ new Comparator<Map<String, Object>>() {
private final Collator collator = Collator.getInstance();
- public int compare(Map map1, Map map2) {
+ public int compare(Map<String, Object> map1, Map<String, Object> map2) {
return collator.compare(map1.get("title"), map2.get("title"));
}
};
@@ -128,7 +129,7 @@
return result;
}
- protected void addItem(List<Map> data, String name, Intent intent) {
+ protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("title", name);
temp.put("intent", intent);
@@ -136,11 +137,11 @@
}
@Override
+ @SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
- Map map = (Map) l.getItemAtPosition(position);
+ Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
Intent intent = (Intent) map.get("intent");
startActivity(intent);
}
-
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
index 90831f5..5ba41c4 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java
@@ -22,7 +22,6 @@
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;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilter.java b/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilter.java
index bb843e5..d5b3deb 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilter.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilter.java
@@ -20,8 +20,6 @@
// class is in a sub-package.
import android.app.Activity;
import android.content.ComponentName;
-import android.content.Context;
-import android.os.RemoteException;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
@@ -29,7 +27,6 @@
import com.example.android.apis.R;
-
/**
* Front-end for launching {@link ContactsFilterInstrumentation} example
* instrumentation class.
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilterInstrumentation.java b/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilterInstrumentation.java
index 04bb671..6895363 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilterInstrumentation.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ContactsFilterInstrumentation.java
@@ -23,8 +23,6 @@
import android.os.Bundle;
import android.util.Log;
-import java.util.Map;
-
/**
* This is an example implementation of the {@link android.app.Instrumentation}
* class, allowing you to run tests against application code. The
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/DefaultValues.java b/samples/ApiDemos/src/com/example/android/apis/app/DefaultValues.java
index 35bdf13..494a2ea 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/DefaultValues.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/DefaultValues.java
@@ -19,7 +19,6 @@
import com.example.android.apis.ApiDemosApplication;
import com.example.android.apis.R;
-import android.app.Application;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
index c7a2dfb..7e061ed 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
@@ -49,9 +49,9 @@
static final String ACTION_BACKGROUND = "com.example.android.apis.BACKGROUND";
// BEGIN_INCLUDE(foreground_compatibility)
- private static final Class[] mStartForegroundSignature = new Class[] {
+ private static final Class<?>[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
- private static final Class[] mStopForegroundSignature = new Class[] {
+ private static final Class<?>[] mStopForegroundSignature = new Class[] {
boolean.class};
private NotificationManager mNM;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LocalSample.java b/samples/ApiDemos/src/com/example/android/apis/app/LocalSample.java
index 1bb26e9..0e4b66e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LocalSample.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LocalSample.java
@@ -20,8 +20,6 @@
// class is in a sub-package.
import android.app.Activity;
import android.content.ComponentName;
-import android.content.Context;
-import android.os.RemoteException;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
@@ -29,7 +27,6 @@
import com.example.android.apis.R;
-
/**
* Front-end for launching {@link LocalSampleInstrumentation} example
* instrumentation class.
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LocalSampleInstrumentation.java b/samples/ApiDemos/src/com/example/android/apis/app/LocalSampleInstrumentation.java
index e0f6163..aabfec3 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LocalSampleInstrumentation.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LocalSampleInstrumentation.java
@@ -23,8 +23,6 @@
import android.os.Bundle;
import android.util.Log;
-import java.util.Map;
-
/**
* This is an example implementation of the {@link android.app.Instrumentation}
* class demonstrating instrumentation against one of this application's sample
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java b/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
index 859969c..0c7c108 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LocalService.java
@@ -45,6 +45,10 @@
public class LocalService extends Service {
private NotificationManager mNM;
+ // Unique Identification Number for the Notification.
+ // We use it on Notification start, and to cancel it.
+ private int NOTIFICATION = R.string.local_service_started;
+
/**
* Class for clients to access. Because we know this service always
* runs in the same process as its clients, we don't need to deal with
@@ -75,7 +79,7 @@
@Override
public void onDestroy() {
// Cancel the persistent notification.
- mNM.cancel(R.string.local_service_started);
+ mNM.cancel(NOTIFICATION);
// Tell the user we stopped.
Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT).show();
@@ -110,8 +114,7 @@
text, contentIntent);
// Send the notification.
- // We use a layout id because it is a unique number. We use it later to cancel.
- mNM.notify(R.string.local_service_started, notification);
+ mNM.notify(NOTIFICATION, notification);
}
}
//END_INCLUDE(service)
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/NotificationDisplay.java b/samples/ApiDemos/src/com/example/android/apis/app/NotificationDisplay.java
index a6c20ea..25b5d56 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/NotificationDisplay.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/NotificationDisplay.java
@@ -24,14 +24,11 @@
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
-import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
-import android.widget.LinearLayout;
import android.widget.RelativeLayout;
-
/**
* Activity used by StatusBarNotification to show the notification to the user.
*/
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/NotifyingController.java b/samples/ApiDemos/src/com/example/android/apis/app/NotifyingController.java
index a0de699..b8b4e3f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/NotifyingController.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/NotifyingController.java
@@ -21,14 +21,12 @@
import com.example.android.apis.R;
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;
-
/**
* Controller to start and stop a service. The serivce will update a status bar
* notification every 5 seconds for a minute.
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/NotifyingService.java b/samples/ApiDemos/src/com/example/android/apis/app/NotifyingService.java
index e580978..3b8139f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/NotifyingService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/NotifyingService.java
@@ -30,7 +30,6 @@
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
-import android.widget.RemoteViews;
/**
* This is an example of service that will update its status bar balloon
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromXml.java b/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromXml.java
index 23461c6..63bbac2 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromXml.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromXml.java
@@ -18,9 +18,7 @@
import com.example.android.apis.R;
-import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.Preference;
import android.preference.PreferenceActivity;
public class PreferencesFromXml extends PreferenceActivity {
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/QuickContactsDemo.java b/samples/ApiDemos/src/com/example/android/apis/app/QuickContactsDemo.java
index 1ee5742..004e568 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/QuickContactsDemo.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/QuickContactsDemo.java
@@ -75,8 +75,6 @@
@Override
public void bindView(View view, Context context, Cursor cursor) {
final ContactListItemCache cache = (ContactListItemCache) view.getTag();
- TextView nameView = cache.nameView;
- QuickContactBadge photoView = cache.photoView;
// Set the name
cursor.copyStringToBuffer(SUMMARY_NAME_COLUMN_INDEX, cache.nameBuffer);
int size = cache.nameBuffer.sizeCopied;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.java b/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.java
index 4e248b9..22ae7f4 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.java
@@ -18,8 +18,6 @@
// Need the following import to get access to the app resources, since this
// class is in a sub-package.
-import java.util.Map;
-
import com.example.android.apis.R;
import android.app.Activity;
@@ -31,8 +29,6 @@
import android.widget.Button;
import android.widget.TextView;
-import java.util.Map;
-
/**
* Shows how an activity can send data to its launching activity when done.y.
* <p>This can be used, for example, to implement a dialog alowing the user to
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/RedirectGetter.java b/samples/ApiDemos/src/com/example/android/apis/app/RedirectGetter.java
index 982317c..c96e1bb 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/RedirectGetter.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/RedirectGetter.java
@@ -32,8 +32,11 @@
*/
public class RedirectGetter extends Activity
{
+ private String mTextPref;
+ private TextView mText;
+
@Override
- protected void onCreate(Bundle savedInstanceState)
+ protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
@@ -45,9 +48,12 @@
// The text being set.
mText = (TextView)findViewById(R.id.text);
+
+ // Display the stored values, or if not stored initialize with an empty String
+ loadPrefs();
}
- private final boolean loadPrefs()
+ private final void loadPrefs()
{
// Retrieve the current redirect values.
// NOTE: because this preference is shared between multiple
@@ -58,10 +64,9 @@
mTextPref = preferences.getString("text", null);
if (mTextPref != null) {
mText.setText(mTextPref);
- return true;
+ } else {
+ mText.setText("");
}
-
- return false;
}
private OnClickListener mApplyListener = new OnClickListener()
@@ -79,8 +84,4 @@
finish();
}
};
-
- private String mTextPref;
- TextView mText;
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/SetWallpaperActivity.java b/samples/ApiDemos/src/com/example/android/apis/app/SetWallpaperActivity.java
index 8630b1c..f3d4ffb 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/SetWallpaperActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/SetWallpaperActivity.java
@@ -29,7 +29,6 @@
import android.graphics.drawable.Drawable;
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;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/WallpaperActivity.java b/samples/ApiDemos/src/com/example/android/apis/app/WallpaperActivity.java
index 8d7f5a1..7b5eea2 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/WallpaperActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/WallpaperActivity.java
@@ -22,7 +22,6 @@
import android.app.Activity;
import android.os.Bundle;
-import android.view.WindowManager;
/**
* <h3>Wallpaper Activity</h3>
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java b/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
index 8fff231..90d3450 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/AlphaBitmap.java
@@ -18,15 +18,12 @@
import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
import java.io.InputStream;
-import java.io.ByteArrayOutputStream;
public class AlphaBitmap extends GraphicsActivity {
@@ -35,23 +32,23 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Bitmap mBitmap;
private Bitmap mBitmap2;
private Bitmap mBitmap3;
private Shader mShader;
-
+
private static void drawIntoBitmap(Bitmap bm) {
float x = bm.getWidth();
float y = bm.getHeight();
Canvas c = new Canvas(bm);
Paint p = new Paint();
p.setAntiAlias(true);
-
+
p.setAlpha(0x80);
c.drawCircle(x/2, y/2, x/2, p);
-
+
p.setAlpha(0x30);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
p.setTextSize(60);
@@ -59,28 +56,28 @@
Paint.FontMetrics fm = p.getFontMetrics();
c.drawText("Alpha", x/2, (y-fm.ascent)/2, p);
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
InputStream is = context.getResources().openRawResource(R.drawable.app_sample_code);
mBitmap = BitmapFactory.decodeStream(is);
mBitmap2 = mBitmap.extractAlpha();
mBitmap3 = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
drawIntoBitmap(mBitmap3);
-
+
mShader = new LinearGradient(0, 0, 100, 70, new int[] {
Color.RED, Color.GREEN, Color.BLUE },
null, Shader.TileMode.MIRROR);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
Paint p = new Paint();
float y = 10;
-
+
p.setColor(Color.RED);
canvas.drawBitmap(mBitmap, 10, y, p);
y += mBitmap.getHeight() + 10;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java b/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java
index 279b588..330924e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawable.java
@@ -23,23 +23,23 @@
import android.view.animation.Transformation;
public class AnimateDrawable extends ProxyDrawable {
-
+
private Animation mAnimation;
private Transformation mTransformation = new Transformation();
public AnimateDrawable(Drawable target) {
super(target);
}
-
+
public AnimateDrawable(Drawable target, Animation animation) {
super(target);
mAnimation = animation;
}
-
+
public Animation getAnimation() {
return mAnimation;
}
-
+
public void setAnimation(Animation anim) {
mAnimation = anim;
}
@@ -47,11 +47,11 @@
public boolean hasStarted() {
return mAnimation != null && mAnimation.hasStarted();
}
-
+
public boolean hasEnded() {
return mAnimation == null || mAnimation.hasEnded();
}
-
+
@Override
public void draw(Canvas canvas) {
Drawable dr = getProxy();
@@ -69,4 +69,4 @@
}
}
}
-
+
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawables.java b/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawables.java
index 7c9473d..0398fbf 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawables.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/AnimateDrawables.java
@@ -18,14 +18,14 @@
import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
-import android.graphics.*;
-import android.graphics.drawable.*;
-import android.view.animation.*;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
public class AnimateDrawables extends GraphicsActivity {
@@ -34,7 +34,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private AnimateDrawable mDrawable;
@@ -45,17 +45,18 @@
Drawable dr = context.getResources().getDrawable(R.drawable.beach);
dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
-
+
Animation an = new TranslateAnimation(0, 100, 0, 200);
an.setDuration(2000);
an.setRepeatCount(-1);
an.initialize(10, 10, 10, 10);
-
+
mDrawable = new AnimateDrawable(dr, an);
an.startNow();
}
-
- @Override protected void onDraw(Canvas canvas) {
+
+ @Override
+ protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
mDrawable.draw(canvas);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Arcs.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Arcs.java
index ff8b38b..1bd07f9 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Arcs.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Arcs.java
@@ -20,7 +20,6 @@
// class is in a sub-package.
//import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -33,7 +32,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint[] mPaints;
private Paint mFramePaint;
@@ -43,27 +42,27 @@
private float mStart;
private float mSweep;
private int mBigIndex;
-
+
private static final float SWEEP_INC = 2;
private static final float START_INC = 15;
-
+
public SampleView(Context context) {
super(context);
-
+
mPaints = new Paint[4];
mUseCenters = new boolean[4];
mOvals = new RectF[4];
-
+
mPaints[0] = new Paint();
mPaints[0].setAntiAlias(true);
mPaints[0].setStyle(Paint.Style.FILL);
mPaints[0].setColor(0x88FF0000);
mUseCenters[0] = false;
-
+
mPaints[1] = new Paint(mPaints[0]);
mPaints[1].setColor(0x8800FF00);
mUseCenters[1] = true;
-
+
mPaints[2] = new Paint(mPaints[0]);
mPaints[2].setStyle(Paint.Style.STROKE);
mPaints[2].setStrokeWidth(4);
@@ -73,36 +72,36 @@
mPaints[3] = new Paint(mPaints[2]);
mPaints[3].setColor(0x88888888);
mUseCenters[3] = true;
-
+
mBigOval = new RectF(40, 10, 280, 250);
-
+
mOvals[0] = new RectF( 10, 270, 70, 330);
mOvals[1] = new RectF( 90, 270, 150, 330);
mOvals[2] = new RectF(170, 270, 230, 330);
mOvals[3] = new RectF(250, 270, 310, 330);
-
+
mFramePaint = new Paint();
mFramePaint.setAntiAlias(true);
mFramePaint.setStyle(Paint.Style.STROKE);
mFramePaint.setStrokeWidth(0);
}
-
+
private void drawArcs(Canvas canvas, RectF oval, boolean useCenter,
Paint paint) {
canvas.drawRect(oval, mFramePaint);
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
-
+
drawArcs(canvas, mBigOval, mUseCenters[mBigIndex],
mPaints[mBigIndex]);
-
+
for (int i = 0; i < 4; i++) {
drawArcs(canvas, mOvals[i], mUseCenters[i], mPaints[i]);
}
-
+
mSweep += SWEEP_INC;
if (mSweep > 360) {
mSweep -= 360;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.java b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.java
index 88f0c1d..6a8b542 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.java
@@ -18,36 +18,36 @@
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.*;
-import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
public class BitmapDecode extends GraphicsActivity {
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Bitmap mBitmap;
private Bitmap mBitmap2;
private Bitmap mBitmap3;
private Bitmap mBitmap4;
private Drawable mDrawable;
-
+
private Movie mMovie;
private long mMovieStart;
-
+
+ //Set to false to use decodeByteArray
+ private static final boolean DECODE_STREAM = true;
+
private static byte[] streamToBytes(InputStream is) {
ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
@@ -60,33 +60,33 @@
}
return os.toByteArray();
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
java.io.InputStream is;
is = context.getResources().openRawResource(R.drawable.beach);
-
+
BitmapFactory.Options opts = new BitmapFactory.Options();
Bitmap bm;
-
+
opts.inJustDecodeBounds = true;
bm = BitmapFactory.decodeStream(is, null, opts);
-
+
// now opts.outWidth and opts.outHeight are the dimension of the
// bitmap, even though bm is null
-
+
opts.inJustDecodeBounds = false; // this will request the bm
opts.inSampleSize = 4; // scaled down by 4
bm = BitmapFactory.decodeStream(is, null, opts);
-
+
mBitmap = bm;
-
+
// decode an image with transparency
is = context.getResources().openRawResource(R.drawable.frog);
mBitmap2 = BitmapFactory.decodeStream(is);
-
+
// create a deep copy of it using getPixels() into different configs
int w = mBitmap2.getWidth();
int h = mBitmap2.getHeight();
@@ -96,32 +96,34 @@
Bitmap.Config.ARGB_8888);
mBitmap4 = Bitmap.createBitmap(pixels, 0, w, w, h,
Bitmap.Config.ARGB_4444);
-
+
mDrawable = context.getResources().getDrawable(R.drawable.button);
mDrawable.setBounds(150, 20, 300, 100);
-
+
is = context.getResources().openRawResource(R.drawable.animated_gif);
- if (true) {
+
+ if (DECODE_STREAM) {
mMovie = Movie.decodeStream(is);
} else {
byte[] array = streamToBytes(is);
mMovie = Movie.decodeByteArray(array, 0, array.length);
}
}
-
- @Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(0xFFCCCCCC);
-
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawColor(0xFFCCCCCC);
+
Paint p = new Paint();
p.setAntiAlias(true);
-
+
canvas.drawBitmap(mBitmap, 10, 10, null);
canvas.drawBitmap(mBitmap2, 10, 170, null);
canvas.drawBitmap(mBitmap3, 110, 170, null);
canvas.drawBitmap(mBitmap4, 210, 170, null);
-
+
mDrawable.draw(canvas);
-
+
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) { // first time
mMovieStart = now;
@@ -140,4 +142,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.java b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.java
index 4d48a1e..12c79ca 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.java
@@ -31,16 +31,16 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private static final int WIDTH = 20;
private static final int HEIGHT = 20;
private static final int COUNT = (WIDTH + 1) * (HEIGHT + 1);
-
+
private final Bitmap mBitmap;
private final float[] mVerts = new float[COUNT*2];
private final float[] mOrig = new float[COUNT*2];
-
+
private final Matrix mMatrix = new Matrix();
private final Matrix mInverse = new Matrix();
@@ -55,7 +55,7 @@
mBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.beach);
-
+
float w = mBitmap.getWidth();
float h = mBitmap.getHeight();
// construct our mesh
@@ -63,17 +63,17 @@
for (int y = 0; y <= HEIGHT; y++) {
float fy = h * y / HEIGHT;
for (int x = 0; x <= WIDTH; x++) {
- float fx = w * x / WIDTH;
+ float fx = w * x / WIDTH;
setXY(mVerts, index, fx, fy);
setXY(mOrig, index, fx, fy);
index += 1;
}
}
-
+
mMatrix.setTranslate(10, 10);
mMatrix.invert(mInverse);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
@@ -81,7 +81,7 @@
canvas.drawBitmapMesh(mBitmap, WIDTH, HEIGHT, mVerts, 0,
null, 0, null);
}
-
+
private void warp(float cx, float cy) {
final float K = 10000;
float[] src = mOrig;
@@ -94,7 +94,7 @@
float dd = dx*dx + dy*dy;
float d = FloatMath.sqrt(dd);
float pull = K / (dd + 0.000001f);
-
+
pull /= (d + 0.000001f);
// android.util.Log.d("skia", "index " + i + " dist=" + d + " pull=" + pull);
@@ -114,7 +114,7 @@
@Override public boolean onTouchEvent(MotionEvent event) {
float[] pt = { event.getX(), event.getY() };
mInverse.mapPoints(pt);
-
+
int x = (int)pt[0];
int y = (int)pt[1];
if (mLastWarpX != x || mLastWarpY != y) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapPixels.java b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapPixels.java
index 88717bc..e9b2167 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapPixels.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapPixels.java
@@ -16,32 +16,26 @@
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.*;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
public class BitmapPixels extends GraphicsActivity {
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Bitmap mBitmap1;
private Bitmap mBitmap2;
private Bitmap mBitmap3;
- private Bitmap mBitmap4;
// access the red component from a premultiplied color
private static int getR32(int c) { return (c >> 0) & 0xFF; }
@@ -67,7 +61,7 @@
private static short pack4444(int r, int g, int b, int a) {
return (short)((a << 0) | ( b << 4) | (g << 8) | (r << 12));
}
-
+
private static int mul255(int c, int a) {
int prod = c * a + 128;
return (prod + (prod >> 8)) >> 8;
@@ -88,7 +82,7 @@
// now pack it in the correct order
return pack8888(r, g, b, a);
}
-
+
private static void makeRamp(int from, int to, int n,
int[] ramp8888, short[] ramp565,
short[] ramp4444) {
@@ -113,7 +107,7 @@
a += da;
}
}
-
+
private static IntBuffer makeBuffer(int[] src, int n) {
IntBuffer dst = IntBuffer.allocate(n*n);
for (int i = 0; i < n; i++) {
@@ -122,7 +116,7 @@
dst.rewind();
return dst;
}
-
+
private static ShortBuffer makeBuffer(short[] src, int n) {
ShortBuffer dst = ShortBuffer.allocate(n*n);
for (int i = 0; i < n; i++) {
@@ -131,31 +125,31 @@
dst.rewind();
return dst;
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
final int N = 100;
int[] data8888 = new int[N];
short[] data565 = new short[N];
short[] data4444 = new short[N];
-
+
makeRamp(premultiplyColor(Color.RED), premultiplyColor(Color.GREEN),
N, data8888, data565, data4444);
-
+
mBitmap1 = Bitmap.createBitmap(N, N, Bitmap.Config.ARGB_8888);
mBitmap2 = Bitmap.createBitmap(N, N, Bitmap.Config.RGB_565);
mBitmap3 = Bitmap.createBitmap(N, N, Bitmap.Config.ARGB_4444);
-
+
mBitmap1.copyPixelsFromBuffer(makeBuffer(data8888, N));
mBitmap2.copyPixelsFromBuffer(makeBuffer(data565, N));
mBitmap3.copyPixelsFromBuffer(makeBuffer(data4444, N));
}
-
+
@Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(0xFFCCCCCC);
-
+ canvas.drawColor(0xFFCCCCCC);
+
int y = 10;
canvas.drawBitmap(mBitmap1, 10, y, null);
y += mBitmap1.getHeight() + 10;
@@ -165,4 +159,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Clipping.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Clipping.java
index cf83597..42f8be3 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Clipping.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Clipping.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,7 +28,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint;
private Path mPath;
@@ -37,46 +36,46 @@
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(6);
mPaint.setTextSize(16);
mPaint.setTextAlign(Paint.Align.RIGHT);
-
+
mPath = new Path();
}
-
+
private void drawScene(Canvas canvas) {
canvas.clipRect(0, 0, 100, 100);
-
+
canvas.drawColor(Color.WHITE);
-
+
mPaint.setColor(Color.RED);
canvas.drawLine(0, 0, 100, 100, mPaint);
-
+
mPaint.setColor(Color.GREEN);
canvas.drawCircle(30, 70, 30, mPaint);
-
+
mPaint.setColor(Color.BLUE);
canvas.drawText("Clipping", 100, 30, mPaint);
}
-
+
@Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(Color.GRAY);
+ canvas.drawColor(Color.GRAY);
canvas.save();
canvas.translate(10, 10);
drawScene(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 10);
canvas.clipRect(10, 10, 90, 90);
canvas.clipRect(30, 30, 70, 70, Region.Op.DIFFERENCE);
drawScene(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(10, 160);
mPath.reset();
@@ -85,21 +84,21 @@
canvas.clipPath(mPath, Region.Op.REPLACE);
drawScene(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 160);
canvas.clipRect(0, 0, 60, 60);
canvas.clipRect(40, 40, 100, 100, Region.Op.UNION);
drawScene(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(10, 310);
canvas.clipRect(0, 0, 60, 60);
canvas.clipRect(40, 40, 100, 100, Region.Op.XOR);
drawScene(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 310);
canvas.clipRect(0, 0, 60, 60);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorFilters.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorFilters.java
index 92d18ba..8eb60b5 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorFilters.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorFilters.java
@@ -23,18 +23,17 @@
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;
@@ -52,7 +51,7 @@
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);
}
@@ -61,7 +60,7 @@
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);
@@ -84,13 +83,13 @@
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,
@@ -106,10 +105,10 @@
PorterDuff.Mode.MULTIPLY,
};
mModeIndex = 0;
-
+
updateTitle();
}
-
+
private void swapPaintColors() {
if (mPaint.getColor() == 0xFF000000) {
mPaint.setColor(0xFFFFFFFF);
@@ -120,11 +119,11 @@
}
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;
@@ -134,15 +133,15 @@
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.drawColor(0xFFCCCCCC);
canvas.translate(8, 12);
for (int color : mColors) {
@@ -160,8 +159,6 @@
@Override
public boolean onTouchEvent(MotionEvent event) {
- float x = event.getX();
- float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
@@ -181,4 +178,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorMatrixSample.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorMatrixSample.java
index 19a0f7f..f438e73 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorMatrixSample.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorMatrixSample.java
@@ -18,35 +18,31 @@
import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.View;
public class ColorMatrixSample extends GraphicsActivity {
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- private ColorMatrix mCM = new ColorMatrix();
private Bitmap mBitmap;
- private float mSaturation;
private float mAngle;
-
+
public SampleView(Context context) {
super(context);
-
+
mBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.balloons);
}
-
+
private static void setTranslate(ColorMatrix cm, float dr, float dg,
float db, float da) {
cm.set(new float[] {
@@ -55,7 +51,7 @@
0, 0, 2, 0, db,
0, 0, 0, 1, da });
}
-
+
private static void setContrast(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
@@ -65,7 +61,7 @@
0, 0, scale, 0, translate,
0, 0, 0, 1, 0 });
}
-
+
private static void setContrastTranslateOnly(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
@@ -75,7 +71,7 @@
0, 0, 1, 0, translate,
0, 0, 0, 1, 0 });
}
-
+
private static void setContrastScaleOnly(ColorMatrix cm, float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
@@ -85,40 +81,40 @@
0, 0, scale, 0, 0,
0, 0, 0, 1, 0 });
}
-
+
@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
float x = 20;
float y = 20;
-
+
canvas.drawColor(Color.WHITE);
-
+
paint.setColorFilter(null);
canvas.drawBitmap(mBitmap, x, y, paint);
-
+
ColorMatrix cm = new ColorMatrix();
-
+
mAngle += 2;
if (mAngle > 180) {
mAngle = 0;
}
-
+
//convert our animated angle [-180...180] to a contrast value of [-1..1]
float contrast = mAngle / 180.f;
-
+
setContrast(cm, contrast);
paint.setColorFilter(new ColorMatrixColorFilter(cm));
canvas.drawBitmap(mBitmap, x + mBitmap.getWidth() + 10, y, paint);
-
+
setContrastScaleOnly(cm, contrast);
paint.setColorFilter(new ColorMatrixColorFilter(cm));
canvas.drawBitmap(mBitmap, x, y + mBitmap.getHeight() + 10, paint);
-
+
setContrastTranslateOnly(cm, contrast);
paint.setColorFilter(new ColorMatrixColorFilter(cm));
canvas.drawBitmap(mBitmap, x, y + 2*(mBitmap.getHeight() + 10),
paint);
-
+
invalidate();
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.java
index 7588180..1c7125f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.java
@@ -37,7 +37,7 @@
private Paint mCenterPaint;
private final int[] mColors;
private OnColorChangedListener mListener;
-
+
ColorPickerView(Context c, OnColorChangedListener l, int color) {
super(c);
mListener = l;
@@ -46,33 +46,33 @@
0xFFFFFF00, 0xFFFF0000
};
Shader s = new SweepGradient(0, 0, mColors, null);
-
+
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setShader(s);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(32);
-
+
mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCenterPaint.setColor(color);
mCenterPaint.setStrokeWidth(5);
}
-
+
private boolean mTrackingCenter;
private boolean mHighlightCenter;
- @Override
+ @Override
protected void onDraw(Canvas canvas) {
float r = CENTER_X - mPaint.getStrokeWidth()*0.5f;
-
+
canvas.translate(CENTER_X, CENTER_X);
-
- canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
+
+ canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
-
+
if (mTrackingCenter) {
int c = mCenterPaint.getColor();
mCenterPaint.setStyle(Paint.Style.STROKE);
-
+
if (mHighlightCenter) {
mCenterPaint.setAlpha(0xFF);
} else {
@@ -81,17 +81,17 @@
canvas.drawCircle(0, 0,
CENTER_RADIUS + mCenterPaint.getStrokeWidth(),
mCenterPaint);
-
+
mCenterPaint.setStyle(Paint.Style.FILL);
mCenterPaint.setColor(c);
}
}
-
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(CENTER_X*2, CENTER_Y*2);
}
-
+
private static final int CENTER_X = 100;
private static final int CENTER_Y = 100;
private static final int CENTER_RADIUS = 32;
@@ -108,11 +108,11 @@
}
return n;
}
-
+
private int ave(int s, int d, float p) {
return s + java.lang.Math.round(p * (d - s));
}
-
+
private int interpColor(int colors[], float unit) {
if (unit <= 0) {
return colors[0];
@@ -120,7 +120,7 @@
if (unit >= 1) {
return colors[colors.length - 1];
}
-
+
float p = unit * (colors.length - 1);
int i = (int)p;
p -= i;
@@ -132,16 +132,16 @@
int r = ave(Color.red(c0), Color.red(c1), p);
int g = ave(Color.green(c0), Color.green(c1), p);
int b = ave(Color.blue(c0), Color.blue(c1), p);
-
+
return Color.argb(a, r, g, b);
}
-
+
private int rotateColor(int color, float rad) {
float deg = rad * 180 / 3.1415927f;
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
-
+
ColorMatrix cm = new ColorMatrix();
ColorMatrix tmp = new ColorMatrix();
@@ -150,17 +150,17 @@
cm.postConcat(tmp);
tmp.setYUV2RGB();
cm.postConcat(tmp);
-
+
final float[] a = cm.getArray();
int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);
-
+
return Color.argb(Color.alpha(color), pinToByte(ir),
pinToByte(ig), pinToByte(ib));
}
-
+
private static final float PI = 3.1415926f;
@Override
@@ -168,7 +168,7 @@
float x = event.getX() - CENTER_X;
float y = event.getY() - CENTER_Y;
boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS;
-
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mTrackingCenter = inCenter;
@@ -212,7 +212,7 @@
OnColorChangedListener listener,
int initialColor) {
super(context);
-
+
mListener = listener;
mInitialColor = initialColor;
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.java
index d3b0981..85471d9 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.java
@@ -35,10 +35,10 @@
private Sensor mSensor;
private SampleView mView;
private float[] mValues;
-
+
private final SensorEventListener mListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
- if (Config.LOGD) Log.d(TAG,
+ if (Config.DEBUG) Log.d(TAG,
"sensorChanged (" + event.values[0] + ", " + event.values[1] + ", " + event.values[2] + ")");
mValues = event.values;
if (mView != null) {
@@ -62,17 +62,17 @@
@Override
protected void onResume()
{
- if (Config.LOGD) Log.d(TAG, "onResume");
+ if (Config.DEBUG) Log.d(TAG, "onResume");
super.onResume();
mSensorManager.registerListener(mListener, mSensor,
SensorManager.SENSOR_DELAY_GAME);
}
-
+
@Override
protected void onStop()
{
- if (Config.LOGD) Log.d(TAG, "onStop");
+ if (Config.DEBUG) Log.d(TAG, "onStop");
mSensorManager.unregisterListener(mListener);
super.onStop();
}
@@ -81,7 +81,6 @@
private Paint mPaint = new Paint();
private Path mPath = new Path();
private boolean mAnimate;
- private long mNextTime;
public SampleView(Context context) {
super(context);
@@ -93,12 +92,12 @@
mPath.lineTo(20, 60);
mPath.close();
}
-
+
@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
canvas.drawColor(Color.WHITE);
-
+
paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
@@ -109,23 +108,24 @@
int cy = h / 2;
canvas.translate(cx, cy);
- if (mValues != null) {
+ if (mValues != null) {
canvas.rotate(-mValues[0]);
}
canvas.drawPath(mPath, mPaint);
}
-
+
@Override
protected void onAttachedToWindow() {
mAnimate = true;
+ if (Config.DEBUG) Log.d(TAG, "onAttachedToWindow. mAnimate=" + mAnimate);
super.onAttachedToWindow();
}
-
+
@Override
protected void onDetachedFromWindow() {
mAnimate = false;
+ if (Config.DEBUG) Log.d(TAG, "onDetachedFromWindow. mAnimate=" + mAnimate);
super.onDetachedFromWindow();
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/CreateBitmap.java b/samples/ApiDemos/src/com/example/android/apis/graphics/CreateBitmap.java
index e3e5d9a..61fe9d5 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/CreateBitmap.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/CreateBitmap.java
@@ -16,13 +16,9 @@
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.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
import java.io.ByteArrayOutputStream;
@@ -34,11 +30,11 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static final int WIDTH = 50;
private static final int HEIGHT = 50;
private static final int STRIDE = 64; // must be >= WIDTH
-
+
private static int[] createColors() {
int[] colors = new int[STRIDE * HEIGHT];
for (int y = 0; y < HEIGHT; y++) {
@@ -52,18 +48,18 @@
}
return colors;
}
-
+
private static class SampleView extends View {
private Bitmap[] mBitmaps;
private Bitmap[] mJPEG;
private Bitmap[] mPNG;
private int[] mColors;
private Paint mPaint;
-
+
private static Bitmap codec(Bitmap src, Bitmap.CompressFormat format,
int quality) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
- src.compress(format, quality, os);
+ src.compress(format, quality, os);
byte[] array = os.toByteArray();
return BitmapFactory.decodeByteArray(array, 0, array.length);
@@ -72,7 +68,7 @@
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mColors = createColors();
int[] colors = mColors;
@@ -84,7 +80,7 @@
Bitmap.Config.RGB_565);
mBitmaps[2] = Bitmap.createBitmap(colors, 0, STRIDE, WIDTH, HEIGHT,
Bitmap.Config.ARGB_4444);
-
+
// these three will have their colors set later
mBitmaps[3] = Bitmap.createBitmap(WIDTH, HEIGHT,
Bitmap.Config.ARGB_8888);
@@ -95,10 +91,10 @@
for (int i = 3; i <= 5; i++) {
mBitmaps[i].setPixels(colors, 0, STRIDE, 0, 0, WIDTH, HEIGHT);
}
-
+
mPaint = new Paint();
mPaint.setDither(true);
-
+
// now encode/decode using JPEG and PNG
mJPEG = new Bitmap[mBitmaps.length];
mPNG = new Bitmap[mBitmaps.length];
@@ -107,7 +103,7 @@
mPNG[i] = codec(mBitmaps[i], Bitmap.CompressFormat.PNG, 0);
}
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
@@ -117,7 +113,7 @@
canvas.drawBitmap(mPNG[i], 160, 0, null);
canvas.translate(0, mBitmaps[i].getHeight());
}
-
+
// draw the color array directly, w/o craeting a bitmap object
canvas.drawBitmap(mColors, 0, STRIDE, 0, 0, WIDTH, HEIGHT,
true, null);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Cube.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Cube.java
index bb154eb..715e175 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Cube.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Cube.java
@@ -88,10 +88,10 @@
public void draw(GL10 gl)
{
- gl.glFrontFace(gl.GL_CW);
- gl.glVertexPointer(3, gl.GL_FIXED, 0, mVertexBuffer);
- gl.glColorPointer(4, gl.GL_FIXED, 0, mColorBuffer);
- gl.glDrawElements(gl.GL_TRIANGLES, 36, gl.GL_UNSIGNED_BYTE, mIndexBuffer);
+ gl.glFrontFace(GL10.GL_CW);
+ gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer);
+ gl.glColorPointer(4, GL10.GL_FIXED, 0, mColorBuffer);
+ gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE, mIndexBuffer);
}
private IntBuffer mVertexBuffer;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/CubeRenderer.java b/samples/ApiDemos/src/com/example/android/apis/graphics/CubeRenderer.java
index 0f15f91..ac0ae27 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/CubeRenderer.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/CubeRenderer.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/DensityActivity.java b/samples/ApiDemos/src/com/example/android/apis/graphics/DensityActivity.java
index 8c5c93a..0288ad1 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/DensityActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/DensityActivity.java
@@ -47,7 +47,7 @@
final LayoutInflater li = (LayoutInflater)getSystemService(
LAYOUT_INFLATER_SERVICE);
-
+
this.setTitle(R.string.density_title);
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
@@ -76,11 +76,11 @@
layout = (LinearLayout)li.inflate(R.layout.density_image_views, null);
addLabelToRoot(root, "Inflated layout");
addChildToRoot(root, layout);
-
+
layout = (LinearLayout)li.inflate(R.layout.density_styled_image_views, null);
addLabelToRoot(root, "Inflated styled layout");
addChildToRoot(root, layout);
-
+
layout = new LinearLayout(this);
addCanvasBitmap(layout, R.drawable.logo120dpi, true);
addCanvasBitmap(layout, R.drawable.logo160dpi, true);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/DrawPoints.java b/samples/ApiDemos/src/com/example/android/apis/graphics/DrawPoints.java
index cbe6373..21eba0d 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/DrawPoints.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/DrawPoints.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,7 +28,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint();
private float[] mPts;
@@ -38,11 +37,11 @@
private static final int SEGS = 32;
private static final int X = 0;
private static final int Y = 1;
-
+
private void buildPoints() {
final int ptCount = (SEGS + 1) * 2;
mPts = new float[ptCount * 2];
-
+
float value = 0;
final float delta = SIZE / SEGS;
for (int i = 0; i <= SEGS; i++) {
@@ -53,16 +52,16 @@
value += delta;
}
}
-
+
public SampleView(Context context) {
super(context);
-
+
buildPoints();
}
-
+
@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
-
+
canvas.translate(10, 10);
canvas.drawColor(Color.WHITE);
@@ -70,7 +69,7 @@
paint.setColor(Color.RED);
paint.setStrokeWidth(0);
canvas.drawLines(mPts, paint);
-
+
paint.setColor(Color.BLUE);
paint.setStrokeWidth(3);
canvas.drawPoints(mPts, paint);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java b/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java
index 867da4c..fcfd28f 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -26,7 +25,7 @@
import android.view.View;
public class FingerPaint extends GraphicsActivity
- implements ColorPickerDialog.OnColorChangedListener {
+ implements ColorPickerDialog.OnColorChangedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -41,34 +40,34 @@
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(12);
-
+
mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
0.4f, 6, 3.5f);
mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);
}
-
+
private Paint mPaint;
private MaskFilter mEmboss;
private MaskFilter mBlur;
-
+
public void colorChanged(int color) {
mPaint.setColor(color);
}
public class MyView extends View {
-
+
private static final float MINP = 0.25f;
private static final float MAXP = 0.75f;
-
+
private Bitmap mBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
-
+
public MyView(Context c) {
super(c);
-
+
mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
mPath = new Path();
@@ -79,19 +78,19 @@
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
}
-
+
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFAAAAAA);
-
+
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
-
+
canvas.drawPath(mPath, mPaint);
}
-
+
private float mX, mY;
private static final float TOUCH_TOLERANCE = 4;
-
+
private void touch_start(float x, float y) {
mPath.reset();
mPath.moveTo(x, y);
@@ -114,12 +113,12 @@
// kill this so we don't double draw
mPath.reset();
}
-
+
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
-
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touch_start(x, y);
@@ -137,7 +136,7 @@
return true;
}
}
-
+
private static final int COLOR_MENU_ID = Menu.FIRST;
private static final int EMBOSS_MENU_ID = Menu.FIRST + 1;
private static final int BLUR_MENU_ID = Menu.FIRST + 2;
@@ -147,7 +146,7 @@
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
-
+
menu.add(0, COLOR_MENU_ID, 0, "Color").setShortcut('3', 'c');
menu.add(0, EMBOSS_MENU_ID, 0, "Emboss").setShortcut('4', 's');
menu.add(0, BLUR_MENU_ID, 0, "Blur").setShortcut('5', 'z');
@@ -164,13 +163,13 @@
*****/
return true;
}
-
+
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
return true;
}
-
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
mPaint.setXfermode(null);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/GradientDrawable1.java b/samples/ApiDemos/src/com/example/android/apis/graphics/GradientDrawable1.java
index eb6d47d..fa7a6b7 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/GradientDrawable1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/GradientDrawable1.java
@@ -20,7 +20,6 @@
// class is in a sub-package.
import com.example.android.apis.R;
-import android.app.Activity;
import android.os.Bundle;
public class GradientDrawable1 extends GraphicsActivity {
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/GraphicsActivity.java b/samples/ApiDemos/src/com/example/android/apis/graphics/GraphicsActivity.java
index 023c0d7..69682d4 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/GraphicsActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/GraphicsActivity.java
@@ -20,9 +20,11 @@
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
-import android.view.Window;
class GraphicsActivity extends Activity {
+ // set to true to test Picture
+ private static final boolean TEST_PICTURE = false;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -30,13 +32,12 @@
@Override
public void setContentView(View view) {
- if (false) { // set to true to test Picture
+ if (TEST_PICTURE) {
ViewGroup vg = new PictureLayout(this);
vg.addView(view);
view = vg;
}
-
+
super.setContentView(view);
}
-}
-
+}
\ No newline at end of file
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Layers.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Layers.java
index d9f5db0..7e2a694 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Layers.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Layers.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,7 +28,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private static final int LAYER_FLAGS = Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
@@ -42,23 +41,23 @@
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mPaint = new Paint();
mPaint.setAntiAlias(true);
}
-
+
@Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(Color.WHITE);
-
+ canvas.drawColor(Color.WHITE);
+
canvas.translate(10, 10);
-
+
canvas.saveLayerAlpha(0, 0, 200, 200, 0x88, LAYER_FLAGS);
-
+
mPaint.setColor(Color.RED);
canvas.drawCircle(75, 75, 75, mPaint);
mPaint.setColor(Color.BLUE);
canvas.drawCircle(125, 125, 75, mPaint);
-
+
canvas.restore();
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/MeasureText.java b/samples/ApiDemos/src/com/example/android/apis/graphics/MeasureText.java
index e159efe..c2d433e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/MeasureText.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/MeasureText.java
@@ -16,13 +16,9 @@
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.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
public class MeasureText extends GraphicsActivity {
@@ -32,11 +28,11 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static final int WIDTH = 50;
private static final int HEIGHT = 50;
private static final int STRIDE = 64; // must be >= WIDTH
-
+
private static int[] createColors() {
int[] colors = new int[STRIDE * HEIGHT];
for (int y = 0; y < HEIGHT; y++) {
@@ -50,16 +46,16 @@
}
return colors;
}
-
+
private static class SampleView extends View {
private Paint mPaint;
private float mOriginX = 10;
private float mOriginY = 80;
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(5);
@@ -68,22 +64,22 @@
mPaint.setTypeface(Typeface.create(Typeface.SERIF,
Typeface.ITALIC));
}
-
+
private void showText(Canvas canvas, String text, Paint.Align align) {
// mPaint.setTextAlign(align);
-
+
Rect bounds = new Rect();
float[] widths = new float[text.length()];
int count = mPaint.getTextWidths(text, 0, text.length(), widths);
float w = mPaint.measureText(text, 0, text.length());
mPaint.getTextBounds(text, 0, text.length(), bounds);
-
+
mPaint.setColor(0xFF88FF88);
canvas.drawRect(bounds, mPaint);
mPaint.setColor(Color.BLACK);
canvas.drawText(text, 0, 0, mPaint);
-
+
float[] pts = new float[2 + count*2];
float x = 0;
float y = 0;
@@ -100,12 +96,12 @@
mPaint.setStrokeWidth(5);
canvas.drawPoints(pts, 0, (count + 1) << 1, mPaint);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
-
+
canvas.translate(mOriginX, mOriginY);
-
+
showText(canvas, "Measure", Paint.Align.LEFT);
canvas.translate(0, 80);
showText(canvas, "wiggy!", Paint.Align.CENTER);
@@ -114,4 +110,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/PathEffects.java b/samples/ApiDemos/src/com/example/android/apis/graphics/PathEffects.java
index 80ddf38..2894fa9 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/PathEffects.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/PathEffects.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -30,7 +29,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint;
private Path mPath;
@@ -41,7 +40,7 @@
private static PathEffect makeDash(float phase) {
return new DashPathEffect(new float[] { 15, 5, 8, 5 }, phase);
}
-
+
private static void makeEffects(PathEffect[] e, float phase) {
e[0] = null; // no effect
e[1] = new CornerPathEffect(10);
@@ -51,7 +50,7 @@
e[4] = new ComposePathEffect(e[2], e[1]);
e[5] = new ComposePathEffect(e[3], e[1]);
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
@@ -60,23 +59,23 @@
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(6);
-
+
mPath = makeFollowPath();
-
+
mEffects = new PathEffect[6];
-
+
mColors = new int[] { Color.BLACK, Color.RED, Color.BLUE,
Color.GREEN, Color.MAGENTA, Color.BLACK
};
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
-
+
RectF bounds = new RectF();
mPath.computeBounds(bounds, false);
canvas.translate(10 - bounds.left, 10 - bounds.top);
-
+
makeEffects(mEffects, mPhase);
mPhase += 1;
invalidate();
@@ -88,7 +87,7 @@
canvas.translate(0, 28);
}
}
-
+
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
@@ -106,7 +105,7 @@
}
return p;
}
-
+
private static Path makePathDash() {
Path p = new Path();
p.moveTo(4, 0);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/PathFillTypes.java b/samples/ApiDemos/src/com/example/android/apis/graphics/PathFillTypes.java
index 78dba26..10cfc49 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/PathFillTypes.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/PathFillTypes.java
@@ -20,11 +20,9 @@
// class is in a sub-package.
//import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.View;
public class PathFillTypes extends GraphicsActivity {
@@ -34,7 +32,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Path mPath;
@@ -48,7 +46,7 @@
mPath.addCircle(40, 40, 45, Path.Direction.CCW);
mPath.addCircle(80, 80, 45, Path.Direction.CCW);
}
-
+
private void showPath(Canvas canvas, int x, int y, Path.FillType ft,
Paint paint) {
canvas.save();
@@ -59,14 +57,14 @@
canvas.drawPath(mPath, paint);
canvas.restore();
}
-
+
@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
canvas.drawColor(0xFFCCCCCC);
-
+
canvas.translate(20, 20);
-
+
paint.setAntiAlias(true);
showPath(canvas, 0, 0, Path.FillType.WINDING, paint);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Patterns.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Patterns.java
index d2a51ff..6b6d8e1 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Patterns.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Patterns.java
@@ -16,11 +16,9 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.*;
@@ -31,7 +29,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static Bitmap makeBitmap1() {
Bitmap bm = Bitmap.createBitmap(40, 40, Bitmap.Config.RGB_565);
Canvas c = new Canvas(bm);
@@ -41,7 +39,7 @@
c.drawRect(5, 5, 35, 35, p);
return bm;
}
-
+
private static Bitmap makeBitmap2() {
Bitmap bm = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
@@ -51,13 +49,13 @@
c.drawCircle(32, 32, 27, p);
return bm;
}
-
+
private static class SampleView extends View {
private final Shader mShader1;
private final Shader mShader2;
private final Paint mPaint;
private final DrawFilter mFastDF;
-
+
private float mTouchStartX;
private float mTouchStartY;
private float mTouchCurrX;
@@ -72,25 +70,25 @@
mFastDF = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG |
Paint.DITHER_FLAG,
0);
-
+
mShader1 = new BitmapShader(makeBitmap1(), Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT);
mShader2 = new BitmapShader(makeBitmap2(), Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT);
-
+
Matrix m = new Matrix();
m.setRotate(30);
mShader2.setLocalMatrix(m);
-
+
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.setDrawFilter(mDF);
mPaint.setShader(mShader1);
canvas.drawPaint(mPaint);
-
+
canvas.translate(mTouchCurrX - mTouchStartX,
mTouchCurrY - mTouchStartY);
@@ -102,7 +100,7 @@
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
-
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouchStartX = mTouchCurrX = x;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/PictureLayout.java b/samples/ApiDemos/src/com/example/android/apis/graphics/PictureLayout.java
index cfa3c29..c1d22a8 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/PictureLayout.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/PictureLayout.java
@@ -26,7 +26,6 @@
import android.view.ViewGroup;
import android.view.ViewParent;
-
public class PictureLayout extends ViewGroup {
private final Picture mPicture = new Picture();
@@ -36,7 +35,7 @@
public PictureLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- }
+ }
@Override
public void addView(View child) {
@@ -105,7 +104,7 @@
setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec),
resolveSize(maxHeight, heightMeasureSpec));
}
-
+
private void drawPict(Canvas canvas, int x, int y, int w, int h,
float sx, float sy) {
canvas.save();
@@ -121,10 +120,10 @@
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(mPicture.beginRecording(getWidth(), getHeight()));
mPicture.endRecording();
-
+
int x = getWidth()/2;
int y = getHeight()/2;
-
+
if (false) {
canvas.drawPicture(mPicture);
} else {
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Pictures.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Pictures.java
index 1bd0a8c..61842dd 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Pictures.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Pictures.java
@@ -16,13 +16,11 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PictureDrawable;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.View;
import java.io.*;
@@ -34,17 +32,17 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Picture mPicture;
private Drawable mDrawable;
static void drawSomething(Canvas canvas) {
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
-
+
p.setColor(0x88FF0000);
canvas.drawCircle(50, 50, 40, p);
-
+
p.setColor(Color.GREEN);
p.setTextSize(30);
canvas.drawText("Pictures", 60, 60, p);
@@ -58,20 +56,20 @@
mPicture = new Picture();
drawSomething(mPicture.beginRecording(200, 100));
mPicture.endRecording();
-
+
mDrawable = new PictureDrawable(mPicture);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
canvas.drawPicture(mPicture);
-
+
canvas.drawPicture(mPicture, new RectF(0, 100, getWidth(), 200));
-
+
mDrawable.setBounds(0, 200, getWidth(), 300);
mDrawable.draw(canvas);
-
+
ByteArrayOutputStream os = new ByteArrayOutputStream();
mPicture.writeToStream(os);
InputStream is = new ByteArrayInputStream(os.toByteArray());
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/PolyToPoly.java b/samples/ApiDemos/src/com/example/android/apis/graphics/PolyToPoly.java
index 15d92de..a1f1ed4 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/PolyToPoly.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/PolyToPoly.java
@@ -20,7 +20,6 @@
// class is in a sub-package.
//import com.example.android.apis.R;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -33,7 +32,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Matrix mMatrix = new Matrix();
@@ -43,13 +42,13 @@
canvas.save();
mMatrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
canvas.concat(mMatrix);
-
+
mPaint.setColor(Color.GRAY);
mPaint.setStyle(Paint.Style.STROKE);
canvas.drawRect(0, 0, 64, 64, mPaint);
canvas.drawLine(0, 0, 64, 64, mPaint);
canvas.drawLine(0, 64, 64, 0, mPaint);
-
+
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.FILL);
// how to draw the text center on our square
@@ -58,7 +57,7 @@
// centering in Y, we need to measure ascent/descent first
float y = 64/2 - (mFontMetrics.ascent + mFontMetrics.descent)/2;
canvas.drawText(src.length/2 + "", x, y, mPaint);
-
+
canvas.restore();
}
@@ -72,10 +71,9 @@
mPaint.setTextAlign(Paint.Align.CENTER);
mFontMetrics = mPaint.getFontMetrics();
}
-
- @Override protected void onDraw(Canvas canvas) {
- Paint paint = mPaint;
+ @Override
+ protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
canvas.save();
@@ -83,7 +81,7 @@
// translate (1 point)
doDraw(canvas, new float[] { 0, 0 }, new float[] { 5, 5 });
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 10);
// rotate/uniform-scale (2 points)
@@ -107,4 +105,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ProxyDrawable.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ProxyDrawable.java
index d264134..635132e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ProxyDrawable.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ProxyDrawable.java
@@ -22,18 +22,18 @@
import android.graphics.drawable.Drawable;
public class ProxyDrawable extends Drawable {
-
+
private Drawable mProxy;
private boolean mMutated;
public ProxyDrawable(Drawable target) {
mProxy = target;
}
-
+
public Drawable getProxy() {
return mProxy;
}
-
+
public void setProxy(Drawable proxy) {
if (proxy != this) {
mProxy = proxy;
@@ -46,43 +46,43 @@
mProxy.draw(canvas);
}
}
-
+
@Override
public int getIntrinsicWidth() {
return mProxy != null ? mProxy.getIntrinsicWidth() : -1;
}
-
+
@Override
public int getIntrinsicHeight() {
return mProxy != null ? mProxy.getIntrinsicHeight() : -1;
}
-
+
@Override
public int getOpacity() {
return mProxy != null ? mProxy.getOpacity() : PixelFormat.TRANSPARENT;
}
-
+
@Override
public void setFilterBitmap(boolean filter) {
if (mProxy != null) {
mProxy.setFilterBitmap(filter);
}
}
-
+
@Override
public void setDither(boolean dither) {
if (mProxy != null) {
mProxy.setDither(dither);
}
}
-
+
@Override
public void setColorFilter(ColorFilter colorFilter) {
if (mProxy != null) {
mProxy.setColorFilter(colorFilter);
}
}
-
+
@Override
public void setAlpha(int alpha) {
if (mProxy != null) {
@@ -99,4 +99,4 @@
return this;
}
}
-
+
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Regions.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Regions.java
index 833274b..fc0aa08 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Regions.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Regions.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,7 +28,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private final Paint mPaint = new Paint();
private final Rect mRect1 = new Rect();
@@ -38,11 +37,11 @@
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mPaint.setAntiAlias(true);
mPaint.setTextSize(16);
mPaint.setTextAlign(Paint.Align.CENTER);
-
+
mRect1.set(10, 10, 100, 80);
mRect2.set(50, 50, 130, 110);
}
@@ -55,25 +54,25 @@
mPaint.setColor(Color.BLUE);
mPaint.setAlpha(alpha);
drawCentered(canvas, mRect2, mPaint);
-
+
// restore style
mPaint.setStyle(Paint.Style.FILL);
}
-
+
private void drawRgn(Canvas canvas, int color, String str, Region.Op op) {
if (str != null) {
mPaint.setColor(Color.BLACK);
canvas.drawText(str, 80, 24, mPaint);
}
-
+
Region rgn = new Region();
rgn.set(mRect1);
rgn.op(mRect2, op);
-
+
mPaint.setColor(color);
RegionIterator iter = new RegionIterator(rgn);
Rect r = new Rect();
-
+
canvas.translate(0, 30);
mPaint.setColor(color);
while (iter.next(r)) {
@@ -81,7 +80,7 @@
}
drawOriginalRects(canvas, 0x80);
}
-
+
private static void drawCentered(Canvas c, Rect r, Paint p) {
float inset = p.getStrokeWidth() * 0.5f;
if (inset == 0) { // catch hairlines
@@ -90,32 +89,33 @@
c.drawRect(r.left + inset, r.top + inset,
r.right - inset, r.bottom - inset, p);
}
-
- @Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(Color.GRAY);
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawColor(Color.GRAY);
canvas.save();
canvas.translate(80, 5);
drawOriginalRects(canvas, 0xFF);
canvas.restore();
-
+
mPaint.setStyle(Paint.Style.FILL);
-
+
canvas.save();
canvas.translate(0, 140);
drawRgn(canvas, Color.RED, "Union", Region.Op.UNION);
canvas.restore();
-
+
canvas.save();
canvas.translate(0, 280);
drawRgn(canvas, Color.BLUE, "Xor", Region.Op.XOR);
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 140);
drawRgn(canvas, Color.GREEN, "Difference", Region.Op.DIFFERENCE);
canvas.restore();
-
+
canvas.save();
canvas.translate(160, 280);
drawRgn(canvas, Color.WHITE, "Intersect", Region.Op.INTERSECT);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/RoundRects.java b/samples/ApiDemos/src/com/example/android/apis/graphics/RoundRects.java
index b0ff035..74c2406 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/RoundRects.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/RoundRects.java
@@ -16,14 +16,10 @@
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 RoundRects extends GraphicsActivity {
@@ -33,7 +29,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Path mPath;
private Paint mPaint;
@@ -47,73 +43,71 @@
mPath = new Path();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRect = new Rect(0, 0, 120, 120);
-
+
mDrawable = new GradientDrawable(GradientDrawable.Orientation.TL_BR,
new int[] { 0xFFFF0000, 0xFF00FF00,
0xFF0000FF });
mDrawable.setShape(GradientDrawable.RECTANGLE);
mDrawable.setGradientRadius((float)(Math.sqrt(2) * 60));
}
-
+
static void setCornerRadii(GradientDrawable drawable, float r0,
float r1, float r2, float r3) {
drawable.setCornerRadii(new float[] { r0, r0, r1, r1,
r2, r2, r3, r3 });
}
-
+
@Override protected void onDraw(Canvas canvas) {
-
+
mDrawable.setBounds(mRect);
float r = 16;
-
+
canvas.save();
canvas.translate(10, 10);
mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
setCornerRadii(mDrawable, r, r, 0, 0);
mDrawable.draw(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(10 + mRect.width() + 10, 10);
mDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
setCornerRadii(mDrawable, 0, 0, r, r);
mDrawable.draw(canvas);
canvas.restore();
-
+
canvas.translate(0, mRect.height() + 10);
-
+
canvas.save();
canvas.translate(10, 10);
mDrawable.setGradientType(GradientDrawable.SWEEP_GRADIENT);
setCornerRadii(mDrawable, 0, r, r, 0);
mDrawable.draw(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(10 + mRect.width() + 10, 10);
mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
setCornerRadii(mDrawable, r, 0, 0, r);
mDrawable.draw(canvas);
canvas.restore();
-
+
canvas.translate(0, mRect.height() + 10);
-
+
canvas.save();
canvas.translate(10, 10);
mDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
setCornerRadii(mDrawable, r, 0, r, 0);
mDrawable.draw(canvas);
canvas.restore();
-
+
canvas.save();
canvas.translate(10 + mRect.width() + 10, 10);
mDrawable.setGradientType(GradientDrawable.SWEEP_GRADIENT);
setCornerRadii(mDrawable, 0, r, 0, r);
mDrawable.draw(canvas);
canvas.restore();
-
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ScaleToFit.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ScaleToFit.java
index f55e55b..6ffdb5b 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ScaleToFit.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ScaleToFit.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,14 +28,14 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint mHairPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint mLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Matrix mMatrix = new Matrix();
private final RectF mSrcR = new RectF();
-
+
private static final Matrix.ScaleToFit[] sFits =
new Matrix.ScaleToFit[] {
Matrix.ScaleToFit.FILL,
@@ -44,11 +43,11 @@
Matrix.ScaleToFit.CENTER,
Matrix.ScaleToFit.END
};
-
+
private static final String[] sFitLabels = new String[] {
"FILL", "START", "CENTER", "END"
};
-
+
private static final int[] sSrcData = new int[] {
80, 40, Color.RED,
40, 80, Color.GREEN,
@@ -56,7 +55,7 @@
80, 80, Color.BLACK
};
private static final int N = 4;
-
+
private static final int WIDTH = 52;
private static final int HEIGHT = 52;
private final RectF mDstR = new RectF(0, 0, WIDTH, HEIGHT);
@@ -67,34 +66,33 @@
mHairPaint.setStyle(Paint.Style.STROKE);
mLabelPaint.setTextSize(16);
}
-
+
private void setSrcR(int index) {
int w = sSrcData[index*3 + 0];
int h = sSrcData[index*3 + 1];
mSrcR.set(0, 0, w, h);
}
-
+
private void drawSrcR(Canvas canvas, int index) {
mPaint.setColor(sSrcData[index*3 + 2]);
canvas.drawOval(mSrcR, mPaint);
}
-
+
private void drawFit(Canvas canvas, int index, Matrix.ScaleToFit stf) {
canvas.save();
-
+
setSrcR(index);
mMatrix.setRectToRect(mSrcR, mDstR, stf);
canvas.concat(mMatrix);
drawSrcR(canvas, index);
-
+
canvas.restore();
-
+
canvas.drawRect(mDstR, mHairPaint);
}
- @Override protected void onDraw(Canvas canvas) {
- Paint paint = mPaint;
-
+ @Override
+ protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
canvas.translate(10, 10);
@@ -106,7 +104,7 @@
canvas.translate(mSrcR.width() + 15, 0);
}
canvas.restore();
-
+
canvas.translate(0, 100);
for (int j = 0; j < sFits.length; j++) {
canvas.save();
@@ -121,4 +119,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/SensorTest.java b/samples/ApiDemos/src/com/example/android/apis/graphics/SensorTest.java
index 87e0461..dc07a27 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/SensorTest.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/SensorTest.java
@@ -24,6 +24,7 @@
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Config;
+import android.util.Log;
import android.view.View;
public class SensorTest extends GraphicsActivity {
@@ -33,7 +34,7 @@
private Sensor mSensor;
private SampleView mView;
private float[] mValues;
-
+
private static class RunAve {
private final float[] mWeights;
private final float mWeightScale;
@@ -43,7 +44,7 @@
public RunAve(float[] weights) {
mWeights = weights;
-
+
float sum = 0;
for (int i = 0; i < weights.length; i++) {
sum += weights[i];
@@ -54,12 +55,12 @@
mSamples = new float[mDepth];
mCurr = 0;
}
-
+
public void addSample(float value) {
mSamples[mCurr] = value;
mCurr = (mCurr + 1) % mDepth;
}
-
+
public float computeAve() {
final int depth = mDepth;
int index = mCurr;
@@ -92,20 +93,20 @@
}
mPrev[i] = event.values[i];
}
-
+
if (show) {
// only shows if we think the delta is big enough, in an attempt
// to detect "serious" moves left/right or up/down
- android.util.Log.e(TAG, "sensorChanged " + event.sensor.getName() +
+ Log.e(TAG, "sensorChanged " + event.sensor.getName() +
" (" + event.values[0] + ", " + event.values[1] + ", " +
event.values[2] + ")" + " diff(" + diff[0] +
" " + diff[1] + " " + diff[2] + ")");
}
-
+
long now = android.os.SystemClock.uptimeMillis();
if (now - mLastGestureTime > 1000) {
mLastGestureTime = 0;
-
+
float x = diff[0];
float y = diff[1];
boolean gestX = Math.abs(x) > 3;
@@ -114,15 +115,15 @@
if ((gestX || gestY) && !(gestX && gestY)) {
if (gestX) {
if (x < 0) {
- android.util.Log.e("test", "<<<<<<<< LEFT <<<<<<<<<<<<");
+ Log.e("test", "<<<<<<<< LEFT <<<<<<<<<<<<");
} else {
- android.util.Log.e("test", ">>>>>>>>> RITE >>>>>>>>>>>");
+ Log.e("test", ">>>>>>>>> RITE >>>>>>>>>>>");
}
} else {
if (y < -2) {
- android.util.Log.e("test", "<<<<<<<< UP <<<<<<<<<<<<");
+ Log.e("test", "<<<<<<<< UP <<<<<<<<<<<<");
} else {
- android.util.Log.e("test", ">>>>>>>>> DOWN >>>>>>>>>>>");
+ Log.e("test", ">>>>>>>>> DOWN >>>>>>>>>>>");
}
}
mLastGestureTime = now;
@@ -141,28 +142,27 @@
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mView = new SampleView(this);
setContentView(mView);
- if (Config.LOGD) android.util.Log.d(TAG, "create " + mSensorManager);
+ if (Config.DEBUG) Log.d(TAG, "create " + mSensorManager);
}
@Override
protected void onResume() {
super.onResume();
mSensorManager.registerListener(mListener, mSensor, SensorManager.SENSOR_DELAY_FASTEST);
- if (Config.LOGD) android.util.Log.d(TAG, "resume " + mSensorManager);
+ if (Config.DEBUG) Log.d(TAG, "resume " + mSensorManager);
}
-
+
@Override
protected void onStop() {
mSensorManager.unregisterListener(mListener);
super.onStop();
- if (Config.LOGD) android.util.Log.d(TAG, "stop " + mSensorManager);
+ if (Config.DEBUG) Log.d(TAG, "stop " + mSensorManager);
}
private class SampleView extends View {
private Paint mPaint = new Paint();
private Path mPath = new Path();
private boolean mAnimate;
- private long mNextTime;
public SampleView(Context context) {
super(context);
@@ -174,13 +174,13 @@
mPath.lineTo(20, 60);
mPath.close();
}
-
+
@Override
protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
canvas.drawColor(Color.WHITE);
-
+
paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
@@ -191,21 +191,23 @@
int cy = h / 2;
canvas.translate(cx, cy);
- if (mValues != null) {
+ if (mValues != null) {
canvas.rotate(-mValues[0]);
}
canvas.drawPath(mPath, mPaint);
}
-
+
@Override
protected void onAttachedToWindow() {
mAnimate = true;
+ if (Config.DEBUG) Log.d(TAG, "onAttachedToWindow. mAnimate="+mAnimate);
super.onAttachedToWindow();
}
-
+
@Override
protected void onDetachedFromWindow() {
mAnimate = false;
+ if (Config.DEBUG) Log.d(TAG, "onAttachedToWindow. mAnimate="+mAnimate);
super.onDetachedFromWindow();
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/ShapeDrawable1.java b/samples/ApiDemos/src/com/example/android/apis/graphics/ShapeDrawable1.java
index 6d450bb..236f4fc 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/ShapeDrawable1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/ShapeDrawable1.java
@@ -16,16 +16,12 @@
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.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.*;
import android.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
public class ShapeDrawable1 extends GraphicsActivity {
@@ -35,49 +31,49 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private ShapeDrawable[] mDrawables;
-
+
private static Shader makeSweep() {
return new SweepGradient(150, 25,
new int[] { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFF0000 },
null);
}
-
+
private static Shader makeLinear() {
return new LinearGradient(0, 0, 50, 50,
new int[] { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF },
null, Shader.TileMode.MIRROR);
}
-
+
private static Shader makeTiling() {
int[] pixels = new int[] { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0};
Bitmap bm = Bitmap.createBitmap(pixels, 2, 2,
Bitmap.Config.ARGB_8888);
-
+
return new BitmapShader(bm, Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT);
}
-
+
private static class MyShapeDrawable extends ShapeDrawable {
private Paint mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-
+
public MyShapeDrawable(Shape s) {
super(s);
mStrokePaint.setStyle(Paint.Style.STROKE);
}
-
+
public Paint getStrokePaint() {
return mStrokePaint;
}
-
+
@Override protected void onDraw(Shape s, Canvas c, Paint p) {
s.draw(c, p);
s.draw(c, mStrokePaint);
}
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
@@ -85,14 +81,14 @@
float[] outerR = new float[] { 12, 12, 12, 12, 0, 0, 0, 0 };
RectF inset = new RectF(6, 6, 6, 6);
float[] innerR = new float[] { 12, 12, 0, 0, 12, 12, 0, 0 };
-
+
Path path = new Path();
path.moveTo(50, 0);
path.lineTo(0, 50);
path.lineTo(50, 100);
path.lineTo(100, 50);
path.close();
-
+
mDrawables = new ShapeDrawable[7];
mDrawables[0] = new ShapeDrawable(new RectShape());
mDrawables[1] = new ShapeDrawable(new OvalShape());
@@ -104,7 +100,7 @@
innerR));
mDrawables[5] = new ShapeDrawable(new PathShape(path, 100, 100));
mDrawables[6] = new MyShapeDrawable(new ArcShape(45, -270));
-
+
mDrawables[0].getPaint().setColor(0xFFFF0000);
mDrawables[1].getPaint().setColor(0xFF00FF00);
mDrawables[2].getPaint().setColor(0xFF0000FF);
@@ -112,26 +108,26 @@
mDrawables[4].getPaint().setShader(makeLinear());
mDrawables[5].getPaint().setShader(makeTiling());
mDrawables[6].getPaint().setColor(0x88FF8844);
-
+
PathEffect pe = new DiscretePathEffect(10, 4);
PathEffect pe2 = new CornerPathEffect(4);
mDrawables[3].getPaint().setPathEffect(
new ComposePathEffect(pe2, pe));
-
+
MyShapeDrawable msd = (MyShapeDrawable)mDrawables[6];
msd.getStrokePaint().setStrokeWidth(4);
}
-
+
@Override protected void onDraw(Canvas canvas) {
-
+
int x = 10;
int y = 10;
int width = 300;
int height = 50;
-
+
for (Drawable dr : mDrawables) {
dr.setBounds(x, y, x + width, y + height);
- dr.draw(canvas);
+ dr.draw(canvas);
y += height + 5;
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Sweep.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Sweep.java
index dc127fd..5da10cf 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Sweep.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Sweep.java
@@ -16,11 +16,6 @@
package com.example.android.apis.graphics;
-// 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.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -34,7 +29,7 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private float mRotate;
@@ -55,7 +50,7 @@
Color.GREEN }, null);
mPaint.setShader(mShader);
}
-
+
@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;
float x = 160;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/TextAlign.java b/samples/ApiDemos/src/com/example/android/apis/graphics/TextAlign.java
index 0576a7c..0ecba16 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/TextAlign.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/TextAlign.java
@@ -16,13 +16,9 @@
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.os.Bundle;
-import android.view.KeyEvent;
import android.view.*;
public class TextAlign extends GraphicsActivity {
@@ -32,27 +28,27 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint;
private float mX;
private float[] mPos;
-
+
private Path mPath;
private Paint mPathPaint;
-
+
private static final int DY = 30;
private static final String TEXT_L = "Left";
private static final String TEXT_C = "Center";
private static final String TEXT_R = "Right";
private static final String POSTEXT = "Positioned";
private static final String TEXTONPATH = "Along a path";
-
+
private static void makePath(Path p) {
p.moveTo(10, 0);
p.cubicTo(100, -50, 200, 50, 300, 0);
}
-
+
private float[] buildTextPositions(String text, float y, Paint paint) {
float[] widths = new float[text.length()];
// initially get the widths for each char
@@ -67,18 +63,18 @@
}
return pos;
}
-
+
public SampleView(Context context) {
super(context);
setFocusable(true);
-
+
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextSize(30);
mPaint.setTypeface(Typeface.SERIF);
-
+
mPos = buildTextPositions(POSTEXT, 0, mPaint);
-
+
mPath = new Path();
makePath(mPath);
@@ -87,7 +83,7 @@
mPathPaint.setColor(0x800000FF);
mPathPaint.setStyle(Paint.Style.STROKE);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
@@ -95,13 +91,13 @@
float x = mX;
float y = 0;
float[] pos = mPos;
-
+
// draw the normal strings
p.setColor(0x80FF0000);
canvas.drawLine(x, y, x, y+DY*3, p);
p.setColor(Color.BLACK);
-
+
canvas.translate(0, DY);
p.setTextAlign(Paint.Align.LEFT);
canvas.drawText(TEXT_L, x, y, p);
@@ -113,11 +109,11 @@
canvas.translate(0, DY);
p.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(TEXT_R, x, y, p);
-
+
canvas.translate(100, DY*2);
// now draw the positioned strings
-
+
p.setColor(0xBB00FF00);
for (int i = 0; i < pos.length/2; i++) {
canvas.drawLine(pos[i*2+0], pos[i*2+1]-DY,
@@ -127,17 +123,17 @@
p.setTextAlign(Paint.Align.LEFT);
canvas.drawPosText(POSTEXT, pos, p);
-
+
canvas.translate(0, DY);
p.setTextAlign(Paint.Align.CENTER);
canvas.drawPosText(POSTEXT, pos, p);
-
+
canvas.translate(0, DY);
p.setTextAlign(Paint.Align.RIGHT);
canvas.drawPosText(POSTEXT, pos, p);
-
+
// now draw the text on path
-
+
canvas.translate(-100, DY*2);
canvas.drawPath(mPath, mPathPaint);
@@ -148,7 +144,7 @@
canvas.drawPath(mPath, mPathPaint);
p.setTextAlign(Paint.Align.CENTER);
canvas.drawTextOnPath(TEXTONPATH, mPath, 0, 0, p);
-
+
canvas.translate(0, DY*1.5f);
canvas.drawPath(mPath, mPathPaint);
p.setTextAlign(Paint.Align.RIGHT);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.java b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.java
index 0942852..ba48da0 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -41,34 +40,34 @@
public class TouchPaint extends GraphicsActivity {
/** Used as a pulse to gradually fade the contents of the window. */
private static final int FADE_MSG = 1;
-
+
/** Menu ID for the command to clear the window. */
private static final int CLEAR_ID = Menu.FIRST;
/** Menu ID for the command to toggle fading. */
private static final int FADE_ID = Menu.FIRST+1;
-
+
/** How often to fade the contents of the window (in ms). */
private static final int FADE_DELAY = 100;
-
+
/** The view responsible for drawing the window. */
MyView mView;
/** Is fading mode enabled? */
boolean mFading;
-
+
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
// Create and attach the view that is responsible for painting.
mView = new MyView(this);
setContentView(mView);
mView.requestFocus();
-
+
// Restore the fading option if we are being thawed from a
// previously saved state. Note that we are not currently remembering
// the contents of the bitmap.
mFading = savedInstanceState != null ? savedInstanceState.getBoolean("fading", true) : true;
}
-
+
@Override public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, CLEAR_ID, 0, "Clear");
menu.add(0, FADE_ID, 0, "Fade").setCheckable(true);
@@ -130,14 +129,14 @@
mHandler.sendMessageDelayed(
mHandler.obtainMessage(FADE_MSG), FADE_DELAY);
}
-
+
/**
* Stop the pulse to fade the screen.
*/
void stopFading() {
mHandler.removeMessages(FADE_MSG);
}
-
+
private Handler mHandler = new Handler() {
@Override public void handleMessage(Message msg) {
switch (msg.what) {
@@ -155,7 +154,7 @@
}
}
};
-
+
public class MyView extends View {
private static final int FADE_ALPHA = 0x06;
private static final int MAX_FADE_STEPS = 256/FADE_ALPHA + 4;
@@ -171,7 +170,7 @@
private float mCurSize;
private int mCurWidth;
private int mFadeSteps = MAX_FADE_STEPS;
-
+
public MyView(Context c) {
super(c);
mPaint = new Paint();
@@ -190,7 +189,7 @@
mFadeSteps = MAX_FADE_STEPS;
}
}
-
+
public void fade() {
if (mCanvas != null && mFadeSteps < MAX_FADE_STEPS) {
mCanvas.drawPaint(mFadePaint);
@@ -198,7 +197,7 @@
mFadeSteps++;
}
}
-
+
@Override protected void onSizeChanged(int w, int h, int oldw,
int oldh) {
int curW = mBitmap != null ? mBitmap.getWidth() : 0;
@@ -206,10 +205,10 @@
if (curW >= w && curH >= h) {
return;
}
-
+
if (curW < w) curW = w;
if (curH < h) curH = h;
-
+
Bitmap newBitmap = Bitmap.createBitmap(curW, curH,
Bitmap.Config.RGB_565);
Canvas newCanvas = new Canvas();
@@ -221,7 +220,7 @@
mCanvas = newCanvas;
mFadeSteps = MAX_FADE_STEPS;
}
-
+
@Override protected void onDraw(Canvas canvas) {
if (mBitmap != null) {
canvas.drawBitmap(mBitmap, 0, 0, null);
@@ -252,7 +251,7 @@
mCurDown = oldDown;
return true;
}
-
+
@Override public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
mCurDown = action == MotionEvent.ACTION_DOWN
@@ -268,7 +267,7 @@
event.getSize());
return true;
}
-
+
private void drawPoint(float x, float y, float pressure, float size) {
//Log.i("TouchPaint", "Drawing: " + x + "x" + y + " p="
// + pressure + " s=" + size);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
index c0f32a7..4133c04 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/TriangleRenderer.java b/samples/ApiDemos/src/com/example/android/apis/graphics/TriangleRenderer.java
index ede6ef5..c41d173 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/TriangleRenderer.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/TriangleRenderer.java
@@ -23,7 +23,6 @@
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
-import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java
index aefc311..08facaa 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Typefaces.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,20 +28,20 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;
-
+
public SampleView(Context context) {
super(context);
mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
-
+
mPaint.setTextSize(64);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/UnicodeChart.java b/samples/ApiDemos/src/com/example/android/apis/graphics/UnicodeChart.java
index 7ee99d0..0a2f630 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/UnicodeChart.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/UnicodeChart.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
@@ -29,20 +28,20 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
requestWindowFeature(Window.FEATURE_NO_TITLE);
-
+
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private Paint mBigCharPaint;
private Paint mLabelPaint;
private final char[] mChars = new char[256];
private final float[] mPos = new float[512];
-
+
private int mBase;
-
+
private static final int XMUL = 20;
private static final int YMUL = 28;
private static final int YBASE = 18;
@@ -51,49 +50,49 @@
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
-
+
mBigCharPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBigCharPaint.setTextSize(15);
mBigCharPaint.setTextAlign(Paint.Align.CENTER);
-
+
mLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mLabelPaint.setTextSize(8);
mLabelPaint.setTextAlign(Paint.Align.CENTER);
-
+
// the position array is the same for all charts
float[] pos = mPos;
int index = 0;
for (int col = 0; col < 16; col++) {
- final float x = col * 20 + 10;
+ final float x = col * XMUL + 10;
for (int row = 0; row < 16; row++) {
pos[index++] = x;
pos[index++] = row * YMUL + YBASE;
}
}
}
-
+
private float computeX(int index) {
- return (index >> 4) * 20 + 10;
+ return (index >> 4) * XMUL + 10;
}
private float computeY(int index) {
return (index & 0xF) * YMUL + YMUL;
}
-
+
private void drawChart(Canvas canvas, int base) {
char[] chars = mChars;
for (int i = 0; i < 256; i++) {
int unichar = base + i;
chars[i] = (char)unichar;
-
+
canvas.drawText(Integer.toHexString(unichar),
computeX(i), computeY(i), mLabelPaint);
}
canvas.drawPosText(chars, 0, 256, mPos, mBigCharPaint);
}
-
+
@Override protected void onDraw(Canvas canvas) {
- canvas.drawColor(Color.WHITE);
+ canvas.drawColor(Color.WHITE);
canvas.translate(0, 1);
drawChart(canvas, mBase * 256);
@@ -118,4 +117,3 @@
}
}
}
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Vertices.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Vertices.java
index 1e61906..ac1ab8a 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Vertices.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Vertices.java
@@ -18,17 +18,11 @@
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.*;
-import java.io.IOException;
-import java.io.InputStream;
-
public class Vertices extends GraphicsActivity {
@Override
@@ -36,14 +30,13 @@
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private final Paint mPaint = new Paint();
private final float[] mVerts = new float[10];
private final float[] mTexs = new float[10];
- private final int[] mColors = new int[10];
private final short[] mIndices = { 0, 1, 2, 3, 4, 1 };
-
+
private final Matrix mMatrix = new Matrix();
private final Matrix mInverse = new Matrix();
@@ -61,7 +54,7 @@
Shader s = new BitmapShader(bm, Shader.TileMode.CLAMP,
Shader.TileMode.CLAMP);
mPaint.setShader(s);
-
+
float w = bm.getWidth();
float h = bm.getHeight();
// construct our mesh
@@ -70,18 +63,18 @@
setXY(mTexs, 2, w, 0);
setXY(mTexs, 3, w, h);
setXY(mTexs, 4, 0, h);
-
+
setXY(mVerts, 0, w/2, h/2);
setXY(mVerts, 1, 0, 0);
setXY(mVerts, 2, w, 0);
setXY(mVerts, 3, w, h);
setXY(mVerts, 4, 0, h);
-
+
mMatrix.setScale(0.8f, 0.8f);
mMatrix.preTranslate(20, 20);
mMatrix.invert(mInverse);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
canvas.save();
@@ -104,7 +97,7 @@
invalidate();
return true;
}
-
+
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/Xfermodes.java b/samples/ApiDemos/src/com/example/android/apis/graphics/Xfermodes.java
index b9f8424..54e15e3 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/Xfermodes.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/Xfermodes.java
@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
@@ -33,35 +32,35 @@
import android.view.View;
public class Xfermodes extends GraphicsActivity {
-
+
// create a bitmap with a circle, used for the "dst" image
static Bitmap makeDst(int w, int h) {
Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
-
- p.setColor(0xFFFFCC44);
+
+ p.setColor(0xFFFFCC44);
c.drawOval(new RectF(0, 0, w*3/4, h*3/4), p);
return bm;
}
-
+
// create a bitmap with a rect, used for the "src" image
static Bitmap makeSrc(int w, int h) {
Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
-
+
p.setColor(0xFF66AAFF);
c.drawRect(w/3, h/3, w*19/20, h*19/20, p);
return bm;
}
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
-
+
private static class SampleView extends View {
private static final int W = 64;
private static final int H = 64;
@@ -70,7 +69,7 @@
private Bitmap mSrcB;
private Bitmap mDstB;
private Shader mBG; // background checker-board pattern
-
+
private static final Xfermode[] sModes = {
new PorterDuffXfermode(PorterDuff.Mode.CLEAR),
new PorterDuffXfermode(PorterDuff.Mode.SRC),
@@ -89,20 +88,20 @@
new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY),
new PorterDuffXfermode(PorterDuff.Mode.SCREEN)
};
-
+
private static final String[] sLabels = {
"Clear", "Src", "Dst", "SrcOver",
"DstOver", "SrcIn", "DstIn", "SrcOut",
"DstOut", "SrcATop", "DstATop", "Xor",
"Darken", "Lighten", "Multiply", "Screen"
};
-
+
public SampleView(Context context) {
super(context);
-
+
mSrcB = makeSrc(W, H);
mDstB = makeDst(W, H);
-
+
// make a ckeckerboard pattern
Bitmap bm = Bitmap.createBitmap(new int[] { 0xFFFFFFFF, 0xFFCCCCCC,
0xFFCCCCCC, 0xFFFFFFFF }, 2, 2,
@@ -114,18 +113,18 @@
m.setScale(6, 6);
mBG.setLocalMatrix(m);
}
-
+
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
-
+
Paint labelP = new Paint(Paint.ANTI_ALIAS_FLAG);
labelP.setTextAlign(Paint.Align.CENTER);
-
+
Paint paint = new Paint();
paint.setFilterBitmap(false);
-
+
canvas.translate(15, 35);
-
+
int x = 0;
int y = 0;
for (int i = 0; i < sModes.length; i++) {
@@ -134,12 +133,12 @@
paint.setShader(null);
canvas.drawRect(x - 0.5f, y - 0.5f,
x + W + 0.5f, y + H + 0.5f, paint);
-
+
// draw the checker-board pattern
paint.setStyle(Paint.Style.FILL);
paint.setShader(mBG);
canvas.drawRect(x, y, x + W, y + H, paint);
-
+
// draw the src/dst example into our offscreen bitmap
int sc = canvas.saveLayer(x, y, x + W, y + H, null,
Canvas.MATRIX_SAVE_FLAG |
@@ -153,13 +152,13 @@
canvas.drawBitmap(mSrcB, 0, 0, paint);
paint.setXfermode(null);
canvas.restoreToCount(sc);
-
+
// draw the label
canvas.drawText(sLabels[i],
x + W/2, y - labelP.getTextSize()/2, labelP);
-
+
x += W + 10;
-
+
// wrap around when we've drawn enough for one row
if ((i % ROW_MAX) == ROW_MAX - 1) {
x = 0;
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Animation2.java b/samples/ApiDemos/src/com/example/android/apis/view/Animation2.java
index b2236aa..041794e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Animation2.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Animation2.java
@@ -49,7 +49,7 @@
s.setOnItemSelectedListener(this);
}
- public void onItemSelected(AdapterView parent, View v, int position, long id) {
+ public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
switch (position) {
case 0:
@@ -79,7 +79,7 @@
}
}
- public void onNothingSelected(AdapterView parent) {
+ public void onNothingSelected(AdapterView<?> parent) {
}
private String[] mStrings = {
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Animation3.java b/samples/ApiDemos/src/com/example/android/apis/view/Animation3.java
index 11fc9ed..2cd7605 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Animation3.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Animation3.java
@@ -50,7 +50,7 @@
s.setOnItemSelectedListener(this);
}
- public void onItemSelected(AdapterView parent, View v, int position, long id) {
+ public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
final View target = findViewById(R.id.target);
final View targetParent = (View) target.getParent();
@@ -96,6 +96,6 @@
target.startAnimation(a);
}
- public void onNothingSelected(AdapterView parent) {
+ public void onNothingSelected(AdapterView<?> parent) {
}
}
\ No newline at end of file
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete1.java b/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete1.java
index f4274e5..bec4a5d 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete1.java
@@ -19,12 +19,9 @@
import com.example.android.apis.R;
import android.app.Activity;
-import android.widget.Spinner;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.os.Bundle;
-import android.view.View;
-
public class AutoComplete1 extends Activity {
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete6.java b/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete6.java
index 3573bfb..2c28d65 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete6.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/AutoComplete6.java
@@ -19,12 +19,9 @@
import com.example.android.apis.R;
import android.app.Activity;
-import android.widget.Spinner;
import android.widget.ArrayAdapter;
import android.widget.MultiAutoCompleteTextView;
import android.os.Bundle;
-import android.view.View;
-
public class AutoComplete6 extends Activity {
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Buttons1.java b/samples/ApiDemos/src/com/example/android/apis/view/Buttons1.java
index e2f8cc8..a88ee30 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Buttons1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Buttons1.java
@@ -22,9 +22,6 @@
import android.app.Activity;
import android.os.Bundle;
-import android.widget.Spinner;
-import android.widget.ArrayAdapter;
-
/**
* A gallery of the different styles of buttons.
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Focus1.java b/samples/ApiDemos/src/com/example/android/apis/view/Focus1.java
index 86f6ee7..c816b31 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Focus1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Focus1.java
@@ -20,12 +20,10 @@
import android.app.Activity;
import android.os.Bundle;
-import android.view.View;
import android.webkit.WebView;
import android.widget.ListView;
import android.widget.ArrayAdapter;
-
/**
* Demonstrates the use of non-focusable views.
*/
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Gallery1.java b/samples/ApiDemos/src/com/example/android/apis/view/Gallery1.java
index a539a5b..7aaaaef 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Gallery1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Gallery1.java
@@ -49,7 +49,7 @@
// Set a item click listener, and just Toast the clicked position
g.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView parent, View v, int position, long id) {
+ public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(Gallery1.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.java b/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.java
index 66ef282..7f17c82 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/ImageSwitcher1.java
@@ -56,11 +56,11 @@
g.setOnItemSelectedListener(this);
}
- public void onItemSelected(AdapterView parent, View v, int position, long id) {
+ public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
mSwitcher.setImageResource(mImageIds[position]);
}
- public void onNothingSelected(AdapterView parent) {
+ public void onNothingSelected(AdapterView<?> parent) {
}
public View makeView() {
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/List13.java b/samples/ApiDemos/src/com/example/android/apis/view/List13.java
index b3087be..68179ed 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/List13.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/List13.java
@@ -52,7 +52,6 @@
private LayoutInflater mInflater;
public SlowAdapter(Context context) {
- mContext = context;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@@ -114,11 +113,6 @@
return text;
}
-
- /**
- * Remember our context so we can use it when constructing views.
- */
- private Context mContext;
}
@Override
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/List9.java b/samples/ApiDemos/src/com/example/android/apis/view/List9.java
index 15b3cc1..b2aea05 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/List9.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/List9.java
@@ -111,8 +111,8 @@
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int lastItem = firstVisibleItem + visibleItemCount - 1;
+ public void onScroll(AbsListView view, int firstVisibleItem,
+ int visibleItemCount, int totalItemCount) {
if (mReady) {
char firstLetter = mStrings[firstVisibleItem].charAt(0);
@@ -120,8 +120,6 @@
mShowing = true;
mDialogText.setVisibility(View.VISIBLE);
-
-
}
mDialogText.setText(((Character)firstLetter).toString());
mHandler.removeCallbacks(mRemoveWindow);
@@ -316,5 +314,4 @@
"Woodside Cabecou", "Xanadu", "Xynotyro", "Yarg Cornish",
"Yarra Valley Pyramid", "Yorkshire Blue", "Zamorano",
"Zanetti Grana Padano", "Zanetti Parmigiano Reggiano"};
-
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/RatingBar1.java b/samples/ApiDemos/src/com/example/android/apis/view/RatingBar1.java
index 97416d4..5fbf6dd 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/RatingBar1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/RatingBar1.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.os.Bundle;
import android.widget.RatingBar;
-import android.widget.SeekBar;
import android.widget.TextView;
import com.example.android.apis.R;
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/ScrollView2.java b/samples/ApiDemos/src/com/example/android/apis/view/ScrollView2.java
index 1af3c81..02fcd0e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/ScrollView2.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/ScrollView2.java
@@ -24,7 +24,6 @@
import android.widget.TextView;
import android.widget.Button;
-
/**
* Demonstrates wrapping a layout in a ScrollView.
*
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout10.java b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout10.java
index f1f8f24..f904f84 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout10.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout10.java
@@ -19,15 +19,9 @@
import com.example.android.apis.R;
import android.app.Activity;
-import android.widget.TableLayout;
-import android.widget.Button;
import android.os.Bundle;
-import android.view.View;
-
public class TableLayout10 extends Activity {
- private boolean mShrink;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout11.java b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout11.java
index 770238f..09b19a2 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout11.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout11.java
@@ -25,8 +25,6 @@
* <p>This example shows how to use horizontal gravity in a table layout.</p>
*/
public class TableLayout11 extends Activity {
- private boolean mShrink;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout12.java b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout12.java
index 14cbd0d..f3fe850 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/TableLayout12.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/TableLayout12.java
@@ -25,8 +25,6 @@
* <p>This example shows how to use cell spanning in a table layout.</p>
*/
public class TableLayout12 extends Activity {
- private boolean mShrink;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/Tabs1.java b/samples/ApiDemos/src/com/example/android/apis/view/Tabs1.java
index 455969e..39f7e9b 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/Tabs1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/Tabs1.java
@@ -21,7 +21,6 @@
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.view.LayoutInflater;
-import android.view.View;
import com.example.android.apis.R;
diff --git a/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java b/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
index a4ffef5..15c5923 100644
--- a/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
+++ b/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
@@ -21,7 +21,6 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.Window;
import android.widget.TextView;
import com.example.android.lunarlander.LunarView.LunarThread;
@@ -58,7 +57,7 @@
/**
* Invoked during init to give the Activity a chance to set up its Menu.
- *
+ *
* @param menu the Menu to which entries may be added
* @return true
*/
@@ -79,7 +78,7 @@
/**
* Invoked when the user selects an item from the Menu.
- *
+ *
* @param item the Menu entry which was selected
* @return true if the Menu item was legit (and we consumed it), false
* otherwise
@@ -116,7 +115,7 @@
/**
* Invoked when the Activity is created.
- *
+ *
* @param savedInstanceState a Bundle containing state saved from a previous
* execution, or null if this is a new execution
*/
@@ -157,7 +156,7 @@
/**
* Notification that something is about to happen, to give the Activity a
* chance to save state.
- *
+ *
* @param outState a Bundle into which this Activity should save its state
*/
@Override
diff --git a/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java b/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
index c52c7ab..2a46147 100644
--- a/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
+++ b/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
@@ -37,7 +37,7 @@
/**
* View that draws, takes keystrokes, etc. for a simple LunarLander game.
- *
+ *
* Has a mode which RUNNING, PAUSED, etc. Has a x, y, dx, dy, ... capturing the
* current ship physics. All x/y etc. are measured with (0,0) at the lower left.
* updatePhysics() advances the physics based on realtime. draw() renders the
@@ -112,14 +112,14 @@
/**
* Current height of the surface/canvas.
- *
+ *
* @see #setSurfaceSize
*/
private int mCanvasHeight = 1;
/**
* Current width of the surface/canvas.
- *
+ *
* @see #setSurfaceSize
*/
private int mCanvasWidth = 1;
@@ -321,7 +321,7 @@
* Restores game state from the indicated Bundle. Typically called when
* the Activity is being restored after having been previously
* destroyed.
- *
+ *
* @param savedState Bundle containing the game state
*/
public synchronized void restoreState(Bundle savedState) {
@@ -372,7 +372,7 @@
/**
* Dump game state to the provided Bundle. Typically called when the
* Activity is being suspended.
- *
+ *
* @return Bundle with this view's state
*/
public Bundle saveState(Bundle map) {
@@ -400,7 +400,7 @@
/**
* Sets the current difficulty.
- *
+ *
* @param difficulty
*/
public void setDifficulty(int difficulty) {
@@ -423,7 +423,7 @@
* Passing true allows the thread to run; passing false will shut it
* down if it's already running. Calling start() after this was most
* recently called with false will result in an immediate shutdown.
- *
+ *
* @param b true to run, false to shut down
*/
public void setRunning(boolean b) {
@@ -433,7 +433,7 @@
/**
* Sets the game mode. That is, whether we are running, paused, in the
* failure state, in the victory state, etc.
- *
+ *
* @see #setState(int, CharSequence)
* @param mode one of the STATE_* constants
*/
@@ -446,7 +446,7 @@
/**
* Sets the game mode. That is, whether we are running, paused, in the
* failure state, in the victory state, etc.
- *
+ *
* @param mode one of the STATE_* constants
* @param message string to add to screen or null
*/
@@ -509,7 +509,7 @@
mCanvasHeight = height;
// don't forget to resize the background image
- mBackgroundImage = mBackgroundImage.createScaledBitmap(
+ mBackgroundImage = Bitmap.createScaledBitmap(
mBackgroundImage, width, height, true);
}
}
@@ -527,7 +527,7 @@
/**
* Handles a key-down event.
- *
+ *
* @param keyCode the key that was pressed
* @param msg the original event object
* @return true
@@ -539,8 +539,6 @@
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) okStart = true;
if (keyCode == KeyEvent.KEYCODE_S) okStart = true;
- boolean center = (keyCode == KeyEvent.KEYCODE_DPAD_UP);
-
if (okStart
&& (mMode == STATE_READY || mMode == STATE_LOSE || mMode == STATE_WIN)) {
// ready-to-start -> start
@@ -579,7 +577,7 @@
/**
* Handles a key-up event.
- *
+ *
* @param keyCode the key that was pressed
* @param msg the original event object
* @return true if the key was handled and consumed, or else false
@@ -807,7 +805,7 @@
/**
* Fetches the animation thread corresponding to this LunarView.
- *
+ *
* @return the animation thread
*/
public LunarThread getThread() {