Merge pull request #14454 from Simonx22/android/remove-pre-api24-version-guards
Android: Remove version guards for API levels below 23 (Marshmallow)
This commit is contained in:
@@ -5,9 +5,7 @@ package org.dolphinemu.dolphinemu.utils
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.LinkAddress
|
import android.net.LinkAddress
|
||||||
import android.os.Build
|
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import org.dolphinemu.dolphinemu.DolphinApplication
|
import org.dolphinemu.dolphinemu.DolphinApplication
|
||||||
import java.net.Inet4Address
|
import java.net.Inet4Address
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
@@ -24,7 +22,6 @@ object NetworkHelper {
|
|||||||
return manager
|
return manager
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
private fun getIPv4Link(): LinkAddress? {
|
private fun getIPv4Link(): LinkAddress? {
|
||||||
val manager = getConnectivityManager() ?: return null
|
val manager = getConnectivityManager() ?: return null
|
||||||
val activeNetwork = manager.activeNetwork
|
val activeNetwork = manager.activeNetwork
|
||||||
@@ -52,21 +49,18 @@ object NetworkHelper {
|
|||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNetworkIpAddress(): Int {
|
fun getNetworkIpAddress(): Int {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
|
||||||
return getIPv4Link()?.address?.inetAddressToInt() ?: 0
|
return getIPv4Link()?.address?.inetAddressToInt() ?: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNetworkPrefixLength(): Int {
|
fun getNetworkPrefixLength(): Int {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
|
||||||
return getIPv4Link()?.prefixLength ?: 0
|
return getIPv4Link()?.prefixLength ?: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getNetworkGateway(): Int {
|
fun getNetworkGateway(): Int {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
|
||||||
val manager = getConnectivityManager() ?: return 0
|
val manager = getConnectivityManager() ?: return 0
|
||||||
val activeNetwork = manager.activeNetwork ?: return 0
|
val activeNetwork = manager.activeNetwork ?: return 0
|
||||||
val properties = manager.getLinkProperties(activeNetwork) ?: return 0
|
val properties = manager.getLinkProperties(activeNetwork) ?: return 0
|
||||||
|
|||||||
-9
@@ -26,18 +26,12 @@ public class PermissionsHandler
|
|||||||
|
|
||||||
public static void requestWritePermission(final FragmentActivity activity)
|
public static void requestWritePermission(final FragmentActivity activity)
|
||||||
{
|
{
|
||||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
|
||||||
return;
|
|
||||||
|
|
||||||
activity.requestPermissions(new String[]{WRITE_EXTERNAL_STORAGE},
|
activity.requestPermissions(new String[]{WRITE_EXTERNAL_STORAGE},
|
||||||
REQUEST_CODE_WRITE_PERMISSION);
|
REQUEST_CODE_WRITE_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasWriteAccess(Context context)
|
public static boolean hasWriteAccess(Context context)
|
||||||
{
|
{
|
||||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!isExternalStorageLegacy())
|
if (!isExternalStorageLegacy())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -70,9 +64,6 @@ public class PermissionsHandler
|
|||||||
|
|
||||||
public static void requestRecordAudioPermission(Activity activity)
|
public static void requestRecordAudioPermission(Activity activity)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (activity == null)
|
if (activity == null)
|
||||||
{
|
{
|
||||||
// Calling from C++ code
|
// Calling from C++ code
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ object ThemeHelper {
|
|||||||
activity.setTheme(R.style.ThemeOverlay_Dolphin_Dark)
|
activity.setTheme(R.style.ThemeOverlay_Dolphin_Dark)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since the top app bar matches the color of the status bar, devices below API 23 have to get a
|
|
||||||
// black status bar since their icons do not adapt based on background color
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
activity.window.statusBarColor =
|
|
||||||
ContextCompat.getColor(activity.applicationContext, android.R.color.black)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setThemeMode(activity: AppCompatActivity) {
|
private fun setThemeMode(activity: AppCompatActivity) {
|
||||||
@@ -168,12 +162,7 @@ object ThemeHelper {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun setStatusBarColor(activity: AppCompatActivity, @ColorInt color: Int) {
|
fun setStatusBarColor(activity: AppCompatActivity, @ColorInt color: Int) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
activity.window.statusBarColor = color
|
||||||
activity.window.statusBarColor =
|
|
||||||
ContextCompat.getColor(activity.applicationContext, android.R.color.black)
|
|
||||||
} else {
|
|
||||||
activity.window.statusBarColor = color
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
Reference in New Issue
Block a user