mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-04-27 21:45:09 -06:00
Android: Bug fix for incorrect screen size detection (#1495)
This commit is contained in:
parent
b1717b6fc2
commit
48cbeb0993
@ -44,7 +44,6 @@ import org.citra.citra_emu.utils.BirthdayMonth
|
||||
import org.citra.citra_emu.utils.Log
|
||||
import org.citra.citra_emu.utils.SystemSaveGame
|
||||
import org.citra.citra_emu.utils.ThemeUtil
|
||||
import org.citra.citra_emu.utils.EmulationMenuSettings
|
||||
|
||||
class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) {
|
||||
private var menuTag: String? = null
|
||||
@ -111,20 +110,24 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
}
|
||||
|
||||
/** Returns the portrait mode width */
|
||||
private fun getWidth(): Int {
|
||||
val dm = Resources.getSystem().displayMetrics;
|
||||
return if (dm.widthPixels < dm.heightPixels)
|
||||
dm.widthPixels
|
||||
else
|
||||
dm.heightPixels
|
||||
private fun getDimensions(): IntArray {
|
||||
val dm = Resources.getSystem().displayMetrics
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val wm = settingsActivity.windowManager.maximumWindowMetrics
|
||||
val height = wm.bounds.height().coerceAtLeast(dm.heightPixels)
|
||||
val width = wm.bounds.width().coerceAtLeast(dm.widthPixels)
|
||||
intArrayOf(width, height)
|
||||
} else {
|
||||
intArrayOf(dm.widthPixels, dm.heightPixels)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getHeight(): Int {
|
||||
val dm = Resources.getSystem().displayMetrics;
|
||||
return if (dm.widthPixels < dm.heightPixels)
|
||||
dm.heightPixels
|
||||
else
|
||||
dm.widthPixels
|
||||
private fun getSmallerDimension(): Int {
|
||||
return getDimensions().min()
|
||||
}
|
||||
|
||||
private fun getLargerDimension(): Int {
|
||||
return getDimensions().max()
|
||||
}
|
||||
|
||||
private fun addConfigSettings(sl: ArrayList<SettingsItem>) {
|
||||
@ -1405,7 +1408,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_x,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_TOP_X.key,
|
||||
IntSetting.LANDSCAPE_TOP_X.defaultValue.toFloat()
|
||||
@ -1417,7 +1420,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_y,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_TOP_Y.key,
|
||||
IntSetting.LANDSCAPE_TOP_Y.defaultValue.toFloat()
|
||||
@ -1429,7 +1432,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_width,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_TOP_WIDTH.key,
|
||||
IntSetting.LANDSCAPE_TOP_WIDTH.defaultValue.toFloat()
|
||||
@ -1441,7 +1444,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_height,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_TOP_HEIGHT.key,
|
||||
IntSetting.LANDSCAPE_TOP_HEIGHT.defaultValue.toFloat()
|
||||
@ -1454,7 +1457,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_x,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_BOTTOM_X.key,
|
||||
IntSetting.LANDSCAPE_BOTTOM_X.defaultValue.toFloat()
|
||||
@ -1466,7 +1469,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_y,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_BOTTOM_Y.key,
|
||||
IntSetting.LANDSCAPE_BOTTOM_Y.defaultValue.toFloat()
|
||||
@ -1478,7 +1481,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_width,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_BOTTOM_WIDTH.key,
|
||||
IntSetting.LANDSCAPE_BOTTOM_WIDTH.defaultValue.toFloat()
|
||||
@ -1490,7 +1493,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_height,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.LANDSCAPE_BOTTOM_HEIGHT.key,
|
||||
IntSetting.LANDSCAPE_BOTTOM_HEIGHT.defaultValue.toFloat()
|
||||
@ -1510,7 +1513,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_x,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_TOP_X.key,
|
||||
IntSetting.PORTRAIT_TOP_X.defaultValue.toFloat()
|
||||
@ -1522,7 +1525,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_y,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_TOP_Y.key,
|
||||
IntSetting.PORTRAIT_TOP_Y.defaultValue.toFloat()
|
||||
@ -1534,7 +1537,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_width,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_TOP_WIDTH.key,
|
||||
IntSetting.PORTRAIT_TOP_WIDTH.defaultValue.toFloat()
|
||||
@ -1546,7 +1549,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_height,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_TOP_HEIGHT.key,
|
||||
IntSetting.PORTRAIT_TOP_HEIGHT.defaultValue.toFloat()
|
||||
@ -1559,7 +1562,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_x,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_BOTTOM_X.key,
|
||||
IntSetting.PORTRAIT_BOTTOM_X.defaultValue.toFloat()
|
||||
@ -1571,7 +1574,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_y,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_BOTTOM_Y.key,
|
||||
IntSetting.PORTRAIT_BOTTOM_Y.defaultValue.toFloat()
|
||||
@ -1583,7 +1586,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_width,
|
||||
0,
|
||||
0,
|
||||
getWidth(),
|
||||
getSmallerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_BOTTOM_WIDTH.key,
|
||||
IntSetting.PORTRAIT_BOTTOM_WIDTH.defaultValue.toFloat()
|
||||
@ -1595,7 +1598,7 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||
R.string.emulation_custom_layout_height,
|
||||
0,
|
||||
0,
|
||||
getHeight(),
|
||||
getLargerDimension(),
|
||||
"px",
|
||||
IntSetting.PORTRAIT_BOTTOM_HEIGHT.key,
|
||||
IntSetting.PORTRAIT_BOTTOM_HEIGHT.defaultValue.toFloat()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user