mirror of
https://github.com/rafaelvcaetano/melonDS-android.git
synced 2024-11-27 15:40:27 +00:00
Merge branch 'rafaelvcaetano:master' into master
This commit is contained in:
commit
a847357a3c
@ -59,7 +59,7 @@ class RewindPreferencesFragment : MasterSwitchPreferenceFragment(), PreferenceFr
|
||||
val maximumRewindStates = rewindWindow / rewindPeriod
|
||||
// Assume 20MB per save state
|
||||
val maximumMemoryUsage = SizeUnit.MB(20) * maximumRewindStates
|
||||
val memoryUsageRepresentation = SizeUtils.getBestSizeStringRepresentation(maximumMemoryUsage, 2)
|
||||
val memoryUsageRepresentation = SizeUtils.getBestSizeStringRepresentation(requireContext(), maximumMemoryUsage, 2)
|
||||
|
||||
val summaryStringBuilder = StringBuilder()
|
||||
summaryStringBuilder.append(getString(R.string.rewind_max_memory_usage, memoryUsageRepresentation))
|
||||
|
@ -55,13 +55,13 @@ class RomsPreferencesFragment : PreferenceFragmentCompat(), PreferenceFragmentTi
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
viewModel.getRomCacheSize().observe(viewLifecycleOwner) {
|
||||
val cacheSizeRepresentation = SizeUtils.getBestSizeStringRepresentation(it)
|
||||
val cacheSizeRepresentation = SizeUtils.getBestSizeStringRepresentation(requireContext(), it)
|
||||
clearRomCachePreference.summary = getString(R.string.cache_size, cacheSizeRepresentation)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateMaxCacheSizePreferenceSummary(maxCacheSizePreference: SeekBarPreference, cacheSizeStep: Int) {
|
||||
val cacheSize = SizeUnit.MB(128) * 2.toDouble().pow(cacheSizeStep).toLong()
|
||||
maxCacheSizePreference.summary = SizeUtils.getBestSizeStringRepresentation(cacheSize)
|
||||
maxCacheSizePreference.summary = SizeUtils.getBestSizeStringRepresentation(requireContext(), cacheSize)
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package me.magnum.melonds.utils
|
||||
|
||||
import android.content.Context
|
||||
import me.magnum.melonds.R
|
||||
import me.magnum.melonds.domain.model.SizeUnit
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
@ -8,18 +10,18 @@ typealias SizeRepresentation = Pair<Double, String>
|
||||
|
||||
object SizeUtils {
|
||||
|
||||
fun getBestSizeStringRepresentation(size: SizeUnit, decimalPlaces: Int = 0): String {
|
||||
val (sizeValue, sizeUnits) = getBestSizeRepresentation(size)
|
||||
fun getBestSizeStringRepresentation(context: Context, size: SizeUnit, decimalPlaces: Int = 0): String {
|
||||
val (sizeValue, sizeUnits) = getBestSizeRepresentation(context, size)
|
||||
val sizeDecimal = BigDecimal(sizeValue).setScale(decimalPlaces, RoundingMode.HALF_EVEN)
|
||||
return "${sizeDecimal}${sizeUnits}"
|
||||
}
|
||||
|
||||
fun getBestSizeRepresentation(size: SizeUnit): SizeRepresentation {
|
||||
fun getBestSizeRepresentation(context: Context, size: SizeUnit): SizeRepresentation {
|
||||
return when(size.toBestRepresentation()) {
|
||||
is SizeUnit.Bytes -> size.toBytes().toDouble() to "B"
|
||||
is SizeUnit.KB -> size.toKB() to "KB"
|
||||
is SizeUnit.MB -> size.toMB() to "MB"
|
||||
is SizeUnit.GB -> size.toGB() to "GB"
|
||||
is SizeUnit.Bytes -> size.toBytes().toDouble() to context.getString(R.string.size_bytes)
|
||||
is SizeUnit.KB -> size.toKB() to context.getString(R.string.size_kb)
|
||||
is SizeUnit.MB -> size.toMB() to context.getString(R.string.size_mb)
|
||||
is SizeUnit.GB -> size.toGB() to context.getString(R.string.size_gb)
|
||||
}
|
||||
}
|
||||
}
|
@ -26,6 +26,11 @@
|
||||
<string name="console_ds_full">Nintendo DS</string>
|
||||
<string name="console_dsi_full">Nintendo DSi</string>
|
||||
|
||||
<string name="size_bytes">B</string>
|
||||
<string name="size_kb">KB</string>
|
||||
<string name="size_mb">MB</string>
|
||||
<string name="size_gb">GB</string>
|
||||
|
||||
<string name="error_rom_not_found">Could not find ROM</string>
|
||||
<string name="error_rom_not_found_info">The ROM you have selected has not been found. Make sure the selected ROM can be found in the current ROM search directory.</string>
|
||||
<string name="error_load_rom">Could not load ROM</string>
|
||||
@ -96,6 +101,8 @@
|
||||
<string name="error_invalid_directory">Invalid directory</string>
|
||||
<string name="error_invalid_directory_description">It\'s not possible to write to the selected directory. Please select a different one. If you are selecting a compressed file, try extracting its contents.</string>
|
||||
<string name="no_roms_found">No ROMs found</string>
|
||||
<string name="dsiware_title_cannot_be_launched_directly_title">DSiWare titles cannot be launched</string>
|
||||
<string name="dsiware_title_cannot_be_launched_directly_message">DSiWare titles cannot be launched directly. They must be installed to the NAND (through the DSiWare Manager)</string>
|
||||
|
||||
<string name="press_any_button">Press any button…</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user