Use new android R APIs for hiding insets

This commit is contained in:
Billy Laws 2020-07-06 21:47:23 +01:00 committed by ◱ PixelyIon
parent 1e484a7766
commit b1e15efbab
3 changed files with 22 additions and 16 deletions

View File

@ -43,11 +43,6 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="emu.skyline.SettingsActivity" />
</activity>
<activity android:name="emu.skyline.preference.LicenseDialog">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="emu.skyline.SettingsActivity" />
</activity>
<activity
android:name="emu.skyline.EmulationActivity"
android:configChanges="orientation|screenSize"

View File

@ -8,12 +8,11 @@ package emu.skyline
import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.ParcelFileDescriptor
import android.util.Log
import android.view.Surface
import android.view.SurfaceHolder
import android.view.View
import android.view.*
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import emu.skyline.loader.getRomFormat
@ -121,12 +120,18 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback {
setContentView(R.layout.emu_activity)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.navigationBars() or WindowInsets.Type.systemBars() or WindowInsets.Type.systemGestures() or WindowInsets.Type.statusBars())
window.insetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
val preference = File("${applicationInfo.dataDir}/shared_prefs/${applicationInfo.packageName}_preferences.xml")
preferenceFd = ParcelFileDescriptor.open(preference, ParcelFileDescriptor.MODE_READ_WRITE)

View File

@ -10,6 +10,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Build
import android.os.ParcelFileDescriptor
import android.provider.OpenableColumns
import android.view.Surface
@ -104,8 +105,13 @@ class AppEntry : Serializable {
if (author != null)
output.writeUTF(author)
output.writeBoolean(icon != null)
if (icon != null)
if (icon != null) {
@Suppress("DEPRECATION")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
icon!!.compress(Bitmap.CompressFormat.WEBP_LOSSY, 100, output)
else
icon!!.compress(Bitmap.CompressFormat.WEBP, 100, output)
}
}
/**