mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Wrap some android code in api version checks
This commit is contained in:
parent
dd1fc5f3da
commit
c9218bbd23
@ -49,6 +49,7 @@ public class RetroActivityCommon extends RetroActivityLocation
|
||||
long[] pattern = {16};
|
||||
int[] strengths = {strength};
|
||||
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||
if (id == -1)
|
||||
vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
|
||||
else
|
||||
@ -58,6 +59,7 @@ public class RetroActivityCommon extends RetroActivityLocation
|
||||
if (dev != null)
|
||||
vibrator = dev.getVibrator();
|
||||
}
|
||||
}
|
||||
|
||||
if (vibrator == null)
|
||||
return;
|
||||
@ -72,7 +74,7 @@ public class RetroActivityCommon extends RetroActivityLocation
|
||||
else
|
||||
pattern[0] = 1000;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
if (id >= 0)
|
||||
Log.i("RetroActivity", "Vibrate id " + id + ": strength " + strength);
|
||||
|
||||
|
@ -40,6 +40,8 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
}
|
||||
|
||||
private boolean addPermission(List<String> permissionsList, String permission)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
{
|
||||
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
@ -49,13 +51,14 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
if (!shouldShowRequestPermissionRationale(permission))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkRuntimePermissions()
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= 23)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
{
|
||||
// Android 6.0+ needs runtime permission checks
|
||||
List<String> permissionsNeeded = new ArrayList<String>();
|
||||
@ -89,6 +92,8 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
if (which == AlertDialog.BUTTON_POSITIVE)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
{
|
||||
requestPermissions(permissionsList.toArray(new String[permissionsList.size()]),
|
||||
REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
|
||||
@ -96,6 +101,7 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
Log.i("MainMenuActivity", "User accepted request for external storage permissions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -40,6 +40,8 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
|
||||
// Check for Android UI specific parameters
|
||||
Intent retro = getIntent();
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
String refresh = retro.getStringExtra("REFRESH");
|
||||
|
||||
// If REFRESH parameter is provided then try to set refreshrate accordingly
|
||||
@ -48,6 +50,7 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
params.preferredRefreshRate = Integer.parseInt(refresh);
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
// If QUITFOCUS parameter is provided then enable that Retroarch quits when focus is lost
|
||||
quitfocus = retro.hasExtra("QUITFOCUS");
|
||||
@ -61,6 +64,7 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
|
||||
public void hideMouseCursor() {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||
// Check for NVIDIA extensions and minimum SDK version
|
||||
Method mInputManager_setCursorVisibility;
|
||||
try { mInputManager_setCursorVisibility =
|
||||
@ -76,6 +80,7 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
catch (InvocationTargetException ite) { }
|
||||
catch (IllegalAccessException iae) { }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
Loading…
Reference in New Issue
Block a user