Move media router samples to new Support7Demos project.

Add media router support library to SDK build.

Bug: 8175766
Change-Id: I2f333d40ad39e820e8d706a7dab086241692a861
This commit is contained in:
Jeff Brown
2013-03-19 17:06:22 -07:00
parent 3221bcdb88
commit bda0c73168
21 changed files with 494 additions and 45 deletions

View File

@@ -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
##############################################################################

View File

@@ -309,22 +309,5 @@
</provider>
<!-- END_INCLUDE(file_provider_declaration) -->
<!-- MediaRouter Support Samples -->
<activity android:name=".media.SampleMediaRouterActivity"
android:label="@string/sample_media_router_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
</intent-filter>
</activity>
<service android:name=".media.SampleMediaRouteProviderService"
android:label="@string/sample_media_route_provider_service"
android:process=":mediarouteprovider">
<intent-filter>
<action android:name="android.media.MediaRouteProviderService" />
</intent-filter>
</service>
</application>
</manifest>

View File

@@ -32,7 +32,9 @@
<string name="violet">Violet</string>
<string name="receive_result_instructions">Press the button to get an activity result, which will be displayed here:</string>
<string name="receive_result_result">Get Result</string>
<!-- Fragment API -->
<string name="fragment_alert_dialog_support">Fragment/Alert Dialog</string>
<string name="fragment_arguments_support">Fragment/Arguments</string>
@@ -136,19 +138,7 @@
<string name="file_provider_example">FileProvider example</string>
<!-- MediaRouter -->
<string name="sample_media_router_activity">Media/MediaRouter</string>
<string name="sample_media_router_text">This activity demonstrates how to
use MediaRouter from the support library. Select a route from the action bar.</string>
<string name="sample_media_router_play_on">Play on...</string>
<string name="play_button_text">Play</string>
<string name="statistics_button_text">Show Statistics</string>
<string name="sample_media_route_provider_service">Media Route Provider Service Support Library Sample</string>
<string name="fixed_volume_route_name">Fixed Volume Remote Playback Route</string>
<string name="variable_volume_route_name">Variable Volume Remote Playback Route</string>
<!-- Text API -->
<string name="without_bidiformatter">Without BidiFormatter:</string>
<string name="with_bidiformatter">With BidiFormatter:</string>

View File

@@ -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)

View File

@@ -0,0 +1,64 @@
<?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.
-->
<!-- Declare the contents of this Android application. The namespace
attribute brings in the Android platform namespace, and the package
supplies a unique name for the application. When writing your
own application, the package name must be changed from "com.example.*"
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.supportv7">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" />
<!-- The smallest screen this app works on is a phone. The app will
scale its UI to larger screens but doesn't make good use of them
so allow the compatibility mode button to be shown (mostly because
this is just convenient for testing). -->
<supports-screens android:requiresSmallestWidthDp="320"
android:compatibleWidthLimitDp="480" />
<application android:label="@string/activity_sample_code"
android:icon="@drawable/app_sample_code"
android:hardwareAccelerated="true">
<activity android:name="Support7Demos">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- MediaRouter Support Samples -->
<activity android:name=".media.SampleMediaRouterActivity"
android:label="@string/sample_media_router_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SUPPORT4_SAMPLE_CODE" />
</intent-filter>
</activity>
<service android:name=".media.SampleMediaRouteProviderService"
android:label="@string/sample_media_route_provider_service"
android:process=":mediarouteprovider">
<intent-filter>
<action android:name="android.media.MediaRouteProviderService" />
</intent-filter>
</service>
</application>
</manifest>

View File

@@ -0,0 +1,30 @@
<p>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.
</p>
<script type="text/javascript">
// This is a totally temporary hack to display the following content only
// when the docs are online. This will be changed once the samples get moved.
if (toRoot == "/") {
document.write(""+
"<p>You'll notice that all the samples are included in a single Android "+
"project, so the application code and other resource files for all samples are batched "+
"together. To help you find the code that's relevant to you, here's a directory that "+
"points to the program code for the different topics included in the project:</p>"+
"<ul>"+
"<li><a href='src/com/example/android/supportv7/app/index.html'>App</a></li>"+
"<li><a href='src/com/example/android/supportv7/media/index.html'>Media</a></li>"+
"<li><a href='src/com/example/android/supportv7/view/index.html'>Views</a></li>"+
"</ul>");
}
</script>

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -0,0 +1,33 @@
<?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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="activity_sample_code">Support v7 Demos</string>
<!-- MediaRouter -->
<string name="sample_media_router_activity">Media/MediaRouter</string>
<string name="sample_media_router_text">This activity demonstrates how to
use MediaRouter from the support library. Select a route from the action bar.</string>
<string name="sample_media_router_play_on">Play on...</string>
<string name="play_button_text">Play</string>
<string name="statistics_button_text">Show Statistics</string>
<string name="sample_media_route_provider_service">Media Route Provider Service Support Library Sample</string>
<string name="fixed_volume_route_name">Fixed Volume Remote Playback Route</string>
<string name="variable_volume_route_name">Variable Volume Remote Playback Route</string>
</resources>

View File

@@ -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<Map<String, Object>> getData(String prefix) {
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory("com.example.android.supportv7.SUPPORT4_SAMPLE_CODE");
PackageManager pm = getPackageManager();
List<ResolveInfo> 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<String, Boolean> entries = new HashMap<String, Boolean>();
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<Map<String, Object>> sDisplayNameComparator =
new Comparator<Map<String, Object>>() {
private final Collator collator = Collator.getInstance();
@Override
public int compare(Map<String, Object> map1, Map<String, Object> 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<Map<String, Object>> data, String name, Intent intent) {
Map<String, Object> temp = new HashMap<String, Object>();
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<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
Intent intent = (Intent) map.get("intent");
startActivity(intent);
}
}

View File

@@ -0,0 +1,24 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="assets/style.css" />
<script type="text/javascript" src="http://www.corp.google.com/style/prettify.js"></script>
<script src="http://www.corp.google.com/eng/techpubs/include/navbar.js" type="text/javascript"></script>
</head>
<body>
<p>
Examples of how to use support library APIs. See:
<ol>
<li> <a href="com.example.android.supportv7.app">sdk.app</a> for examples
of using the application package support APIs.
</ol>
</p>
</body>
</html>

View File

@@ -0,0 +1,102 @@
<p>This section includes samples showing the use of the application
package features of the static support library, in particular fragments
and loaders.</p>
<ul>
<li><a href="#Fragment">Fragment</a></li>
<li><a href="#LoaderManager">LoaderManager</a></li>
</ul>
<h3 id="Fragment">Fragment</h3>
<dl>
<dt><a href="FragmentAlertDialogSupport.html">Fragment Alert Dialog</a></dt>
<dd>Demonstrates how to use a DialogFragment to show and manage an
AlertDialog.</dd>
<dt><a href="FragmentArgumentsSupport.html">Fragment Arguments</a></dt>
<dd>Demonstrates how a fragment can be initialized with arguments,
supplying them either as an argument Bundle at runtime or XML attributes
in a &lt;fragment> tag.</dd>
<dt><a href="FragmentContextMenuSupport.html">Fragment Context Menu</a></dt>
<dd>Demonstrates how to display and respond to a context menu that is
display from a fragment's view hierarchy.</dd>
<dt><a href="FragmentCustomAnimationSupport.html">Fragment Custom Animation</a></dt>
<dd>Demonstrates the use of a custom animation for pushing and popping fragments
on the back stack.</dd>
<dt><a href="FragmentDialogSupport.html">Fragment Dialog</a></dt>
<dd>Demonstrates use of DialogFragment to show various types of dialogs.</dd>
<dt><a href="FragmentDialogOrActivitySupport.html">Fragment Dialog or Activity</a></dt>
<dd>Demonstrates how the same Fragment implementation can be used to provide the UI
for either an Activity or Dialog.</dd>
<dt><a href="FragmentHideShowSupport.html">Fragment Hide Show</a></dt>
<dd>Demonstrates hiding and showing fragments.</dd>
<dt><a href="FragmentLayoutSupport.html">Fragment Layout</a></dt>
<dd>Demonstrates use of the &lt;fragment&gt; 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.</dd>
<dt><a href="FragmentListArraySupport.html">Fragment List Array</a></dt>
<dd>Demonstrates use of ListFragment to show the contents of a simple ArrayAdapter.</dd>
<dt><a href="FragmentMenuSupport.html">Fragment Menu</a></dt>
<dd>Demonstrates populating custom menu items from a Fragment.</dd>
<dt><a href="FragmentPagerSupport.html">Fragment Pager Support</a></dt>
<dd>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.</dd>
<dt><a href="FragmentStatePagerSupport.html">Fragment State Pager Support</a></dt>
<dd>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.</dd>
<dt><a href="FragmentReceiveResultSupport.html">Fragment Receive Result</a></dt>
<dd>Demonstrates starting a new Activity from a Fragment, and receiving
a result back from it.</dd>
<dt><a href="FragmentRetainInstanceSupport.html">Fragment Retain Instance</a></dt>
<dd>Demonstrates a Fragment can be used to easily retain active state across
an Activity's configuration change.</dd>
<dt><a href="FragmentStackSupport.html">Fragment Stack</a></dt>
<dd>Demonstrates creating a stack of Fragment instances similar to the
traditional stack of activities.</dd>
<dt><a href="FragmentTabs.html">Fragment Tabs</a></dt>
<dd>Demonstrates the use of fragments to implement switching between
tabs in a TabHost.</dd>
<dt><a href="FragmentTabsPager.html">Fragment Tabs Pager</a></dt>
<dd>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.</dd>
</dl>
<h3 id="LoaderManager">LoaderManager</h3>
<dl>
<dt><a href="LoaderCursorSupport.html">Loader Cursor</a></dt>
<dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
populates a ListFragment.</dd>
<dt><a href="LoaderCustomSupport.html">Loader Custom</a></dt>
<dd>Demonstrates implementation and use of a custom Loader class. The
custom class here "loads" the currently installed applications.</dd>
<dt><a href="LoaderThrottleSupport.html">Loader Throttle</a></dt>
<dd>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.</dd>
</dl>

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -0,0 +1,23 @@
<p>This section includes samples showing the use of the application
package features of the static support library.</p>
<ul>
<li><a href="#MediaRouter">MediaRouter</a></li>
</ul>
<h3 id="MediaRouter">MediaRouter</h3>
<dl>
<dt><a href="SampleMediaRouteProvider.html">Media Route Provider</a></dt>
<dd>Demonstrates how to implement a MediaRouteProvider to discover,
publish and control custom media routes.</dd>
<dt><a href="SampleMediaRouteProviderService.html">Media Route Provider Service</a></dt>
<dd>Demonstrates how to make a MediaRouteProvider available to all
running applications by registering it as a service.</dd>
<dt><a href="SampleMediaRouterActivity.html">Media Router Activity</a></dt>
<dd>Demonstrates how to use MediaRouter within an Activity to support
remote media playback.</dd>
</dl>