Merge "Enhanced demo for view transformation properties"
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index cda740a..f23a215 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -262,7 +262,6 @@
<activity android:name=".app.FragmentLayout$DetailsActivity" />
<activity android:name=".app.FragmentListCursorLoader"
- android:theme="@android:style/Theme.WithActionBar"
android:label="@string/fragment_list_cursor_loader">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -279,7 +278,6 @@
</activity>
<activity android:name=".app.FragmentMenu"
- android:theme="@android:style/Theme.WithActionBar"
android:label="@string/fragment_menu">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -669,8 +667,7 @@
</intent-filter>
</activity>
- <activity android:name=".app.ActionBarUsage" android:label="@string/action_bar_usage"
- android:theme="@android:style/Theme.WithActionBar">
+ <activity android:name=".app.ActionBarUsage" android:label="@string/action_bar_usage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1387,8 +1384,14 @@
</intent-filter>
</activity>
- <activity android:name=".view.List15" android:label="Views/Lists/15. Selection Mode"
- android:theme="@android:style/Theme.WithActionBar">
+ <activity android:name=".view.List15" android:label="Views/Lists/15. Selection Mode">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".view.List16" android:label="Views/Lists/16. Border selection mode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1461,8 +1464,7 @@
</activity>
<activity android:name=".view.Grid3"
- android:label="Views/Grid/3. Selection Mode"
- android:theme="@android:style/Theme.WithActionBar">
+ android:label="Views/Grid/3. Selection Mode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1755,6 +1757,13 @@
</intent-filter>
</activity>
+ <activity android:name=".view.SecureView" android:label="Views/Secure View">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<!-- ************************************* -->
<!-- GRAPHICS SAMPLES -->
<!-- ************************************* -->
diff --git a/samples/ApiDemos/res/layout/secure_view.xml b/samples/ApiDemos/res/layout/secure_view.xml
new file mode 100644
index 0000000..82a1f79
--- /dev/null
+++ b/samples/ApiDemos/res/layout/secure_view.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Demonstrates secure views. -->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <LinearLayout
+ android:orientation="vertical"
+ android:padding="10dip"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextView
+ android:id="@+id/secure_view_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_description"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip"
+ android:textStyle="bold"
+ android:text="@string/secure_view_step1_heading"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_step1_detail"/>
+
+ <Button
+ android:id="@+id/secure_view_toast_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/secure_view_pop_toast"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip"
+ android:textStyle="bold"
+ android:text="@string/secure_view_step2_heading"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_step2_detail"/>
+
+ <Button
+ android:id="@+id/secure_view_unsecure_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:textColor="#833"
+ android:text="@string/secure_view_button"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip"
+ android:textStyle="bold"
+ android:text="@string/secure_view_step3_heading"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_step3_detail"/>
+
+ <Button
+ android:id="@+id/secure_view_builtin_secure_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:filterTouchesWhenObscured="true"
+ android:textColor="#833"
+ android:text="@string/secure_view_button"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip"
+ android:textStyle="bold"
+ android:text="@string/secure_view_step4_heading"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_step4_detail"/>
+
+ <Button
+ android:id="@+id/secure_view_custom_secure_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:textColor="#833"
+ android:text="@string/secure_view_button"/>
+ </LinearLayout>
+</ScrollView>
diff --git a/samples/ApiDemos/res/layout/secure_view_overlay.xml b/samples/ApiDemos/res/layout/secure_view_overlay.xml
new file mode 100644
index 0000000..aaa043a
--- /dev/null
+++ b/samples/ApiDemos/res/layout/secure_view_overlay.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- An overlay that will appear on top of the secure view in an attempt to obscure
+ its true purpose and encourage the user to click on the secure button. -->
+<com.example.android.apis.view.SecureViewOverlay
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/secure_view_overlay_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/secure_view_overlay_description"/>
+
+ <Button
+ android:id="@+id/secure_view_overlay_button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="#383"
+ android:text="@string/secure_view_overlay_button1"/>
+
+ <Button
+ android:id="@+id/secure_view_overlay_button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="#383"
+ android:text="@string/secure_view_overlay_button2"/>
+
+ <Button
+ android:id="@+id/secure_view_overlay_button3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="#383"
+ android:text="@string/secure_view_overlay_button3"/>
+</com.example.android.apis.view.SecureViewOverlay>
diff --git a/samples/ApiDemos/res/values/arrays.xml b/samples/ApiDemos/res/values/arrays.xml
index e462868..8b32e86 100644
--- a/samples/ApiDemos/res/values/arrays.xml
+++ b/samples/ApiDemos/res/values/arrays.xml
@@ -103,4 +103,12 @@
<item>Complex</item>
</string-array>
+ <!-- Used in view/Secure View examples -->
+ <string-array name="secure_view_clicked">
+ <item>*bzzt*\nTransferred $1,000,000 to J. Phisher. Thank you!</item>
+ <item>*bzzt*\nSending all life savings to the International Cabal of Evil Penguins.</item>
+ <item>*bzzt*\nOpening portal to R\'lyeh. Long live Cthulhu!</item>
+ <item>*bzzt*\nYou\'re not very good at this, are you?</item>
+ <item>*bzzt*\nGo away...</item>
+ </string-array>
</resources>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index a29df0f..2f95bb9 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -610,6 +610,49 @@
<string name="popup_menu_share">Share</string>
<string name="popup_menu_button">Make a Popup!</string>
+ <string name="secure_view_description">
+ This activity demonstrates a view that detects when it is potentially obscured
+ by other windows.
+ </string>
+ <string name="secure_view_step1_heading">Click me first:</string>
+ <string name="secure_view_step1_detail">
+ Pop up a toast that will overlay and obscure this window in a poor attempt to fool
+ you into clicking the big red buttons. Don\'t do it!
+ </string>
+ <string name="secure_view_step2_heading">Unfiltered demo:</string>
+ <string name="secure_view_step2_detail">
+ This button does no filtering. This button will still work as usual while the
+ toast is visible and is spoofing the view. Careful!
+ </string>
+ <string name="secure_view_step3_heading">Built-in filtering demo:</string>
+ <string name="secure_view_step3_detail">
+ This button uses the built-in secure touch filtering provided by the framework
+ using the android:filterTouchesWhenObscured attribute. This button will be inoperable
+ while the toast is visible.
+ </string>
+ <string name="secure_view_step4_heading">Custom filtering demo:</string>
+ <string name="secure_view_step4_detail">
+ This button filters touches using a touch listener to examine the MotionEvent flags
+ and warns the user. This button will display a message if touched while the
+ toast is visible.
+ </string>
+
+ <string name="secure_view_pop_toast">Pop toast</string>
+ <string name="secure_view_button">Don\'t click! It\'ll cost you!</string>
+ <string name="secure_view_action_dialog_title">Oh no!</string>
+ <string name="secure_view_action_dialog_dismiss">Oops...</string>
+ <string name="secure_view_caught_dialog_title">Saved!</string>
+ <string name="secure_view_caught_dialog_message">
+ Careful! There appears to be another window partly obscuring this window...
+ Something unutterably HORRIBLE might have happened.
+ </string>
+ <string name="secure_view_caught_dialog_dismiss">Phew!</string>
+
+ <string name="secure_view_overlay_description">A toast! A toast!</string>
+ <string name="secure_view_overlay_button1">Totally safe, trust me...</string>
+ <string name="secure_view_overlay_button2">Clicky?</string>
+ <string name="secure_view_overlay_button3">Think of the penguins!</string>
+
<!-- ============================== -->
<!-- GoogleLogin examples strings -->
<!-- ============================== -->
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/List16.java b/samples/ApiDemos/src/com/example/android/apis/view/List16.java
new file mode 100644
index 0000000..8e19a7f
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/List16.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.apis.view;
+
+import com.example.android.apis.R;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.view.ActionMode;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+
+/**
+ * This demo illustrates the use of CHOICE_MODE_MULTIPLE_MODAL, a.k.a. selection mode on ListView
+ * couple with the new simple_selectable_list_item which uses a highligted border for selected items.
+ */
+public class List16 extends ListActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ ListView lv = getListView();
+ lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
+ lv.setMultiChoiceModeListener(new ModeCallback());
+ setListAdapter(new ArrayAdapter<String>(this,
+ android.R.layout.simple_selectable_list_item, mStrings));
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ getActionBar().setSubtitle("Long press to start selection");
+ }
+
+ private class ModeCallback implements ListView.MultiChoiceModeListener {
+
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.list_select_menu, menu);
+ mode.setTitle("Select Items");
+ return true;
+ }
+
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return true;
+ }
+
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.share:
+ Toast.makeText(List16.this, "Shared " + getListView().getCheckedItemCount() +
+ " items", Toast.LENGTH_SHORT).show();
+ mode.finish();
+ break;
+ default:
+ Toast.makeText(List16.this, "Clicked " + item.getTitle(),
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ return true;
+ }
+
+ public void onDestroyActionMode(ActionMode mode) {
+ }
+
+ public void onItemCheckedStateChanged(ActionMode mode,
+ int position, long id, boolean checked) {
+ final int checkedCount = getListView().getCheckedItemCount();
+ switch (checkedCount) {
+ case 0:
+ mode.setSubtitle(null);
+ break;
+ case 1:
+ mode.setSubtitle("One item selected");
+ break;
+ default:
+ mode.setSubtitle("" + checkedCount + " items selected");
+ break;
+ }
+ }
+
+ }
+
+ private String[] mStrings = {
+ "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
+ "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
+ "Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
+ "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell",
+ "Aragon", "Ardi Gasna", "Ardrahan", "Armenian String", "Aromes au Gene de Marc",
+ "Asadero", "Asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss",
+ "Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "Bandal", "Banon",
+ "Barry's Bay Cheddar", "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase",
+ "Baylough", "Beaufort", "Beauvoorde", "Beenleigh Blue", "Beer Cheese", "Bel Paese",
+ "Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir", "Bierkase", "Bishop Kennedy",
+ "Blarney", "Bleu d'Auvergne", "Bleu de Gex", "Bleu de Laqueuille",
+ "Bleu de Septmoncel", "Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore",
+ "Blue Vein (Australian)", "Blue Vein Cheeses", "Bocconcini", "Bocconcini (Australian)",
+ "Boeren Leidenkaas", "Bonchester", "Bosworth", "Bougon", "Boule Du Roves",
+ "Boulette d'Avesnes", "Boursault", "Boursin", "Bouyssou", "Bra", "Braudostur",
+ "Breakfast Cheese", "Brebis du Lavort", "Brebis du Lochois", "Brebis du Puyfaucon",
+ "Bresse Bleu", "Brick", "Brie", "Brie de Meaux", "Brie de Melun", "Brillat-Savarin",
+ "Brin", "Brin d' Amour", "Brin d'Amour", "Brinza (Burduf Brinza)",
+ "Briquette de Brebis", "Briquette du Forez", "Broccio", "Broccio Demi-Affine",
+ "Brousse du Rove", "Bruder Basil", "Brusselae Kaas (Fromage de Bruxelles)", "Bryndza",
+ "Buchette d'Anjou", "Buffalo", "Burgos", "Butte", "Butterkase", "Button (Innes)",
+ "Buxton Blue", "Cabecou", "Caboc", "Cabrales", "Cachaille", "Caciocavallo", "Caciotta",
+ "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola", "Camembert de Normandie",
+ "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux", "Capricorn Goat",
+ "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano",
+ "Castelleno", "Castelmagno", "Castelo Branco", "Castigliano", "Cathelain",
+ "Celtic Promise", "Cendre d'Olivet", "Cerney", "Chabichou", "Chabichou du Poitou",
+ "Chabis de Gatine", "Chaource", "Charolais", "Chaumes", "Cheddar",
+ "Cheddar Clothbound", "Cheshire", "Chevres", "Chevrotin des Aravis", "Chontaleno",
+ "Civray", "Coeur de Camembert au Calvados", "Coeur de Chevre", "Colby", "Cold Pack",
+ "Comte", "Coolea", "Cooleney", "Coquetdale", "Corleggy", "Cornish Pepper",
+ "Cotherstone", "Cotija", "Cottage Cheese", "Cottage Cheese (Australian)",
+ "Cougar Gold", "Coulommiers", "Coverdale", "Crayeux de Roncq", "Cream Cheese",
+ "Cream Havarti", "Crema Agria", "Crema Mexicana", "Creme Fraiche", "Crescenza",
+ "Croghan", "Crottin de Chavignol", "Crottin du Chavignol", "Crowdie", "Crowley",
+ "Cuajada", "Curd", "Cure Nantais", "Curworthy", "Cwmtawe Pecorino",
+ "Cypress Grove Chevre", "Danablu (Danish Blue)", "Danbo", "Danish Fontina",
+ "Daralagjazsky", "Dauphin", "Delice des Fiouves", "Denhany Dorset Drum", "Derby",
+ "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Dolcelatte", "Doolin",
+ "Doppelrhamstufel", "Dorset Blue Vinney", "Double Gloucester", "Double Worcester",
+ "Dreux a la Feuille", "Dry Jack", "Duddleswell", "Dunbarra", "Dunlop", "Dunsyre Blue",
+ "Duroblando", "Durrus", "Dutch Mimolette (Commissiekaas)", "Edam", "Edelpilz",
+ "Emental Grand Cru", "Emlett", "Emmental", "Epoisses de Bourgogne", "Esbareich",
+ "Esrom", "Etorki", "Evansdale Farmhouse Brie", "Evora De L'Alentejo", "Exmoor Blue",
+ "Explorateur", "Feta", "Feta (Australian)", "Figue", "Filetta", "Fin-de-Siecle",
+ "Finlandia Swiss", "Finn", "Fiore Sardo", "Fleur du Maquis", "Flor de Guia",
+ "Flower Marie", "Folded", "Folded cheese with mint", "Fondant de Brebis",
+ "Fontainebleau", "Fontal", "Fontina Val d'Aosta", "Formaggio di capra", "Fougerus",
+ "Four Herb Gouda", "Fourme d' Ambert", "Fourme de Haute Loire", "Fourme de Montbrison",
+ "Fresh Jack", "Fresh Mozzarella", "Fresh Ricotta", "Fresh Truffles", "Fribourgeois",
+ "Friesekaas", "Friesian", "Friesla", "Frinault", "Fromage a Raclette", "Fromage Corse",
+ "Fromage de Montagne de Savoie", "Fromage Frais", "Fruit Cream Cheese",
+ "Frying Cheese", "Fynbo", "Gabriel", "Galette du Paludier", "Galette Lyonnaise",
+ "Galloway Goat's Milk Gems", "Gammelost", "Gaperon a l'Ail", "Garrotxa", "Gastanberra",
+ "Geitost", "Gippsland Blue", "Gjetost", "Gloucester", "Golden Cross", "Gorgonzola",
+ "Gornyaltajski", "Gospel Green", "Gouda", "Goutu", "Gowrie", "Grabetto", "Graddost",
+ "Grafton Village Cheddar", "Grana", "Grana Padano", "Grand Vatel",
+ "Grataron d' Areches", "Gratte-Paille", "Graviera", "Greuilh", "Greve",
+ "Gris de Lille", "Gruyere", "Gubbeen", "Guerbigny", "Halloumi",
+ "Halloumy (Australian)", "Haloumi-Style Cheese", "Harbourne Blue", "Havarti",
+ "Heidi Gruyere", "Hereford Hop", "Herrgardsost", "Herriot Farmhouse", "Herve",
+ "Hipi Iti", "Hubbardston Blue Cow", "Hushallsost", "Iberico", "Idaho Goatster",
+ "Idiazabal", "Il Boschetto al Tartufo", "Ile d'Yeu", "Isle of Mull", "Jarlsberg",
+ "Jermi Tortes", "Jibneh Arabieh", "Jindi Brie", "Jubilee Blue", "Juustoleipa",
+ "Kadchgall", "Kaseri", "Kashta", "Kefalotyri", "Kenafa", "Kernhem", "Kervella Affine",
+ "Kikorangi", "King Island Cape Wickham Brie", "King River Gold", "Klosterkaese",
+ "Knockalara", "Kugelkase", "L'Aveyronnais", "L'Ecir de l'Aubrac", "La Taupiniere",
+ "La Vache Qui Rit", "Laguiole", "Lairobell", "Lajta", "Lanark Blue", "Lancashire",
+ "Langres", "Lappi", "Laruns", "Lavistown", "Le Brin", "Le Fium Orbo", "Le Lacandou",
+ "Le Roule", "Leafield", "Lebbene", "Leerdammer", "Leicester", "Leyden", "Limburger",
+ "Lincolnshire Poacher", "Lingot Saint Bousquet d'Orb", "Liptauer", "Little Rydings",
+ "Livarot", "Llanboidy", "Llanglofan Farmhouse", "Loch Arthur Farmhouse",
+ "Loddiswell Avondale", "Longhorn", "Lou Palou", "Lou Pevre", "Lyonnais", "Maasdam",
+ "Macconais", "Mahoe Aged Gouda", "Mahon", "Malvern", "Mamirolle", "Manchego",
+ "Manouri", "Manur", "Marble Cheddar", "Marbled Cheeses", "Maredsous", "Margotin",
+ "Maribo", "Maroilles", "Mascares", "Mascarpone", "Mascarpone (Australian)",
+ "Mascarpone Torta", "Matocq", "Maytag Blue", "Meira", "Menallack Farmhouse",
+ "Menonita", "Meredith Blue", "Mesost", "Metton (Cancoillotte)", "Meyer Vintage Gouda",
+ "Mihalic Peynir", "Milleens", "Mimolette", "Mine-Gabhar", "Mini Baby Bells", "Mixte",
+ "Molbo", "Monastery Cheeses", "Mondseer", "Mont D'or Lyonnais", "Montasio",
+ "Monterey Jack", "Monterey Jack Dry", "Morbier", "Morbier Cru de Montagne",
+ "Mothais a la Feuille", "Mozzarella", "Mozzarella (Australian)",
+ "Mozzarella di Bufala", "Mozzarella Fresh, in water", "Mozzarella Rolls", "Munster",
+ "Murol", "Mycella", "Myzithra", "Naboulsi", "Nantais", "Neufchatel",
+ "Neufchatel (Australian)", "Niolo", "Nokkelost", "Northumberland", "Oaxaca",
+ "Olde York", "Olivet au Foin", "Olivet Bleu", "Olivet Cendre",
+ "Orkney Extra Mature Cheddar", "Orla", "Oschtjepka", "Ossau Fermier", "Ossau-Iraty",
+ "Oszczypek", "Oxford Blue", "P'tit Berrichon", "Palet de Babligny", "Paneer", "Panela",
+ "Pannerone", "Pant ys Gawn", "Parmesan (Parmigiano)", "Parmigiano Reggiano",
+ "Pas de l'Escalette", "Passendale", "Pasteurized Processed", "Pate de Fromage",
+ "Patefine Fort", "Pave d'Affinois", "Pave d'Auge", "Pave de Chirac", "Pave du Berry",
+ "Pecorino", "Pecorino in Walnut Leaves", "Pecorino Romano", "Peekskill Pyramid",
+ "Pelardon des Cevennes", "Pelardon des Corbieres", "Penamellera", "Penbryn",
+ "Pencarreg", "Perail de Brebis", "Petit Morin", "Petit Pardou", "Petit-Suisse",
+ "Picodon de Chevre", "Picos de Europa", "Piora", "Pithtviers au Foin",
+ "Plateau de Herve", "Plymouth Cheese", "Podhalanski", "Poivre d'Ane", "Polkolbin",
+ "Pont l'Eveque", "Port Nicholson", "Port-Salut", "Postel", "Pouligny-Saint-Pierre",
+ "Pourly", "Prastost", "Pressato", "Prince-Jean", "Processed Cheddar", "Provolone",
+ "Provolone (Australian)", "Pyengana Cheddar", "Pyramide", "Quark",
+ "Quark (Australian)", "Quartirolo Lombardo", "Quatre-Vents", "Quercy Petit",
+ "Queso Blanco", "Queso Blanco con Frutas --Pina y Mango", "Queso de Murcia",
+ "Queso del Montsec", "Queso del Tietar", "Queso Fresco", "Queso Fresco (Adobera)",
+ "Queso Iberico", "Queso Jalapeno", "Queso Majorero", "Queso Media Luna",
+ "Queso Para Frier", "Queso Quesadilla", "Rabacal", "Raclette", "Ragusano", "Raschera",
+ "Reblochon", "Red Leicester", "Regal de la Dombes", "Reggianito", "Remedou",
+ "Requeson", "Richelieu", "Ricotta", "Ricotta (Australian)", "Ricotta Salata", "Ridder",
+ "Rigotte", "Rocamadour", "Rollot", "Romano", "Romans Part Dieu", "Roncal", "Roquefort",
+ "Roule", "Rouleau De Beaulieu", "Royalp Tilsit", "Rubens", "Rustinu", "Saaland Pfarr",
+ "Saanenkaese", "Saga", "Sage Derby", "Sainte Maure", "Saint-Marcellin",
+ "Saint-Nectaire", "Saint-Paulin", "Salers", "Samso", "San Simon", "Sancerre",
+ "Sap Sago", "Sardo", "Sardo Egyptian", "Sbrinz", "Scamorza", "Schabzieger", "Schloss",
+ "Selles sur Cher", "Selva", "Serat", "Seriously Strong Cheddar", "Serra da Estrela",
+ "Sharpam", "Shelburne Cheddar", "Shropshire Blue", "Siraz", "Sirene", "Smoked Gouda",
+ "Somerset Brie", "Sonoma Jack", "Sottocenare al Tartufo", "Soumaintrain",
+ "Sourire Lozerien", "Spenwood", "Sraffordshire Organic", "St. Agur Blue Cheese",
+ "Stilton", "Stinking Bishop", "String", "Sussex Slipcote", "Sveciaost", "Swaledale",
+ "Sweet Style Swiss", "Swiss", "Syrian (Armenian String)", "Tala", "Taleggio", "Tamie",
+ "Tasmania Highland Chevre Log", "Taupiniere", "Teifi", "Telemea", "Testouri",
+ "Tete de Moine", "Tetilla", "Texas Goat Cheese", "Tibet", "Tillamook Cheddar",
+ "Tilsit", "Timboon Brie", "Toma", "Tomme Brulee", "Tomme d'Abondance",
+ "Tomme de Chevre", "Tomme de Romans", "Tomme de Savoie", "Tomme des Chouans", "Tommes",
+ "Torta del Casar", "Toscanello", "Touree de L'Aubier", "Tourmalet",
+ "Trappe (Veritable)", "Trois Cornes De Vendee", "Tronchon", "Trou du Cru", "Truffe",
+ "Tupi", "Turunmaa", "Tymsboro", "Tyn Grug", "Tyning", "Ubriaco", "Ulloa",
+ "Vacherin-Fribourgeois", "Valencay", "Vasterbottenost", "Venaco", "Vendomois",
+ "Vieux Corse", "Vignotte", "Vulscombe", "Waimata Farmhouse Blue",
+ "Washed Rind Cheese (Australian)", "Waterloo", "Weichkaese", "Wellington",
+ "Wensleydale", "White Stilton", "Whitestone Farmhouse", "Wigmore", "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/SecureView.java b/samples/ApiDemos/src/com/example/android/apis/view/SecureView.java
new file mode 100644
index 0000000..b9aaeab
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/SecureView.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.view;
+
+import com.example.android.apis.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
+import android.widget.Button;
+import android.widget.Toast;
+
+
+/**
+ * This activity demonstrates two different ways in which views can be made more secure to
+ * touch spoofing attacks by leveraging framework features.
+ *
+ * The activity presents 3 buttons that obtensibly perform a risky security critical
+ * function. Under ordinary circumstances, the user would never click on these buttons
+ * or would at least think long and hard about it. However, a carefully crafted toast can
+ * overlay the contents of the activity in such a way as to make the user believe the buttons
+ * are innocuous. Since the toast cannot receive input, the touches are passed down to the
+ * activity potentially yielding an effect other than what the user intended.
+ *
+ * To simulate the spoofing risk, this activity pops up a specially crafted overlay as
+ * a toast layed out so as to cover the buttons and part of the descriptive text.
+ * For the purposes of this demonstration, pretend that the overlay was actually popped
+ * up by a malicious application published by the International Cabal of Evil Penguins.
+ *
+ * The 3 buttons are set up as follows:
+ *
+ * 1. The "unsecured button" does not apply any touch filtering of any kind.
+ * When the toast appears, this button remains clickable as usual which creates an
+ * opportunity for spoofing to occur.
+ *
+ * 2. The "built-in secured button" leverages the android:filterTouchesWhenObscured view
+ * attribute to ask the framework to filter out touches when the window is obscured.
+ * When the toast appears, the button does not receive the touch and appears to be inoperable.
+ *
+ * 3. The "custom secured button" adds a touch listener to the button which intercepts the
+ * touch event and checks whether the window is obscured. If so, it warns the user and
+ * drops the touch event. This example is intended to demonstrate how a view can
+ * perform its own filtering and provide additional feedback by examining the {@MotionEvent}
+ * flags to determine whether the window is obscured. Here we use a touch listener but
+ * a custom view subclass could perform the filtering by overriding
+ * {@link View#onFilterTouchEventForSecurity(MotionEvent)}.
+ *
+ * Refer to the comments on {@View} for more information about view security.
+ */
+public class SecureView extends Activity {
+ private int mClickCount;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.secure_view);
+
+ Button toastButton = (Button) findViewById(R.id.secure_view_toast_button);
+ toastButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ showOverlay();
+ }
+ });
+
+ Button unsecureButton = (Button) findViewById(R.id.secure_view_unsecure_button);
+ setClickedAction(unsecureButton);
+
+ Button builtinSecureButton = (Button) findViewById(R.id.secure_view_builtin_secure_button);
+ setClickedAction(builtinSecureButton);
+
+ Button customSecureButton = (Button) findViewById(R.id.secure_view_custom_secure_button);
+ setClickedAction(customSecureButton);
+ setTouchFilter(customSecureButton);
+ }
+
+ private void showOverlay() {
+ // Generate a toast view with a special layout that will position itself right
+ // on top of this view's interesting widgets. Sneaky huh?
+ SecureViewOverlay overlay = (SecureViewOverlay)
+ getLayoutInflater().inflate(R.layout.secure_view_overlay, null);
+ overlay.setActivityToSpoof(this);
+
+ Toast toast = new Toast(getApplicationContext());
+ toast.setGravity(Gravity.FILL, 0, 0);
+ toast.setView(overlay);
+ toast.show();
+ }
+
+ private void setClickedAction(Button button) {
+ button.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ String[] messages = getResources().getStringArray(R.array.secure_view_clicked);
+ String message = messages[mClickCount++ % messages.length];
+
+ new AlertDialog.Builder(SecureView.this)
+ .setTitle(R.string.secure_view_action_dialog_title)
+ .setMessage(message)
+ .setNeutralButton(getResources().getString(
+ R.string.secure_view_action_dialog_dismiss), null)
+ .show();
+ }
+ });
+ }
+
+ private void setTouchFilter(Button button) {
+ button.setOnTouchListener(new OnTouchListener() {
+ public boolean onTouch(View v, MotionEvent event) {
+ if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ new AlertDialog.Builder(SecureView.this)
+ .setTitle(R.string.secure_view_caught_dialog_title)
+ .setMessage(R.string.secure_view_caught_dialog_message)
+ .setNeutralButton(getResources().getString(
+ R.string.secure_view_caught_dialog_dismiss), null)
+ .show();
+ }
+ // Return true to prevent the button from processing the touch.
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/SecureViewOverlay.java b/samples/ApiDemos/src/com/example/android/apis/view/SecureViewOverlay.java
new file mode 100644
index 0000000..2095fee
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/view/SecureViewOverlay.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.apis.view;
+
+import com.example.android.apis.R;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * This view is part of the {@link SecureView} demonstration activity.
+ *
+ * This view is constructed in such a way as to obscure the buttons and descriptive
+ * text of the activity in a poor attempt to fool the user into clicking on the buttons
+ * despite the activity telling the user that they may be harmful.
+ */
+public class SecureViewOverlay extends ViewGroup {
+ private SecureView mActivity;
+
+ public SecureViewOverlay(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setActivityToSpoof(SecureView activity) {
+ this.mActivity = activity;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ measureChildren(widthMeasureSpec, heightMeasureSpec);
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ spoofLayout(findViewById(R.id.secure_view_overlay_description),
+ mActivity.findViewById(R.id.secure_view_description));
+ spoofLayout(findViewById(R.id.secure_view_overlay_button1),
+ mActivity.findViewById(R.id.secure_view_unsecure_button));
+ spoofLayout(findViewById(R.id.secure_view_overlay_button2),
+ mActivity.findViewById(R.id.secure_view_builtin_secure_button));
+ spoofLayout(findViewById(R.id.secure_view_overlay_button3),
+ mActivity.findViewById(R.id.secure_view_custom_secure_button));
+ }
+
+ private void spoofLayout(View spoof, View original) {
+ final int[] globalPos = new int[2];
+ getLocationOnScreen(globalPos);
+ int x = globalPos[0];
+ int y = globalPos[1];
+
+ original.getLocationOnScreen(globalPos);
+ x = globalPos[0] - x;
+ y = globalPos[1] - y;
+ spoof.layout(x, y, x + original.getWidth(), y + original.getHeight());
+ }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/_index.html b/samples/ApiDemos/src/com/example/android/apis/view/_index.html
index 21d756f..0a435c1 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/_index.html
+++ b/samples/ApiDemos/src/com/example/android/apis/view/_index.html
@@ -163,6 +163,30 @@
<dt><a href="List8.html">8. Photos</a></dt>
<dd> Demonstrates a list activity that uses a custom ListAdapter, setting the view for an empty item, and also how to customize the layout of a ListActivity. </dd>
+
+ <dt><a href="List9.html">9. Array (Overlay)</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List10.html">10. Single choice list</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List11.html">11. Multiple choice list</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List12.html">12. Transcript</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List13.html">13. Slow Adapter</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List14.html">14. Efficient Adapter</a></dt>
+ <dd> </dd>
+
+ <dt><a href="List15.html">15. Selection Mode</a></dt>
+ <dd> Demonstrates the use of selection Contextual Action mode to select multiple items in a list activity. </dd>
+
+ <dt><a href="List16.html">16. Border selection mode</a></dt>
+ <dd> Demonstrates a multi-select list activity that uses the <code>simple_selectable_list_item</code> border layout for selected items. </dd>
</dl>