summaryrefslogtreecommitdiffstats
path: root/android/src/org/rockbox/Helper
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-12-10 18:41:09 +0000
committerThomas Martitz <kugel@rockbox.org>2010-12-10 18:41:09 +0000
commitf5a461d1820f08c2001256f514a6b92eb78545f6 (patch)
tree5051cd45d29cc61858f6457e104d8b96bff58871 /android/src/org/rockbox/Helper
parentc47d81345151166083ab10d6f5d11e56462056d5 (diff)
downloadrockbox-f5a461d1820f08c2001256f514a6b92eb78545f6.tar.gz
rockbox-f5a461d1820f08c2001256f514a6b92eb78545f6.zip
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/src/org/rockbox/Helper')
-rw-r--r--android/src/org/rockbox/Helper/RunForegroundManager.java41
1 files changed, 24 insertions, 17 deletions
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
{