From ddf83fd2943aca5d333e637a9fa232b7876f953d Mon Sep 17 00:00:00 2001 From: kugel Date: Fri, 10 Dec 2010 18:41:09 +0000 Subject: [PATCH] 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 --- android/installApk.sh | 2 +- android/res/drawable-hdpi/notification.png | Bin 0 -> 1013 bytes android/res/drawable-hdpi/notification_small.png | Bin 0 -> 1011 bytes android/res/drawable-ldpi/notification.png | Bin 0 -> 549 bytes android/res/drawable-ldpi/notification_small.png | Bin 0 -> 533 bytes android/res/drawable-mdpi/launcher.png | Bin 1855 -> 886 bytes android/res/drawable-mdpi/notification.png | Bin 0 -> 675 bytes android/res/drawable-mdpi/notification_small.png | Bin 0 -> 628 bytes android/res/layout/statusbar.xml | 53 ++++++++++++ .../org/rockbox/Helper/RunForegroundManager.java | 41 +++++---- android/src/org/rockbox/RockboxService.java | 11 ++- apps/SOURCES | 1 + apps/apps.make | 3 + apps/gui/wps.c | 2 + apps/hosted/notification.c | 96 +++++++++++++++++++++ apps/hosted/notification.h | 27 ++++++ apps/main.c | 10 ++- 17 files changed, 222 insertions(+), 24 deletions(-) create mode 100644 android/res/drawable-hdpi/notification.png create mode 100644 android/res/drawable-hdpi/notification_small.png create mode 100644 android/res/drawable-ldpi/notification.png create mode 100644 android/res/drawable-ldpi/notification_small.png rewrite android/res/drawable-mdpi/launcher.png (99%) create mode 100644 android/res/drawable-mdpi/notification.png create mode 100644 android/res/drawable-mdpi/notification_small.png create mode 100644 android/res/layout/statusbar.xml create mode 100644 apps/hosted/notification.c create mode 100644 apps/hosted/notification.h 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 new file mode 100644 index 0000000000000000000000000000000000000000..a6e212d4310180b3ed65ac8bcd7486b4388185f2 GIT binary patch literal 1013 zcwPbZ0}A|!P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*a9DEADUr000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0009}Nkl6|VmlqHVtLang5%#_*0Mo1?7QNuzkb6K0v7Oh-k$bHkrWyYFI zOolT|n%s#~w#aQXlH9hg^2gH|r=2*h)91`Q|2*IOeed_ZzwdpY_kAw#U;Yv4)Uuts zid_L-M5r}rlo-6WmKuFI`H^YF0!=2tP9?E7ER?%1^a$m@4d`W#%GA;=e0D$4=Z zRMV&{;Ar?7q7CG!LAWWXcU9mU0gf7IXawgjuyz5=o@5y?jWaerTEc$4XY}8l z)u>Iq*u@c?onT}zR9t}gC|I~2=B7YXlV#x4cE)2HFGwqc*sJ06R=EBEmTiHAXxNrBUN4BNJJ9_%l0V;4bPJ-GFN;v0U1MurBy6_=fy=z5aRi8vV+QW=Qc=O&$ zz&?Hvy>YS3-qZxBt+N8KPhUlA-QZ9Pl)Zu#8Gq@xF!B=3Z))to(;W_`z~tr7-xHkd z#jp1BfXFf6K}enJ7v8V@taK}<4S zED|?n08|7lZkiZ>W*%(FHh#8xF5E2z-A%||^K+AQ_);1idVCaQ9D|iR;YhyN)#q<; z^^RP>t%TmL3L3vbwkJSVGK3D1fYPwUCAskUI0Se@>VbA_%Db6uvwOKFaz#KGZna=uv=n7@Z)SZzsM6afQq=120a z46L|JB8?|6%nvA4zpZ3gKwefr@GQ7+L)w+q=2cOQz#8hQwKP~S7s)^OpOEw~z{hmI z`a0vWjZXgJr<~Gii8EEdXiq?S>mc0L!>~ZGQJF5Pl)m8nAIngI-b_*1w$ELeE8iPw j&_CmR%QDn|`Df$@pzq~4O$)@@00000NkvXXu0mjf>3Z7I literal 0 HcwPel00001 diff --git a/android/res/drawable-hdpi/notification_small.png b/android/res/drawable-hdpi/notification_small.png new file mode 100644 index 0000000000000000000000000000000000000000..e8b27ee965818c1192ba887feab2bab2a22d55e2 GIT binary patch literal 1011 zcwPbX0}T9$P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*iq3-;Eyt000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0009{Nklw0q8vM6^XK5A63BZ4?yk_^A5<#k zzT%5qw8HNW#@nu*N4vRL!yf~<_)Yw{gBs2!!L28-Vh6-T!2VcB z&442p723B(bDI?nLxVtf0Md1^AORvn!Cwoh7nBcnTXQ=O3=pWXi=nC-JUT;ezVbl- zbY6mc3slx^xcL}5I=3uElktAg=k2U}V(5t8T+fO0;VH*G{Ef??P05fCZ{l``Y z`tnu$)}^vq(_)~qsuh9Czlqm+z_B>Ue+R4fSozpDHoN*!8hh~W21nyy@=ECA4bBdt zd%e9NYz#O%T49AW_VtQgFU=E2z=#1NDKR@C=NT;B2K{EhivlYEIXQ@bRU|%L2R9x; zkFLh?lZyw%pMQ3#zEwIxRN7s zV*s-#Q1o;O>XZ!FlJKE+;-=y|WIvGd zhfmPGixq;}V7p=|n*a*%l8nXNguvoJAR>DrtBnBV z=8N*bd~4oCPGvI7SI7#BA$T@iz9aQdWzD}ZGyv69Q>iqNr@Q2Dht5bE73gQWUv-sn z?uIXQ?kmn|wM3iB?^|kiws7w#+}Fd9Ah1!Her(8l%cUltV}g8{qOxtdr2LEhtffZ( hnoEtJW7@4b`vszAPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*`Nkymfd0000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0004iNklQ>We=;=hy(rr0gMkD>g$ycI(5u_=gbwl(wxkZinj*VDh`a)OrN;wX#|pSn}W`U z%V?B$GxThx|1`5-Tf-7b!Me3}L8SRIh;p~Uoe8?vGg(@E*^z%8rW0I0NAX1izAPAI zQta5m?T0KZEE5Lh8hf{M=~f$HaIBw?pEz`uM%$0|9>B} zg7tKB?LIdK`CQ@hJz^_DI?H8wJjKOPrd~B7mkkM9o#FWyTQ{<5CB+d+FGH3IYq~hP z|M$Lc50lTx?het-W)19P{7J~K(X6ovsPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*{bJ)nz6C000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0004SNklfgQSzu`eRI_O$&k8;={nE%D)J9Or`P$HLJ9f}%G3`M3A*|c3@hX9gEW@hQ$P2VNv zeyomUvchd!9ZD=OhDn}Ocsx$mb|z|T8!gdZ$Y;2BmFn9ibX^D(ava#hqvtFxt`mWJ z#L@lSdiWm*oa^JuS595w{B=G|$3*fOK7OL!=!pJe4bSc5R45PNT=)&Gxdh*$%^4W X?Koi}i$XZH00000NkvXXu0mjf96a2% literal 0 HcwPel00001 diff --git a/android/res/drawable-mdpi/launcher.png b/android/res/drawable-mdpi/launcher.png dissimilarity index 99% index 8999c4e543e4ff21b9edee1988198032018b6d41..089ebaec76faee8404eaa6aeeffd0496fafb8791 100644 GIT binary patch delta 877 zcwPZ*1Cso|4)z8>iBL{Q4GJ0x0000DNk~Le0000P0000P2nGNE0L1BqV*mgE0drDE zLIAGL9O(c600v@9M??Vs0RI60puMM)kuey52XskIMF-jp3K9<_)yI&_!k*J?xYETvz$uY5WbcwmOhlCU z#GiX$&Sq#|0LS*hjL9IjQhKc=3dw&(rPk62{M4nMlSx2O0tnEM1jmItXJN^9xb*~- z@?-x3f=VU_Wtq84V9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rzrF%`?+QmX@|e~2uEkU;yceO-0;&Cma{T_9}o7}hFraiPV|wG(@;2Er|{k10upF{rm?eGgIF@V=#jBOr`$q}YMoM{RaYo}ZrA?vo1bg!Y$BmR sPy0n*=>C3vYLL`$v3~4vvC;nl`@e}rxEDtr00000NkvXX1g=70f@Fz@JOBUy diff --git a/android/res/drawable-mdpi/notification.png b/android/res/drawable-mdpi/notification.png new file mode 100644 index 0000000000000000000000000000000000000000..c37989366a5bc1ee47135b543a1592e716ec47bd GIT binary patch literal 675 zcwPac0$lxxP)P000>X1^@s6#OZ}&00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*sZhcX)jO000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}00060NklW)V=Q*8k=RD7I7%37HF)r@5V`jFh zlw?UmP1@e6^Fgyc8xA}D7o_E^H#vFIBm2vZ?5}6WR4P_cI%{B{Cy%_&-y{=45ob6o z;m@E+6N0t2B7hycFfd3sL1M%X{V!;K5!K~X)N!JUeW&^Ib#U#A?dxz&DWMQs4)Wm> zZ`*%Y7&Qp2T13Z3?mQ+fb#Rr0`V*9$#kcR&o*72S`wtZ7a<7?&o5Rp9=>AOlSnBss zT1inhaj_&PGA1cXmBf!GoWSICHZ3D-DI06ZUrYU!C_&OvX?{jeFXykZehG!yTs_XV zqd_}|49S^B+bbIHaOnVN_j13P?>|UQrn4&wknv-fUr6;yGA9x{ic`B;xs#GSres9n z;-PLUWtB`{&b&h2bp**57DwrI!R&n68o2c^`1K{Zfq%hf%2$vS9%8#9l93infVl;X zjtg}AI*wnA!kzRbs~2Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign@ z5*#2Ghmr>X00Hz#L_t(Y$F( zwMcR?$rk3h>`r7Z5OPH+YA)PR^UxADYegtGBAcALA)eIXq@{#Bc~T^3@8#4k?zGVVh4fUqx(Z(6yKt2YO3YN6nf2(t>fc54XWhfW6_v+e0$;JrP12Lm59 zg61~nm;Aoo-K+aYwKPAnKN4qqQnG|t;EM`^0neU%>qR~Knp@QxYJCN8x_vaObyYF| O0000 + + + + + + + + + + + + + + + + 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(); + } } } diff --git a/apps/SOURCES b/apps/SOURCES index 8aa469fa4d..4755ad42c3 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -91,6 +91,7 @@ gui/statusbar-skinned.c #endif #if (CONFIG_PLATFORM&PLATFORM_ANDROID) hosted/yesno.c +hosted/notification.c #else gui/yesno.c #endif diff --git a/apps/apps.make b/apps/apps.make index 6afcd12b5c..a430288870 100644 --- a/apps/apps.make +++ b/apps/apps.make @@ -8,6 +8,9 @@ # INCLUDES += -I$(APPSDIR) $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) +ifdef APP_TYPE + INCLUDES += -I$(APPSDIR)/hosted +endif SRC += $(call preprocess, $(APPSDIR)/SOURCES) # apps/features.txt is a file that (is preprocessed and) lists named features diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 7d633ad4e8..717a58aa8e 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -1189,6 +1189,8 @@ static void wps_state_init(void) /* add the WPS track event callbacks */ add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false, nextid3available_callback); + extern void notification_init(void); + notification_init(); } diff --git a/apps/hosted/notification.c b/apps/hosted/notification.c new file mode 100644 index 0000000000..13c88eca4b --- /dev/null +++ b/apps/hosted/notification.c @@ -0,0 +1,96 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include +#include "notification.h" +#include "appevents.h" +#include "metadata.h" +#include "misc.h" + +extern JNIEnv *env_ptr; +extern jclass RockboxService_class; +extern jobject RockboxService_instance; + +static jmethodID updateNotification; +static jobject NotificationManager_instance; +static jstring headline, content, ticker; + +#define NZV(a) (a && a[0]) + +/* + * notify about track change, and show track info */ +static void track_changed_callback(void *param) +{ + struct mp3entry* id3 = (struct mp3entry*)param; + JNIEnv e = *env_ptr; + if (id3) + { + /* passing NULL to DeleteLocalRef() is OK */ + e->DeleteLocalRef(env_ptr, headline); + e->DeleteLocalRef(env_ptr, content); + e->DeleteLocalRef(env_ptr, ticker); + + char buf[200]; + const char * title = id3->title; + if (!title) + { /* pass the filename as title if id3 info isn't available */ + title = + strip_extension(buf, sizeof(buf), strrchr(id3->path,'/') + 1); + } + + /* do text for the notification area in the scrolled-down statusbar */ + headline = e->NewStringUTF(env_ptr, title); + + /* add a \n so that android does split into two lines */ + snprintf(buf, sizeof(buf), "%s\n%s", id3->artist ?: "", id3->album ?: ""); + content = e->NewStringUTF(env_ptr, buf); + + /* now do the text for the notification in the statusbar itself */ + if (NZV(id3->artist)) + { /* title - artist */ + snprintf(buf, sizeof(buf), "%s - %s", title, id3->artist); + ticker = e->NewStringUTF(env_ptr, buf); + } + else + { /* title */ + ticker = e->NewStringUTF(env_ptr, title); + } + e->CallVoidMethod(env_ptr, NotificationManager_instance, + updateNotification, headline, content, ticker); + } +} + +void notification_init(void) +{ + JNIEnv e = *env_ptr; + jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class, + "fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;"); + NotificationManager_instance = e->GetObjectField(env_ptr, + RockboxService_instance, nNM); + + jclass class = e->GetObjectClass(env_ptr, NotificationManager_instance); + updateNotification = e->GetMethodID(env_ptr, class, "updateNotification", + "(Ljava/lang/String;" + "Ljava/lang/String;" + "Ljava/lang/String;)V"); + add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, track_changed_callback); +} diff --git a/apps/hosted/notification.h b/apps/hosted/notification.h new file mode 100644 index 0000000000..d182c7f8e7 --- /dev/null +++ b/apps/hosted/notification.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef __NOTIFICATION_H__ +#define __NOTIFICATION_H__ + +void notification_init(void); + +#endif diff --git a/apps/main.c b/apps/main.c index 7af4cca37e..dd1f60a849 100644 --- a/apps/main.c +++ b/apps/main.c @@ -76,6 +76,9 @@ #include "skin_engine/skin_engine.h" #include "statusbar-skinned.h" #include "bootchart.h" +#if defined(APPLICATION) && (CONFIG_PLATFORM & PLATFORM_ANDROID) +#include "notification.h" +#endif #ifdef IPOD_ACCESSORY_PROTOCOL #include "iap.h" @@ -333,11 +336,11 @@ static void init_tagcache(void) static void init(void) { + system_init(); + kernel_init(); #ifdef APPLICATION paths_init(); #endif - system_init(); - kernel_init(); buffer_init(); enable_irq(); lcd_init(); @@ -351,6 +354,9 @@ static void init(void) #if (CONFIG_PLATFORM & PLATFORM_SDL) sim_tasks_init(); #endif +#if (CONFIG_PLATFORM & PLATFORM_ANDROID) + notification_init(); +#endif lang_init(core_language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY); #ifdef DEBUG -- 2.11.4.GIT