From ee8c055641cafcd59b1951c7dde198a0ee681ce7 Mon Sep 17 00:00:00 2001 From: lynxnb Date: Wed, 9 Nov 2022 12:48:48 +0100 Subject: [PATCH] Make `GpuDriverInstallResult` PascalCase --- .../skyline/preference/GpuDriverActivity.kt | 14 +++++----- .../java/emu/skyline/utils/GpuDriverHelper.kt | 26 +++++++++---------- .../main/java/emu/skyline/utils/ZipUtils.kt | 1 - 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/emu/skyline/preference/GpuDriverActivity.kt b/app/src/main/java/emu/skyline/preference/GpuDriverActivity.kt index 48944b22..5d1741e7 100644 --- a/app/src/main/java/emu/skyline/preference/GpuDriverActivity.kt +++ b/app/src/main/java/emu/skyline/preference/GpuDriverActivity.kt @@ -59,7 +59,7 @@ class GpuDriverActivity : AppCompatActivity() { val result = GpuDriverHelper.installDriver(this@GpuDriverActivity, fileStream) runOnUiThread { Snackbar.make(binding.root, resolveInstallResultString(result), Snackbar.LENGTH_LONG).show() - if (result == GpuDriverInstallResult.SUCCESS) + if (result == GpuDriverInstallResult.Success) populateAdapter() } } @@ -185,11 +185,11 @@ class GpuDriverActivity : AppCompatActivity() { } private fun resolveInstallResultString(result : GpuDriverInstallResult) = when (result) { - GpuDriverInstallResult.SUCCESS -> getString(R.string.gpu_driver_install_success) - GpuDriverInstallResult.INVALID_ARCHIVE -> getString(R.string.gpu_driver_install_invalid_archive) - GpuDriverInstallResult.MISSING_METADATA -> getString(R.string.gpu_driver_install_missing_metadata) - GpuDriverInstallResult.INVALID_METADATA -> getString(R.string.gpu_driver_install_invalid_metadata) - GpuDriverInstallResult.UNSUPPORTED_ANDROID_VERSION -> getString(R.string.gpu_driver_install_unsupported_android_version) - GpuDriverInstallResult.ALREADY_INSTALLED -> getString(R.string.gpu_driver_install_already_installed) + GpuDriverInstallResult.Success -> getString(R.string.gpu_driver_install_success) + GpuDriverInstallResult.InvalidArchive -> getString(R.string.gpu_driver_install_invalid_archive) + GpuDriverInstallResult.MissingMetadata -> getString(R.string.gpu_driver_install_missing_metadata) + GpuDriverInstallResult.InvalidMetadata -> getString(R.string.gpu_driver_install_invalid_metadata) + GpuDriverInstallResult.UnsupportedAndroidVersion -> getString(R.string.gpu_driver_install_unsupported_android_version) + GpuDriverInstallResult.AlreadyInstalled -> getString(R.string.gpu_driver_install_already_installed) } } diff --git a/app/src/main/java/emu/skyline/utils/GpuDriverHelper.kt b/app/src/main/java/emu/skyline/utils/GpuDriverHelper.kt index 392a6c05..bade4be1 100644 --- a/app/src/main/java/emu/skyline/utils/GpuDriverHelper.kt +++ b/app/src/main/java/emu/skyline/utils/GpuDriverHelper.kt @@ -104,7 +104,7 @@ interface GpuDriverHelper { } catch (e : Exception) { e.printStackTrace() installTempDir.deleteRecursively() - return GpuDriverInstallResult.INVALID_ARCHIVE + return GpuDriverInstallResult.InvalidArchive } return installUnpackedDriver(context, installTempDir) @@ -125,7 +125,7 @@ interface GpuDriverHelper { } catch (e : Exception) { e.printStackTrace() installTempDir.deleteRecursively() - return GpuDriverInstallResult.INVALID_ARCHIVE + return GpuDriverInstallResult.InvalidArchive } return installUnpackedDriver(context, installTempDir) @@ -145,7 +145,7 @@ interface GpuDriverHelper { val metadataFile = File(unpackDir, GPU_DRIVER_META_FILE) if (!metadataFile.isFile) { cleanup() - return GpuDriverInstallResult.MISSING_METADATA + return GpuDriverInstallResult.MissingMetadata } // Check that the driver metadata is valid @@ -153,13 +153,13 @@ interface GpuDriverHelper { GpuDriverMetadata.deserialize(metadataFile) } catch (e : SerializationException) { cleanup() - return GpuDriverInstallResult.INVALID_METADATA + return GpuDriverInstallResult.InvalidMetadata } // Check that the device satisfies the driver's minimum Android version requirements if (Build.VERSION.SDK_INT < driverMetadata.minApi) { cleanup() - return GpuDriverInstallResult.UNSUPPORTED_ANDROID_VERSION + return GpuDriverInstallResult.UnsupportedAndroidVersion } // Check that the driver is not already installed @@ -167,7 +167,7 @@ interface GpuDriverHelper { val finalInstallDir = File(getDriversDirectory(context), driverMetadata.label) if (installedDrivers[finalInstallDir] != null) { cleanup() - return GpuDriverInstallResult.ALREADY_INSTALLED + return GpuDriverInstallResult.AlreadyInstalled } // Move the driver files to the final location @@ -176,7 +176,7 @@ interface GpuDriverHelper { throw IOException("Failed to create directory ${finalInstallDir.name}") } - return GpuDriverInstallResult.SUCCESS + return GpuDriverInstallResult.Success } /** @@ -216,10 +216,10 @@ interface GpuDriverHelper { } enum class GpuDriverInstallResult { - SUCCESS, - INVALID_ARCHIVE, - MISSING_METADATA, - INVALID_METADATA, - UNSUPPORTED_ANDROID_VERSION, - ALREADY_INSTALLED, + Success, + InvalidArchive, + MissingMetadata, + InvalidMetadata, + UnsupportedAndroidVersion, + AlreadyInstalled, } diff --git a/app/src/main/java/emu/skyline/utils/ZipUtils.kt b/app/src/main/java/emu/skyline/utils/ZipUtils.kt index 46caf9e7..9b4c3b6e 100644 --- a/app/src/main/java/emu/skyline/utils/ZipUtils.kt +++ b/app/src/main/java/emu/skyline/utils/ZipUtils.kt @@ -6,7 +6,6 @@ package emu.skyline.utils import java.io.* -import java.lang.reflect.Field import java.util.zip.ZipEntry import java.util.zip.ZipFile import java.util.zip.ZipInputStream