mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-12 21:17:41 +08:00
@@ -43,9 +43,6 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
tools:replace="android:allowBackup">
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.EnableImpeller"
|
||||
android:value="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
|
||||
@@ -26,12 +26,10 @@ import kotlin.system.exitProcess
|
||||
import java.io.File
|
||||
|
||||
class MainActivity : AudioServiceActivity() {
|
||||
private lateinit var methodChannel: MethodChannel
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
|
||||
methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "PiliPlus")
|
||||
val methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "PiliPlus")
|
||||
methodChannel.setMethodCallHandler { call, result ->
|
||||
when (call.method) {
|
||||
"back" -> back();
|
||||
@@ -174,12 +172,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
"maxScreenSize" -> {
|
||||
maxScreenSize()?.let {
|
||||
result.success(it)
|
||||
}
|
||||
}
|
||||
|
||||
"sdkInt" -> {
|
||||
result.success(Build.VERSION.SDK_INT)
|
||||
}
|
||||
@@ -189,28 +181,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun maxScreenSize(): Map<String, Int>? {
|
||||
try {
|
||||
val density = resources.displayMetrics.density
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val maxBounds = windowManager.maximumWindowMetrics.bounds
|
||||
return mapOf(
|
||||
"maxWidth" to (maxBounds.width() / density).roundToInt(),
|
||||
"maxHeight" to (maxBounds.height() / density).roundToInt(),
|
||||
)
|
||||
} else {
|
||||
val realSizePoint = Point()
|
||||
windowManager.defaultDisplay.getRealSize(realSizePoint)
|
||||
return mapOf(
|
||||
"maxWidth" to (realSizePoint.x / density).roundToInt(),
|
||||
"maxHeight" to (realSizePoint.y / density).roundToInt(),
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun back() {
|
||||
val intent = Intent(Intent.ACTION_MAIN).apply {
|
||||
addCategory(Intent.CATEGORY_HOME)
|
||||
@@ -232,11 +202,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
super.onUserLeaveHint()
|
||||
methodChannel.invokeMethod("onUserLeaveHint", null)
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(
|
||||
isInPictureInPictureMode: Boolean,
|
||||
newConfig: Configuration?
|
||||
|
||||
Reference in New Issue
Block a user