summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rwxr-xr-xandroid/installApk.sh2
-rw-r--r--android/res/drawable-hdpi/notification.pngbin0 -> 1013 bytes
-rw-r--r--android/res/drawable-hdpi/notification_small.pngbin0 -> 1011 bytes
-rw-r--r--android/res/drawable-ldpi/notification.pngbin0 -> 549 bytes
-rw-r--r--android/res/drawable-ldpi/notification_small.pngbin0 -> 533 bytes
-rw-r--r--android/res/drawable-mdpi/launcher.pngbin1855 -> 886 bytes
-rw-r--r--android/res/drawable-mdpi/notification.pngbin0 -> 675 bytes
-rw-r--r--android/res/drawable-mdpi/notification_small.pngbin0 -> 628 bytes
-rw-r--r--android/res/layout/statusbar.xml53
-rw-r--r--android/src/org/rockbox/Helper/RunForegroundManager.java41
-rw-r--r--android/src/org/rockbox/RockboxService.java11
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 @@
2ADB="$ANDROID_SDK_PATH/tools/adb" 2ADB="$ANDROID_SDK_PATH/tools/adb"
3 3
4$ADB install -r rockbox.apk 4$ADB install -r rockbox.apk
5echo 'am start -W -a android.intent.action.MAIN -n org.rockbox/.RockboxActivity; exit' | $ADB shell 5echo '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
new file mode 100644
index 0000000000..a6e212d431
--- /dev/null
+++ b/android/res/drawable-hdpi/notification.png
Binary files differ
diff --git a/android/res/drawable-hdpi/notification_small.png b/android/res/drawable-hdpi/notification_small.png
new file mode 100644
index 0000000000..e8b27ee965
--- /dev/null
+++ b/android/res/drawable-hdpi/notification_small.png
Binary files differ
diff --git a/android/res/drawable-ldpi/notification.png b/android/res/drawable-ldpi/notification.png
new file mode 100644
index 0000000000..432f33f77d
--- /dev/null
+++ b/android/res/drawable-ldpi/notification.png
Binary files differ
diff --git a/android/res/drawable-ldpi/notification_small.png b/android/res/drawable-ldpi/notification_small.png
new file mode 100644
index 0000000000..0b36529e56
--- /dev/null
+++ b/android/res/drawable-ldpi/notification_small.png
Binary files differ
diff --git a/android/res/drawable-mdpi/launcher.png b/android/res/drawable-mdpi/launcher.png
index 8999c4e543..089ebaec76 100644
--- a/android/res/drawable-mdpi/launcher.png
+++ b/android/res/drawable-mdpi/launcher.png
Binary files differ
diff --git a/android/res/drawable-mdpi/notification.png b/android/res/drawable-mdpi/notification.png
new file mode 100644
index 0000000000..c37989366a
--- /dev/null
+++ b/android/res/drawable-mdpi/notification.png
Binary files differ
diff --git a/android/res/drawable-mdpi/notification_small.png b/android/res/drawable-mdpi/notification_small.png
new file mode 100644
index 0000000000..8a1f9faaad
--- /dev/null
+++ b/android/res/drawable-mdpi/notification_small.png
Binary files differ
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 @@
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:paddingLeft="6dp"
6 android:paddingRight="6dp"
7 android:paddingTop="0dp"
8 android:paddingBottom="0dp"
9 android:orientation="horizontal">
10
11 <LinearLayout android:layout_width="match_parent"
12 android:layout_height="wrap_content"
13 android:orientation="vertical">
14 <LinearLayout android:layout_width="match_parent"
15 android:layout_height="wrap_content"
16 android:orientation="horizontal">
17
18 <ImageView android:src="@drawable/notification_small"
19 android:gravity="center"
20 android:paddingTop="2dp"
21 android:layout_width="wrap_content"
22 android:layout_height="wrap_content">
23 </ImageView>
24
25 <TextView android:id="@+id/title"
26 android:layout_width="wrap_content"
27 android:layout_height="wrap_content"
28 android:focusable="true"
29 android:ellipsize="end"
30 android:textStyle="bold"
31 android:singleLine="true"
32 android:textAppearance="?android:attr/textAppearanceMediumInverse"
33 android:gravity="center"
34 android:paddingTop="0dp"
35 android:paddingLeft="6dp" />
36 </LinearLayout>
37
38 <LinearLayout android:layout_width="wrap_content"
39 android:layout_height="wrap_content"
40 android:paddingLeft="3dp"
41 android:orientation="vertical">
42 <TextView android:id="@+id/content"
43 android:layout_gravity="left"
44 android:scrollHorizontally="true"
45 android:maxLines="2"
46 android:ellipsize="end"
47 android:layout_width="wrap_content"
48 android:layout_height="wrap_content"
49 android:textAppearance="?android:attr/textAppearanceSmallInverse"
50 />
51 </LinearLayout>
52 </LinearLayout>
53</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;
12import android.app.Service; 12import android.app.Service;
13import android.content.Intent; 13import android.content.Intent;
14import android.util.Log; 14import android.util.Log;
15import android.widget.RemoteViews;
15 16
16public class RunForegroundManager 17public class RunForegroundManager
17{ 18{
@@ -25,34 +26,32 @@ public class RunForegroundManager
25 26
26 public RunForegroundManager(Service service) throws Exception 27 public RunForegroundManager(Service service) throws Exception
27 { 28 {
29 mCurrentService = service;
28 mNM = (NotificationManager) 30 mNM = (NotificationManager)
29 service.getSystemService(Service.NOTIFICATION_SERVICE); 31 service.getSystemService(Service.NOTIFICATION_SERVICE);
30 /* For now we'll use the same text for the ticker and the 32 RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.statusbar);
31 * expanded notification */ 33 /* create Intent for clicking on the expanded notifcation area */
32 CharSequence text = service.getText(R.string.notification);
33 /* Set the icon, scrolling text and timestamp */
34 mNotification = new Notification(R.drawable.icon, text,
35 System.currentTimeMillis());
36
37 /* The PendingIntent to launch our activity if the user selects
38 * this notification */
39 Intent intent = new Intent(service, RockboxActivity.class); 34 Intent intent = new Intent(service, RockboxActivity.class);
40 PendingIntent contentIntent = 35 intent = intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
41 PendingIntent.getActivity(service, 0, intent, 0); 36
37 mNotification = new Notification();
38 mNotification.tickerText = service.getString(R.string.notification);
39 mNotification.icon = R.drawable.notification;
40 mNotification.contentView = views;
41 mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
42 mNotification.contentIntent = PendingIntent.getActivity(service, 0, intent, 0);
42 43
43 /* Set the info for the views that show in the notification panel. */
44 mNotification.setLatestEventInfo(service,
45 service.getText(R.string.notification), text, contentIntent);
46
47 try { 44 try {
48 api = new newForegroundApi(R.string.notification, mNotification); 45 api = new newForegroundApi(R.string.notification, mNotification);
49 } catch (NoSuchMethodException e) { 46 } catch (NoSuchMethodException e) {
50 /* Fall back on the old API */ 47 /* Fall back on the old API */
51 api = new oldForegroundApi(); 48 api = new oldForegroundApi();
52 } 49 }
53 mCurrentService = service;
54 } 50 }
55 51 private void LOG(CharSequence text)
52 {
53 Log.d("Rockbox", (String)text);
54 }
56 private void LOG(CharSequence text, Throwable tr) 55 private void LOG(CharSequence text, Throwable tr)
57 { 56 {
58 Log.d("Rockbox", (String)text, tr); 57 Log.d("Rockbox", (String)text, tr);
@@ -83,6 +82,14 @@ public class RunForegroundManager
83 api.stopForeground(); 82 api.stopForeground();
84 } 83 }
85 84
85 public void updateNotification(String title, String content, String ticker)
86 {
87 RemoteViews views = mNotification.contentView;
88 views.setTextViewText(R.id.title, title);
89 views.setTextViewText(R.id.content, content);
90 mNotification.tickerText = ticker;
91 mNM.notify(R.string.notification, mNotification);
92 }
86 93
87 private interface IRunForeground 94 private interface IRunForeground
88 { 95 {
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
117 117
118 /* Display a notification about us starting. 118 /* Display a notification about us starting.
119 * We put an icon in the status bar. */ 119 * We put an icon in the status bar. */
120 try { 120 if (fg_runner == null)
121 fg_runner = new RunForegroundManager(this); 121 {
122 } catch (Exception e) { 122 try {
123 e.printStackTrace(); 123 fg_runner = new RunForegroundManager(this);
124 } catch (Exception e) {
125 e.printStackTrace();
126 }
124 } 127 }
125 } 128 }
126 129