diff options
Diffstat (limited to 'NotificationShowcase')
15 files changed, 227 insertions, 0 deletions
diff --git a/NotificationShowcase/Android.mk b/NotificationShowcase/Android.mk new file mode 100644 index 0000000..1130c70 --- /dev/null +++ b/NotificationShowcase/Android.mk @@ -0,0 +1,31 @@ +# +# Copyright (C) 2012 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) + +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_AAPT_FLAGS += -c mdpi,hdpi,xhdpi + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := NotificationShowcase +LOCAL_CERTIFICATE := platform +include $(BUILD_PACKAGE) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/NotificationShowcase/AndroidManifest.xml b/NotificationShowcase/AndroidManifest.xml new file mode 100644 index 0000000..08ed3b1 --- /dev/null +++ b/NotificationShowcase/AndroidManifest.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.example.notificationshowcase" + android:versionCode="1" + android:versionName="1.0"> + <uses-sdk android:minSdkVersion="13" /> + + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <activity android:name=".NotificationShowcaseActivity" + 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>
\ No newline at end of file diff --git a/NotificationShowcase/proguard.cfg b/NotificationShowcase/proguard.cfg new file mode 100644 index 0000000..b1cdf17 --- /dev/null +++ b/NotificationShowcase/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native <methods>; +} + +-keepclasseswithmembers class * { + public <init>(android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public <init>(android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/NotificationShowcase/res/drawable-hdpi/googleplus_icon.png b/NotificationShowcase/res/drawable-hdpi/googleplus_icon.png Binary files differnew file mode 100644 index 0000000..ba57c1f --- /dev/null +++ b/NotificationShowcase/res/drawable-hdpi/googleplus_icon.png diff --git a/NotificationShowcase/res/drawable-nodpi/arubin_hed.jpeg b/NotificationShowcase/res/drawable-nodpi/arubin_hed.jpeg Binary files differnew file mode 100644 index 0000000..c6d8ae9 --- /dev/null +++ b/NotificationShowcase/res/drawable-nodpi/arubin_hed.jpeg diff --git a/NotificationShowcase/res/drawable-nodpi/page_hed.jpg b/NotificationShowcase/res/drawable-nodpi/page_hed.jpg Binary files differnew file mode 100644 index 0000000..ea950c8 --- /dev/null +++ b/NotificationShowcase/res/drawable-nodpi/page_hed.jpg diff --git a/NotificationShowcase/res/drawable-xhdpi/icon.png b/NotificationShowcase/res/drawable-xhdpi/icon.png Binary files differnew file mode 100644 index 0000000..189e85b --- /dev/null +++ b/NotificationShowcase/res/drawable-xhdpi/icon.png diff --git a/NotificationShowcase/res/drawable-xhdpi/stat_notify_calendar.png b/NotificationShowcase/res/drawable-xhdpi/stat_notify_calendar.png Binary files differnew file mode 100644 index 0000000..5ae7782 --- /dev/null +++ b/NotificationShowcase/res/drawable-xhdpi/stat_notify_calendar.png diff --git a/NotificationShowcase/res/drawable-xhdpi/stat_notify_email.png b/NotificationShowcase/res/drawable-xhdpi/stat_notify_email.png Binary files differnew file mode 100644 index 0000000..23c4672 --- /dev/null +++ b/NotificationShowcase/res/drawable-xhdpi/stat_notify_email.png diff --git a/NotificationShowcase/res/drawable-xhdpi/stat_notify_sms.png b/NotificationShowcase/res/drawable-xhdpi/stat_notify_sms.png Binary files differnew file mode 100644 index 0000000..323cb3d --- /dev/null +++ b/NotificationShowcase/res/drawable-xhdpi/stat_notify_sms.png diff --git a/NotificationShowcase/res/drawable-xhdpi/twitter_icon.png b/NotificationShowcase/res/drawable-xhdpi/twitter_icon.png Binary files differnew file mode 100644 index 0000000..f982849 --- /dev/null +++ b/NotificationShowcase/res/drawable-xhdpi/twitter_icon.png diff --git a/NotificationShowcase/res/layout/main.xml b/NotificationShowcase/res/layout/main.xml new file mode 100644 index 0000000..f5a740f --- /dev/null +++ b/NotificationShowcase/res/layout/main.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + > + <LinearLayout android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_width="match_parent" android:layout_margin="35dp"> + <Button android:id="@+id/button1" android:text="@string/post_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doPost"></Button> + <Button android:id="@+id/button2" android:text="@string/remove_button_label" android:layout_height="wrap_content" android:layout_width="match_parent" android:onClick="doRemove"></Button> + </LinearLayout> +</FrameLayout> diff --git a/NotificationShowcase/res/values/strings.xml b/NotificationShowcase/res/values/strings.xml new file mode 100644 index 0000000..c514e2a --- /dev/null +++ b/NotificationShowcase/res/values/strings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="hello">Hello World, NotificationShowcaseActivity!</string> + <string name="app_name">NotificationShowcase</string> + <string name="post_button_label">Post Notifications</string> + <string name="remove_button_label">Remove Notifications</string> +</resources> diff --git a/NotificationShowcase/showcase.png b/NotificationShowcase/showcase.png Binary files differnew file mode 100644 index 0000000..5fd1675 --- /dev/null +++ b/NotificationShowcase/showcase.png diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java new file mode 100644 index 0000000..fcd9ccc --- /dev/null +++ b/NotificationShowcase/src/com/android/example/notificationshowcase/NotificationShowcaseActivity.java @@ -0,0 +1,120 @@ +// dummy notifications for demos +// for anandx@google.com by dsandler@google.com + +package com.android.example.notificationshowcase; + +import java.util.ArrayList; + +import android.app.Activity; +import android.app.Notification; +import android.app.NotificationManager; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; + +public class NotificationShowcaseActivity extends Activity { + private static final int NOTIFICATION_ID = 31338; + + private static final boolean FIRE_AND_FORGET = true; + + private ArrayList<Notification> mNotifications = new ArrayList<Notification>(); + + NotificationManager mNoMa; + int mLargeIconWidth, mLargeIconHeight; + + private Bitmap getBitmap(int resId) { + Drawable d = getResources().getDrawable(resId); + Bitmap b = Bitmap.createBitmap(mLargeIconWidth, mLargeIconHeight, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(b); + d.setBounds(0, 0, mLargeIconWidth, mLargeIconHeight); + d.draw(c); + return b; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + mLargeIconWidth = (int) getResources().getDimension(android.R.dimen.notification_large_icon_width); + mLargeIconHeight = (int) getResources().getDimension(android.R.dimen.notification_large_icon_height); + + mNoMa = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + + + // these will appear in the shade in reverse post order, so adjust the order here to taste + + // none of them does anything; if you want them to auto-destruct when tapped, add a + // .setAutoCancel(true) + // if you want to launch an app, you need to do more work, but then again it won't launch the + // right thing anyway because these notifications are just dummies. :) + + mNotifications.add(new Notification.Builder(this) + .setContentTitle("Larry Page") + .setContentText("hey, free nachos at MoMA!") + .setLargeIcon(getBitmap(R.drawable.page_hed)) + .setSmallIcon(android.R.drawable.stat_notify_chat) + .setPriority(Notification.PRIORITY_HIGH) + .setNumber(2) + .getNotification()); + + mNotifications.add(new Notification.Builder(this) + .setContentTitle("Andy Rubin") + .setContentText("Drinks tonight?") + .setTicker("Andy Rubin: Drinks tonight?") + .setLargeIcon(getBitmap(R.drawable.arubin_hed)) + .setSmallIcon(R.drawable.stat_notify_sms) + .setPriority(Notification.PRIORITY_MAX) + .getNotification()); + + mNotifications.add(new Notification.Builder(this) + .setContentTitle("J Planning") + .setContentText("The Botcave") + .setSmallIcon(R.drawable.stat_notify_calendar) + .setContentInfo("7PM") + .getNotification()); + + // Note: this may conflict with real email notifications + mNotifications.add(new Notification.Builder(this) + .setContentTitle("24 new messages") + .setContentText("test.hugo2@gmail.com") + .setSmallIcon(R.drawable.stat_notify_email) + .getNotification()); + + // No idea what this would really look like since the app is in flux + mNotifications.add(new Notification.Builder(this) + .setContentTitle("Google+") + .setContentText("Kanye West has added you to his circles") + .setSmallIcon(R.drawable.googleplus_icon) + .setPriority(Notification.PRIORITY_LOW) + .getNotification()); + + mNotifications.add(new Notification.Builder(this) + .setContentTitle("Twitter") + .setContentText("New mentions") + .setSmallIcon(R.drawable.twitter_icon) + .setNumber(15) + .setPriority(Notification.PRIORITY_LOW) + .getNotification()); + + if (FIRE_AND_FORGET) { + doPost(null); + finish(); + } + } + + public void doPost(View v) { + for (int i=0; i<mNotifications.size(); i++) { + mNoMa.notify(NOTIFICATION_ID + i, mNotifications.get(i)); + } + } + + public void doRemove(View v) { + for (int i=0; i<mNotifications.size(); i++) { + mNoMa.cancel(NOTIFICATION_ID + i); + } + } +} |