mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Wrap some android code in api version checks
This commit is contained in:
parent
dd1fc5f3da
commit
c9218bbd23
@ -49,14 +49,16 @@ public class RetroActivityCommon extends RetroActivityLocation
|
||||
long[] pattern = {16};
|
||||
int[] strengths = {strength};
|
||||
|
||||
if (id == -1)
|
||||
vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
|
||||
else
|
||||
{
|
||||
InputDevice dev = InputDevice.getDevice(id);
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
||||
if (id == -1)
|
||||
vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
|
||||
else
|
||||
{
|
||||
InputDevice dev = InputDevice.getDevice(id);
|
||||
|
||||
if (dev != null)
|
||||
vibrator = dev.getVibrator();
|
||||
if (dev != null)
|
||||
vibrator = dev.getVibrator();
|
||||
}
|
||||
}
|
||||
|
||||
if (vibrator == null)
|
||||
@ -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);
|
||||
|
||||
|
@ -41,13 +41,16 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
|
||||
private boolean addPermission(List<String> permissionsList, String permission)
|
||||
{
|
||||
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
|
||||
{
|
||||
permissionsList.add(permission);
|
||||
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
permissionsList.add(permission);
|
||||
|
||||
// Check for Rationale Option
|
||||
if (!shouldShowRequestPermissionRationale(permission))
|
||||
return false;
|
||||
// Check for Rationale Option
|
||||
if (!shouldShowRequestPermissionRationale(permission))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -55,7 +58,7 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
|
||||
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>();
|
||||
@ -90,10 +93,13 @@ public final class MainMenuActivity extends PreferenceActivity
|
||||
{
|
||||
if (which == AlertDialog.BUTTON_POSITIVE)
|
||||
{
|
||||
requestPermissions(permissionsList.toArray(new String[permissionsList.size()]),
|
||||
REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
|
||||
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);
|
||||
|
||||
Log.i("MainMenuActivity", "User accepted request for external storage permissions.");
|
||||
Log.i("MainMenuActivity", "User accepted request for external storage permissions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -40,13 +40,16 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
|
||||
// Check for Android UI specific parameters
|
||||
Intent retro = getIntent();
|
||||
String refresh = retro.getStringExtra("REFRESH");
|
||||
|
||||
// If REFRESH parameter is provided then try to set refreshrate accordingly
|
||||
if(refresh != null) {
|
||||
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.preferredRefreshRate = Integer.parseInt(refresh);
|
||||
getWindow().setAttributes(params);
|
||||
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
|
||||
if(refresh != null) {
|
||||
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.preferredRefreshRate = Integer.parseInt(refresh);
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
// If QUITFOCUS parameter is provided then enable that Retroarch quits when focus is lost
|
||||
@ -61,20 +64,22 @@ public final class RetroActivityFuture extends RetroActivityCamera {
|
||||
|
||||
public void hideMouseCursor() {
|
||||
|
||||
// Check for NVIDIA extensions and minimum SDK version
|
||||
Method mInputManager_setCursorVisibility;
|
||||
try { mInputManager_setCursorVisibility =
|
||||
InputManager.class.getMethod("setCursorVisibility", boolean.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
return; // Extensions were not available so do nothing
|
||||
}
|
||||
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 =
|
||||
InputManager.class.getMethod("setCursorVisibility", boolean.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
return; // Extensions were not available so do nothing
|
||||
}
|
||||
|
||||
// Hide the mouse cursor
|
||||
InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
|
||||
try { mInputManager_setCursorVisibility.invoke(inputManager, false); }
|
||||
catch (InvocationTargetException ite) { }
|
||||
catch (IllegalAccessException iae) { }
|
||||
// Hide the mouse cursor
|
||||
InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
|
||||
try { mInputManager_setCursorVisibility.invoke(inputManager, false); }
|
||||
catch (InvocationTargetException ite) { }
|
||||
catch (IllegalAccessException iae) { }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user