diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-12-10 18:41:09 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-12-10 18:41:09 +0000 |
commit | f5a461d1820f08c2001256f514a6b92eb78545f6 (patch) | |
tree | 5051cd45d29cc61858f6457e104d8b96bff58871 /android | |
parent | c47d81345151166083ab10d6f5d11e56462056d5 (diff) |
Android: Rework notification and change icon sizes to better meet the systems' standard.
The notification now announces the new track on track change, and the the area in the scrolled down notification area shows track infos (title, artist, album).
Someone should check if it looks good on hdpi and ldpi screens as I can't verify it right now (emulator crashes).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28785 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rwxr-xr-x | android/installApk.sh | 2 | ||||
-rw-r--r-- | android/res/drawable-hdpi/notification.png | bin | 0 -> 1013 bytes | |||
-rw-r--r-- | android/res/drawable-hdpi/notification_small.png | bin | 0 -> 1011 bytes | |||
-rw-r--r-- | android/res/drawable-ldpi/notification.png | bin | 0 -> 549 bytes | |||
-rw-r--r-- | android/res/drawable-ldpi/notification_small.png | bin | 0 -> 533 bytes | |||
-rw-r--r-- | android/res/drawable-mdpi/launcher.png | bin | 1855 -> 886 bytes | |||
-rw-r--r-- | android/res/drawable-mdpi/notification.png | bin | 0 -> 675 bytes | |||
-rw-r--r-- | android/res/drawable-mdpi/notification_small.png | bin | 0 -> 628 bytes | |||
-rw-r--r-- | android/res/layout/statusbar.xml | 53 | ||||
-rw-r--r-- | android/src/org/rockbox/Helper/RunForegroundManager.java | 41 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxService.java | 11 |
11 files changed, 85 insertions, 22 deletions
diff --git a/android/installApk.sh b/android/installApk.sh index 2cb98a1c01..2c82b115c6 100755 --- a/android/installApk.sh +++ b/android/installApk.sh @@ -2,4 +2,4 @@ ADB="$ANDROID_SDK_PATH/tools/adb" $ADB install -r rockbox.apk -echo 'am start -W -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $ADB shell +echo 'am start -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $ADB shell diff --git a/android/res/drawable-hdpi/notification.png b/android/res/drawable-hdpi/notification.png Binary files differnew file mode 100644 index 0000000000..a6e212d431 --- /dev/null +++ b/android/res/drawable-hdpi/notification.png diff --git a/android/res/drawable-hdpi/notification_small.png b/android/res/drawable-hdpi/notification_small.png Binary files differnew file mode 100644 index 0000000000..e8b27ee965 --- /dev/null +++ b/android/res/drawable-hdpi/notification_small.png diff --git a/android/res/drawable-ldpi/notification.png b/android/res/drawable-ldpi/notification.png Binary files differnew file mode 100644 index 0000000000..432f33f77d --- /dev/null +++ b/android/res/drawable-ldpi/notification.png diff --git a/android/res/drawable-ldpi/notification_small.png b/android/res/drawable-ldpi/notification_small.png Binary files differnew file mode 100644 index 0000000000..0b36529e56 --- /dev/null +++ b/android/res/drawable-ldpi/notification_small.png diff --git a/android/res/drawable-mdpi/launcher.png b/android/res/drawable-mdpi/launcher.png Binary files differindex 8999c4e543..089ebaec76 100644 --- a/android/res/drawable-mdpi/launcher.png +++ b/android/res/drawable-mdpi/launcher.png diff --git a/android/res/drawable-mdpi/notification.png b/android/res/drawable-mdpi/notification.png Binary files differnew file mode 100644 index 0000000000..c37989366a --- /dev/null +++ b/android/res/drawable-mdpi/notification.png diff --git a/android/res/drawable-mdpi/notification_small.png b/android/res/drawable-mdpi/notification_small.png Binary files differnew file mode 100644 index 0000000000..8a1f9faaad --- /dev/null +++ b/android/res/drawable-mdpi/notification_small.png diff --git a/android/res/layout/statusbar.xml b/android/res/layout/statusbar.xml new file mode 100644 index 0000000000..c795008225 --- /dev/null +++ b/android/res/layout/statusbar.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="0dp" + android:paddingBottom="0dp" + android:orientation="horizontal"> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <ImageView android:src="@drawable/notification_small" + android:gravity="center" + android:paddingTop="2dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + </ImageView> + + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:focusable="true" + android:ellipsize="end" + android:textStyle="bold" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceMediumInverse" + android:gravity="center" + android:paddingTop="0dp" + android:paddingLeft="6dp" /> + </LinearLayout> + + <LinearLayout android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingLeft="3dp" + android:orientation="vertical"> + <TextView android:id="@+id/content" + android:layout_gravity="left" + android:scrollHorizontally="true" + android:maxLines="2" + android:ellipsize="end" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmallInverse" + /> + </LinearLayout> + </LinearLayout> +</LinearLayout> diff --git a/android/src/org/rockbox/Helper/RunForegroundManager.java b/android/src/org/rockbox/Helper/RunForegroundManager.java index eb6e4c96ef..513089ff9f 100644 --- a/android/src/org/rockbox/Helper/RunForegroundManager.java +++ b/android/src/org/rockbox/Helper/RunForegroundManager.java @@ -12,6 +12,7 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Intent; import android.util.Log; +import android.widget.RemoteViews; public class RunForegroundManager { @@ -25,34 +26,32 @@ public class RunForegroundManager public RunForegroundManager(Service service) throws Exception { + mCurrentService = service; mNM = (NotificationManager) service.getSystemService(Service.NOTIFICATION_SERVICE); - /* For now we'll use the same text for the ticker and the - * expanded notification */ - CharSequence text = service.getText(R.string.notification); - /* Set the icon, scrolling text and timestamp */ - mNotification = new Notification(R.drawable.icon, text, - System.currentTimeMillis()); - - /* The PendingIntent to launch our activity if the user selects - * this notification */ + RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.statusbar); + /* create Intent for clicking on the expanded notifcation area */ Intent intent = new Intent(service, RockboxActivity.class); - PendingIntent contentIntent = - PendingIntent.getActivity(service, 0, intent, 0); + intent = intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + + mNotification = new Notification(); + mNotification.tickerText = service.getString(R.string.notification); + mNotification.icon = R.drawable.notification; + mNotification.contentView = views; + mNotification.flags |= Notification.FLAG_ONGOING_EVENT; + mNotification.contentIntent = PendingIntent.getActivity(service, 0, intent, 0); - /* Set the info for the views that show in the notification panel. */ - mNotification.setLatestEventInfo(service, - service.getText(R.string.notification), text, contentIntent); - try { api = new newForegroundApi(R.string.notification, mNotification); } catch (NoSuchMethodException e) { /* Fall back on the old API */ api = new oldForegroundApi(); } - mCurrentService = service; } - + private void LOG(CharSequence text) + { + Log.d("Rockbox", (String)text); + } private void LOG(CharSequence text, Throwable tr) { Log.d("Rockbox", (String)text, tr); @@ -83,6 +82,14 @@ public class RunForegroundManager api.stopForeground(); } + public void updateNotification(String title, String content, String ticker) + { + RemoteViews views = mNotification.contentView; + views.setTextViewText(R.id.title, title); + views.setTextViewText(R.id.content, content); + mNotification.tickerText = ticker; + mNM.notify(R.string.notification, mNotification); + } private interface IRunForeground { diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 033ece320c..23086eae29 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java @@ -117,10 +117,13 @@ public class RockboxService extends Service /* Display a notification about us starting. * We put an icon in the status bar. */ - try { - fg_runner = new RunForegroundManager(this); - } catch (Exception e) { - e.printStackTrace(); + if (fg_runner == null) + { + try { + fg_runner = new RunForegroundManager(this); + } catch (Exception e) { + e.printStackTrace(); + } } } |