mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 18:10:05 +00:00
android: Show memory warning once
This commit is contained in:
parent
11991fbd7f
commit
ff6d35f2c7
@ -34,11 +34,14 @@ import androidx.core.view.WindowCompat
|
|||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.YuzuApplication
|
||||||
import org.yuzu.yuzu_emu.databinding.ActivityEmulationBinding
|
import org.yuzu.yuzu_emu.databinding.ActivityEmulationBinding
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
|
import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
||||||
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
|
import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
|
||||||
import org.yuzu.yuzu_emu.model.Game
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
|
import org.yuzu.yuzu_emu.utils.ControllerMappingHelper
|
||||||
@ -107,20 +110,26 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||||||
inputHandler = InputHandler()
|
inputHandler = InputHandler()
|
||||||
inputHandler.initialize()
|
inputHandler.initialize()
|
||||||
|
|
||||||
if (MemoryUtil.isLessThan(MemoryUtil.REQUIRED_MEMORY, MemoryUtil.Gb)) {
|
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||||
Toast.makeText(
|
if (!preferences.getBoolean(Settings.PREF_MEMORY_WARNING_SHOWN, false)) {
|
||||||
this,
|
if (MemoryUtil.isLessThan(MemoryUtil.REQUIRED_MEMORY, MemoryUtil.Gb)) {
|
||||||
getString(
|
Toast.makeText(
|
||||||
R.string.device_memory_inadequate,
|
this,
|
||||||
MemoryUtil.getDeviceRAM(),
|
|
||||||
getString(
|
getString(
|
||||||
R.string.memory_formatted,
|
R.string.device_memory_inadequate,
|
||||||
NumberFormat.getInstance().format(MemoryUtil.REQUIRED_MEMORY),
|
MemoryUtil.getDeviceRAM(),
|
||||||
getString(R.string.memory_gigabyte)
|
getString(
|
||||||
)
|
R.string.memory_formatted,
|
||||||
),
|
NumberFormat.getInstance().format(MemoryUtil.REQUIRED_MEMORY),
|
||||||
Toast.LENGTH_LONG
|
getString(R.string.memory_gigabyte)
|
||||||
).show()
|
)
|
||||||
|
),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
preferences.edit()
|
||||||
|
.putBoolean(Settings.PREF_MEMORY_WARNING_SHOWN, true)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a foreground service to prevent the app from getting killed in the background
|
// Start a foreground service to prevent the app from getting killed in the background
|
||||||
|
@ -110,6 +110,8 @@ class Settings {
|
|||||||
const val SECTION_THEME = "Theme"
|
const val SECTION_THEME = "Theme"
|
||||||
const val SECTION_DEBUG = "Debug"
|
const val SECTION_DEBUG = "Debug"
|
||||||
|
|
||||||
|
const val PREF_MEMORY_WARNING_SHOWN = "MemoryWarningShown"
|
||||||
|
|
||||||
const val PREF_OVERLAY_INIT = "OverlayInit"
|
const val PREF_OVERLAY_INIT = "OverlayInit"
|
||||||
const val PREF_CONTROL_SCALE = "controlScale"
|
const val PREF_CONTROL_SCALE = "controlScale"
|
||||||
const val PREF_CONTROL_OPACITY = "controlOpacity"
|
const val PREF_CONTROL_OPACITY = "controlOpacity"
|
||||||
|
Loading…
Reference in New Issue
Block a user