Commit 650a1e84 authored by Geoffrey Métais's avatar Geoffrey Métais

Clean constants

parent 4f4d12c7
......@@ -42,6 +42,7 @@ import android.text.TextUtils;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
......@@ -80,7 +81,7 @@ public class ExternalMonitor extends BroadcastReceiver {
private static void checkNewStorages(final Context ctx) {
if (VLCApplication.getMLInstance().isInitiated())
ctx.startService(new Intent(MediaParsingService.ACTION_CHECK_STORAGES, null,ctx, MediaParsingService.class));
ctx.startService(new Intent(Constants.ACTION_CHECK_STORAGES, null,ctx, MediaParsingService.class));
}
static void unregister(Context ctx) {
......@@ -141,13 +142,13 @@ public class ExternalMonitor extends BroadcastReceiver {
if (!containsDevice(knownDevices, path) && ml.addDevice(uuid, path, true)) {
notifyStorageChanges(path);
} else {
LocalBroadcastManager.getInstance(appCtx).sendBroadcast(new Intent(MediaParsingService.ACTION_SERVICE_ENDED));
LocalBroadcastManager.getInstance(appCtx).sendBroadcast(new Intent(Constants.ACTION_SERVICE_ENDED));
}
}
break;
case ACTION_MEDIA_UNMOUNTED:
VLCApplication.getMLInstance().removeDevice(uuid);
LocalBroadcastManager.getInstance(appCtx).sendBroadcast(new Intent(MediaParsingService.ACTION_SERVICE_ENDED));
LocalBroadcastManager.getInstance(appCtx).sendBroadcast(new Intent(Constants.ACTION_SERVICE_ENDED));
break;
}
}
......
......@@ -25,6 +25,7 @@ import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.interfaces.DevicesDiscoveryCb;
import org.videolan.vlc.gui.helpers.NotificationHelper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
......@@ -38,25 +39,7 @@ import java.util.concurrent.Executors;
public class MediaParsingService extends Service implements DevicesDiscoveryCb {
public final static String TAG = "VLC/MediaParsingService";
public final static String ACTION_INIT = "medialibrary_init";
public final static String ACTION_RELOAD = "medialibrary_reload";
public final static String ACTION_DISCOVER = "medialibrary_discover";
public final static String ACTION_DISCOVER_DEVICE = "medialibrary_discover_device";
public final static String ACTION_CHECK_STORAGES = "medialibrary_check_storages";
public final static String EXTRA_PATH = "extra_path";
public final static String EXTRA_UUID = "extra_uuid";
public final static String ACTION_RESUME_SCAN = "action_resume_scan";
public final static String ACTION_PAUSE_SCAN = "action_pause_scan";
public final static String ACTION_SERVICE_STARTED = "action_service_started";
public final static String ACTION_SERVICE_ENDED = "action_service_ended";
public final static String ACTION_NEW_STORAGE = "action_new_storage";
public final static String ACTION_PROGRESS = "action_progress";
public final static String ACTION_PROGRESS_TEXT = "action_progress_text";
public final static String ACTION_PROGRESS_VALUE = "action_progress_value";
public static final long NOTIFICATION_DELAY = 1000L;
private static final long NOTIFICATION_DELAY = 1000L;
private PowerManager.WakeLock mWakeLock;
private LocalBroadcastManager mLocalBroadcastManager;
......@@ -74,13 +57,13 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case ACTION_PAUSE_SCAN:
case Constants.ACTION_PAUSE_SCAN:
if (mWakeLock.isHeld())
mWakeLock.release();
mScanPaused = true;
mMedialibrary.pauseBackgroundOperations();
break;
case ACTION_RESUME_SCAN:
case Constants.ACTION_RESUME_SCAN:
if (!mWakeLock.isHeld())
mWakeLock.acquire();
mMedialibrary.resumeBackgroundOperations();
......@@ -105,8 +88,8 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
mMedialibrary = VLCApplication.getMLInstance();
mMedialibrary.addDeviceDiscoveryCb(MediaParsingService.this);
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_PAUSE_SCAN);
filter.addAction(ACTION_RESUME_SCAN);
filter.addAction(Constants.ACTION_PAUSE_SCAN);
filter.addAction(Constants.ACTION_RESUME_SCAN);
registerReceiver(mReceiver, filter);
mLocalBroadcastManager.registerReceiver(mReceiver, new IntentFilter(Medialibrary.ACTION_IDLE));
PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
......@@ -135,26 +118,26 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
showNotification();
}
switch (intent.getAction()) {
case ACTION_INIT:
setupMedialibrary(intent.getBooleanExtra(StartActivity.EXTRA_UPGRADE, false));
case Constants.ACTION_INIT:
setupMedialibrary(intent.getBooleanExtra(Constants.EXTRA_UPGRADE, false));
break;
case ACTION_RELOAD:
reload(intent.getStringExtra(EXTRA_PATH));
case Constants.ACTION_RELOAD:
reload(intent.getStringExtra(Constants.EXTRA_PATH));
break;
case ACTION_DISCOVER:
discover(intent.getStringExtra(EXTRA_PATH));
case Constants.ACTION_DISCOVER:
discover(intent.getStringExtra(Constants.EXTRA_PATH));
break;
case ACTION_DISCOVER_DEVICE:
discoverStorage(intent.getStringExtra(EXTRA_PATH));
case Constants.ACTION_DISCOVER_DEVICE:
discoverStorage(intent.getStringExtra(Constants.EXTRA_PATH));
break;
case ACTION_CHECK_STORAGES:
case Constants.ACTION_CHECK_STORAGES:
updateStorages();
break;
default:
exitCommand();
return START_NOT_STICKY;
}
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_SERVICE_STARTED));
mLocalBroadcastManager.sendBroadcast(new Intent(Constants.ACTION_SERVICE_STARTED));
return START_NOT_STICKY;
}
......@@ -273,7 +256,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
handler.postDelayed(new Runnable() {
@Override
public void run() {
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_NEW_STORAGE).putExtra(EXTRA_PATH, device));
mLocalBroadcastManager.sendBroadcast(new Intent(Constants.ACTION_NEW_STORAGE).putExtra(Constants.EXTRA_PATH, device));
}
}, 2000);
}
......@@ -305,7 +288,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
final boolean isNew = mMedialibrary.addDevice(uuid, device, true);
final boolean isIgnored = sharedPreferences.getBoolean("ignore_"+ uuid, false);
if (!isIgnored && isNew)
LocalBroadcastManager.getInstance(ctx).sendBroadcast(new Intent(ACTION_NEW_STORAGE).putExtra(EXTRA_PATH, device));
LocalBroadcastManager.getInstance(ctx).sendBroadcast(new Intent(Constants.ACTION_NEW_STORAGE).putExtra(Constants.EXTRA_PATH, device));
}
for (String device : missingDevices)
mMedialibrary.removeDevice(FileUtils.getFileNameFromPath(device));
......@@ -316,7 +299,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
}
private boolean wasWorking;
final StringBuilder sb = new StringBuilder();
private final Intent progessIntent = new Intent(ACTION_PROGRESS);
private final Intent progessIntent = new Intent(Constants.ACTION_PROGRESS);
private void showNotification() {
final long currentTime = System.currentTimeMillis();
synchronized (MediaParsingService.this) {
......@@ -342,8 +325,8 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
synchronized (MediaParsingService.this) {
if (mLastNotificationTime != -1L) {
mLocalBroadcastManager.sendBroadcast(progessIntent
.putExtra(ACTION_PROGRESS_TEXT, progressText)
.putExtra(ACTION_PROGRESS_VALUE, mParsing));
.putExtra(Constants.ACTION_PROGRESS_TEXT, progressText)
.putExtra(Constants.ACTION_PROGRESS_VALUE, mParsing));
try {
startForeground(43, notification);
} catch (IllegalArgumentException ignored) {}
......@@ -407,7 +390,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
@Override
public void onDestroy() {
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_SERVICE_ENDED));
mLocalBroadcastManager.sendBroadcast(new Intent(Constants.ACTION_SERVICE_ENDED));
hideNotification();
mMedialibrary.removeDeviceDiscoveryCb(this);
unregisterReceiver(mReceiver);
......
......@@ -79,7 +79,6 @@ import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.medialibrary.media.SearchAggregate;
import org.videolan.vlc.extensions.ExtensionsManager;
import org.videolan.vlc.gui.AudioPlayerContainerActivity;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.BitmapUtil;
import org.videolan.vlc.gui.helpers.NotificationHelper;
......@@ -92,9 +91,9 @@ import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapperList;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
......@@ -126,20 +125,6 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
private static final int SHOW_PROGRESS = 0;
private static final int SHOW_TOAST = 1;
private static final int END_MEDIASESSION = 2;
public static final String ACTION_REMOTE_GENERIC = Strings.buildPkgString("remote.");
public static final String ACTION_REMOTE_BACKWARD = ACTION_REMOTE_GENERIC+"Backward";
public static final String ACTION_REMOTE_PLAY = ACTION_REMOTE_GENERIC+"Play";
public static final String ACTION_REMOTE_PLAYPAUSE = ACTION_REMOTE_GENERIC+"PlayPause";
public static final String ACTION_REMOTE_PAUSE = ACTION_REMOTE_GENERIC+"Pause";
public static final String ACTION_REMOTE_STOP = ACTION_REMOTE_GENERIC+"Stop";
public static final String ACTION_REMOTE_FORWARD = ACTION_REMOTE_GENERIC+"Forward";
public static final String ACTION_REMOTE_LAST_PLAYLIST = ACTION_REMOTE_GENERIC+"LastPlaylist";
public static final String ACTION_REMOTE_LAST_VIDEO_PLAYLIST = ACTION_REMOTE_GENERIC+"LastVideoPlaylist";
public static final String ACTION_REMOTE_SWITCH_VIDEO = ACTION_REMOTE_GENERIC+"SwitchToVideo";
public static final String ACTION_PLAY_FROM_SEARCH = ACTION_REMOTE_GENERIC+"play_from_search";
public static final String ACTION_CAR_MODE_EXIT = "android.app.action.EXIT_CAR_MODE";
public static final String EXTRA_SEARCH_BUNDLE = ACTION_REMOTE_GENERIC+"extra_search_bundle";
private static final int DELAY_DOUBLE_CLICK = 800;
private static final int DELAY_LONG_CLICK = 1000;
......@@ -201,15 +186,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
| PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PLAY_FROM_URI
| PlaybackStateCompat.ACTION_PLAY_PAUSE;
public static final int TYPE_AUDIO = 0;
public static final int TYPE_VIDEO = 1;
public static final int REPEAT_NONE = 0;
public static final int REPEAT_ONE = 1;
public static final int REPEAT_ALL = 2;
private boolean mHasWidget;
private boolean mShuffling = false;
private int mRepeating = REPEAT_NONE;
private int mRepeating = Constants.REPEAT_NONE;
private Random mRandom = null; // Used in shuffling process
private long mSavedTime = 0L;
private boolean mHasAudioFocus = false;
......@@ -273,22 +252,22 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
final IntentFilter filter = new IntentFilter();
filter.setPriority(Integer.MAX_VALUE);
filter.addAction(ACTION_REMOTE_BACKWARD);
filter.addAction(ACTION_REMOTE_PLAYPAUSE);
filter.addAction(ACTION_REMOTE_PLAY);
filter.addAction(ACTION_REMOTE_PAUSE);
filter.addAction(ACTION_REMOTE_STOP);
filter.addAction(ACTION_REMOTE_FORWARD);
filter.addAction(ACTION_REMOTE_LAST_PLAYLIST);
filter.addAction(ACTION_REMOTE_LAST_VIDEO_PLAYLIST);
filter.addAction(ACTION_REMOTE_SWITCH_VIDEO);
filter.addAction(Constants.ACTION_REMOTE_BACKWARD);
filter.addAction(Constants.ACTION_REMOTE_PLAYPAUSE);
filter.addAction(Constants.ACTION_REMOTE_PLAY);
filter.addAction(Constants.ACTION_REMOTE_PAUSE);
filter.addAction(Constants.ACTION_REMOTE_STOP);
filter.addAction(Constants.ACTION_REMOTE_FORWARD);
filter.addAction(Constants.ACTION_REMOTE_LAST_PLAYLIST);
filter.addAction(Constants.ACTION_REMOTE_LAST_VIDEO_PLAYLIST);
filter.addAction(Constants.ACTION_REMOTE_SWITCH_VIDEO);
filter.addAction(VLCAppWidgetProvider.ACTION_WIDGET_INIT);
filter.addAction(VLCAppWidgetProvider.ACTION_WIDGET_ENABLED);
filter.addAction(VLCAppWidgetProvider.ACTION_WIDGET_DISABLED);
filter.addAction(Intent.ACTION_HEADSET_PLUG);
filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
filter.addAction(VLCApplication.SLEEP_INTENT);
filter.addAction(ACTION_CAR_MODE_EXIT);
filter.addAction(Constants.ACTION_CAR_MODE_EXIT);
registerReceiver(mReceiver, filter);
final boolean stealRemoteControl = mSettings.getBoolean("enable_steal_remote_control", false);
......@@ -312,7 +291,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (mLibraryReceiver == null) {
mLibraryReceiver = new MedialibraryReceiver();
lbm.registerReceiver(mLibraryReceiver, new IntentFilter(VLCApplication.ACTION_MEDIALIBRARY_READY));
Util.startService(PlaybackService.this, new Intent(MediaParsingService.ACTION_INIT, null, this, MediaParsingService.class));
Util.startService(PlaybackService.this, new Intent(Constants.ACTION_INIT, null, this, MediaParsingService.class));
}
if (action != null)
mLibraryReceiver.addAction(action);
......@@ -333,20 +312,20 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
MediaButtonReceiver.handleIntent(mMediaSession, intent);
return START_NOT_STICKY;
}
if (ACTION_REMOTE_PLAYPAUSE.equals(action)) {
if (Constants.ACTION_REMOTE_PLAYPAUSE.equals(action)) {
if (hasCurrentMedia())
return START_NOT_STICKY;
else
loadLastAudioPlaylist();
} else if (ACTION_REMOTE_PLAY.equals(action)) {
} else if (Constants.ACTION_REMOTE_PLAY.equals(action)) {
if (hasCurrentMedia())
play();
else
loadLastAudioPlaylist();
} else if (ACTION_PLAY_FROM_SEARCH.equals(action)) {
} else if (Constants.ACTION_PLAY_FROM_SEARCH.equals(action)) {
if (mMediaSession == null)
initMediaSession();
final Bundle extras = intent.getBundleExtra(EXTRA_SEARCH_BUNDLE);
final Bundle extras = intent.getBundleExtra(Constants.EXTRA_SEARCH_BUNDLE);
mMediaSession.getController().getTransportControls()
.playFromSearch(extras.getString(SearchManager.QUERY), extras);
}
......@@ -505,7 +484,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
/*
* Launch the activity if needed
*/
if (action.startsWith(ACTION_REMOTE_GENERIC) && !mMediaPlayer.isPlaying() && !hasCurrentMedia()) {
if (action.startsWith(Constants.ACTION_REMOTE_GENERIC) && !mMediaPlayer.isPlaying() && !hasCurrentMedia()) {
final Intent activityIntent = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (activityIntent != null)
context.startActivity(activityIntent);
......@@ -514,31 +493,31 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
/*
* Remote / headset control events
*/
if (action.equalsIgnoreCase(ACTION_REMOTE_PLAYPAUSE)) {
if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_PLAYPAUSE)) {
if (!hasCurrentMedia())
loadLastAudioPlaylist();
if (mMediaPlayer.isPlaying())
pause();
else
play();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_PLAY)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_PLAY)) {
if (!mMediaPlayer.isPlaying() && hasCurrentMedia())
play();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_PAUSE)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_PAUSE)) {
if (hasCurrentMedia())
pause();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_BACKWARD)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_BACKWARD)) {
previous(false);
} else if (action.equalsIgnoreCase(ACTION_REMOTE_STOP) ||
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_STOP) ||
action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) {
stop();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_FORWARD)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_FORWARD)) {
next();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_LAST_PLAYLIST)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_LAST_PLAYLIST)) {
loadLastAudioPlaylist();
} else if (action.equalsIgnoreCase(ACTION_REMOTE_LAST_VIDEO_PLAYLIST)) {
loadLastPlaylist(TYPE_VIDEO);
} else if (action.equalsIgnoreCase(ACTION_REMOTE_SWITCH_VIDEO)) {
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_LAST_VIDEO_PLAYLIST)) {
loadLastPlaylist(Constants.PLAYLIST_TYPE_VIDEO);
} else if (action.equalsIgnoreCase(Constants.ACTION_REMOTE_SWITCH_VIDEO)) {
removePopup();
if (hasMedia()) {
getCurrentMediaWrapper().removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
......@@ -564,7 +543,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (wasPlaying && hasCurrentMedia() && mSettings.getBoolean("enable_play_on_headset_insertion", false))
play();
}
} else if (action.equalsIgnoreCase(ACTION_CAR_MODE_EXIT))
} else if (action.equalsIgnoreCase(Constants.ACTION_CAR_MODE_EXIT))
BrowserProvider.unbindExtensionConnection();
}
};
......@@ -772,7 +751,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
}
private void showPlayer() {
sendBroadcast(new Intent(AudioPlayerContainerActivity.ACTION_SHOW_PLAYER));
sendBroadcast(new Intent(Constants.ACTION_SHOW_PLAYER));
}
public void saveMediaMeta() {
......@@ -886,7 +865,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (isVideoPlaying()) {//Player is already running, just send it an intent
setVideoTrackEnabled(true);
LocalBroadcastManager.getInstance(this).sendBroadcast(
VideoPlayerActivity.getIntent(VideoPlayerActivity.PLAY_FROM_SERVICE,
VideoPlayerActivity.getIntent(Constants.PLAY_FROM_SERVICE,
media, false, mCurrentIndex));
} else if (!mSwitchingToVideo) {//Start the video player
VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
......@@ -1041,12 +1020,12 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
return PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
} if (mVideoBackground || (canSwitchToVideo() && !mMediaList.getMedia(mCurrentIndex).hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO))) { //resume video playback
/* Resume VideoPlayerActivity from ACTION_REMOTE_SWITCH_VIDEO intent */
final Intent notificationIntent = new Intent(ACTION_REMOTE_SWITCH_VIDEO);
final Intent notificationIntent = new Intent(Constants.ACTION_REMOTE_SWITCH_VIDEO);
return PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
} else {
/* Show audio player */
final Intent notificationIntent = new Intent(this, StartActivity.class);
notificationIntent.setAction(AudioPlayerContainerActivity.ACTION_SHOW_PLAYER);
notificationIntent.setAction(Constants.ACTION_SHOW_PLAYER);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
return PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}
......@@ -1126,7 +1105,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mShuffling &= size > 2;
// Repeating once doesn't change the index
if (mRepeating == REPEAT_ONE) {
if (mRepeating == Constants.REPEAT_ONE) {
mPrevIndex = mNextIndex = mCurrentIndex;
} else {
if (mShuffling) {
......@@ -1144,7 +1123,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
// If we've played all songs already in shuffle, then either
// reshuffle or stop (depending on RepeatType).
if (mPrevious.size() + 1 == size) {
if(mRepeating == REPEAT_NONE) {
if (mRepeating == Constants.REPEAT_NONE) {
mNextIndex = -1;
return;
} else {
......@@ -1165,7 +1144,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (mCurrentIndex + 1 < size)
mNextIndex = mCurrentIndex + 1;
else {
if (mRepeating == REPEAT_NONE) {
if (mRepeating == Constants.REPEAT_NONE) {
mNextIndex = -1;
} else {
mNextIndex = 0;
......@@ -1273,15 +1252,15 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
shuffle();
} else if (TextUtils.equals(action, "repeat")) {
switch (getRepeatType()) {
case PlaybackService.REPEAT_NONE:
setRepeatType(PlaybackService.REPEAT_ALL);
case Constants.REPEAT_NONE:
setRepeatType(Constants.REPEAT_ALL);
break;
case PlaybackService.REPEAT_ALL:
setRepeatType(PlaybackService.REPEAT_ONE);
case Constants.REPEAT_ALL:
setRepeatType(Constants.REPEAT_ONE);
break;
default:
case PlaybackService.REPEAT_ONE:
setRepeatType(PlaybackService.REPEAT_NONE);
case Constants.REPEAT_ONE:
setRepeatType(Constants.REPEAT_NONE);
break;
}
}
......@@ -1477,15 +1456,15 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
}
}
pscb.setState(state, time, getRate());
if (mRepeating != REPEAT_NONE || hasNext())
if (mRepeating != Constants.REPEAT_NONE || hasNext())
actions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
if (mRepeating != REPEAT_NONE || hasPrevious() || isSeekable())
if (mRepeating != Constants.REPEAT_NONE || hasPrevious() || isSeekable())
actions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
if (isSeekable())
actions |= PlaybackStateCompat.ACTION_FAST_FORWARD | PlaybackStateCompat.ACTION_REWIND;
actions |= PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM;
pscb.setActions(actions);
final int repeatResId = getRepeatType() == REPEAT_ALL ? R.drawable.ic_auto_repeat_pressed : getRepeatType() == REPEAT_ONE ? R.drawable.ic_auto_repeat_one_pressed : R.drawable.ic_auto_repeat_normal;
final int repeatResId = getRepeatType() == Constants.REPEAT_ALL ? R.drawable.ic_auto_repeat_pressed : getRepeatType() == Constants.REPEAT_ONE ? R.drawable.ic_auto_repeat_one_pressed : R.drawable.ic_auto_repeat_normal;
if (mMediaList.size() > 2)
pscb.addCustomAction("shuffle", getString(R.string.shuffle_title), isShuffling() ? R.drawable.ic_auto_shuffle_pressed : R.drawable.ic_auto_shuffle_normal);
pscb.addCustomAction("repeat", getString(R.string.repeat_title), repeatResId);
......@@ -1523,7 +1502,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
saveCurrentMedia();
Log.w(TAG, "Warning: invalid next index, aborted !");
//Close video player if started
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(VideoPlayerActivity.EXIT_PLAYER));
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(Constants.EXIT_PLAYER));
stop();
return;
}
......@@ -1633,12 +1612,12 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
private void loadLastAudioPlaylist() {
if (mMedialibrary.isInitiated() && mLibraryReceiver == null)
loadLastPlaylist(TYPE_AUDIO);
loadLastPlaylist(Constants.PLAYLIST_TYPE_AUDIO);
else
registerMedialibrary(new Runnable() {
@Override
public void run() {
loadLastPlaylist(TYPE_AUDIO);
loadLastPlaylist(Constants.PLAYLIST_TYPE_AUDIO);
}
});
}
......@@ -1650,7 +1629,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final boolean audio = type == TYPE_AUDIO;
final boolean audio = type == Constants.PLAYLIST_TYPE_AUDIO;
final String[] locations;
synchronized (PlaybackService.this) {
final String currentMedia = mSettings.getString(audio ? "current_song" : "current_media", "");
......@@ -1673,7 +1652,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
final int position;
synchronized (PlaybackService.this) {
mShuffling = mSettings.getBoolean(audio ? "audio_shuffling" : "media_shuffling", false);
mRepeating = mSettings.getInt(audio ? "audio_repeating" : "media_repeating", REPEAT_NONE);
mRepeating = mSettings.getInt(audio ? "audio_repeating" : "media_repeating", Constants.REPEAT_NONE);
position = mSettings.getInt(audio ? "position_in_audio_list" : "position_in_media_list", 0);
mSavedTime = mSettings.getLong(audio ? "position_in_song" : "position_in_media", -1);
}
......@@ -1987,7 +1966,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mMediaList.addEventListener(mListEventListener);
if (mMediaList.isAudioList() && mSettings.getBoolean("audio_save_repeat", false))
mRepeating = mSettings.getInt(AUDIO_REPEAT_MODE_KEY, REPEAT_NONE);
mRepeating = mSettings.getInt(AUDIO_REPEAT_MODE_KEY, Constants.REPEAT_NONE);
playIndex(mCurrentIndex, 0);
onMediaChanged();
updateMediaQueue();
......
......@@ -34,6 +34,7 @@ import android.support.v4.content.ContextCompat;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.gui.helpers.BitmapUtil;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Util;
import java.util.Arrays;
......@@ -89,10 +90,10 @@ public class RecommendationsService extends IntentService {
private PendingIntent buildPendingIntent(MediaWrapper mediaWrapper, int id) {
Intent intent = new Intent(RecommendationsService.this, VideoPlayerActivity.class);
intent.setAction(VideoPlayerActivity.PLAY_FROM_VIDEOGRID);
intent.putExtra(VideoPlayerActivity.PLAY_EXTRA_ITEM_LOCATION, mediaWrapper.getUri());
intent.putExtra(VideoPlayerActivity.PLAY_EXTRA_ITEM_TITLE, mediaWrapper.getTitle());
intent.putExtra(VideoPlayerActivity.PLAY_EXTRA_FROM_START, false);
intent.setAction(Constants.PLAY_FROM_VIDEOGRID);
intent.putExtra(Constants.PLAY_EXTRA_ITEM_LOCATION, mediaWrapper.getUri());
intent.putExtra(Constants.PLAY_EXTRA_ITEM_TITLE, mediaWrapper.getTitle());
intent.putExtra(Constants.PLAY_EXTRA_FROM_START, false);
return PendingIntent.getActivity(this, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
......
......@@ -27,6 +27,7 @@ import android.view.KeyEvent;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Util;
/**
......@@ -72,33 +73,33 @@ public class RemoteControlClientReceiver extends MediaButtonReceiver {
case KeyEvent.ACTION_UP:
if (AndroidDevices.hasTsp) { //no backward/forward on TV
if (time - mHeadsetDownTime >= 1000) { // long click
i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_BACKWARD, null, context, PlaybackService.class);
break;
} else if (time - mHeadsetUpTime <= 500) { // double click
i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_FORWARD, null, context, PlaybackService.class);
break;
}
}
// one click
i = new Intent(PlaybackService.ACTION_REMOTE_PLAYPAUSE, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_PLAYPAUSE, null, context, PlaybackService.class);
mHeadsetUpTime = time;
break;
}
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
i = new Intent(PlaybackService.ACTION_REMOTE_PLAY, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_PLAY, null, context, PlaybackService.class);
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
i = new Intent(PlaybackService.ACTION_REMOTE_PAUSE, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_PAUSE, null, context, PlaybackService.class);
break;
case KeyEvent.KEYCODE_MEDIA_STOP:
i = new Intent(PlaybackService.ACTION_REMOTE_STOP, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_STOP, null, context, PlaybackService.class);
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_FORWARD, null, context, PlaybackService.class);
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, context, PlaybackService.class);
i = new Intent(Constants.ACTION_REMOTE_BACKWARD, null, context, PlaybackService.class);
break;
}
......@@ -108,9 +109,9 @@ public class RemoteControlClientReceiver extends MediaButtonReceiver {
Util.startService(context, i);
return;
}
} else if (action.equals(PlaybackService.ACTION_REMOTE_PLAYPAUSE)) {
} else if (action.equals(Constants.ACTION_REMOTE_PLAYPAUSE)) {
intent = new Intent(context, PlaybackService.class);
intent.setAction(PlaybackService.ACTION_REMOTE_PLAYPAUSE);
intent.setAction(Constants.ACTION_REMOTE_PLAYPAUSE);
Util.startService(context, intent);
return;
}
......
......@@ -31,7 +31,6 @@ import android.provider.MediaStore;
import android.support.v4.app.FragmentActivity;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.gui.AudioPlayerContainerActivity;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.SearchActivity;
import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate;
......@@ -40,6 +39,7 @@ import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
......@@ -47,10 +47,6 @@ public class StartActivity extends FragmentActivity implements StoragePermission
public final static String TAG = "VLC/StartActivity";
private static final String PREF_FIRST_RUN = "first_run";
public static final String EXTRA_FIRST_RUN = "extra_first_run";
public static final String EXTRA_UPGRADE = "extra_upgrade";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -68,12 +64,12 @@ public class StartActivity extends FragmentActivity implements StoragePermission
/* Get the current version from package */
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
final int currentVersionNumber = BuildConfig.VERSION_CODE;
final int savedVersionNumber = settings.getInt(PREF_FIRST_RUN, -1);
final int savedVersionNumber = settings.getInt(Constants.PREF_FIRST_RUN, -1);
/* Check if it's the first run */
final boolean firstRun = savedVersionNumber == -1;
final boolean upgrade = firstRun || savedVersionNumber != currentVersionNumber;
if (upgrade)
settings.edit().putInt(PREF_FIRST_RUN, currentVersionNumber).apply();
settings.edit().putInt(Constants.PREF_FIRST_RUN, currentVersionNumber).apply();
startMedialibrary(firstRun, upgrade);
// Route search query
if (Intent.ACTION_SEARCH.equals(action) || "com.google.android.gms.actions.SEARCH_ACTION".equals(action)) {
......@@ -81,15 +77,15 @@ public class StartActivity extends FragmentActivity implements StoragePermission
finish();
return;
} else if (MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.equals(action)) {
final Intent serviceInent = new Intent(PlaybackService.ACTION_PLAY_FROM_SEARCH, null, this, PlaybackService.class)
.putExtra(PlaybackService.EXTRA_SEARCH_BUNDLE, intent.getExtras());
final Intent serviceInent = new Intent(Constants.ACTION_PLAY_FROM_SEARCH, null, this, PlaybackService.class)
.putExtra(Constants.EXTRA_SEARCH_BUNDLE, intent.getExtras());
Util.startService(this, serviceInent);
} else if (AudioPlayerContainerActivity.ACTION_SHOW_PLAYER.equals(action)) {
} else if (Constants.ACTION_SHOW_PLAYER.equals(action)) {
startActivity(new Intent(this, tv ? AudioPlayerActivity.class : MainActivity.class));
} else {
startActivity(new Intent(this, tv ? MainTvActivity.class : MainActivity.class)
.putExtra(EXTRA_FIRST_RUN, firstRun)
.putExtra(EXTRA_UPGRADE, upgrade));
.putExtra(Constants.EXTRA_FIRST_RUN, firstRun)
.putExtra(Constants.EXTRA_UPGRADE, upgrade));
}
finish();
}
......@@ -104,9 +100,9 @@ public class StartActivity extends FragmentActivity implements StoragePermission
private void startMedialibrary(final boolean firstRun, final boolean upgrade) {
if (!VLCApplication.getMLInstance().isInitiated() && Permissions.canReadStorage(StartActivity.this))
startService(new Intent(MediaParsingService.ACTION_INIT, null, StartActivity.this, MediaParsingService.class)
.putExtra(EXTRA_FIRST_RUN, firstRun)
.putExtra(EXTRA_UPGRADE, upgrade));
startService(new Intent(Constants.ACTION_INIT, null, StartActivity.this, MediaParsingService.class)
.putExtra(Constants.EXTRA_FIRST_RUN, firstRun)
.putExtra(Constants.EXTRA_UPGRADE, upgrade));
}
private boolean showTvUi() {
......
......@@ -58,14 +58,13 @@ import org.videolan.vlc.gui.audio.AudioPlayer;
import org.videolan.vlc.gui.browser.StorageBrowserFragment;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.interfaces.IRefreshable;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.WeakHandler;