Commit 073e76ed authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Do not define is*OrLater() methods twice

parent 0ca09bf7
......@@ -40,6 +40,7 @@ import java.util.Stack;
import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaList;
import org.videolan.vlc.gui.MainActivity;
......@@ -173,7 +174,7 @@ public class AudioService extends Service {
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
boolean stealRemoteControl = pref.getBoolean("enable_steal_remote_control", false);
if(!Util.isFroyoOrLater() || stealRemoteControl) {
if (!LibVlcUtil.isFroyoOrLater() || stealRemoteControl) {
/* Backward compatibility for API 7 */
filter = new IntentFilter();
if (stealRemoteControl)
......@@ -194,7 +195,7 @@ public class AudioService extends Service {
Context context = VLCApplication.getAppContext();
AudioManager audioManager = (AudioManager)context.getSystemService(AUDIO_SERVICE);
if(Util.isICSOrLater()) {
if (LibVlcUtil.isICSOrLater()) {
audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent);
if (mRemoteControlClient == null) {
......@@ -213,7 +214,7 @@ public class AudioService extends Service {
RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
} else if (Util.isFroyoOrLater()) {
} else if (LibVlcUtil.isFroyoOrLater()) {
audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent);
}
}
......@@ -226,7 +227,7 @@ public class AudioService extends Service {
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setRemoteControlClientPlaybackState(int state) {
if(!Util.isICSOrLater() || mRemoteControlClient == null)
if (!LibVlcUtil.isICSOrLater() || mRemoteControlClient == null)
return;
switch (state) {
......@@ -268,7 +269,7 @@ public class AudioService extends Service {
@TargetApi(Build.VERSION_CODES.FROYO)
private void changeAudioFocus(boolean gain) {
if(!Util.isFroyoOrLater()) // NOP if not supported
if (!LibVlcUtil.isFroyoOrLater()) // NOP if not supported
return;
if (audioFocusListener == null) {
......@@ -678,7 +679,7 @@ public class AudioService extends Service {
notificationIntent.putExtra(START_FROM_NOTIFICATION, true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (Util.isJellyBeanOrLater()) {
if (LibVlcUtil.isJellyBeanOrLater()) {
Intent iBackward = new Intent(ACTION_REMOTE_BACKWARD);
Intent iPlay = new Intent(ACTION_REMOTE_PLAYPAUSE);
Intent iForward = new Intent(ACTION_REMOTE_FORWARD);
......@@ -719,7 +720,8 @@ public class AudioService extends Service {
else {
builder.setLargeIcon(cover)
.setContentTitle(title)
.setContentText(Util.isJellyBeanOrLater() ? artist : media.getSubtitle())
.setContentText(LibVlcUtil.isJellyBeanOrLater() ? artist
: media.getSubtitle())
.setContentInfo(album)
.setContentIntent(pendingIntent);
notification = builder.build();
......@@ -857,7 +859,7 @@ public class AudioService extends Service {
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
if(!Util.isICSOrLater()) // NOP check
if (!LibVlcUtil.isICSOrLater()) // NOP check
return;
Media media = getCurrentMedia();
......
......@@ -41,6 +41,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import android.content.Context;
......@@ -69,7 +70,8 @@ public class Util {
devicesWithoutNavBar.add("HTC One S");
devicesWithoutNavBar.add("HTC One X");
devicesWithoutNavBar.add("HTC One XL");
hasNavBar = isICSOrLater() && !devicesWithoutNavBar.contains(android.os.Build.MODEL);
hasNavBar = LibVlcUtil.isICSOrLater()
&& !devicesWithoutNavBar.contains(android.os.Build.MODEL);
}
public static LibVLC getLibVlcInstance() throws LibVlcException {
......@@ -392,36 +394,6 @@ public class Util {
);
}
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;
}
public static boolean isICSOrLater()
{
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
}
public static boolean isJellyBeanOrLater()
{
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN;
}
public static boolean isJellyBeanMR1OrLater()
{
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES. JELLY_BEAN_MR1;
}
public static boolean hasExternalStorage() {
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
}
......
......@@ -21,6 +21,7 @@
package org.videolan.vlc.gui;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.vlc.AudioService;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.BitmapCache;
......@@ -212,18 +213,18 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
// Audio output
ListPreference aoutPref = (ListPreference) findPreference("aout");
int aoutEntriesId = Util.isGingerbreadOrLater() ? R.array.aouts : R.array.aouts_froyo;
int aoutEntriesIdValues = Util.isGingerbreadOrLater() ? R.array.aouts_values : R.array.aouts_values_froyo;
int aoutEntriesId = LibVlcUtil.isGingerbreadOrLater() ? R.array.aouts : R.array.aouts_froyo;
int aoutEntriesIdValues = LibVlcUtil.isGingerbreadOrLater() ? R.array.aouts_values : R.array.aouts_values_froyo;
aoutPref.setEntries(aoutEntriesId);
aoutPref.setEntryValues(aoutEntriesIdValues);
if (aoutPref.getValue() == null)
aoutPref.setValue(Util.isGingerbreadOrLater()
aoutPref.setValue(LibVlcUtil.isGingerbreadOrLater()
? "2"/*AOUT_OPENSLES*/
: "0"/*AOUT_AUDIOTRACK_JAVA*/);
// Video output
ListPreference voutPref = (ListPreference) findPreference("vout");
int voutEntriesId = Util.isGingerbreadOrLater() ? R.array.vouts : R.array.vouts_froyo;
int voutEntriesIdValues = Util.isGingerbreadOrLater() ? R.array.vouts_values : R.array.vouts_values_froyo;
int voutEntriesId = LibVlcUtil.isGingerbreadOrLater() ? R.array.vouts : R.array.vouts_froyo;
int voutEntriesIdValues = LibVlcUtil.isGingerbreadOrLater() ? R.array.vouts_values : R.array.vouts_values_froyo;
voutPref.setEntries(voutEntriesId);
voutPref.setEntryValues(voutEntriesIdValues);
if (voutPref.getValue() == null)
......
......@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.MediaLibrary;
......@@ -46,15 +47,15 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.TabHost;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;
......@@ -102,6 +103,7 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
mMediaLibrary = MediaLibrary.getInstance(getActivity());
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
updateList();
......@@ -340,7 +342,7 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
if (!Util.isHoneycombOrLater()) {
if (!LibVlcUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
......
......@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.MediaLibrary;
......@@ -54,13 +55,13 @@ import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.PopupMenu;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import com.actionbarsherlock.app.SherlockFragment;
......@@ -401,7 +402,7 @@ public class AudioBrowserFragment extends SherlockFragment {
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
if (!Util.isHoneycombOrLater()) {
if (!LibVlcUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
......
......@@ -106,7 +106,7 @@ public class AudioUtil {
@SuppressLint("NewApi")
public static void prepareCacheFolder(Context context) {
if (Util.isFroyoOrLater() && Util.hasExternalStorage() && context.getExternalCacheDir() != null)
if (LibVlcUtil.isFroyoOrLater() && Util.hasExternalStorage() && context.getExternalCacheDir() != null)
CACHE_DIR = context.getExternalCacheDir().getPath();
else
CACHE_DIR = Environment.getExternalStorageDirectory().getPath() + "/Android/data/" + context.getPackageName() + "/cache";
......
......@@ -26,6 +26,7 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import org.videolan.android.ui.SherlockGridFragment;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.MediaDatabase;
......@@ -326,7 +327,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onContextPopupMenu(View anchor, final int position) {
if (!Util.isHoneycombOrLater()) {
if (!LibVlcUtil.isHoneycombOrLater()) {
// Call the "classic" context menu
anchor.performLongClick();
return;
......
......@@ -41,6 +41,7 @@ import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.MediaDatabase;
......@@ -216,7 +217,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
setContentView(R.layout.player);
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
if(Util.isICSOrLater())
if (LibVlcUtil.isICSOrLater())
getWindow().getDecorView().findViewById(android.R.id.content).setOnSystemUiVisibilityChangeListener(
new OnSystemUiVisibilityChangeListener() {
@Override
......@@ -280,7 +281,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mSurfaceHolder = mSurface.getHolder();
mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
String chroma = pref.getString("chroma_format", "");
if(Util.isGingerbreadOrLater() && chroma.equals("YV12")) {
if(LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) {
mSurfaceHolder.setFormat(ImageFormat.YV12);
} else if (chroma.equals("RV16")) {
mSurfaceHolder.setFormat(PixelFormat.RGB_565);
......@@ -340,7 +341,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
? mScreenOrientation
: getScreenOrientation());
if (Util.isJellyBeanMR1OrLater()) {
if (LibVlcUtil.isJellyBeanMR1OrLater()) {
// Get the media router service (miracast)
mMediaRouter = (MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE);
mMediaRouterCallback = new MediaRouter.SimpleCallback() {
......@@ -491,7 +492,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}
}
if (Util.isJellyBeanMR1OrLater()) {
if (LibVlcUtil.isJellyBeanMR1OrLater()) {
updatePresentation();
}
}
......@@ -688,7 +689,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
@TargetApi(Build.VERSION_CODES.FROYO)
private void changeAudioFocus(boolean gain) {
if(!Util.isFroyoOrLater()) // NOP if not supported
if(!LibVlcUtil.isFroyoOrLater()) // NOP if not supported
return;
if (mAudioFocusListener == null) {
......@@ -1493,10 +1494,10 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void dimStatusBar(boolean dim) {
if (!Util.isHoneycombOrLater() || !Util.hasNavBar())
if (!LibVlcUtil.isHoneycombOrLater() || !Util.hasNavBar())
return;
int layout = 0;
if (!Util.hasCombBar() && Util.isJellyBeanOrLater())
if (!Util.hasCombBar() && LibVlcUtil.isJellyBeanOrLater())
layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
int visibility = (dim ? (Util.hasCombBar()
? View.SYSTEM_UI_FLAG_LOW_PROFILE
......@@ -1921,7 +1922,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mSurfaceHolder = mSurface.getHolder();
mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);
String chroma = pref.getString("chroma_format", "");
if(Util.isGingerbreadOrLater() && chroma.equals("YV12")) {
if(LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) {
mSurfaceHolder.setFormat(ImageFormat.YV12);
} else if (chroma.equals("RV16")) {
mSurfaceHolder.setFormat(PixelFormat.RGB_565);
......
......@@ -20,8 +20,8 @@
package org.videolan.vlc.widget;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import android.annotation.TargetApi;
import android.app.PendingIntent;
......@@ -77,7 +77,7 @@ public class VLCAppWidgetProvider extends AppWidgetProvider {
}
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.vlcwidget);
boolean partial = Util.isHoneycombOrLater();
boolean partial = LibVlcUtil.isHoneycombOrLater();
if (ACTION_WIDGET_INIT.equals(action) || !partial) {
/* commands */
......
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