Docs: Sync browseable samples for lmp-docs
Synced to developers/samples/android commit
bc036ecdf44cd03163c206096172299f3940b057.
Change-Id: Ib68230d79ca300e7db906aff2ebfc2cb6c6968f7
diff --git a/samples/browseable/Notifications/Application/AndroidManifest.xml b/samples/browseable/Notifications/Application/AndroidManifest.xml
index a0ed729..3f1274d 100644
--- a/samples/browseable/Notifications/Application/AndroidManifest.xml
+++ b/samples/browseable/Notifications/Application/AndroidManifest.xml
@@ -17,9 +17,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.support.wearable.notifications" >
+ <uses-sdk android:minSdkVersion="18"
+ android:targetSdkVersion="21" />
- <uses-sdk android:minSdkVersion="19"
- android:targetSdkVersion="19" />
+ <uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
diff --git a/samples/browseable/Notifications/Application/res/drawable-nodpi/qr_code.png b/samples/browseable/Notifications/Application/res/drawable-nodpi/qr_code.png
new file mode 100644
index 0000000..0dcd7b7
--- /dev/null
+++ b/samples/browseable/Notifications/Application/res/drawable-nodpi/qr_code.png
Binary files differ
diff --git a/samples/browseable/Notifications/Application/res/values-v21/base-colors.xml b/samples/browseable/Notifications/Application/res/values-v21/base-colors.xml
new file mode 100644
index 0000000..34c9cd1
--- /dev/null
+++ b/samples/browseable/Notifications/Application/res/values-v21/base-colors.xml
@@ -0,0 +1,20 @@
+<?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>
+
+
+</resources>
diff --git a/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml b/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml
new file mode 100644
index 0000000..0b2948f
--- /dev/null
+++ b/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.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>
+
+ <!-- Activity themes -->
+ <style name="Theme.Base" parent="android:Theme.Material.Light">
+ </style>
+
+</resources>
diff --git a/samples/browseable/Notifications/Application/res/values-v21/template-styles.xml b/samples/browseable/Notifications/Application/res/values-v21/template-styles.xml
deleted file mode 100644
index 134fcd9..0000000
--- a/samples/browseable/Notifications/Application/res/values-v21/template-styles.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- Copyright 2014 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>
-
- <!-- Activity themes -->
- <style name="Theme.Base" parent="android:Theme.Material.Light" />
-
-</resources>
diff --git a/samples/browseable/Notifications/Application/res/values/base-strings.xml b/samples/browseable/Notifications/Application/res/values/base-strings.xml
index 9abe486..55d83b0 100644
--- a/samples/browseable/Notifications/Application/res/values/base-strings.xml
+++ b/samples/browseable/Notifications/Application/res/values/base-strings.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
<resources>
- <string name="app_name">Notifications</string>
+ <string name="app_name">Wearable Notifications</string>
<string name="intro_message">
<![CDATA[
diff --git a/samples/browseable/Notifications/Application/res/values/colors.xml b/samples/browseable/Notifications/Application/res/values/colors.xml
index 9464085..fbcf956 100644
--- a/samples/browseable/Notifications/Application/res/values/colors.xml
+++ b/samples/browseable/Notifications/Application/res/values/colors.xml
@@ -15,5 +15,5 @@
-->
<resources>
- <color name="divider_text">@android:color/holo_blue_bright</color>
+ <color name="divider_text">@android:color/holo_blue_dark</color>
</resources>
diff --git a/samples/browseable/Notifications/Application/res/values/strings.xml b/samples/browseable/Notifications/Application/res/values/strings.xml
index 52f0f10..ffcb9f3 100644
--- a/samples/browseable/Notifications/Application/res/values/strings.xml
+++ b/samples/browseable/Notifications/Application/res/values/strings.xml
@@ -38,6 +38,7 @@
<string name="content_icon_example">Content icon example</string>
<string name="multiple_page_example">Multiple page example</string>
<string name="bundle_example">Bundle example</string>
+ <string name="barcode_example">Barcode example</string>
<string name="min_priority">Min priority</string>
<string name="low_priority">Low priority</string>
@@ -161,6 +162,9 @@
<string name="big_picture_style_example_title">Big picture style example title</string>
<string name="big_picture_style_example_summary_text">Big picture style example summary</string>
+ <string name="barcode_content_title">Barcode example</string>
+ <string name="barcode_content_text">Swipe to view</string>
+
<string name="second_page_content_title">Second page title</string>
<string name="second_page_content_text">Second page text</string>
diff --git a/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java
index c2be395..4ade3ed 100644
--- a/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java
+++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/MainActivity.java
@@ -170,12 +170,12 @@
}
private void updateTextEditors(NotificationPreset preset) {
+ mTitleEditText.setText(getString(preset.titleResId));
+ mTextEditText.setText(getString(preset.textResId));
if (preset == NotificationPresets.BASIC) {
findViewById(R.id.title_edit_field).setVisibility(View.VISIBLE);
- mTitleEditText.setText(getString(preset.titleResId));
mTitleEditText.addTextChangedListener(mTextChangedListener);
findViewById(R.id.text_edit_field).setVisibility(View.VISIBLE);
- mTextEditText.setText(getString(preset.textResId));
mTextEditText.addTextChangedListener(mTextChangedListener);
} else {
findViewById(R.id.title_edit_field).setVisibility(View.GONE);
diff --git a/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java
index e175d11..641b861 100644
--- a/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java
+++ b/samples/browseable/Notifications/Application/src/com.example.android.support.wearable.notifications/NotificationPresets.java
@@ -50,6 +50,7 @@
public static final NotificationPreset CONTENT_ICON = new ContentIconNotificationPreset();
public static final NotificationPreset MULTIPLE_PAGE = new MultiplePageNotificationPreset();
public static final NotificationPreset BUNDLE = new NotificationBundlePreset();
+ public static final NotificationPreset BARCODE = new NotificationBarcodePreset();
public static final NotificationPreset[] PRESETS = new NotificationPreset[] {
BASIC,
@@ -62,7 +63,8 @@
CONTENT_ACTION,
CONTENT_ICON,
MULTIPLE_PAGE,
- BUNDLE
+ BUNDLE,
+ BARCODE
};
private static NotificationCompat.Builder applyBasicOptions(Context context,
@@ -476,4 +478,33 @@
childBuilder2.build() };
}
}
+
+ private static class NotificationBarcodePreset extends NotificationPreset {
+ public NotificationBarcodePreset() {
+ super(R.string.barcode_example, R.string.barcode_content_title,
+ R.string.barcode_content_text);
+ }
+
+ @Override
+ public Notification[] buildNotifications(Context context, BuildOptions options) {
+ NotificationCompat.Builder secondPageBuilder = new NotificationCompat.Builder(context)
+ .extend(new NotificationCompat.WearableExtender()
+ .setHintShowBackgroundOnly(true)
+ .setBackground(BitmapFactory.decodeResource(context.getResources(),
+ R.drawable.qr_code))
+ .setHintAvoidBackgroundClipping(true)
+ .setHintScreenTimeout(
+ NotificationCompat.WearableExtender.SCREEN_TIMEOUT_LONG));
+
+ NotificationCompat.Builder firstPageBuilder = new NotificationCompat.Builder(context);
+ NotificationCompat.WearableExtender firstPageWearableOptions =
+ new NotificationCompat.WearableExtender();
+ applyBasicOptions(context, firstPageBuilder, firstPageWearableOptions, options);
+
+ firstPageBuilder.extend(
+ firstPageWearableOptions.addPage(secondPageBuilder.build()));
+
+ return new Notification[]{ firstPageBuilder.build() };
+ }
+ }
}
diff --git a/samples/browseable/Notifications/Wearable/AndroidManifest.xml b/samples/browseable/Notifications/Wearable/AndroidManifest.xml
index 57cd7c4..34a29ff 100644
--- a/samples/browseable/Notifications/Wearable/AndroidManifest.xml
+++ b/samples/browseable/Notifications/Wearable/AndroidManifest.xml
@@ -18,7 +18,7 @@
package="com.example.android.support.wearable.notifications" >
<uses-sdk android:minSdkVersion="20"
- android:targetSdkVersion="20" />
+ android:targetSdkVersion="21" />
<uses-feature android:name="android.hardware.type.watch" />
diff --git a/samples/browseable/Notifications/Wearable/src/com.example.android.support.wearable.notifications/WearableListItemLayout.java b/samples/browseable/Notifications/Wearable/src/com.example.android.support.wearable.notifications/WearableListItemLayout.java
index 773dfe4..4ec554c 100644
--- a/samples/browseable/Notifications/Wearable/src/com.example.android.support.wearable.notifications/WearableListItemLayout.java
+++ b/samples/browseable/Notifications/Wearable/src/com.example.android.support.wearable.notifications/WearableListItemLayout.java
@@ -24,7 +24,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;
-public class WearableListItemLayout extends LinearLayout implements WearableListView.Item {
+public class WearableListItemLayout extends LinearLayout
+ implements WearableListView.OnCenterProximityListener {
private final float mFadedTextAlpha;
private final int mFadedCircleColor;
@@ -56,35 +57,13 @@
}
@Override
- public float getProximityMinValue() {
- return 1f;
- }
-
- @Override
- public float getProximityMaxValue() {
- return 1.6f;
- }
-
- @Override
- public float getCurrentProximityValue() {
- return mScale;
- }
-
- @Override
- public void setScalingAnimatorValue(float scale) {
- mScale = scale;
- mCircle.setScaleX(scale);
- mCircle.setScaleY(scale);
- }
-
- @Override
- public void onScaleUpStart() {
+ public void onCenterPosition(boolean animate) {
mName.setAlpha(1f);
((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor);
}
@Override
- public void onScaleDownStart() {
+ public void onNonCenterPosition(boolean animate) {
((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor);
mName.setAlpha(mFadedTextAlpha);
}
diff --git a/samples/browseable/Notifications/_index.jd b/samples/browseable/Notifications/_index.jd
index 7fa5d23..ba28233 100644
--- a/samples/browseable/Notifications/_index.jd
+++ b/samples/browseable/Notifications/_index.jd
@@ -1,4 +1,4 @@
-page.tags="Notifications"
+page.tags="Wearable Notifications"
sample.group=Wearable
@jd:body