Add custom rewind and fast forward for Android Auto

This commit is contained in:
Tony Tam 2020-02-18 06:58:08 -08:00
parent 3e51442560
commit 3bb2e2ae17
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.service.playback;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.app.UiModeManager;
import android.bluetooth.BluetoothA2dp;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@ -10,6 +11,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.MediaPlayer;
@ -1094,6 +1096,20 @@ public class PlaybackService extends MediaBrowserServiceCompat {
capabilities = capabilities | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
}
UiModeManager uiModeManager = (UiModeManager) getApplicationContext().getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
sessionState.addCustomAction(
new PlaybackStateCompat.CustomAction.Builder(
CUSTOM_ACTION_REWIND,
getString(R.string.rewind_label), R.drawable.ic_notification_fast_rewind)
.build());
sessionState.addCustomAction(
new PlaybackStateCompat.CustomAction.Builder(
CUSTOM_ACTION_FAST_FORWARD,
getString(R.string.fast_forward_label), R.drawable.ic_notification_fast_forward)
.build());
}
sessionState.setActions(capabilities);
flavorHelper.sessionStateAddActionForWear(sessionState,