forked from len0rd/rockbox
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
This commit is contained in:
parent
952d82b7bd
commit
883ff8507e
9 changed files with 49 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue