android: Convert memory sizes to resource
This commit is contained in:
parent
699e78c666
commit
8b841aa7ba
|
@ -109,9 +109,9 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this,
|
this,
|
||||||
getString(
|
getString(
|
||||||
R.string.device_memory_inadequate_description,
|
R.string.device_memory_inadequate,
|
||||||
memoryUtil.getDeviceRAM(),
|
memoryUtil.getDeviceRAM(),
|
||||||
"8 GB"
|
"8 ${getString(R.string.memory_gigabyte)}"
|
||||||
),
|
),
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
|
|
|
@ -5,22 +5,23 @@ package org.yuzu.yuzu_emu.utils
|
||||||
|
|
||||||
import android.app.ActivityManager
|
import android.app.ActivityManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import org.yuzu.yuzu_emu.R
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class MemoryUtil(context: Context) {
|
class MemoryUtil(val context: Context) {
|
||||||
|
|
||||||
private val Long.floatForm: String
|
private val Long.floatForm: String
|
||||||
get() = String.format(Locale.ROOT, "%.2f", this.toDouble())
|
get() = String.format(Locale.ROOT, "%.2f", this.toDouble())
|
||||||
|
|
||||||
private fun bytesToSizeUnit(size: Long): String {
|
private fun bytesToSizeUnit(size: Long): String {
|
||||||
return when {
|
return when {
|
||||||
size < Kb -> size.floatForm + " byte"
|
size < Kb -> "${size.floatForm} ${context.getString(R.string.memory_byte)}"
|
||||||
size < Mb -> (size / Kb).floatForm + " KB"
|
size < Mb -> "${(size / Kb).floatForm} ${context.getString(R.string.memory_kilobyte)}"
|
||||||
size < Gb -> (size / Mb).floatForm + " MB"
|
size < Gb -> "${(size / Mb).floatForm} ${context.getString(R.string.memory_megabyte)}"
|
||||||
size < Tb -> (size / Gb).floatForm + " GB"
|
size < Tb -> "${(size / Gb).floatForm} ${context.getString(R.string.memory_gigabyte)}"
|
||||||
size < Pb -> (size / Tb).floatForm + " TB"
|
size < Pb -> "${(size / Tb).floatForm} ${context.getString(R.string.memory_terabyte)}"
|
||||||
size < Eb -> (size / Pb).floatForm + " Pb"
|
size < Eb -> "${(size / Pb).floatForm} ${context.getString(R.string.memory_petabyte)}"
|
||||||
else -> (size / Eb).floatForm + " Eb"
|
else -> "${(size / Eb).floatForm} ${context.getString(R.string.memory_exabyte)}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@
|
||||||
<string name="fatal_error">Fatal Error</string>
|
<string name="fatal_error">Fatal Error</string>
|
||||||
<string name="fatal_error_message">A fatal error occurred. Check the log for details.\nContinuing emulation may result in crashes and bugs.</string>
|
<string name="fatal_error_message">A fatal error occurred. Check the log for details.\nContinuing emulation may result in crashes and bugs.</string>
|
||||||
<string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string>
|
<string name="performance_warning">Turning off this setting will significantly reduce emulation performance! For the best experience, it is recommended that you leave this setting enabled.</string>
|
||||||
<string name="device_memory_inadequate_description">Device RAM: %1$s\nRecommended: %2$s</string>
|
<string name="device_memory_inadequate">Device RAM: %1$s\nRecommended: %2$s</string>
|
||||||
|
|
||||||
<!-- Region Names -->
|
<!-- Region Names -->
|
||||||
<string name="region_japan">Japan</string>
|
<string name="region_japan">Japan</string>
|
||||||
|
@ -301,6 +301,15 @@
|
||||||
<string name="language_traditional_chinese">Traditional Chinese (正體中文)</string>
|
<string name="language_traditional_chinese">Traditional Chinese (正體中文)</string>
|
||||||
<string name="language_brazilian_portuguese">Brazilian Portuguese (Português do Brasil)</string>
|
<string name="language_brazilian_portuguese">Brazilian Portuguese (Português do Brasil)</string>
|
||||||
|
|
||||||
|
<!-- Memory Sizes -->
|
||||||
|
<string name="memory_byte">Byte</string>
|
||||||
|
<string name="memory_kilobyte">KB</string>
|
||||||
|
<string name="memory_megabyte">MB</string>
|
||||||
|
<string name="memory_gigabyte">GB</string>
|
||||||
|
<string name="memory_terabyte">TB</string>
|
||||||
|
<string name="memory_petabyte">PB</string>
|
||||||
|
<string name="memory_exabyte">EB</string>
|
||||||
|
|
||||||
<!-- Renderer APIs -->
|
<!-- Renderer APIs -->
|
||||||
<string name="renderer_vulkan">Vulkan</string>
|
<string name="renderer_vulkan">Vulkan</string>
|
||||||
<string name="renderer_none">None</string>
|
<string name="renderer_none">None</string>
|
||||||
|
|
Loading…
Reference in a new issue