am 4edf078e: Add sample _index.jd to test new samples in browser generator.
* commit '4edf078eb9ebf551f2d3c3882d46a195726a0c3d':
Add sample _index.jd to test new samples in browser generator.
diff --git a/common/src/com/example/android/common/play/PlayHelper.java b/common/src/com/example/android/common/play/PlayHelper.java
new file mode 100644
index 0000000..c38c2bb
--- /dev/null
+++ b/common/src/com/example/android/common/play/PlayHelper.java
@@ -0,0 +1,102 @@
+package com.example.android.common.play;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.FragmentActivity;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+
+/**
+ * Helper class for Google Play Services functions.
+ * <ul>
+ * <li>
+ * Checks availability
+ * </li>
+ * <li>
+ * Validates version for version bound features
+ * </li>
+ * </ul>
+ */
+public class PlayHelper {
+
+ /**
+ * Checks for Google Play Services installation on the device. If found, validates the
+ * installed version against the requested version. If the service is installed but
+ * can't be used, the utility initiates a recovery with user intervention.
+ *
+ * @param context The context to be associated with the request. For compatibility with 1.6+,
+ * subclass {@link FragmentActivity}.
+ * @param requestCode If we need to download Google Play Services, the download activity will be
+ * started using {@link Activity#startActivityForResult(Intent, int)}
+ * @param versionCode The minimum required version of the library.
+ * @return True, if successful.
+ */
+ public static boolean checkGooglePlayServiceAvailability(
+ FragmentActivity context, int requestCode, int versionCode) {
+
+ // Query for the status of Google Play services on the device
+ int statusCode = GooglePlayServicesUtil
+ .isGooglePlayServicesAvailable(context);
+
+ if ((statusCode == ConnectionResult.SUCCESS )
+ && (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= versionCode)) {
+ return true;
+ } else {
+ if (GooglePlayServicesUtil.isUserRecoverableError(statusCode)) {
+ Dialog eDialog = GooglePlayServicesUtil.getErrorDialog(statusCode,
+ context, requestCode);
+ // If Google Play services can provide an error dialog
+ if (eDialog != null) {
+ // Create a new DialogFragment for the error dialog
+ ErrorDialogFragment errorFragment =
+ new ErrorDialogFragment();
+ // Set the dialog in the DialogFragment
+ errorFragment.setDialog(eDialog);
+ // Show the error dialog in the DialogFragment
+ errorFragment.show(
+ context.getSupportFragmentManager(),
+ "Activity Recognition");
+ }
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks for Google Play Services installation on the device. If the service is installed but
+ * can't be used, the utility initiates a recovery with user intervention.
+ *
+ * @param context The context to be associated with the request. For compatibility with 1.6+,
+ * subclass {@link FragmentActivity}.
+ * @return True, if successful.
+ */
+ public static boolean checkGooglePlayServiceAvailability(FragmentActivity context,
+ int requestCode) {
+ return checkGooglePlayServiceAvailability(context, requestCode, -1);
+ }
+
+ // Define a DialogFragment that displays the error dialog
+ public static class ErrorDialogFragment extends DialogFragment {
+ // Global field to contain the error dialog
+ private Dialog mDialog;
+ // Default constructor. Sets the dialog field to null
+ public ErrorDialogFragment() {
+ super();
+ mDialog = null;
+ }
+ // Set the dialog to display
+ public void setDialog(Dialog dialog) {
+ mDialog = dialog;
+ }
+ // Return a Dialog to the DialogFragment.
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return mDialog;
+ }
+ }
+}
diff --git a/connectivity/bluetooth/BluetoothLeGatt/BluetoothLeGatt/build.gradle b/connectivity/bluetooth/BluetoothLeGatt/BluetoothLeGatt/build.gradle
index b461fdf..945e1f5 100644
--- a/connectivity/bluetooth/BluetoothLeGatt/BluetoothLeGatt/build.gradle
+++ b/connectivity/bluetooth/BluetoothLeGatt/BluetoothLeGatt/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
compileSdkVersion 18
- buildToolsVersion "17.0.0"
+ buildToolsVersion "18.0.0"
}
diff --git a/connectivity/bluetooth/BluetoothLeGatt/build.gradle b/connectivity/bluetooth/BluetoothLeGatt/build.gradle
index 495c503..036abc8 100644
--- a/connectivity/bluetooth/BluetoothLeGatt/build.gradle
+++ b/connectivity/bluetooth/BluetoothLeGatt/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/connectivity/network/BasicNetworkDemo/BasicNetworkDemo/build.gradle b/connectivity/network/BasicNetworkDemo/BasicNetworkDemo/build.gradle
index e3b2dce..0baece9 100644
--- a/connectivity/network/BasicNetworkDemo/BasicNetworkDemo/build.gradle
+++ b/connectivity/network/BasicNetworkDemo/BasicNetworkDemo/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/connectivity/network/BasicNetworkDemo/build.gradle b/connectivity/network/BasicNetworkDemo/build.gradle
index 495c503..036abc8 100644
--- a/connectivity/network/BasicNetworkDemo/build.gradle
+++ b/connectivity/network/BasicNetworkDemo/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/connectivity/network/NetworkConnect/NetworkConnect/build.gradle b/connectivity/network/NetworkConnect/NetworkConnect/build.gradle
index e3b2dce..0baece9 100644
--- a/connectivity/network/NetworkConnect/NetworkConnect/build.gradle
+++ b/connectivity/network/NetworkConnect/NetworkConnect/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/connectivity/network/NetworkConnect/build.gradle b/connectivity/network/NetworkConnect/build.gradle
index 495c503..036abc8 100644
--- a/connectivity/network/NetworkConnect/build.gradle
+++ b/connectivity/network/NetworkConnect/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle
index 555c6dc..e802f1b 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
repositories {
@@ -18,6 +10,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/content/LoaderCursor/AndroidManifest.xml b/content/LoaderCursor/AndroidManifest.xml
new file mode 100644
index 0000000..2305045
--- /dev/null
+++ b/content/LoaderCursor/AndroidManifest.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.content.loadercursor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="17" />
+ <uses-permission android:name="android.permission.READ_CONTACTS"/>
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.android.content.loadercursor.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/content/LoaderCursor/loadercursor.jd b/content/LoaderCursor/loadercursor.jd
new file mode 100644
index 0000000..dba0a0f
--- /dev/null
+++ b/content/LoaderCursor/loadercursor.jd
@@ -0,0 +1,14 @@
+page.title=LoaderCursor Sample
+@jd:body
+
+<p>This sample demonstrates the use of the
+<pre><a href="http://developer.android.com/reference/android/app/LoaderManager.html">LoaderManager
+</a></pre> to retrieve data from a
+<pre><a href="http://developer.android.com/reference/android/database/Cursor.html">Cursor</a></pre>
+.</p>
+
+<p>Here, a list of contacts is displayed in a
+<pre><a href="http://developer.android.com/reference/android/app/ListFragment.html">ListFragment
+</a></pre> and filtered using a
+<pre><a href="http://developer.android.com/reference/android/widget/SearchView.html">SearchView
+</a></pre> ActionBar item.</p>
\ No newline at end of file
diff --git a/content/LoaderCursor/res/drawable-hdpi/ic_launcher.png b/content/LoaderCursor/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a196c51
--- /dev/null
+++ b/content/LoaderCursor/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/content/LoaderCursor/res/drawable-mdpi/ic_launcher.png b/content/LoaderCursor/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..7cde937
--- /dev/null
+++ b/content/LoaderCursor/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/content/LoaderCursor/res/drawable-xhdpi/ic_launcher.png b/content/LoaderCursor/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..ab34c07
--- /dev/null
+++ b/content/LoaderCursor/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/content/LoaderCursor/res/drawable-xxhdpi/ic_launcher.png b/content/LoaderCursor/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..9c5a93d
--- /dev/null
+++ b/content/LoaderCursor/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/content/LoaderCursor/res/layout/activity_main.xml b/content/LoaderCursor/res/layout/activity_main.xml
new file mode 100644
index 0000000..9ef8d23
--- /dev/null
+++ b/content/LoaderCursor/res/layout/activity_main.xml
@@ -0,0 +1,34 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/FrameLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity" >
+
+ <fragment
+ android:id="@+id/fragment_list"
+ android:name="com.example.android.content.loadercursor.CursorLoaderListFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</FrameLayout>
diff --git a/content/LoaderCursor/res/menu/main.xml b/content/LoaderCursor/res/menu/main.xml
new file mode 100644
index 0000000..b7aba0f
--- /dev/null
+++ b/content/LoaderCursor/res/menu/main.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/action_search"
+ android:actionViewClass="android.widget.SearchView"
+ android:icon="@android:drawable/ic_menu_search"
+ android:showAsAction="ifRoom|collapseActionView"
+ android:title="@string/action_search"/>
+
+</menu>
diff --git a/content/LoaderCursor/res/values-sw600dp/dimens.xml b/content/LoaderCursor/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..08cfee1
--- /dev/null
+++ b/content/LoaderCursor/res/values-sw600dp/dimens.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
diff --git a/content/LoaderCursor/res/values-sw720dp-land/dimens.xml b/content/LoaderCursor/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..88cf8c5
--- /dev/null
+++ b/content/LoaderCursor/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/content/LoaderCursor/res/values-v11/styles.xml b/content/LoaderCursor/res/values-v11/styles.xml
new file mode 100644
index 0000000..14848da
--- /dev/null
+++ b/content/LoaderCursor/res/values-v11/styles.xml
@@ -0,0 +1,27 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/content/LoaderCursor/res/values-v14/styles.xml b/content/LoaderCursor/res/values-v14/styles.xml
new file mode 100644
index 0000000..cb99309
--- /dev/null
+++ b/content/LoaderCursor/res/values-v14/styles.xml
@@ -0,0 +1,28 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/content/LoaderCursor/res/values/dimens.xml b/content/LoaderCursor/res/values/dimens.xml
new file mode 100644
index 0000000..393aba0
--- /dev/null
+++ b/content/LoaderCursor/res/values/dimens.xml
@@ -0,0 +1,23 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/content/LoaderCursor/res/values/strings.xml b/content/LoaderCursor/res/values/strings.xml
new file mode 100644
index 0000000..a2c19df
--- /dev/null
+++ b/content/LoaderCursor/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <string name="app_name">LoaderCursor</string>
+ <string name="action_search">Search</string>
+
+</resources>
diff --git a/content/LoaderCursor/res/values/styles.xml b/content/LoaderCursor/res/values/styles.xml
new file mode 100644
index 0000000..c8ee17f
--- /dev/null
+++ b/content/LoaderCursor/res/values/styles.xml
@@ -0,0 +1,36 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
diff --git a/content/LoaderCursor/src/com/example/android/content/loadercursor/CursorLoaderListFragment.java b/content/LoaderCursor/src/com/example/android/content/loadercursor/CursorLoaderListFragment.java
new file mode 100644
index 0000000..9a1726a
--- /dev/null
+++ b/content/LoaderCursor/src/com/example/android/content/loadercursor/CursorLoaderListFragment.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2013 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.content.loadercursor;
+
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.content.CursorLoader;
+import android.content.Loader;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract.Contacts;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.SearchView;
+import android.widget.SearchView.OnCloseListener;
+import android.widget.SearchView.OnQueryTextListener;
+import android.widget.SimpleCursorAdapter;
+import android.widget.Toast;
+
+/**
+ * A {@link ListFragment} that shows the use of a {@link LoaderManager} to
+ * display a list of contacts accessed through a {@link Cursor}.
+ */
+public class CursorLoaderListFragment extends ListFragment implements
+ LoaderManager.LoaderCallbacks<Cursor> {
+
+ // This is the Adapter being used to display the list's data.
+ SimpleCursorAdapter mAdapter;
+
+ // The SearchView for doing filtering.
+ SearchView mSearchView;
+
+ // If non-null, this is the current filter the user has provided.
+ String mCurFilter;
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // Give some text to display if there is no data. In a real
+ // application this would come from a resource.
+ setEmptyText("No phone numbers");
+
+ // We have a menu item to show in action bar.
+ setHasOptionsMenu(true);
+
+ /*
+ * Create an empty adapter we will use to display the loaded data. The
+ * simple_list_item_2 layout contains two rows on top of each other
+ * (text1 and text2) that will show the contact's name and status.
+ */
+ mAdapter = new SimpleCursorAdapter(getActivity(),
+ android.R.layout.simple_list_item_2, null,
+ new String[] {
+ Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS
+ },
+ new int[] {
+ android.R.id.text1, android.R.id.text2
+ }, 0);
+ setListAdapter(mAdapter);
+
+ // Start out with a progress indicator.
+ setListShown(false);
+
+ // BEGIN_INCLUDE(getloader)
+ // Prepare the loader. Either re-connect with an existing one,
+ // or start a new one.
+ getLoaderManager().initLoader(0, null, this);
+ // END_INCLUDE(getloader)
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+
+ inflater.inflate(R.menu.main, menu);
+
+ // Get the search item and update its action view
+ MenuItem item = menu.findItem(R.id.action_search);
+ mSearchView = (SearchView) item.getActionView();
+ mSearchView.setOnQueryTextListener(queryListener);
+ mSearchView.setOnCloseListener(closeListener);
+ mSearchView.setIconifiedByDefault(true);
+ }
+
+ /**
+ * The {@link OnCloseListener} called when the SearchView is closed. Resets
+ * the query field.
+ */
+ private SearchView.OnCloseListener closeListener = new SearchView.OnCloseListener() {
+
+ @Override
+ public boolean onClose() {
+ // Restore the SearchView if a query was entered
+ if (!TextUtils.isEmpty(mSearchView.getQuery())) {
+ mSearchView.setQuery(null, true);
+ }
+ return true;
+ }
+ };
+
+ /**
+ * The {@link OnQueryTextListener} that is called when text in the
+ * {@link SearchView} is changed. Updates the query filter and triggers a
+ * reload of the {@link LoaderManager} to update the displayed list.
+ */
+ private OnQueryTextListener queryListener = new OnQueryTextListener() {
+
+ /**
+ * Called when the action bar search text has changed. Update the search
+ * filter, and restart the loader to do a new query with this filter.
+ *
+ * @param newText the new content of the query text field
+ * @return true, the action has been handled.
+ */
+ public boolean onQueryTextChange(String newText) {
+
+ String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
+
+ // Don't do anything if the filter hasn't actually changed.
+ // Prevents restarting the loader when restoring state.
+ if (mCurFilter == null && newFilter == null) {
+ return true;
+ }
+ if (mCurFilter != null && mCurFilter.equals(newFilter)) {
+ return true;
+ }
+
+ // Restart the Loader.
+ // #onCreateLoader uses the value of mCurFilter as a filter when
+ // creating the query for the Loader.
+ mCurFilter = newFilter;
+ getLoaderManager().restartLoader(0, null, CursorLoaderListFragment.this);
+
+ return true;
+ }
+
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ // Don't care about this.
+ return true;
+ }
+ };
+
+ /**
+ * An item has been clicked in the {@link ListView}. Display a toast with
+ * the tapped item's id.
+ */
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Toast.makeText(getActivity(), "Item clicked: " + id, Toast.LENGTH_LONG).show();
+ }
+
+ // These are the Contacts rows that we will retrieve.
+ static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
+ Contacts._ID,
+ Contacts.DISPLAY_NAME,
+ Contacts.CONTACT_STATUS,
+ Contacts.LOOKUP_KEY,
+ };
+
+ // BEGIN_INCLUDE(oncreateloader)
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ // This is called when a new Loader needs to be created. This
+ // sample only has one Loader, so we don't care about the ID.
+ // First, pick the base URI to use depending on whether we are
+ // currently filtering.
+ Uri baseUri;
+ if (mCurFilter != null) {
+ baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
+ Uri.encode(mCurFilter));
+ } else {
+ baseUri = Contacts.CONTENT_URI;
+ }
+
+ // Now create and return a CursorLoader that will take care of
+ // creating a Cursor for the data being displayed.
+ String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
+ + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
+ + Contacts.DISPLAY_NAME + " != '' ))";
+ String order = Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
+
+ return new CursorLoader(getActivity(), baseUri,
+ CONTACTS_SUMMARY_PROJECTION, select, null, order);
+ }
+
+ // END_INCLUDE(oncreateloader)
+
+ // BEGIN_INCLUDE(onloadfinished)
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ // Swap the new cursor in. (The framework will take care of closing the
+ // old cursor once we return.)
+ mAdapter.swapCursor(data);
+
+ // The list should now be shown.
+ if (isResumed()) {
+ setListShown(true);
+ } else {
+ setListShownNoAnimation(true);
+ }
+ }
+
+ // END_INCLUDE(onloadfinished)
+
+ // BEGIN_INCLUDE(onloaderreset)
+ public void onLoaderReset(Loader<Cursor> loader) {
+ // This is called when the last Cursor provided to onLoadFinished()
+ // above is about to be closed. We need to make sure we are no
+ // longer using it.
+ mAdapter.swapCursor(null);
+ }
+ // END_INCLUDE(onloaderreset)
+
+}
diff --git a/content/LoaderCursor/src/com/example/android/content/loadercursor/MainActivity.java b/content/LoaderCursor/src/com/example/android/content/loadercursor/MainActivity.java
new file mode 100644
index 0000000..c053b90
--- /dev/null
+++ b/content/LoaderCursor/src/com/example/android/content/loadercursor/MainActivity.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2013 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.content.loadercursor;
+
+import android.app.Activity;
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.widget.SearchView;
+
+/**
+ * The entry point to the CursorLoader sample. This sample demonstrates the use
+ * of the {@link LoaderManager} to retrieve data from a {@link Cursor}. Here, a
+ * list of contacts is displayed in a {@link ListFragment} and filtered using a
+ * {@link SearchView} ActionBar item.
+ */
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+}
diff --git a/content/contacts/BasicContactables/BasicContactables/build.gradle b/content/contacts/BasicContactables/BasicContactables/build.gradle
index 3e3e430..0baece9 100644
--- a/content/contacts/BasicContactables/BasicContactables/build.gradle
+++ b/content/contacts/BasicContactables/BasicContactables/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,5 +6,5 @@
android {
compileSdkVersion 18
- buildToolsVersion "17.0.0"
+ buildToolsVersion "18.0.0"
}
diff --git a/content/contacts/BasicContactables/BasicContactables/src/main/java/com/example/android/basiccontactables/ContactablesLoaderCallbacks.java b/content/contacts/BasicContactables/BasicContactables/src/main/java/com/example/android/basiccontactables/ContactablesLoaderCallbacks.java
index e2fcf3d..c583dac 100644
--- a/content/contacts/BasicContactables/BasicContactables/src/main/java/com/example/android/basiccontactables/ContactablesLoaderCallbacks.java
+++ b/content/contacts/BasicContactables/BasicContactables/src/main/java/com/example/android/basiccontactables/ContactablesLoaderCallbacks.java
@@ -54,13 +54,15 @@
// BEGIN_INCLUDE(uri_with_query)
String query = args.getString(QUERY_KEY);
- Uri uri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Contactables.CONTENT_FILTER_URI, query);
+ Uri uri = Uri.withAppendedPath(
+ ContactsContract.CommonDataKinds.Contactables.CONTENT_FILTER_URI, query);
// END_INCLUDE(uri_with_query)
// BEGIN_INCLUDE(cursor_loader)
// Easy way to limit the query to contacts with phone numbers.
- String selection = ContactsContract.CommonDataKinds.Contactables.HAS_PHONE_NUMBER + " = " + 1;
+ String selection =
+ ContactsContract.CommonDataKinds.Contactables.HAS_PHONE_NUMBER + " = " + 1;
// Sort results such that rows for the same contact stay together.
String sortBy = ContactsContract.CommonDataKinds.Contactables.LOOKUP_KEY;
diff --git a/content/contacts/BasicContactables/build.gradle b/content/contacts/BasicContactables/build.gradle
index 495c503..036abc8 100644
--- a/content/contacts/BasicContactables/build.gradle
+++ b/content/contacts/BasicContactables/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/content/multiuser/AppRestrictions/AppRestrictions/build.gradle b/content/multiuser/AppRestrictions/AppRestrictions/build.gradle
index b461fdf..945e1f5 100644
--- a/content/multiuser/AppRestrictions/AppRestrictions/build.gradle
+++ b/content/multiuser/AppRestrictions/AppRestrictions/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
compileSdkVersion 18
- buildToolsVersion "17.0.0"
+ buildToolsVersion "18.0.0"
}
diff --git a/content/multiuser/AppRestrictions/build.gradle b/content/multiuser/AppRestrictions/build.gradle
index 495c503..036abc8 100644
--- a/content/multiuser/AppRestrictions/build.gradle
+++ b/content/multiuser/AppRestrictions/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/input/gestures/BasicGestureDetect/BasicGestureDetect/build.gradle b/input/gestures/BasicGestureDetect/BasicGestureDetect/build.gradle
index e3b2dce..0baece9 100644
--- a/input/gestures/BasicGestureDetect/BasicGestureDetect/build.gradle
+++ b/input/gestures/BasicGestureDetect/BasicGestureDetect/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/input/gestures/BasicGestureDetect/build.gradle b/input/gestures/BasicGestureDetect/build.gradle
index 495c503..036abc8 100644
--- a/input/gestures/BasicGestureDetect/build.gradle
+++ b/input/gestures/BasicGestureDetect/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/input/multitouch/BasicMultitouch/BasicMultitouch/build.gradle b/input/multitouch/BasicMultitouch/BasicMultitouch/build.gradle
index f2eea5d..945e1f5 100644
--- a/input/multitouch/BasicMultitouch/BasicMultitouch/build.gradle
+++ b/input/multitouch/BasicMultitouch/BasicMultitouch/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/input/multitouch/BasicMultitouch/build.gradle b/input/multitouch/BasicMultitouch/build.gradle
index 495c503..036abc8 100644
--- a/input/multitouch/BasicMultitouch/build.gradle
+++ b/input/multitouch/BasicMultitouch/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/media/BasicMediaRouter/BasicMediaRouter/build.gradle b/media/BasicMediaRouter/BasicMediaRouter/build.gradle
index f2eea5d..945e1f5 100644
--- a/media/BasicMediaRouter/BasicMediaRouter/build.gradle
+++ b/media/BasicMediaRouter/BasicMediaRouter/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/media/BasicMediaRouter/build.gradle b/media/BasicMediaRouter/build.gradle
index 495c503..036abc8 100644
--- a/media/BasicMediaRouter/build.gradle
+++ b/media/BasicMediaRouter/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/security/keystore/BasicAndroidKeyStore/BasicAndroidKeyStore/build.gradle b/security/keystore/BasicAndroidKeyStore/BasicAndroidKeyStore/build.gradle
index 3e3e430..0baece9 100644
--- a/security/keystore/BasicAndroidKeyStore/BasicAndroidKeyStore/build.gradle
+++ b/security/keystore/BasicAndroidKeyStore/BasicAndroidKeyStore/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,5 +6,5 @@
android {
compileSdkVersion 18
- buildToolsVersion "17.0.0"
+ buildToolsVersion "18.0.0"
}
diff --git a/security/keystore/BasicAndroidKeyStore/build.gradle b/security/keystore/BasicAndroidKeyStore/build.gradle
index 495c503..036abc8 100644
--- a/security/keystore/BasicAndroidKeyStore/build.gradle
+++ b/security/keystore/BasicAndroidKeyStore/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/accessibility/BasicAccessibility/BasicAccessibility/build.gradle b/ui/accessibility/BasicAccessibility/BasicAccessibility/build.gradle
index e3b2dce..0baece9 100644
--- a/ui/accessibility/BasicAccessibility/BasicAccessibility/build.gradle
+++ b/ui/accessibility/BasicAccessibility/BasicAccessibility/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/accessibility/BasicAccessibility/build.gradle b/ui/accessibility/BasicAccessibility/build.gradle
index 495c503..036abc8 100644
--- a/ui/accessibility/BasicAccessibility/build.gradle
+++ b/ui/accessibility/BasicAccessibility/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/actionbar/DoneBar/DoneBar/build.gradle b/ui/actionbar/DoneBar/DoneBar/build.gradle
index f2eea5d..945e1f5 100644
--- a/ui/actionbar/DoneBar/DoneBar/build.gradle
+++ b/ui/actionbar/DoneBar/DoneBar/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/actionbar/DoneBar/build.gradle b/ui/actionbar/DoneBar/build.gradle
index 495c503..036abc8 100644
--- a/ui/actionbar/DoneBar/build.gradle
+++ b/ui/actionbar/DoneBar/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/actionbarcompat/Basic/Basic/build.gradle b/ui/actionbarcompat/Basic/Basic/build.gradle
index 13f4f48..8e76487 100644
--- a/ui/actionbarcompat/Basic/Basic/build.gradle
+++ b/ui/actionbarcompat/Basic/Basic/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,6 +6,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/actionbarcompat/Basic/build.gradle b/ui/actionbarcompat/Basic/build.gradle
index 495c503..036abc8 100644
--- a/ui/actionbarcompat/Basic/build.gradle
+++ b/ui/actionbarcompat/Basic/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/actionbarcompat/ListPopupMenu/ListPopupMenu/build.gradle b/ui/actionbarcompat/ListPopupMenu/ListPopupMenu/build.gradle
index 13f4f48..8e76487 100644
--- a/ui/actionbarcompat/ListPopupMenu/ListPopupMenu/build.gradle
+++ b/ui/actionbarcompat/ListPopupMenu/ListPopupMenu/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,6 +6,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/actionbarcompat/ListPopupMenu/build.gradle b/ui/actionbarcompat/ListPopupMenu/build.gradle
index 495c503..036abc8 100644
--- a/ui/actionbarcompat/ListPopupMenu/build.gradle
+++ b/ui/actionbarcompat/ListPopupMenu/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/actionbarcompat/ShareActionProvider/ShareActionProvider/build.gradle b/ui/actionbarcompat/ShareActionProvider/ShareActionProvider/build.gradle
index 13f4f48..8e76487 100644
--- a/ui/actionbarcompat/ShareActionProvider/ShareActionProvider/build.gradle
+++ b/ui/actionbarcompat/ShareActionProvider/ShareActionProvider/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,6 +6,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/actionbarcompat/ShareActionProvider/build.gradle b/ui/actionbarcompat/ShareActionProvider/build.gradle
index 495c503..036abc8 100644
--- a/ui/actionbarcompat/ShareActionProvider/build.gradle
+++ b/ui/actionbarcompat/ShareActionProvider/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/actionbarcompat/Styled/Styled/build.gradle b/ui/actionbarcompat/Styled/Styled/build.gradle
index 13f4f48..8e76487 100644
--- a/ui/actionbarcompat/Styled/Styled/build.gradle
+++ b/ui/actionbarcompat/Styled/Styled/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -14,6 +6,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/actionbarcompat/Styled/build.gradle b/ui/actionbarcompat/Styled/build.gradle
index 495c503..036abc8 100644
--- a/ui/actionbarcompat/Styled/build.gradle
+++ b/ui/actionbarcompat/Styled/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/holo/BorderlessButtons/BorderlessButtons/build.gradle b/ui/holo/BorderlessButtons/BorderlessButtons/build.gradle
index f2eea5d..945e1f5 100644
--- a/ui/holo/BorderlessButtons/BorderlessButtons/build.gradle
+++ b/ui/holo/BorderlessButtons/BorderlessButtons/build.gradle
@@ -1,14 +1,6 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/holo/BorderlessButtons/build.gradle b/ui/holo/BorderlessButtons/build.gradle
index f82180e..036abc8 100644
--- a/ui/holo/BorderlessButtons/build.gradle
+++ b/ui/holo/BorderlessButtons/build.gradle
@@ -1,2 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/lists/CustomChoiceList/CustomChoiceList/build.gradle b/ui/lists/CustomChoiceList/CustomChoiceList/build.gradle
index f2eea5d..6083faa 100644
--- a/ui/lists/CustomChoiceList/CustomChoiceList/build.gradle
+++ b/ui/lists/CustomChoiceList/CustomChoiceList/build.gradle
@@ -1,14 +1,7 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
+
apply plugin: 'android'
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/lists/CustomChoiceList/build.gradle b/ui/lists/CustomChoiceList/build.gradle
index f82180e..036abc8 100644
--- a/ui/lists/CustomChoiceList/build.gradle
+++ b/ui/lists/CustomChoiceList/build.gradle
@@ -1,2 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/notifications/BasicNotifications/BasicNotifications/build.gradle b/ui/notifications/BasicNotifications/BasicNotifications/build.gradle
index e3b2dce..0baece9 100644
--- a/ui/notifications/BasicNotifications/BasicNotifications/build.gradle
+++ b/ui/notifications/BasicNotifications/BasicNotifications/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/notifications/BasicNotifications/build.gradle b/ui/notifications/BasicNotifications/build.gradle
index f82180e..036abc8 100644
--- a/ui/notifications/BasicNotifications/build.gradle
+++ b/ui/notifications/BasicNotifications/build.gradle
@@ -1,2 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/build.gradle b/ui/notifications/CustomNotifications/CustomNotifications/build.gradle
new file mode 100644
index 0000000..47fc855
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/build.gradle
@@ -0,0 +1,10 @@
+apply plugin: 'android'
+
+dependencies {
+ compile 'com.android.support:support-v4:18.0.0+'
+}
+
+android {
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
+}
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/AndroidManifest.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8821b1a
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.customnotifications"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="4"
+ android:targetSdkVersion="18" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.android.customnotifications.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/java/com/example/android/customnotifications/MainActivity.java b/ui/notifications/CustomNotifications/CustomNotifications/src/main/java/com/example/android/customnotifications/MainActivity.java
new file mode 100644
index 0000000..eae95f1
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/java/com/example/android/customnotifications/MainActivity.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2013 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.customnotifications;
+
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
+import android.widget.RemoteViews;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+public class MainActivity extends Activity {
+ /**
+ * This sample demonstrates notifications with custom content views.
+ *
+ * <p>On API level 16 and above a big content view is also defined that is used for the
+ * 'expanded' notification. The notification is created by the NotificationCompat.Builder.
+ * The expanded content view is set directly on the {@link Notification} once it has been build.
+ * (See {@link Notification#bigContentView}.) </p>
+ *
+ * <p>The content views are inflated as {@link RemoteViews} directly from their XML layout
+ * definitions using {@link RemoteViews#RemoteViews(String, int)}.</p>
+ */
+ private void createNotification() {
+ // BEGIN_INCLUDE(notificationCompat)
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+ // END_INCLUDE(notificationCompat)
+
+ // BEGIN_INCLUDE(intent)
+ //Create Intent to launch this Activity again if the notification is clicked.
+ Intent i = new Intent(this, MainActivity.class);
+ i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ PendingIntent intent = PendingIntent.getActivity(this, 0, i,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ builder.setContentIntent(intent);
+ // END_INCLUDE(intent)
+
+ // BEGIN_INCLUDE(ticker)
+ // Sets the ticker text
+ builder.setTicker(getResources().getString(R.string.custom_notification));
+
+ // Sets the small icon for the ticker
+ builder.setSmallIcon(R.drawable.ic_stat_custom);
+ // END_INCLUDE(ticker)
+
+ // BEGIN_INCLUDE(buildNotification)
+ // Cancel the notification when clicked
+ builder.setAutoCancel(true);
+
+ // Build the notification
+ Notification notification = builder.build();
+ // END_INCLUDE(buildNotification)
+
+ // BEGIN_INCLUDE(customLayout)
+ // Inflate the notification layout as RemoteViews
+ RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
+
+ // Set text on a TextView in the RemoteViews programmatically.
+ final String time = DateFormat.getTimeInstance().format(new Date()).toString();
+ final String text = getResources().getString(R.string.collapsed, time);
+ contentView.setTextViewText(R.id.textView, text);
+
+ /* Workaround: Need to set the content view here directly on the notification.
+ * NotificationCompatBuilder contains a bug that prevents this from working on platform
+ * versions HoneyComb.
+ * See https://code.google.com/p/android/issues/detail?id=30495
+ */
+ notification.contentView = contentView;
+
+ // Add a big content view to the notification if supported.
+ // Support for expanded notifications was added in API level 16.
+ // (The normal contentView is shown when the notification is collapsed, when expanded the
+ // big content view set here is displayed.)
+ if (Build.VERSION.SDK_INT >= 16) {
+ // Inflate and set the layout for the expanded notification view
+ RemoteViews expandedView =
+ new RemoteViews(getPackageName(), R.layout.notification_expanded);
+ notification.bigContentView = expandedView;
+ }
+ // END_INCLUDE(customLayout)
+
+ // START_INCLUDE(notify)
+ // Use the NotificationManager to show the notification
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.notify(0, notification);
+ // END_INCLUDE(notify)
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ /**
+ * Create and show a notification with a custom layout.
+ * This callback is defined through the 'onClick' attribute of the
+ * 'Show Notification' button in the XML layout.
+ *
+ * @param v
+ */
+ public void showNotificationClicked(View v) {
+ createNotification();
+ }
+}
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v11/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v11/ic_stat_custom.png
new file mode 100644
index 0000000..db182ce
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v11/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v9/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v9/ic_stat_custom.png
new file mode 100644
index 0000000..c35f570
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi-v9/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_launcher.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..155ac98
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_stat_custom.png
new file mode 100644
index 0000000..b0434fd
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-hdpi/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v11/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v11/ic_stat_custom.png
new file mode 100644
index 0000000..50e1b32
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v11/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v9/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v9/ic_stat_custom.png
new file mode 100644
index 0000000..d4de32a
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-ldpi-v9/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v11/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v11/ic_stat_custom.png
new file mode 100644
index 0000000..a46f47f
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v11/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v9/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v9/ic_stat_custom.png
new file mode 100644
index 0000000..2896b63
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi-v9/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_launcher.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6e38dc6
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_stat_custom.png
new file mode 100644
index 0000000..304f7e9
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-mdpi/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v11/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v11/ic_stat_custom.png
new file mode 100644
index 0000000..52f7df8
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v11/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v9/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v9/ic_stat_custom.png
new file mode 100644
index 0000000..5d2617e
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi-v9/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..638fc67
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_stat_custom.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_stat_custom.png
new file mode 100644
index 0000000..79c30a8
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/ic_stat_custom.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot.png
new file mode 100644
index 0000000..e21ee75
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot_expanded.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot_expanded.png
new file mode 100644
index 0000000..f9469d4
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xhdpi/robot_expanded.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..9a9a60c
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/activity_main.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..d67477d
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/activity_main.xml
@@ -0,0 +1,43 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<!-- Layout for MainActivity.
+ Includes an introductory text and a button to show the notification. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:orientation="vertical"
+ tools:context=".MainActivity"
+ android:gravity="center_horizontal">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/intro_text" />
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/show_notification"
+ android:id="@+id/button"
+ android:onClick="showNotificationClicked" />
+
+</LinearLayout>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification.xml
new file mode 100644
index 0000000..9d977d3
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+* Copyright (C) 2013 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.
+-->
+
+<!-- Layout for the collapsed notification. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_horizontal">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/NotificationContent"
+ android:id="@+id/textView"
+ android:gravity="center" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/imageView"
+ android:src="@drawable/robot"
+ android:contentDescription="@string/collapsed_image" />
+
+
+</LinearLayout>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification_expanded.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification_expanded.xml
new file mode 100644
index 0000000..9d5a784
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/layout/notification_expanded.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+* Copyright (C) 2013 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.
+-->
+
+<!-- Layout for the expanded notification. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="right|top">
+
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/NotificationContent"
+ android:text="@string/expanded"
+ android:layout_gravity="center_vertical"
+ android:layout_alignParentTop="false"
+ android:layout_alignParentLeft="true"
+ android:layout_toLeftOf="@+id/imageView"
+ android:gravity="center"
+ android:layout_centerVertical="true" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/robot_expanded"
+ android:layout_gravity="right|top"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentRight="true"
+ android:id="@+id/imageView"
+ android:contentDescription="@string/expanded_image" />
+ </RelativeLayout>
+
+
+</LinearLayout>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw600dp/dimens.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..eb7d98a
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,19 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+ <!-- Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here. -->
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw720dp-land/dimens.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..901314a
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,20 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+ <!-- Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v11/styles.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v11/styles.xml
new file mode 100644
index 0000000..b454dee
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v11/styles.xml
@@ -0,0 +1,26 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v14/styles.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v14/styles.xml
new file mode 100644
index 0000000..1cf1112
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v14/styles.xml
@@ -0,0 +1,27 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v9/styles.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v9/styles.xml
new file mode 100644
index 0000000..85010a5
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values-v9/styles.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <style name="NotificationContent" parent="@android:style/TextAppearance.StatusBar.EventContent">
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/dimens.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..ca1b9e6
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/dimens.xml
@@ -0,0 +1,20 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/strings.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/strings.xml
new file mode 100644
index 0000000..3247f39
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/strings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+
+ <string name="app_name">CustomNotifications</string>
+ <string name="expanded">I\'m the expanded notification.\nCollapse me!</string>
+ <string name="collapsed">I\'m the collapsed notification.\nCreated at: %s</string>
+ <string name="show_notification">Show Notification</string>
+ <string name="custom_notification">I\'m a custom notification.</string>
+
+ <string name="intro_text">This sample demonstrates how a notification is created using the
+ <b>NotificationCompatBuilder</b>
+ with a custom content view. The layout of the notification is defined as a
+ layout resource and inflated as a <b>RemoteViews</b> object.
+ \n\nOn API level 16 and above, a different layout is inflated and set as
+ the <i>big content view</i>, which is used when the notification is expanded.
+ \n\n<b>Use the button below to create the notification.
+ \n\nIf your device is running Jelly Bean or above, try expanding or collapsing
+ the notification to see the different layouts.</b>
+ </string>
+ <string name="collapsed_image">A single Android robot waving. Symbolises a collapsed
+ notification.
+ </string>
+ <string name="expanded_image">Two Androids on top of each other. Symbolises an expanded
+ notification.
+ </string>
+
+</resources>
diff --git a/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/styles.xml b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/styles.xml
new file mode 100644
index 0000000..eca4340
--- /dev/null
+++ b/ui/notifications/CustomNotifications/CustomNotifications/src/main/res/values/styles.xml
@@ -0,0 +1,39 @@
+<!--
+ * Copyright (C) 2013 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.
+ -->
+
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+ <style name="NotificationContent" parent="@android:style/TextAppearance.Small">
+ <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
+ </style>
+
+</resources>
diff --git a/ui/notifications/CustomNotifications/build.gradle b/ui/notifications/CustomNotifications/build.gradle
new file mode 100644
index 0000000..5a6276f
--- /dev/null
+++ b/ui/notifications/CustomNotifications/build.gradle
@@ -0,0 +1,13 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
+
+repositories {
+ mavenCentral()
+}
diff --git a/ui/notifications/CustomNotifications/settings.gradle b/ui/notifications/CustomNotifications/settings.gradle
new file mode 100644
index 0000000..f19c616
--- /dev/null
+++ b/ui/notifications/CustomNotifications/settings.gradle
@@ -0,0 +1 @@
+include ':CustomNotifications'
diff --git a/ui/views/HorizontalPaging/HorizontalPaging/build.gradle b/ui/views/HorizontalPaging/HorizontalPaging/build.gradle
index e3b2dce..0baece9 100644
--- a/ui/views/HorizontalPaging/HorizontalPaging/build.gradle
+++ b/ui/views/HorizontalPaging/HorizontalPaging/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/views/HorizontalPaging/build.gradle b/ui/views/HorizontalPaging/build.gradle
index 495c503..036abc8 100644
--- a/ui/views/HorizontalPaging/build.gradle
+++ b/ui/views/HorizontalPaging/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/ui/views/TextSwitcher/TextSwitcher/build.gradle b/ui/views/TextSwitcher/TextSwitcher/build.gradle
index e3b2dce..0baece9 100644
--- a/ui/views/TextSwitcher/TextSwitcher/build.gradle
+++ b/ui/views/TextSwitcher/TextSwitcher/build.gradle
@@ -1,11 +1,3 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
apply plugin: 'android'
dependencies {
@@ -13,6 +5,6 @@
}
android {
- compileSdkVersion 17
- buildToolsVersion "17.0.0"
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
}
diff --git a/ui/views/TextSwitcher/build.gradle b/ui/views/TextSwitcher/build.gradle
index 495c503..036abc8 100644
--- a/ui/views/TextSwitcher/build.gradle
+++ b/ui/views/TextSwitcher/build.gradle
@@ -1 +1,8 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
diff --git a/views/TextLinkify/AndroidManifest.xml b/views/TextLinkify/AndroidManifest.xml
new file mode 100644
index 0000000..0bf9b97
--- /dev/null
+++ b/views/TextLinkify/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.views.textlinkify"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="4"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.android.views.textlinkify.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/views/TextLinkify/TextLinkify/build.gradle b/views/TextLinkify/TextLinkify/build.gradle
new file mode 100644
index 0000000..5bef5ee
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/build.gradle
@@ -0,0 +1,18 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.5.+'
+ }
+}
+apply plugin: 'android'
+
+dependencies {
+ compile "com.android.support:support-v4:18.0.+"
+}
+
+android {
+ compileSdkVersion 18
+ buildToolsVersion "18.0.0"
+}
diff --git a/views/TextLinkify/TextLinkify/src/main/AndroidManifest.xml b/views/TextLinkify/TextLinkify/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..0bf9b97
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.views.textlinkify"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="4"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.android.views.textlinkify.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/views/TextLinkify/TextLinkify/src/main/java/com/example/android/views/textlinkify/MainActivity.java b/views/TextLinkify/TextLinkify/src/main/java/com/example/android/views/textlinkify/MainActivity.java
new file mode 100644
index 0000000..9e5a7c9
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/java/com/example/android/views/textlinkify/MainActivity.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2013 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.views.textlinkify;
+
+import android.app.Activity;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.method.LinkMovementMethod;
+import android.text.style.StyleSpan;
+import android.text.style.URLSpan;
+import android.widget.TextView;
+
+/**
+ * This sample demonstrates how clickable links can be added to a
+ * {@link TextView}.
+ *
+ * <p>This can be done in three ways:
+ * <ul>
+ * <li><b>Automatically:</b> Text added to a TextView can automatically be linkified by enabling
+ * autoLinking. In XML, use the android:autoLink property, programatically call
+ * {@link android.widget.TextView#setAutoLinkMask(int)} using an option from
+ * {@link android.text.util.Linkify}</li>
+ *
+ * <li><b>Parsing a String as HTML:</b> See {@link Html#fromHtml(String)})</li>
+ *
+ * <li><b>Manually by constructing a {@link android.text.SpannableString}:</b> Consisting of
+ * {@link android.text.style.StyleSpan} and {@link android.text.style.URLSpan} objects that
+ * are contained within a {@link android.text.SpannableString}</li>
+ * </ul></p>
+ *
+ */
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_main);
+
+ // BEGIN_INCLUDE(text_auto_linkify)
+ /*
+ * text_auto_linkify shows the android:autoLink property, which
+ * automatically linkifies things like URLs and phone numbers
+ * found in the text. No java code is needed to make this
+ * work.
+ * This can also be enabled programmatically by calling
+ * .setAutoLinkMask(Linkify.ALL) before the text is set on the TextView.
+ *
+ * See android.text.util.Linkify for other options, for example only
+ * auto-linking email addresses or phone numbers
+ */
+ // END_INCLUDE(text_auto_linkify)
+
+ // BEGIN_INCLUDE(text_html_resource)
+ /*
+ * text_html_resource has links specified by putting anchor tags (<a>) in the string
+ * resource. By default these links will appear but not
+ * respond to user input. To make them active, you need to
+ * call setMovementMethod() on the TextView object.
+ */
+ TextView textViewResource = (TextView) findViewById(R.id.text_html_resource);
+ textViewResource.setText(
+ Html.fromHtml(getResources().getString(R.string.link_text_manual)));
+ textViewResource.setMovementMethod(LinkMovementMethod.getInstance());
+ // END_INCLUDE(text_html_resource)
+
+ // BEGIN_INCLUDE(text_html_program)
+ /*
+ * text_html_program shows creating text with links from HTML in the Java
+ * code, rather than from a string resource. Note that for a
+ * fixed string, using a (localizable) resource as shown above
+ * is usually a better way to go; this example is intended to
+ * illustrate how you might display text that came from a
+ * dynamic source (eg, the network).
+ */
+ TextView textViewHtml = (TextView) findViewById(R.id.text_html_program);
+ textViewHtml.setText(
+ Html.fromHtml(
+ "<b>text_html_program: Constructed from HTML programmatically.</b>"
+ + " Text with a <a href=\"http://www.google.com\">link</a> "
+ + "created in the Java source code using HTML."));
+ textViewHtml.setMovementMethod(LinkMovementMethod.getInstance());
+ // END_INCLUDE(text_html_program)
+
+ // BEGIN_INCLUDE(text_spannable)
+ /*
+ * text_spannable illustrates constructing a styled string containing a
+ * link without using HTML at all. Again, for a fixed string
+ * you should probably be using a string resource, not a
+ * hardcoded value.
+ */
+ SpannableString ss = new SpannableString(
+ "text_spannable: Manually created spans. Click here to dial the phone.");
+
+ /*
+ * Make the first 38 characters bold by applying a StyleSpan with bold typeface.
+ *
+ * Characters 45 to 49 (the word "here") is made clickable by applying a URLSpan
+ * pointing to a telephone number. Clicking it opens the "tel:" URL that starts the dialer.
+ *
+ * The SPAN_EXCLUSIVE_EXCLUSIVE flag defines this span as exclusive, which means
+ * that it will not expand to include text inserted on either side of this span.
+ */
+ ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 39,
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ ss.setSpan(new URLSpan("tel:4155551212"), 40 + 6, 40 + 10,
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+ TextView textViewSpan = (TextView) findViewById(R.id.text_spannable);
+ textViewSpan.setText(ss);
+
+ /*
+ * Set the movement method to move between links in this TextView.
+ * This means that the user traverses through links in this TextView, automatically
+ * handling appropriate scrolling and key commands.
+ */
+ textViewSpan.setMovementMethod(LinkMovementMethod.getInstance());
+ // END_INCLUDE(text_spannable)
+ }
+
+}
diff --git a/views/TextLinkify/TextLinkify/src/main/res/drawable-hdpi/ic_launcher.png b/views/TextLinkify/TextLinkify/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..eae36bc
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/views/TextLinkify/TextLinkify/src/main/res/drawable-mdpi/ic_launcher.png b/views/TextLinkify/TextLinkify/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..f727f48
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/views/TextLinkify/TextLinkify/src/main/res/drawable-xhdpi/ic_launcher.png b/views/TextLinkify/TextLinkify/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..51199d3
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/views/TextLinkify/TextLinkify/src/main/res/drawable-xxhdpi/ic_launcher.png b/views/TextLinkify/TextLinkify/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..c49ec6a
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/views/TextLinkify/TextLinkify/src/main/res/layout/activity_main.xml b/views/TextLinkify/TextLinkify/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..8f35a70
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/layout/activity_main.xml
@@ -0,0 +1,72 @@
+<!--
+ Copyright 2013 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.
+-->
+
+ <ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ tools:context=".MainActivity">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin">
+
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/intro" />
+
+ <!-- text_auto_linkify automatically linkifies things like URLs and phone numbers. -->
+ <TextView
+ android:id="@+id/text_auto_linkify"
+ style="@style/LinkText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:autoLink="all"
+ android:text="@string/link_text_auto" />
+
+ <!--
+ text_html_resource uses a string resource containing explicit anchor tags (<a>)
+ to specify links.
+ -->
+ <TextView
+ android:id="@+id/text_html_resource"
+ style="@style/LinkText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <!-- text_html_program builds the text in the Java code using HTML. -->
+ <TextView
+ android:id="@+id/text_html_program"
+ style="@style/LinkText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <!-- text_spannable builds the text in the Java code without using HTML. -->
+ <TextView
+ android:id="@+id/text_spannable"
+ style="@style/LinkText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+ </LinearLayout>
+ </ScrollView>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values-sw600dp/dimens.xml b/views/TextLinkify/TextLinkify/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..686fe89
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values-sw720dp-land/dimens.xml b/views/TextLinkify/TextLinkify/src/main/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..560bd44
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values-v11/styles.xml b/views/TextLinkify/TextLinkify/src/main/res/values-v11/styles.xml
new file mode 100644
index 0000000..91f4523
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values-v11/styles.xml
@@ -0,0 +1,27 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values/dimens.xml b/views/TextLinkify/TextLinkify/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..3b1975a
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values/dimens.xml
@@ -0,0 +1,23 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values/strings.xml b/views/TextLinkify/TextLinkify/src/main/res/values/strings.xml
new file mode 100644
index 0000000..371ee69
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values/strings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<resources>
+
+ <string name="app_name">TextLinkify Sample</string>
+ <string name="intro">This sample illustrates how links can be added to a TextView.
+ \nThis can be done either automatically by setting the <i>autoLink</i> property
+ or explicitly.</string>
+ <string name="link_text_auto"><b>text_auto_linkify: Various kinds
+ of data that will be auto-linked.</b>
+ In this text are some things that are actionable. For instance,
+ you can click on http://www.google.com and it will launch the
+ web browser. You can click on google.com too. If you
+ click on (415) 555-1212 it should dial the phone. Or just write
+ [email protected] for an e-mail link. If you have a URI like
+ http://www.example.com/lala/[email protected] you should get the
+ full link not the e-mail address. Or you can put a location
+ like 1600 Amphitheatre Parkway, Mountain View, CA 94043. To summarize:
+ https://www.google.com, or 650-253-0000, [email protected],
+ or 9606 North MoPac Expressway, Suite 400, Austin, TX 78759.</string>
+ <string name="link_text_manual"><![CDATA[<b>text_html_resource:
+ Explicit links using <a> markup.</b>
+ This has markup for a <a href="http://www.google.com">link</a> specified
+ via an <a> tag. Use a \"tel:\" URL
+ to <a href="tel:4155551212">dial a phone number</a>.]]></string>
+
+</resources>
diff --git a/views/TextLinkify/TextLinkify/src/main/res/values/styles.xml b/views/TextLinkify/TextLinkify/src/main/res/values/styles.xml
new file mode 100644
index 0000000..91da12c
--- /dev/null
+++ b/views/TextLinkify/TextLinkify/src/main/res/values/styles.xml
@@ -0,0 +1,40 @@
+<!--
+ Copyright 2013 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+ <style name="LinkText">
+ <item name="android:paddingTop">9dp</item>
+ <item name="android:paddingBottom">9dp</item>
+ </style>
+</resources>
diff --git a/views/TextLinkify/build.gradle b/views/TextLinkify/build.gradle
new file mode 100644
index 0000000..495c503
--- /dev/null
+++ b/views/TextLinkify/build.gradle
@@ -0,0 +1 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
diff --git a/views/TextLinkify/settings.gradle b/views/TextLinkify/settings.gradle
new file mode 100644
index 0000000..2042982
--- /dev/null
+++ b/views/TextLinkify/settings.gradle
@@ -0,0 +1,2 @@
+include ':TextLinkify'
+
diff --git a/views/TextLinkify/textLinkify.jd b/views/TextLinkify/textLinkify.jd
new file mode 100644
index 0000000..ca39b7b
--- /dev/null
+++ b/views/TextLinkify/textLinkify.jd
@@ -0,0 +1,15 @@
+page.title=Linkify Sample
+@jd:body
+<p>This sample demonstrates how clickable links can be added to a
+ <a href="http://developer.android.com/reference/android/widget/TextView.html">TextView</a>.
+ This can be done automatically (see
+ <a href="http://developer.android.com/reference/android/widget/TextView.html#setAutoLinkMask(int)">
+TextView#setAutoLinkMask(int)</a>), explicitly by parsing a String as
+ HTML (see
+ <a href="http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)">
+ Html#fromHtml(String)</a>) or using a
+ <a href="http://developer.android.com/reference/android/text/SpannableString.html">SpannableString
+</a> consisting of
+ <a href="http://developer.android.com/reference/android/text/style/StyleSpan.html">StyleSpan</a>
+ and <a href="http://developer.android.com/reference/android/text/style/URLSpan.html">URLSpan</a>
+ objects. </p>
\ No newline at end of file