diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-02-27 20:47:44 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-02-27 20:47:44 +0000 |
commit | 883ff8507e42f7fbba6416e60fb116164219aa5f (patch) | |
tree | 3708181c7a19309f02bb4b93d073745c119338a2 /android | |
parent | 952d82b7bd20f1bef7f3c316ebeb71c0d1e6d20b (diff) |
Android: Show cover art in the widget (including option to hide it).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29437 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rw-r--r-- | android/res/layout/appwidget_2x2.xml | 8 | ||||
-rw-r--r-- | android/res/layout/appwidget_3x3.xml | 6 | ||||
-rw-r--r-- | android/res/layout/appwidget_4x1.xml | 6 | ||||
-rw-r--r-- | android/res/layout/appwidget_configure.xml | 4 | ||||
-rw-r--r-- | android/res/values/strings.xml | 1 | ||||
-rw-r--r-- | android/src/org/rockbox/Helper/RunForegroundManager.java | 4 | ||||
-rw-r--r-- | android/src/org/rockbox/widgets/RockboxWidgetConfigure.java | 5 | ||||
-rw-r--r-- | android/src/org/rockbox/widgets/RockboxWidgetProvider.java | 11 |
8 files changed, 38 insertions, 7 deletions
diff --git a/android/res/layout/appwidget_2x2.xml b/android/res/layout/appwidget_2x2.xml index a29f416b3d..113384f57b 100644 --- a/android/res/layout/appwidget_2x2.xml +++ b/android/res/layout/appwidget_2x2.xml @@ -8,10 +8,12 @@ android:background="@drawable/appwidget_background"> <!-- style="@style/appwidget_background"--> - <ImageView android:id="@+id/logo" + <ImageButton android:id="@+id/logo" + android:layout_marginTop="5dp" android:layout_width="fill_parent" - android:layout_height="40dp" - android:scaleType="centerInside" + android:layout_height="80dp" + android:scaleType="centerInside" + android:background="@drawable/appwidget_infodisplay_background" android:src="@drawable/rockbox" /> <Button android:id="@+id/infoDisplay" style="@style/appwidget_infodisplay" diff --git a/android/res/layout/appwidget_3x3.xml b/android/res/layout/appwidget_3x3.xml index a29f416b3d..b5be5356fa 100644 --- a/android/res/layout/appwidget_3x3.xml +++ b/android/res/layout/appwidget_3x3.xml @@ -8,10 +8,12 @@ android:background="@drawable/appwidget_background"> <!-- style="@style/appwidget_background"--> - <ImageView android:id="@+id/logo" + <ImageButton android:id="@+id/logo" + android:layout_marginTop="15dp" android:layout_width="fill_parent" - android:layout_height="40dp" + android:layout_height="130dp" android:scaleType="centerInside" + android:background="@drawable/appwidget_infodisplay_background" android:src="@drawable/rockbox" /> <Button android:id="@+id/infoDisplay" style="@style/appwidget_infodisplay" diff --git a/android/res/layout/appwidget_4x1.xml b/android/res/layout/appwidget_4x1.xml index 0d2d6df010..db7ebb5d0d 100644 --- a/android/res/layout/appwidget_4x1.xml +++ b/android/res/layout/appwidget_4x1.xml @@ -8,6 +8,12 @@ android:background="@drawable/appwidget_background"> <!-- style="@style/appwidget_background"--> + <ImageButton android:id="@+id/logo" + android:layout_width="68dp" + android:layout_height="fill_parent" + android:scaleType="centerInside" + android:background="@drawable/appwidget_infodisplay_background" + android:src="@drawable/rockbox" /> <Button android:id="@+id/infoDisplay" style="@style/appwidget_infodisplay" android:layout_height="fill_parent" diff --git a/android/res/layout/appwidget_configure.xml b/android/res/layout/appwidget_configure.xml index 8dd0ff2144..1f33afe61e 100644 --- a/android/res/layout/appwidget_configure.xml +++ b/android/res/layout/appwidget_configure.xml @@ -15,6 +15,10 @@ android:layout_height="wrap_content" android:text="@string/appwidget_configure_instructions"/> + <CheckBox android:id="@+id/enable_aa" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/appwidget_configure_albumart"/> <CheckBox android:id="@+id/enable_prev" android:layout_width="fill_parent" android:layout_height="wrap_content" diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 9e818319d4..c92e955edf 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -19,6 +19,7 @@ <!-- Widget configuration --> <string name="appwidget_configure_instructions">Please chose elements to display in widget.</string> +<string name="appwidget_configure_albumart">Cover Art</string> <string name="appwidget_configure_prev">Prev Button</string> <string name="appwidget_configure_stop">Stop Button</string> <string name="appwidget_configure_playpause">Play/Pause Button</string> diff --git a/android/src/org/rockbox/Helper/RunForegroundManager.java b/android/src/org/rockbox/Helper/RunForegroundManager.java index e8b9620280..c08e742aba 100644 --- a/android/src/org/rockbox/Helper/RunForegroundManager.java +++ b/android/src/org/rockbox/Helper/RunForegroundManager.java @@ -11,7 +11,6 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; -import android.net.Uri; import android.util.Log; import android.widget.RemoteViews; @@ -83,7 +82,7 @@ public class RunForegroundManager api.stopForeground(); } - public void updateNotification(String title, String artist, String album) + public void updateNotification(String title, String artist, String album, String albumart) { RemoteViews views = mNotification.contentView; views.setTextViewText(R.id.title, title); @@ -98,6 +97,7 @@ public class RunForegroundManager widgetUpdate.putExtra("title", title); widgetUpdate.putExtra("artist", artist); widgetUpdate.putExtra("album", album); + widgetUpdate.putExtra("albumart", albumart); mCurrentService.sendBroadcast(widgetUpdate); } diff --git a/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java b/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java index 6ce2050780..700fc2fa1a 100644 --- a/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java +++ b/android/src/org/rockbox/widgets/RockboxWidgetConfigure.java @@ -50,6 +50,7 @@ public class RockboxWidgetConfigure extends Activity setResult(RESULT_CANCELED); setContentView(R.layout.appwidget_configure); + ((CheckBox)findViewById(R.id.enable_aa)).setChecked(true); ((CheckBox)findViewById(R.id.enable_prev)).setChecked(false); ((CheckBox)findViewById(R.id.enable_stop)).setChecked(true); ((CheckBox)findViewById(R.id.enable_playpause)).setChecked(true); @@ -73,6 +74,7 @@ public class RockboxWidgetConfigure extends Activity final Context context = RockboxWidgetConfigure.this; WidgetPref state = new WidgetPref(); + state.enableAA = ((CheckBox)findViewById(R.id.enable_aa)).isChecked(); state.enablePrev = ((CheckBox)findViewById(R.id.enable_prev)).isChecked(); state.enableStop = ((CheckBox)findViewById(R.id.enable_stop)).isChecked(); state.enablePlayPause = ((CheckBox)findViewById(R.id.enable_playpause)).isChecked(); @@ -91,6 +93,7 @@ public class RockboxWidgetConfigure extends Activity static public class WidgetPref { + public boolean enableAA = true; public boolean enablePrev = true; public boolean enableStop = true; public boolean enablePlayPause = true; @@ -100,6 +103,7 @@ public class RockboxWidgetConfigure extends Activity static void saveWidgetPref(Context context, int appWidgetId, WidgetPref state) { SharedPreferences.Editor prefs = context.getSharedPreferences("org.rockbox.RockboxWidgetConfigure", 0).edit(); + prefs.putBoolean("albumart"+appWidgetId, state.enableAA); prefs.putBoolean("prev"+appWidgetId, state.enablePrev); prefs.putBoolean("stop"+appWidgetId, state.enableStop); prefs.putBoolean("playpause"+appWidgetId, state.enablePlayPause); @@ -111,6 +115,7 @@ public class RockboxWidgetConfigure extends Activity { SharedPreferences prefs = context.getSharedPreferences("org.rockbox.RockboxWidgetConfigure", 0); WidgetPref state = new WidgetPref(); + state.enableAA = prefs.getBoolean("albumart"+appWidgetId, true); state.enablePrev = prefs.getBoolean("prev"+appWidgetId, true); state.enableStop = prefs.getBoolean("stop"+appWidgetId, true); state.enablePlayPause = prefs.getBoolean("playpause"+appWidgetId, true); diff --git a/android/src/org/rockbox/widgets/RockboxWidgetProvider.java b/android/src/org/rockbox/widgets/RockboxWidgetProvider.java index 867088f601..c6f3baf76c 100644 --- a/android/src/org/rockbox/widgets/RockboxWidgetProvider.java +++ b/android/src/org/rockbox/widgets/RockboxWidgetProvider.java @@ -21,6 +21,7 @@ package org.rockbox.widgets; +import java.io.File; import org.rockbox.R; import org.rockbox.RockboxActivity; import org.rockbox.RockboxService; @@ -108,6 +109,7 @@ public class RockboxWidgetProvider extends AppWidgetProvider Intent intent = new Intent(context, RockboxActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.infoDisplay, pendingIntent); + views.setOnClickPendingIntent(R.id.logo, pendingIntent); RockboxWidgetConfigure.WidgetPref state = RockboxWidgetConfigure.loadWidgetPref(context, appWidgetId); @@ -151,6 +153,9 @@ public class RockboxWidgetProvider extends AppWidgetProvider else views.setViewVisibility(R.id.stop, View.GONE); + if (!state.enableAA) + views.setViewVisibility(R.id.logo, View.GONE); + if (args != null) { if (args.getAction().equals("org.rockbox.TrackUpdateInfo")) @@ -159,12 +164,18 @@ public class RockboxWidgetProvider extends AppWidgetProvider CharSequence artist = args.getCharSequenceExtra("artist"); CharSequence album = args.getCharSequenceExtra("album"); views.setTextViewText(R.id.infoDisplay, title+"\n"+artist+"\n"+album); + CharSequence albumart = args.getCharSequenceExtra("albumart"); + if (albumart != null) + views.setImageViewUri(R.id.logo, Uri.fromFile(new File(albumart.toString()))); + else + views.setImageViewResource(R.id.logo, R.drawable.rockbox); } else if (args.getAction().equals("org.rockbox.TrackFinish")) { // FIXME: looks like this event is always fired earlier than // the actual track change (a few seconds) views.setTextViewText(R.id.infoDisplay, context.getString(R.string.appwidget_infoDisplay)); + views.setImageViewResource(R.id.logo, R.drawable.rockbox); } else if (args.getAction().equals("org.rockbox.UpdateState")) { |