Moved widget from app to core

This commit is contained in:
ByteHamster 2018-05-05 14:04:12 +02:00
parent 0b54d97a0a
commit 7107819a6a
5 changed files with 13 additions and 17 deletions

View File

@ -118,13 +118,13 @@
</activity>
<service
android:name=".service.PlayerWidgetJobService"
android:name=".core.service.PlayerWidgetJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:enabled="true"
android:exported="false">
</service>
<receiver android:name=".receiver.PlayerWidget">
<receiver android:name=".core.receiver.PlayerWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>

View File

@ -1,17 +1,15 @@
package de.danoeh.antennapod.receiver;
package de.danoeh.antennapod.core.receiver;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import de.danoeh.antennapod.core.service.PlayerWidgetJobService;
import java.util.Arrays;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.service.PlayerWidgetJobService;
public class PlayerWidget extends AppWidgetProvider {
private static final String TAG = "PlayerWidget";

View File

@ -1,4 +1,4 @@
package de.danoeh.antennapod.service;
package de.danoeh.antennapod.core.service;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
@ -14,15 +14,13 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.RemoteViews;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.receiver.PlayerWidget;
import de.danoeh.antennapod.core.receiver.PlayerWidget;
/**
* Updates the state of the player widget
@ -78,10 +76,9 @@ public class PlayerWidgetJobService extends JobIntentService {
PendingIntent startMediaplayer = PendingIntent.getActivity(this, 0,
PlaybackService.getPlayerActivityIntent(this), 0);
Intent startApp = new Intent(getBaseContext(), MainActivity.class);
startApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startApp.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, QueueFragment.TAG);
PendingIntent startAppPending = PendingIntent.getActivity(getBaseContext(), 0, startApp, PendingIntent.FLAG_UPDATE_CURRENT);
final PendingIntent startAppPending = PendingIntent.getActivity(this, 0,
PlaybackService.getPlayerActivityIntent(this),
PendingIntent.FLAG_UPDATE_CURRENT);
boolean nothingPlaying = false;
Playable media;

View File

@ -62,6 +62,7 @@ import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.service.PlayerWidgetJobService;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
@ -630,7 +631,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
@Override
public void onWidgetUpdaterTick() {
//PlayerWidgetJobService.updateWidget(getBaseContext()); // TODO: Not accessible from core module
PlayerWidgetJobService.updateWidget(getBaseContext());
}
@Override
@ -692,7 +693,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
Intent statusUpdate = new Intent(ACTION_PLAYER_STATUS_CHANGED);
// statusUpdate.putExtra(EXTRA_NEW_PLAYER_STATUS, newInfo.playerStatus.ordinal());
sendBroadcast(statusUpdate);
//PlayerWidgetJobService.updateWidget(getBaseContext()); // TODO: Not accessible from core module
PlayerWidgetJobService.updateWidget(getBaseContext());
bluetoothNotifyChange(newInfo, AVRCP_ACTION_PLAYER_STATUS_CHANGED);
bluetoothNotifyChange(newInfo, AVRCP_ACTION_META_CHANGED);
}