Commit 5d88c8fa authored by Geoffrey Métais's avatar Geoffrey Métais

Remove checks for FroYo and GingerBread

parent 3ad9b749
...@@ -26,13 +26,6 @@ import android.os.Build; ...@@ -26,13 +26,6 @@ import android.os.Build;
import java.io.File; import java.io.File;
public class AndroidUtil { public class AndroidUtil {
public static boolean isFroyoOrLater() {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO;
}
public static boolean isGingerbreadOrLater() {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD;
}
public static boolean isHoneycombOrLater() { public static boolean isHoneycombOrLater() {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB;
......
...@@ -28,8 +28,6 @@ import java.util.HashMap; ...@@ -28,8 +28,6 @@ import java.util.HashMap;
*/ */
public class HWDecoderUtil { public class HWDecoderUtil {
public static final boolean HAS_SUBTITLES_SURFACE = AndroidUtil.isGingerbreadOrLater();
public enum Decoder { public enum Decoder {
UNKNOWN, NONE, OMX, MEDIACODEC, ALL UNKNOWN, NONE, OMX, MEDIACODEC, ALL
} }
...@@ -162,18 +160,14 @@ public class HWDecoderUtil { ...@@ -162,18 +160,14 @@ public class HWDecoderUtil {
* (By default, returns ALL, i.e AudioTrack + OpenSles) * (By default, returns ALL, i.e AudioTrack + OpenSles)
*/ */
public static AudioOutput getAudioOutputFromDevice() { public static AudioOutput getAudioOutputFromDevice() {
if (!AndroidUtil.isGingerbreadOrLater()) { for (AudioOutputBySOC aoutBySOC : sAudioOutputBySOCList) {
return AudioOutput.AUDIOTRACK; final String prop = getSystemPropertyCached(aoutBySOC.key);
} else { if (prop != null) {
for (AudioOutputBySOC aoutBySOC : sAudioOutputBySOCList) { if (prop.contains(aoutBySOC.value))
final String prop = getSystemPropertyCached(aoutBySOC.key); return aoutBySOC.aout;
if (prop != null) {
if (prop.contains(aoutBySOC.value))
return aoutBySOC.aout;
}
} }
return AudioOutput.ALL;
} }
return AudioOutput.ALL;
} }
private static String getSystemPropertyCached(String key) { private static String getSystemPropertyCached(String key) {
......
...@@ -321,10 +321,7 @@ public class VLCUtil { ...@@ -321,10 +321,7 @@ public class VLCUtil {
libraryPaths = property.split(":"); libraryPaths = property.split(":");
} else { } else {
libraryPaths = new String[1]; libraryPaths = new String[1];
if (AndroidUtil.isGingerbreadOrLater()) libraryPaths[0] = applicationInfo.nativeLibraryDir;
libraryPaths[0] = applicationInfo.nativeLibraryDir;
else
libraryPaths[0] = applicationInfo.dataDir + "/lib";
} }
if (libraryPaths[0] == null) { if (libraryPaths[0] == null) {
Log.e(TAG, "can't find library path"); Log.e(TAG, "can't find library path");
......
...@@ -207,10 +207,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -207,10 +207,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
return mp; return mp;
} }
private static boolean readPhoneState() {
return !AndroidUtil.isFroyoOrLater();
}
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
...@@ -261,7 +257,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -261,7 +257,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
boolean stealRemoteControl = mSettings.getBoolean("enable_steal_remote_control", false); boolean stealRemoteControl = mSettings.getBoolean("enable_steal_remote_control", false);
if (!AndroidUtil.isFroyoOrLater() || stealRemoteControl) { if (stealRemoteControl) {
/* Backward compatibility for API 7 */ /* Backward compatibility for API 7 */
filter = new IntentFilter(); filter = new IntentFilter();
if (stealRemoteControl) if (stealRemoteControl)
...@@ -270,12 +266,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -270,12 +266,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
mRemoteControlClientReceiver = new RemoteControlClientReceiver(); mRemoteControlClientReceiver = new RemoteControlClientReceiver();
registerReceiver(mRemoteControlClientReceiver, filter); registerReceiver(mRemoteControlClientReceiver, filter);
} }
if (readPhoneState()) {
initPhoneListener();
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, mPhoneEvents);
}
} }
@Override @Override
...@@ -315,11 +305,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -315,11 +305,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
mRemoteControlClientReceiver = null; mRemoteControlClientReceiver = null;
} }
mMediaPlayer.release(); mMediaPlayer.release();
if (readPhoneState()) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
} }
@Override @Override
...@@ -338,8 +323,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -338,8 +323,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
return mMediaPlayer.getVLCVout(); return mMediaPlayer.getVLCVout();
} }
private final OnAudioFocusChangeListener mAudioFocusListener = AndroidUtil.isFroyoOrLater() ? private final OnAudioFocusChangeListener mAudioFocusListener = createOnAudioFocusChangeListener();
createOnAudioFocusChangeListener() : null;
@TargetApi(Build.VERSION_CODES.FROYO) @TargetApi(Build.VERSION_CODES.FROYO)
private OnAudioFocusChangeListener createOnAudioFocusChangeListener() { private OnAudioFocusChangeListener createOnAudioFocusChangeListener() {
...@@ -1354,7 +1338,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -1354,7 +1338,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putInt(audio ? "position_in_audio_list" : "position_in_media_list", 0); editor.putInt(audio ? "position_in_audio_list" : "position_in_media_list", 0);
editor.putLong(audio ? "position_in_song" : "position_in_media", 0); editor.putLong(audio ? "position_in_song" : "position_in_media", 0);
Util.commitPreferences(editor); editor.apply();
} }
private synchronized void saveCurrentMedia() { private synchronized void saveCurrentMedia() {
...@@ -1365,7 +1349,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -1365,7 +1349,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
} }
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putString(audio ? "current_song" : "current_media", mMediaList.getMRL(Math.max(mCurrentIndex, 0))); editor.putString(audio ? "current_song" : "current_media", mMediaList.getMRL(Math.max(mCurrentIndex, 0)));
Util.commitPreferences(editor); editor.apply();
} }
private synchronized void saveMediaList() { private synchronized void saveMediaList() {
...@@ -1381,7 +1365,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -1381,7 +1365,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
//We save a concatenated String because putStringSet is APIv11. //We save a concatenated String because putStringSet is APIv11.
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putString(audio ? "audio_list" : "media_list", locations.toString().trim()); editor.putString(audio ? "audio_list" : "media_list", locations.toString().trim());
Util.commitPreferences(editor); editor.apply();
} }
private synchronized void savePosition(){ private synchronized void savePosition(){
...@@ -1401,7 +1385,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -1401,7 +1385,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, !isPlaying()); editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, !isPlaying());
editor.putFloat(PreferencesActivity.VIDEO_SPEED, getRate()); editor.putFloat(PreferencesActivity.VIDEO_SPEED, getRate());
} }
Util.commitPreferences(editor); editor.apply();
} }
private boolean validateLocation(String location) private boolean validateLocation(String location)
...@@ -1949,7 +1933,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -1949,7 +1933,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
public void setRate(float rate, boolean save) { public void setRate(float rate, boolean save) {
mMediaPlayer.setRate(rate); mMediaPlayer.setRate(rate);
if (save && mSettings.getBoolean(PreferencesActivity.KEY_AUDIO_PLAYBACK_SPEED_PERSIST, true)) if (save && mSettings.getBoolean(PreferencesActivity.KEY_AUDIO_PLAYBACK_SPEED_PERSIST, true))
Util.commitPreferences(mSettings.edit().putFloat(PreferencesActivity.KEY_AUDIO_PLAYBACK_RATE, rate)); mSettings.edit().putFloat(PreferencesActivity.KEY_AUDIO_PLAYBACK_RATE, rate).apply();
} }
@MainThread @MainThread
...@@ -2218,21 +2202,4 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -2218,21 +2202,4 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
startService(context); startService(context);
} }
} }
int mPhoneEvents = PhoneStateListener.LISTEN_CALL_STATE;
PhoneStateListener mPhoneStateListener;
private void initPhoneListener() {
mPhoneStateListener = new PhoneStateListener(){
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (!mMediaPlayer.isPlaying() || !hasCurrentMedia())
return;
if (state == TelephonyManager.CALL_STATE_RINGING || state == TelephonyManager.CALL_STATE_OFFHOOK)
pause();
else if (state == TelephonyManager.CALL_STATE_IDLE)
play();
}
};
}
} }
...@@ -205,7 +205,7 @@ public class AudioPlayerContainerActivity extends AppCompatActivity implements P ...@@ -205,7 +205,7 @@ public class AudioPlayerContainerActivity extends AppCompatActivity implements P
removeTipViewIfDisplayed(); removeTipViewIfDisplayed();
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putBoolean(settingKey, true); editor.putBoolean(settingKey, true);
Util.commitPreferences(editor); editor.apply();
} }
}); });
} }
......
...@@ -67,7 +67,6 @@ import org.videolan.libvlc.util.AndroidUtil; ...@@ -67,7 +67,6 @@ import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.BuildConfig; import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.PlaybackService; import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.StartActivity;
import org.videolan.vlc.VLCApplication; import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.extensions.ExtensionListing; import org.videolan.vlc.extensions.ExtensionListing;
import org.videolan.vlc.extensions.ExtensionManagerService; import org.videolan.vlc.extensions.ExtensionManagerService;
...@@ -159,7 +158,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter ...@@ -159,7 +158,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
if (mFirstRun) { if (mFirstRun) {
Editor editor = mSettings.edit(); Editor editor = mSettings.edit();
editor.putInt(PREF_FIRST_RUN, mVersionNumber); editor.putInt(PREF_FIRST_RUN, mVersionNumber);
Util.commitPreferences(editor); editor.apply();
} }
Permissions.checkReadStoragePermission(this, false); Permissions.checkReadStoragePermission(this, false);
...@@ -414,7 +413,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter ...@@ -414,7 +413,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
/* Save the tab status in pref */ /* Save the tab status in pref */
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putInt("fragment_id", mCurrentFragmentId); editor.putInt("fragment_id", mCurrentFragmentId);
Util.commitPreferences(editor); editor.apply();
} }
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
...@@ -533,17 +532,14 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter ...@@ -533,17 +532,14 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.media_library, menu); inflater.inflate(R.menu.media_library, menu);
if (AndroidUtil.isFroyoOrLater()) { SearchManager searchManager =
SearchManager searchManager = (SearchManager) VLCApplication.getAppContext().getSystemService(Context.SEARCH_SERVICE);
(SearchManager) VLCApplication.getAppContext().getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.ml_menu_search));
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.ml_menu_search)); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setQueryHint(getString(R.string.search_hint));
mSearchView.setQueryHint(getString(R.string.search_hint)); SearchSuggestionsAdapter searchSuggestionsAdapter = new SearchSuggestionsAdapter(this, null);
SearchSuggestionsAdapter searchSuggestionsAdapter = new SearchSuggestionsAdapter(this, null); searchSuggestionsAdapter.setFilterQueryProvider(this);
searchSuggestionsAdapter.setFilterQueryProvider(this); mSearchView.setSuggestionsAdapter(searchSuggestionsAdapter);
mSearchView.setSuggestionsAdapter(searchSuggestionsAdapter);
} else
menu.findItem(R.id.ml_menu_search).setVisible(false);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
......
...@@ -316,7 +316,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -316,7 +316,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
if (mService.hasMedia() && !mService.isVideoPlaying()) { if (mService.hasMedia() && !mService.isVideoPlaying()) {
SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(getActivity());
if (isResumed() && mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){ if (isResumed() && mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false)); mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply();
mService.switchToVideo(); mService.switchToVideo();
return; return;
} else } else
......
...@@ -39,7 +39,6 @@ import org.videolan.vlc.databinding.VlcLoginDialogBinding; ...@@ -39,7 +39,6 @@ import org.videolan.vlc.databinding.VlcLoginDialogBinding;
import org.videolan.vlc.gui.helpers.UiTools; import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.preferences.PreferencesActivity; import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.util.AndroidDevices; import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialogBinding> implements View.OnFocusChangeListener { public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialogBinding> implements View.OnFocusChangeListener {
...@@ -69,9 +68,7 @@ public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialog ...@@ -69,9 +68,7 @@ public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialog
public void onLogin(View v) { public void onLogin(View v) {
mVlcDialog.postLogin(mBinding.login.getText().toString().trim(), mVlcDialog.postLogin(mBinding.login.getText().toString().trim(),
mBinding.password.getText().toString().trim(), mBinding.store.isChecked()); mBinding.password.getText().toString().trim(), mBinding.store.isChecked());
SharedPreferences.Editor editor = mSettings.edit(); mSettings.edit().putBoolean(PreferencesActivity.LOGIN_STORE, mBinding.store.isChecked()).apply();
editor.putBoolean(PreferencesActivity.LOGIN_STORE, mBinding.store.isChecked());
Util.commitPreferences(editor);
dismiss(); dismiss();
} }
......
...@@ -134,7 +134,7 @@ public class AudioUtil { ...@@ -134,7 +134,7 @@ public class AudioUtil {
@SuppressLint("NewApi") @SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) { public static void prepareCacheFolder(Context context) {
try { try {
if (AndroidUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null) if (AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
CACHE_DIR = context.getExternalCacheDir().getPath(); CACHE_DIR = context.getExternalCacheDir().getPath();
else else
CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache"; CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
......
...@@ -32,17 +32,14 @@ import android.support.v7.preference.ListPreference; ...@@ -32,17 +32,14 @@ import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager; import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.Toast;
import org.videolan.libvlc.util.HWDecoderUtil; import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.BuildConfig; import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.AudioUtil; import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.BitmapCache; import org.videolan.vlc.gui.helpers.BitmapCache;
import org.videolan.vlc.gui.helpers.UiTools; import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaDatabase; import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance; import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions; import org.videolan.vlc.util.VLCOptions;
...@@ -110,7 +107,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference ...@@ -110,7 +107,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
editor.putInt("network_caching_value", 0); editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0"); editor.putString("network_caching", "0");
} }
Util.commitPreferences(editor); editor.apply();
return true; return true;
} }
}); });
......
...@@ -33,8 +33,6 @@ import android.support.v7.preference.PreferenceManager; ...@@ -33,8 +33,6 @@ import android.support.v7.preference.PreferenceManager;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication; import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.SecondaryActivity; import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance; import org.videolan.vlc.util.VLCInstance;
public class PreferencesFragment extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class PreferencesFragment extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
...@@ -65,7 +63,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share ...@@ -65,7 +63,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("screen_orientation_value", (String) newValue); editor.putString("screen_orientation_value", (String) newValue);
Util.commitPreferences(editor); editor.apply();
return true; return true;
} }
}); });
......
...@@ -155,7 +155,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi ...@@ -155,7 +155,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
if (mService.hasMedia()) { if (mService.hasMedia()) {
SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(this);
if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){ if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false)); mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply();
mService.switchToVideo(); mService.switchToVideo();
finish(); finish();
return; return;
......
...@@ -112,7 +112,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference ...@@ -112,7 +112,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
editor.putInt("network_caching_value", 0); editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0"); editor.putString("network_caching", "0");
} }
Util.commitPreferences(editor); editor.apply();
return true; return true;
} }
}); });
......
...@@ -69,7 +69,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share ...@@ -69,7 +69,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("screen_orientation_value", (String) newValue); editor.putString("screen_orientation_value", (String) newValue);
Util.commitPreferences(editor); editor.apply();
return true; return true;
} }
}); });
......
...@@ -359,7 +359,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View ...@@ -359,7 +359,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putInt(KEY_SORT_BY, mSortBy); editor.putInt(KEY_SORT_BY, mSortBy);
editor.putInt(KEY_SORT_DIRECTION, mSortDirection); editor.putInt(KEY_SORT_DIRECTION, mSortDirection);
Util.commitPreferences(editor); editor.apply();
} }
@Override @Override
......
...@@ -451,11 +451,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -451,11 +451,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSurfaceView = (SurfaceView) findViewById(R.id.player_surface); mSurfaceView = (SurfaceView) findViewById(R.id.player_surface);
mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.subtitles_surface); mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.subtitles_surface);
if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) { mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
mSubtitlesSurfaceView.setZOrderMediaOverlay(true); mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
} else
mSubtitlesSurfaceView.setVisibility(View.GONE);
mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame); mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
...@@ -482,7 +479,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -482,7 +479,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null); editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
// Paused flag - per session too, like the subs list. // Paused flag - per session too, like the subs list.
editor.remove(PreferencesActivity.VIDEO_PAUSED); editor.remove(PreferencesActivity.VIDEO_PAUSED);
Util.commitPreferences(editor); editor.apply();
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
if (mBattery != null) if (mBattery != null)
...@@ -709,7 +706,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -709,7 +706,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (brightness != -1f) { if (brightness != -1f) {
SharedPreferences.Editor editor = mSettings.edit(); SharedPreferences.Editor editor = mSettings.edit();
editor.putFloat("brightness_value", brightness); editor.putFloat("brightness_value", brightness);
Util.commitPreferences(editor); editor.apply();
} }
} }
} }
...@@ -932,7 +929,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -932,7 +929,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.setRate(1.0f, false); mService.setRate(1.0f, false);
mService.stop(); mService.stop();
} }
Util.commitPreferences(editor); editor.apply();
} }
private void cleanUI() { private void cleanUI() {
...@@ -1777,7 +1774,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -1777,7 +1774,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class); Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
startActivity(i); startActivity(i);
} else } else
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true)); mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true).apply();
exitOK(); exitOK();
} }
...@@ -2318,7 +2315,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -2318,7 +2315,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case R.id.player_overlay_time: case R.id.player_overlay_time:
mDisplayRemainingTime = !mDisplayRemainingTime; mDisplayRemainingTime = !mDisplayRemainingTime;
showOverlay(); showOverlay();
Util.commitPreferences(mSettings.edit().putBoolean(KEY_REMAINING_TIME_DISPLAY, mDisplayRemainingTime)); mSettings.edit().putBoolean(KEY_REMAINING_TIME_DISPLAY, mDisplayRemainingTime).apply();
break; break;
case R.id.player_delay_minus: case R.id.player_delay_minus:
if (mPlaybackSetting == DelayState.AUDIO) if (mPlaybackSetting == DelayState.AUDIO)
...@@ -2958,7 +2955,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -2958,7 +2955,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
} else { } else {
Editor editor = mSettings.edit(); Editor editor = mSettings.edit();
editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1); editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
Util.commitPreferences(editor); editor.apply();
savedTime = rTime; savedTime = rTime;
} }
} }
...@@ -3095,15 +3092,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -3095,15 +3092,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR : ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR :
ActivityInfo.SCREEN_ORIENTATION_SENSOR; ActivityInfo.SCREEN_ORIENTATION_SENSOR;
case 101: //screen orientation landscape case 101: //screen orientation landscape
if (AndroidUtil.isGingerbreadOrLater()) return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
else
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
case 102: //screen orientation portrait case 102: //screen orientation portrait
if (AndroidUtil.isGingerbreadOrLater()) return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
else
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
} }
/* /*
mScreenOrientation = 100, we lock screen at its current orientation mScreenOrientation = 100, we lock screen at its current orientation
...@@ -3130,13 +3121,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -3130,13 +3121,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case Surface.ROTATION_180: case Surface.ROTATION_180:
// SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
// Level 9+ // Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
case Surface.ROTATION_270: case Surface.ROTATION_270:
// SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
// Level 9+ // Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
default: default:
return 0; return 0;
} }
...@@ -3149,13 +3138,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C ...@@ -3149,13 +3138,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case Surface.ROTATION_180: case Surface.ROTATION_180:
// SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API // SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
// Level 9+ // Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
case Surface.ROTATION_270: case Surface.ROTATION_270:
// SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API // SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
// Level 9+