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;
import java.io.File;
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() {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB;
......
......@@ -28,8 +28,6 @@ import java.util.HashMap;
*/
public class HWDecoderUtil {
public static final boolean HAS_SUBTITLES_SURFACE = AndroidUtil.isGingerbreadOrLater();
public enum Decoder {
UNKNOWN, NONE, OMX, MEDIACODEC, ALL
}
......@@ -162,9 +160,6 @@ public class HWDecoderUtil {
* (By default, returns ALL, i.e AudioTrack + OpenSles)
*/
public static AudioOutput getAudioOutputFromDevice() {
if (!AndroidUtil.isGingerbreadOrLater()) {
return AudioOutput.AUDIOTRACK;
} else {
for (AudioOutputBySOC aoutBySOC : sAudioOutputBySOCList) {
final String prop = getSystemPropertyCached(aoutBySOC.key);
if (prop != null) {
......@@ -174,7 +169,6 @@ public class HWDecoderUtil {
}
return AudioOutput.ALL;
}
}
private static String getSystemPropertyCached(String key) {
String prop = sSystemPropertyMap.get(key);
......
......@@ -321,10 +321,7 @@ public class VLCUtil {
libraryPaths = property.split(":");
} else {
libraryPaths = new String[1];
if (AndroidUtil.isGingerbreadOrLater())
libraryPaths[0] = applicationInfo.nativeLibraryDir;
else
libraryPaths[0] = applicationInfo.dataDir + "/lib";
}
if (libraryPaths[0] == null) {
Log.e(TAG, "can't find library path");
......
......@@ -207,10 +207,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
return mp;
}
private static boolean readPhoneState() {
return !AndroidUtil.isFroyoOrLater();
}
@Override
public void onCreate() {
super.onCreate();
......@@ -261,7 +257,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
boolean stealRemoteControl = mSettings.getBoolean("enable_steal_remote_control", false);
if (!AndroidUtil.isFroyoOrLater() || stealRemoteControl) {
if (stealRemoteControl) {
/* Backward compatibility for API 7 */
filter = new IntentFilter();
if (stealRemoteControl)
......@@ -270,12 +266,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
mRemoteControlClientReceiver = new RemoteControlClientReceiver();
registerReceiver(mRemoteControlClientReceiver, filter);
}
if (readPhoneState()) {
initPhoneListener();
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, mPhoneEvents);
}
}
@Override
......@@ -315,11 +305,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
mRemoteControlClientReceiver = null;
}
mMediaPlayer.release();
if (readPhoneState()) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
}
@Override
......@@ -338,8 +323,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
return mMediaPlayer.getVLCVout();
}
private final OnAudioFocusChangeListener mAudioFocusListener = AndroidUtil.isFroyoOrLater() ?
createOnAudioFocusChangeListener() : null;
private final OnAudioFocusChangeListener mAudioFocusListener = createOnAudioFocusChangeListener();
@TargetApi(Build.VERSION_CODES.FROYO)
private OnAudioFocusChangeListener createOnAudioFocusChangeListener() {
......@@ -1354,7 +1338,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
SharedPreferences.Editor editor = mSettings.edit();
editor.putInt(audio ? "position_in_audio_list" : "position_in_media_list", 0);
editor.putLong(audio ? "position_in_song" : "position_in_media", 0);
Util.commitPreferences(editor);
editor.apply();
}
private synchronized void saveCurrentMedia() {
......@@ -1365,7 +1349,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
}
SharedPreferences.Editor editor = mSettings.edit();
editor.putString(audio ? "current_song" : "current_media", mMediaList.getMRL(Math.max(mCurrentIndex, 0)));
Util.commitPreferences(editor);
editor.apply();
}
private synchronized void saveMediaList() {
......@@ -1381,7 +1365,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
//We save a concatenated String because putStringSet is APIv11.
SharedPreferences.Editor editor = mSettings.edit();
editor.putString(audio ? "audio_list" : "media_list", locations.toString().trim());
Util.commitPreferences(editor);
editor.apply();
}
private synchronized void savePosition(){
......@@ -1401,7 +1385,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, !isPlaying());
editor.putFloat(PreferencesActivity.VIDEO_SPEED, getRate());
}
Util.commitPreferences(editor);
editor.apply();
}
private boolean validateLocation(String location)
......@@ -1949,7 +1933,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
public void setRate(float rate, boolean save) {
mMediaPlayer.setRate(rate);
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
......@@ -2218,21 +2202,4 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
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
removeTipViewIfDisplayed();
SharedPreferences.Editor editor = mSettings.edit();
editor.putBoolean(settingKey, true);
Util.commitPreferences(editor);
editor.apply();
}
});
}
......
......@@ -67,7 +67,6 @@ import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.StartActivity;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.extensions.ExtensionListing;
import org.videolan.vlc.extensions.ExtensionManagerService;
......@@ -159,7 +158,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
if (mFirstRun) {
Editor editor = mSettings.edit();
editor.putInt(PREF_FIRST_RUN, mVersionNumber);
Util.commitPreferences(editor);
editor.apply();
}
Permissions.checkReadStoragePermission(this, false);
......@@ -414,7 +413,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
/* Save the tab status in pref */
SharedPreferences.Editor editor = mSettings.edit();
editor.putInt("fragment_id", mCurrentFragmentId);
Util.commitPreferences(editor);
editor.apply();
}
protected void onSaveInstanceState(Bundle outState) {
......@@ -533,7 +532,6 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.media_library, menu);
if (AndroidUtil.isFroyoOrLater()) {
SearchManager searchManager =
(SearchManager) VLCApplication.getAppContext().getSystemService(Context.SEARCH_SERVICE);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.ml_menu_search));
......@@ -542,8 +540,6 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
SearchSuggestionsAdapter searchSuggestionsAdapter = new SearchSuggestionsAdapter(this, null);
searchSuggestionsAdapter.setFilterQueryProvider(this);
mSearchView.setSuggestionsAdapter(searchSuggestionsAdapter);
} else
menu.findItem(R.id.ml_menu_search).setVisible(false);
return super.onCreateOptionsMenu(menu);
}
......
......@@ -316,7 +316,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
if (mService.hasMedia() && !mService.isVideoPlaying()) {
SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(getActivity());
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();
return;
} else
......
......@@ -39,7 +39,6 @@ import org.videolan.vlc.databinding.VlcLoginDialogBinding;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialogBinding> implements View.OnFocusChangeListener {
......@@ -69,9 +68,7 @@ public class VlcLoginDialog extends VlcDialog<Dialog.LoginDialog, VlcLoginDialog
public void onLogin(View v) {
mVlcDialog.postLogin(mBinding.login.getText().toString().trim(),
mBinding.password.getText().toString().trim(), mBinding.store.isChecked());
SharedPreferences.Editor editor = mSettings.edit();
editor.putBoolean(PreferencesActivity.LOGIN_STORE, mBinding.store.isChecked());
Util.commitPreferences(editor);
mSettings.edit().putBoolean(PreferencesActivity.LOGIN_STORE, mBinding.store.isChecked()).apply();
dismiss();
}
......
......@@ -134,7 +134,7 @@ public class AudioUtil {
@SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) {
try {
if (AndroidUtil.isFroyoOrLater() && AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
if (AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
CACHE_DIR = context.getExternalCacheDir().getPath();
else
CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
......
......@@ -32,17 +32,14 @@ import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
import android.widget.Toast;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.BitmapCache;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
......@@ -110,7 +107,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0");
}
Util.commitPreferences(editor);
editor.apply();
return true;
}
});
......
......@@ -33,8 +33,6 @@ import android.support.v7.preference.PreferenceManager;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
public class PreferencesFragment extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
......@@ -65,7 +63,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("screen_orientation_value", (String) newValue);
Util.commitPreferences(editor);
editor.apply();
return true;
}
});
......
......@@ -155,7 +155,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
if (mService.hasMedia()) {
SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(this);
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();
finish();
return;
......
......@@ -112,7 +112,7 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0");
}
Util.commitPreferences(editor);
editor.apply();
return true;
}
});
......
......@@ -69,7 +69,7 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("screen_orientation_value", (String) newValue);
Util.commitPreferences(editor);
editor.apply();
return true;
}
});
......
......@@ -359,7 +359,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
SharedPreferences.Editor editor = mSettings.edit();
editor.putInt(KEY_SORT_BY, mSortBy);
editor.putInt(KEY_SORT_DIRECTION, mSortDirection);
Util.commitPreferences(editor);
editor.apply();
}
@Override
......
......@@ -451,11 +451,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSurfaceView = (SurfaceView) findViewById(R.id.player_surface);
mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.subtitles_surface);
if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) {
mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
} else
mSubtitlesSurfaceView.setVisibility(View.GONE);
mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
......@@ -482,7 +479,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
// Paused flag - per session too, like the subs list.
editor.remove(PreferencesActivity.VIDEO_PAUSED);
Util.commitPreferences(editor);
editor.apply();
IntentFilter filter = new IntentFilter();
if (mBattery != null)
......@@ -709,7 +706,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (brightness != -1f) {
SharedPreferences.Editor editor = mSettings.edit();
editor.putFloat("brightness_value", brightness);
Util.commitPreferences(editor);
editor.apply();
}
}
}
......@@ -932,7 +929,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.setRate(1.0f, false);
mService.stop();
}
Util.commitPreferences(editor);
editor.apply();
}
private void cleanUI() {
......@@ -1777,7 +1774,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
startActivity(i);
} else
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true));
mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true).apply();
exitOK();
}
......@@ -2318,7 +2315,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case R.id.player_overlay_time:
mDisplayRemainingTime = !mDisplayRemainingTime;
showOverlay();
Util.commitPreferences(mSettings.edit().putBoolean(KEY_REMAINING_TIME_DISPLAY, mDisplayRemainingTime));
mSettings.edit().putBoolean(KEY_REMAINING_TIME_DISPLAY, mDisplayRemainingTime).apply();
break;
case R.id.player_delay_minus:
if (mPlaybackSetting == DelayState.AUDIO)
......@@ -2958,7 +2955,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
} else {
Editor editor = mSettings.edit();
editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
Util.commitPreferences(editor);
editor.apply();
savedTime = rTime;
}
}
......@@ -3095,15 +3092,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR :
ActivityInfo.SCREEN_ORIENTATION_SENSOR;
case 101: //screen orientation landscape
if (AndroidUtil.isGingerbreadOrLater())
return ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
else
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
case 102: //screen orientation portrait
if (AndroidUtil.isGingerbreadOrLater())
return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
else
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
/*
mScreenOrientation = 100, we lock screen at its current orientation
......@@ -3130,13 +3121,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case Surface.ROTATION_180:
// SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
// Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
case Surface.ROTATION_270:
// SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
// Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
default:
return 0;
}
......@@ -3149,13 +3138,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
case Surface.ROTATION_180:
// SCREEN_ORIENTATION_REVERSE_PORTRAIT only available since API
// Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
case Surface.ROTATION_270:
// SCREEN_ORIENTATION_REVERSE_LANDSCAPE only available since API
// Level 9+
return (AndroidUtil.isGingerbreadOrLater() ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
default:
return 0;
}
......@@ -3235,7 +3222,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private OnClickListener mBtSaveListener = new OnClickListener() {
@Override
public void onClick(View view) {
Util.commitPreferences(mSettings.edit().putLong(KEY_BLUETOOTH_DELAY, mService.getAudioDelay()));
mSettings.edit().putLong(KEY_BLUETOOTH_DELAY, mService.getAudioDelay()).apply();
}
};
......@@ -3320,11 +3307,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);
if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) {
mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
} else
mSubtitlesSurfaceView.setVisibility(View.GONE);
VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
if (activity == null) {
Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
......@@ -3375,7 +3359,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mOverlayTips.setVisibility(View.GONE);
Editor editor = mSettings.edit();
editor.putBoolean(PREF_TIPS_SHOWN, true);
Util.commitPreferences(editor);
editor.apply();
}
private void updateNavStatus() {
......@@ -3447,7 +3431,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (!mSwitchingView)
mHandler.sendEmptyMessage(START_PLAYBACK);
mSwitchingView = false;
Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false));
mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply();
}
@Override
......
......@@ -45,7 +45,7 @@ public class CustomDirectories {
}
SharedPreferences.Editor editor = preferences.edit();
editor.putString("custom_paths", builder.toString());
Util.commitPreferences(editor);
editor.apply();
}
public static void removeCustomDirectory(String path) {
......@@ -70,7 +70,7 @@ public class CustomDirectories {
}
SharedPreferences.Editor editor = preferences.edit();
editor.putString("custom_paths", custom_path);
Util.commitPreferences(editor);
editor.apply();
}
public static String[] getCustomDirectories() {
......
......@@ -140,7 +140,7 @@ public class Permissions {
}
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("user_declined_storage_access", true);
Util.commitPreferences(editor);
editor.apply();
}
});
if (exit) {
......@@ -178,7 +178,7 @@ public class Permissions {
}
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("user_declined_storage_access", true);
Util.commitPreferences(editor);
editor.apply();
}
});
if (exit) {
......@@ -227,7 +227,7 @@ public class Permissions {
} catch (Exception ex) {}
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("user_declined_settings_access", true);
Util.commitPreferences(editor);
editor.apply();
}
});
return dialogBuilder.show();
......
......@@ -20,14 +20,11 @@
package org.videolan.vlc.util;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.support.annotation.Nullable;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.VLCApplication;
import java.io.BufferedReader;
......@@ -67,14 +64,6 @@ public class Util {
}
}
@TargetApi(android.os.Build.VERSION_CODES.GINGERBREAD)
public static void commitPreferences(SharedPreferences.Editor editor){
if (AndroidUtil.isGingerbreadOrLater())
editor.apply();
else
editor.commit();
}
public static boolean close(Closeable closeable) {
if (closeable != null)
try {
......
......@@ -62,8 +62,8 @@ public class VLCOptions {
final String subtitlesEncoding = pref.getString("subtitle_text_encoding", "");
final boolean frameSkip = pref.getBoolean("enable_frame_skip", false);
String chroma = pref.getString("chroma_format", VLCApplication.getAppResources().getString(R.string.chroma_format_default));
if (chroma != null)
chroma = chroma.equals("YV12") && !AndroidUtil.isGingerbreadOrLater() ? "" : chroma;
if (chroma != null && chroma.equals("YV12"))
chroma = "";
final boolean verboseMode = pref.getBoolean("enable_verbose_mode", true);
int deblocking = -1;
......@@ -233,6 +233,6 @@ public class VLCOptions {
} else {
editor.putBoolean("equalizer_enabled", false);
}
Util.commitPreferences(editor);
editor.apply();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment