diff --git a/build/sdk.atree b/build/sdk.atree index 410a43c42..7b14b28f6 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -252,6 +252,17 @@ frameworks/support/v7/appcompat/res frameworks/support/v7/appcompat/src/.readme extras/android/support/v7/appcompat/src/.readme ${OUT_DIR}/target/common/obj/PACKAGING/android-support-v7-appcompat_intermediates/android-support-v7-appcompat.jar extras/android/support/appcompat/libs/android-support-v7-appcompat.jar +frameworks/support/v7/mediarouter/README.txt extras/android/support/v7/mediarouter/README.txt +frameworks/support/v7/mediarouter/.project extras/android/support/v7/mediarouter/.project +frameworks/support/v7/mediarouter/.classpath extras/android/support/v7/mediarouter/.classpath +frameworks/support/v7/mediarouter/AndroidManifest.xml extras/android/support/v7/mediarouter/AndroidManifest.xml +frameworks/support/v7/mediarouter/project.properties extras/android/support/v7/mediarouter/project.properties +frameworks/support/v7/mediarouter/res extras/android/support/v7/mediarouter/res +frameworks/support/v7/mediarouter/src/.readme extras/android/support/v7/mediarouter/src/.readme +${OUT_DIR}/target/common/obj/PACKAGING/android-support-v7-mediarouter_intermediates/android-support-v7-mediarouter.jar extras/android/support/v7/mediarouter/libs/android-support-v7-mediarouter.jar + +development/samples/Support7Demos extras/android/support/samples/Support7Demos + ############################################################################## # Tests Component ############################################################################## diff --git a/samples/Support4Demos/AndroidManifest.xml b/samples/Support4Demos/AndroidManifest.xml index 023034863..99bacd482 100644 --- a/samples/Support4Demos/AndroidManifest.xml +++ b/samples/Support4Demos/AndroidManifest.xml @@ -309,22 +309,5 @@ - - - - - - - - - - - - - - diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml index 3a58835b6..977db2f64 100644 --- a/samples/Support4Demos/res/values/strings.xml +++ b/samples/Support4Demos/res/values/strings.xml @@ -32,7 +32,9 @@ Violet Press the button to get an activity result, which will be displayed here: Get Result - + + + Fragment/Alert Dialog Fragment/Arguments @@ -136,19 +138,7 @@ FileProvider example - - - Media/MediaRouter - This activity demonstrates how to - use MediaRouter from the support library. Select a route from the action bar. - Play on... - - Play - Show Statistics - - Media Route Provider Service Support Library Sample - Fixed Volume Remote Playback Route - Variable Volume Remote Playback Route + Without BidiFormatter: With BidiFormatter: diff --git a/samples/Support7Demos/Android.mk b/samples/Support7Demos/Android.mk new file mode 100644 index 000000000..0e43e3d44 --- /dev/null +++ b/samples/Support7Demos/Android.mk @@ -0,0 +1,38 @@ +# 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. + +LOCAL_PATH:= $(call my-dir) + +# Build the samples. +# We need to add some special AAPT flags to generate R classes +# for resources that are included from the libraries. +include $(CLEAR_VARS) +LOCAL_PACKAGE_NAME := Support7Demos +LOCAL_MODULE_TAGS := samples tests +LOCAL_SDK_VERSION := current +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-support-v4 \ + android-support-v7-appcompat \ + android-support-v7-gridlayout \ + android-support-v7-mediarouter +LOCAL_RESOURCE_DIR = \ + $(LOCAL_PATH)/res \ + frameworks/support/v7/appcompat/res \ + frameworks/support/v7/gridlayout/res \ + frameworks/support/v7/mediarouter/res +LOCAL_AAPT_FLAGS := \ + --auto-add-overlay \ + --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout:android.support.v7.mediarouter +include $(BUILD_PACKAGE) diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml new file mode 100644 index 000000000..6d93b62a0 --- /dev/null +++ b/samples/Support7Demos/AndroidManifest.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Support7Demos/_index.html b/samples/Support7Demos/_index.html new file mode 100644 index 000000000..0c017ab6d --- /dev/null +++ b/samples/Support7Demos/_index.html @@ -0,0 +1,30 @@ +

The Support v7 Demos application contains a variety of small sample +code showing how to use key features of the Android API 7+ Support Library. +This library contains code that you can +build in to your application to access new features and common +utilities while being able to run down to version 2.1 (API 7) +of the platform. +

+ + diff --git a/samples/Support4Demos/res/drawable-hdpi/media_route_icon.png b/samples/Support7Demos/res/drawable-hdpi/app_sample_code.png similarity index 100% rename from samples/Support4Demos/res/drawable-hdpi/media_route_icon.png rename to samples/Support7Demos/res/drawable-hdpi/app_sample_code.png diff --git a/samples/Support7Demos/res/drawable-hdpi/media_route_icon.png b/samples/Support7Demos/res/drawable-hdpi/media_route_icon.png new file mode 100755 index 000000000..66a198496 Binary files /dev/null and b/samples/Support7Demos/res/drawable-hdpi/media_route_icon.png differ diff --git a/samples/Support4Demos/res/drawable-mdpi/media_route_icon.png b/samples/Support7Demos/res/drawable-mdpi/app_sample_code.png similarity index 100% rename from samples/Support4Demos/res/drawable-mdpi/media_route_icon.png rename to samples/Support7Demos/res/drawable-mdpi/app_sample_code.png diff --git a/samples/Support7Demos/res/drawable-mdpi/media_route_icon.png b/samples/Support7Demos/res/drawable-mdpi/media_route_icon.png new file mode 100644 index 000000000..5ae7701a8 Binary files /dev/null and b/samples/Support7Demos/res/drawable-mdpi/media_route_icon.png differ diff --git a/samples/Support4Demos/res/layout/sample_media_router.xml b/samples/Support7Demos/res/layout/sample_media_router.xml similarity index 100% rename from samples/Support4Demos/res/layout/sample_media_router.xml rename to samples/Support7Demos/res/layout/sample_media_router.xml diff --git a/samples/Support4Demos/res/menu/sample_media_router_menu.xml b/samples/Support7Demos/res/menu/sample_media_router_menu.xml similarity index 100% rename from samples/Support4Demos/res/menu/sample_media_router_menu.xml rename to samples/Support7Demos/res/menu/sample_media_router_menu.xml diff --git a/samples/Support4Demos/res/values/arrays.xml b/samples/Support7Demos/res/values/arrays.xml similarity index 100% rename from samples/Support4Demos/res/values/arrays.xml rename to samples/Support7Demos/res/values/arrays.xml diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml new file mode 100644 index 000000000..d7ccc44f5 --- /dev/null +++ b/samples/Support7Demos/res/values/strings.xml @@ -0,0 +1,33 @@ + + + + + Support v7 Demos + + + + Media/MediaRouter + This activity demonstrates how to + use MediaRouter from the support library. Select a route from the action bar. + Play on... + + Play + Show Statistics + + Media Route Provider Service Support Library Sample + Fixed Volume Remote Playback Route + Variable Volume Remote Playback Route + diff --git a/samples/Support7Demos/src/com/example/android/supportv7/Support7Demos.java b/samples/Support7Demos/src/com/example/android/supportv7/Support7Demos.java new file mode 100644 index 000000000..d2e633540 --- /dev/null +++ b/samples/Support7Demos/src/com/example/android/supportv7/Support7Demos.java @@ -0,0 +1,151 @@ +/* + * 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.supportv7; + +import android.app.ListActivity; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Bundle; +import android.view.View; +import android.widget.ListView; +import android.widget.SimpleAdapter; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Support7Demos extends ListActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + String path = intent.getStringExtra("com.example.android.apis.Path"); + + if (path == null) { + path = ""; + } + + setListAdapter(new SimpleAdapter(this, getData(path), + android.R.layout.simple_list_item_1, new String[] { "title" }, + new int[] { android.R.id.text1 })); + getListView().setTextFilterEnabled(true); + } + + protected List> getData(String prefix) { + List> myData = new ArrayList>(); + + Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); + mainIntent.addCategory("com.example.android.supportv7.SUPPORT4_SAMPLE_CODE"); + + PackageManager pm = getPackageManager(); + List list = pm.queryIntentActivities(mainIntent, 0); + + if (null == list) + return myData; + + String[] prefixPath; + String prefixWithSlash = prefix; + + if (prefix.equals("")) { + prefixPath = null; + } else { + prefixPath = prefix.split("/"); + prefixWithSlash = prefix + "/"; + } + + int len = list.size(); + + Map entries = new HashMap(); + + for (int i = 0; i < len; i++) { + ResolveInfo info = list.get(i); + CharSequence labelSeq = info.loadLabel(pm); + String label = labelSeq != null + ? labelSeq.toString() + : info.activityInfo.name; + + if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) { + + String[] labelPath = label.split("/"); + + String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length]; + + if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) { + addItem(myData, nextLabel, activityIntent( + info.activityInfo.applicationInfo.packageName, + info.activityInfo.name)); + } else { + if (entries.get(nextLabel) == null) { + addItem(myData, nextLabel, browseIntent( + prefix.equals("") ? nextLabel : prefix + "/" + nextLabel)); + entries.put(nextLabel, true); + } + } + } + } + + Collections.sort(myData, sDisplayNameComparator); + + return myData; + } + + private final static Comparator> sDisplayNameComparator = + new Comparator>() { + private final Collator collator = Collator.getInstance(); + + @Override + public int compare(Map map1, Map map2) { + return collator.compare(map1.get("title"), map2.get("title")); + } + }; + + protected Intent activityIntent(String pkg, String componentName) { + Intent result = new Intent(); + result.setClassName(pkg, componentName); + return result; + } + + protected Intent browseIntent(String path) { + Intent result = new Intent(); + result.setClass(this, Support7Demos.class); + result.putExtra("com.example.android.apis.Path", path); + return result; + } + + protected void addItem(List> data, String name, Intent intent) { + Map temp = new HashMap(); + temp.put("title", name); + temp.put("intent", intent); + data.add(temp); + } + + @Override + @SuppressWarnings("unchecked") + protected void onListItemClick(ListView l, View v, int position, long id) { + Map map = (Map)l.getItemAtPosition(position); + + Intent intent = (Intent) map.get("intent"); + startActivity(intent); + } +} diff --git a/samples/Support7Demos/src/com/example/android/supportv7/_package.html b/samples/Support7Demos/src/com/example/android/supportv7/_package.html new file mode 100644 index 000000000..be85e7887 --- /dev/null +++ b/samples/Support7Demos/src/com/example/android/supportv7/_package.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + +

+Examples of how to use support library APIs. See: + +

    +
  1. sdk.app for examples + of using the application package support APIs. +
+

+ + + + diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/_index.html b/samples/Support7Demos/src/com/example/android/supportv7/app/_index.html new file mode 100644 index 000000000..d203ffb6b --- /dev/null +++ b/samples/Support7Demos/src/com/example/android/supportv7/app/_index.html @@ -0,0 +1,102 @@ + +

This section includes samples showing the use of the application +package features of the static support library, in particular fragments +and loaders.

+ + + +

Fragment

+
+
Fragment Alert Dialog
+
Demonstrates how to use a DialogFragment to show and manage an + AlertDialog.
+ +
Fragment Arguments
+
Demonstrates how a fragment can be initialized with arguments, + supplying them either as an argument Bundle at runtime or XML attributes + in a <fragment> tag.
+ +
Fragment Context Menu
+
Demonstrates how to display and respond to a context menu that is + display from a fragment's view hierarchy.
+ +
Fragment Custom Animation
+
Demonstrates the use of a custom animation for pushing and popping fragments + on the back stack.
+ +
Fragment Dialog
+
Demonstrates use of DialogFragment to show various types of dialogs.
+ +
Fragment Dialog or Activity
+
Demonstrates how the same Fragment implementation can be used to provide the UI + for either an Activity or Dialog.
+ +
Fragment Hide Show
+
Demonstrates hiding and showing fragments.
+ +
Fragment Layout
+
Demonstrates use of the <fragment> tag to embed a Fragment in + an Activity's content view layout, and making the layout change based on + configuration to achieve different UI flows.
+ +
Fragment List Array
+
Demonstrates use of ListFragment to show the contents of a simple ArrayAdapter.
+ +
Fragment Menu
+
Demonstrates populating custom menu items from a Fragment.
+ +
Fragment Pager Support
+
Demonstrates the use of the support class ViewPager with a + FragmentPagerAdapter to build a user interface where the user can fling + left or right to switch between fragments.
+ +
Fragment State Pager Support
+
Demonstrates the use of the support class ViewPager with a + FragmentStatePagerAdapter to build a user interface where the user can fling + left or right to switch between fragments. This versions of the adapter + doesn't keep around the fragment instances that ViewPager has destroyed.
+ +
Fragment Receive Result
+
Demonstrates starting a new Activity from a Fragment, and receiving + a result back from it.
+ +
Fragment Retain Instance
+
Demonstrates a Fragment can be used to easily retain active state across + an Activity's configuration change.
+ +
Fragment Stack
+
Demonstrates creating a stack of Fragment instances similar to the + traditional stack of activities.
+ +
Fragment Tabs
+
Demonstrates the use of fragments to implement switching between + tabs in a TabHost.
+ +
Fragment Tabs Pager
+
Demonstrates the use of fragments to implement switching between + tabs in a TabHost, using a ViewPager to manager the fragments so that + the user can also fling left and right to switch tabs.
+ +
+ +

LoaderManager

+
+
Loader Cursor
+
Demonstrates use of LoaderManager to perform a query for a Cursor that + populates a ListFragment.
+ +
Loader Custom
+
Demonstrates implementation and use of a custom Loader class. The + custom class here "loads" the currently installed applications.
+ +
Loader Throttle
+
Complete end-to-end demonstration of a simple content provider that + populates data in a list through a cursor loader. The UI allows the list + to be populated with a series of items, showing how AsyncTaskLoader's + throttling facility can be used to control how much a Loader is refreshed + in this case.
+
+ \ No newline at end of file diff --git a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProvider.java b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java similarity index 96% rename from samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProvider.java rename to samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java index 7dc191397..3d8abc992 100644 --- a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProvider.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProvider.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.example.android.supportv4.media; +package com.example.android.supportv7.media; -import com.example.android.supportv4.R; +import com.example.android.supportv7.R; import android.content.Context; import android.content.Intent; @@ -26,9 +26,9 @@ import android.content.res.Resources; import android.media.MediaRouter; import android.net.Uri; import android.os.Bundle; -import android.support.v4.media.MediaControlIntent; -import android.support.v4.media.MediaRouteProvider; -import android.support.v4.media.MediaRouter.ControlRequestCallback; +import android.support.v7.media.MediaControlIntent; +import android.support.v7.media.MediaRouteProvider; +import android.support.v7.media.MediaRouter.ControlRequestCallback; import android.util.Log; import android.widget.Toast; diff --git a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProviderService.java b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProviderService.java similarity index 86% rename from samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProviderService.java rename to samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProviderService.java index 4528e3985..bb0aa07e2 100644 --- a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouteProviderService.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouteProviderService.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.example.android.supportv4.media; +package com.example.android.supportv7.media; -import android.support.v4.media.MediaRouteProvider; -import android.support.v4.media.MediaRouteProviderService; +import android.support.v7.media.MediaRouteProvider; +import android.support.v7.media.MediaRouteProviderService; /** * Demonstrates how to register a custom media route provider service diff --git a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouterActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java similarity index 97% rename from samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouterActivity.java rename to samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java index 48afad214..c3ead3c0a 100644 --- a/samples/Support4Demos/src/com/example/android/supportv4/media/SampleMediaRouterActivity.java +++ b/samples/Support7Demos/src/com/example/android/supportv7/media/SampleMediaRouterActivity.java @@ -14,19 +14,19 @@ * limitations under the License. */ -package com.example.android.supportv4.media; +package com.example.android.supportv7.media; -import com.example.android.supportv4.R; +import com.example.android.supportv7.R; import android.app.Activity; import android.app.MediaRouteActionProvider; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.support.v4.media.MediaControlIntent; -import android.support.v4.media.MediaRouter; -import android.support.v4.media.MediaRouter.RouteInfo; -import android.support.v4.media.MediaRouter.ProviderInfo; +import android.support.v7.media.MediaControlIntent; +import android.support.v7.media.MediaRouter; +import android.support.v7.media.MediaRouter.RouteInfo; +import android.support.v7.media.MediaRouter.ProviderInfo; import android.util.Log; import android.view.Menu; import android.view.MenuItem; diff --git a/samples/Support7Demos/src/com/example/android/supportv7/media/_index.html b/samples/Support7Demos/src/com/example/android/supportv7/media/_index.html new file mode 100644 index 000000000..a443287cc --- /dev/null +++ b/samples/Support7Demos/src/com/example/android/supportv7/media/_index.html @@ -0,0 +1,23 @@ + +

This section includes samples showing the use of the application +package features of the static support library.

+ + + +

MediaRouter

+
+
Media Route Provider
+
Demonstrates how to implement a MediaRouteProvider to discover, + publish and control custom media routes.
+ +
Media Route Provider Service
+
Demonstrates how to make a MediaRouteProvider available to all + running applications by registering it as a service.
+ +
Media Router Activity
+
Demonstrates how to use MediaRouter within an Activity to support + remote media playback.
+
+ \ No newline at end of file