mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-03-18 19:32:41 +00:00
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:
commit
3bc8ba683b
@ -5,9 +5,7 @@ package org.dolphinemu.dolphinemu.utils
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.LinkAddress
|
||||
import android.os.Build
|
||||
import androidx.annotation.Keep
|
||||
import androidx.annotation.RequiresApi
|
||||
import org.dolphinemu.dolphinemu.DolphinApplication
|
||||
import java.net.Inet4Address
|
||||
import java.net.InetAddress
|
||||
@ -24,7 +22,6 @@ object NetworkHelper {
|
||||
return manager
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun getIPv4Link(): LinkAddress? {
|
||||
val manager = getConnectivityManager() ?: return null
|
||||
val activeNetwork = manager.activeNetwork
|
||||
@ -52,21 +49,18 @@ object NetworkHelper {
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun getNetworkIpAddress(): Int {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
||||
return getIPv4Link()?.address?.inetAddressToInt() ?: 0
|
||||
}
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun getNetworkPrefixLength(): Int {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
||||
return getIPv4Link()?.prefixLength ?: 0
|
||||
}
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun getNetworkGateway(): Int {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return 0
|
||||
val manager = getConnectivityManager() ?: return 0
|
||||
val activeNetwork = manager.activeNetwork ?: return 0
|
||||
val properties = manager.getLinkProperties(activeNetwork) ?: return 0
|
||||
|
||||
@ -26,18 +26,12 @@ public class PermissionsHandler
|
||||
|
||||
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},
|
||||
REQUEST_CODE_WRITE_PERMISSION);
|
||||
}
|
||||
|
||||
public static boolean hasWriteAccess(Context context)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return true;
|
||||
|
||||
if (!isExternalStorageLegacy())
|
||||
return false;
|
||||
|
||||
@ -70,9 +64,6 @@ public class PermissionsHandler
|
||||
|
||||
public static void requestRecordAudioPermission(Activity activity)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return;
|
||||
|
||||
if (activity == null)
|
||||
{
|
||||
// Calling from C++ code
|
||||
|
||||
@ -45,12 +45,6 @@ object ThemeHelper {
|
||||
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) {
|
||||
@ -168,12 +162,7 @@ object ThemeHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun setStatusBarColor(activity: AppCompatActivity, @ColorInt color: Int) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
activity.window.statusBarColor =
|
||||
ContextCompat.getColor(activity.applicationContext, android.R.color.black)
|
||||
} else {
|
||||
activity.window.statusBarColor = color
|
||||
}
|
||||
activity.window.statusBarColor = color
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
Loading…
Reference in New Issue
Block a user