Ask for track information to be resent after creating a new widget.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29553 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
64cf0dd765
commit
fd7375c307
5 changed files with 33 additions and 7 deletions
|
@ -23,6 +23,7 @@
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
|
<action android:name="org.rockbox.ResendTrackUpdateInfo" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ public class RunForegroundManager
|
||||||
private NotificationManager mNM;
|
private NotificationManager mNM;
|
||||||
private IRunForeground api;
|
private IRunForeground api;
|
||||||
private Service mCurrentService;
|
private Service mCurrentService;
|
||||||
|
private Intent mWidgetUpdate;
|
||||||
|
|
||||||
public RunForegroundManager(Service service)
|
public RunForegroundManager(Service service)
|
||||||
{
|
{
|
||||||
|
@ -48,10 +49,12 @@ public class RunForegroundManager
|
||||||
api = new oldForegroundApi();
|
api = new oldForegroundApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LOG(CharSequence text)
|
private void LOG(CharSequence text)
|
||||||
{
|
{
|
||||||
Log.d("Rockbox", (String)text);
|
Log.d("Rockbox", (String)text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LOG(CharSequence text, Throwable tr)
|
private void LOG(CharSequence text, Throwable tr)
|
||||||
{
|
{
|
||||||
Log.d("Rockbox", (String)text, tr);
|
Log.d("Rockbox", (String)text, tr);
|
||||||
|
@ -80,6 +83,7 @@ public class RunForegroundManager
|
||||||
*/
|
*/
|
||||||
mNM.cancel(R.string.notification);
|
mNM.cancel(R.string.notification);
|
||||||
api.stopForeground();
|
api.stopForeground();
|
||||||
|
mWidgetUpdate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNotification(String title, String artist, String album, String albumart)
|
public void updateNotification(String title, String artist, String album, String albumart)
|
||||||
|
@ -93,12 +97,18 @@ public class RunForegroundManager
|
||||||
mNotification.tickerText = title+" - "+artist;
|
mNotification.tickerText = title+" - "+artist;
|
||||||
mNM.notify(R.string.notification, mNotification);
|
mNM.notify(R.string.notification, mNotification);
|
||||||
|
|
||||||
Intent widgetUpdate = new Intent("org.rockbox.TrackUpdateInfo");
|
mWidgetUpdate = new Intent("org.rockbox.TrackUpdateInfo");
|
||||||
widgetUpdate.putExtra("title", title);
|
mWidgetUpdate.putExtra("title", title);
|
||||||
widgetUpdate.putExtra("artist", artist);
|
mWidgetUpdate.putExtra("artist", artist);
|
||||||
widgetUpdate.putExtra("album", album);
|
mWidgetUpdate.putExtra("album", album);
|
||||||
widgetUpdate.putExtra("albumart", albumart);
|
mWidgetUpdate.putExtra("albumart", albumart);
|
||||||
mCurrentService.sendBroadcast(widgetUpdate);
|
mCurrentService.sendBroadcast(mWidgetUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resendUpdateNotification()
|
||||||
|
{
|
||||||
|
if (mWidgetUpdate != null)
|
||||||
|
mCurrentService.sendBroadcast(mWidgetUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishNotification()
|
public void finishNotification()
|
||||||
|
|
|
@ -106,6 +106,14 @@ public class RockboxService extends Service
|
||||||
private void do_start(Intent intent)
|
private void do_start(Intent intent)
|
||||||
{
|
{
|
||||||
LOG("Start RockboxService (Intent: " + intent.getAction() + ")");
|
LOG("Start RockboxService (Intent: " + intent.getAction() + ")");
|
||||||
|
|
||||||
|
if (intent.getAction().equals("org.rockbox.ResendTrackUpdateInfo"))
|
||||||
|
{
|
||||||
|
if (rockbox_running)
|
||||||
|
fg_runner.resendUpdateNotification();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (intent.hasExtra("callback"))
|
if (intent.hasExtra("callback"))
|
||||||
resultReceiver = (ResultReceiver) intent.getParcelableExtra("callback");
|
resultReceiver = (ResultReceiver) intent.getParcelableExtra("callback");
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,18 @@
|
||||||
package org.rockbox.widgets;
|
package org.rockbox.widgets;
|
||||||
|
|
||||||
import org.rockbox.R;
|
import org.rockbox.R;
|
||||||
|
import org.rockbox.RockboxService;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
|
||||||
public class RockboxWidgetConfigure extends Activity
|
public class RockboxWidgetConfigure extends Activity
|
||||||
{
|
{
|
||||||
int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
|
@ -84,6 +85,11 @@ public class RockboxWidgetConfigure extends Activity
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
RockboxWidgetProvider.getInstance().updateAppWidget(context, appWidgetManager, mAppWidgetId, null);
|
RockboxWidgetProvider.getInstance().updateAppWidget(context, appWidgetManager, mAppWidgetId, null);
|
||||||
|
|
||||||
|
/* Ask for track information so that new widgets display properly
|
||||||
|
* if rockbox was already playing */
|
||||||
|
context.startService(new Intent("org.rockbox.ResendTrackUpdateInfo",
|
||||||
|
Uri.EMPTY, context, RockboxService.class));
|
||||||
|
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
|
result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
|
||||||
setResult(RESULT_OK, result);
|
setResult(RESULT_OK, result);
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class RockboxWidgetProvider extends AppWidgetProvider
|
||||||
super();
|
super();
|
||||||
mInstance = this;
|
mInstance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue