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/src/org/rockbox/widgets | |
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/src/org/rockbox/widgets')
-rw-r--r-- | android/src/org/rockbox/widgets/RockboxWidgetConfigure.java | 5 | ||||
-rw-r--r-- | android/src/org/rockbox/widgets/RockboxWidgetProvider.java | 11 |
2 files changed, 16 insertions, 0 deletions
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")) { |