fix only bigger than phone can land Orientation
This commit is contained in:
@@ -24,6 +24,7 @@ import com.zhushenwudi.lovelivemusicplayer.native.platform.AndroidShareBridge
|
|||||||
import com.zhushenwudi.lovelivemusicplayer.native.platform.AndroidDesktopLyricController
|
import com.zhushenwudi.lovelivemusicplayer.native.platform.AndroidDesktopLyricController
|
||||||
import com.zhushenwudi.lovelivemusicplayer.native.platform.installAndroidPlatformServices
|
import com.zhushenwudi.lovelivemusicplayer.native.platform.installAndroidPlatformServices
|
||||||
import com.zhushenwudi.lovelivemusicplayer.native.util.AppUtils
|
import com.zhushenwudi.lovelivemusicplayer.native.util.AppUtils
|
||||||
|
import com.zhushenwudi.lovelivemusicplayer.native.util.applyScreenOrientationPolicy
|
||||||
import com.zhushenwudi.lovelivemusicplayer.platform.AndroidUiHost
|
import com.zhushenwudi.lovelivemusicplayer.platform.AndroidUiHost
|
||||||
import com.zhushenwudi.lovelivemusicplayer.platform.PlatformServices
|
import com.zhushenwudi.lovelivemusicplayer.platform.PlatformServices
|
||||||
import com.zhushenwudi.lovelivemusicplayer.platform.initAndroidFileSystem
|
import com.zhushenwudi.lovelivemusicplayer.platform.initAndroidFileSystem
|
||||||
@@ -36,6 +37,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
applyScreenOrientationPolicy()
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
AndroidUiHost.activity = this
|
AndroidUiHost.activity = this
|
||||||
initAndroidFileSystem(applicationContext)
|
initAndroidFileSystem(applicationContext)
|
||||||
|
|||||||
+4
-1
@@ -5,6 +5,8 @@ import androidx.activity.ComponentActivity
|
|||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
import com.zhushenwudi.lovelivemusicplayer.i18n.I18n
|
import com.zhushenwudi.lovelivemusicplayer.i18n.I18n
|
||||||
|
import com.zhushenwudi.lovelivemusicplayer.native.util.applyScreenOrientationPolicy
|
||||||
|
import com.zhushenwudi.lovelivemusicplayer.native.util.isLargeScreenDevice
|
||||||
import com.zhushenwudi.lovelivemusicplayer.platform.AndroidUiHost
|
import com.zhushenwudi.lovelivemusicplayer.platform.AndroidUiHost
|
||||||
|
|
||||||
class QrScanActivity : ComponentActivity() {
|
class QrScanActivity : ComponentActivity() {
|
||||||
@@ -22,11 +24,12 @@ class QrScanActivity : ComponentActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
applyScreenOrientationPolicy()
|
||||||
val options = ScanOptions().apply {
|
val options = ScanOptions().apply {
|
||||||
setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
||||||
setPrompt(I18n.t("scan_qr_prompt"))
|
setPrompt(I18n.t("scan_qr_prompt"))
|
||||||
setBeepEnabled(false)
|
setBeepEnabled(false)
|
||||||
setOrientationLocked(false)
|
setOrientationLocked(!isLargeScreenDevice())
|
||||||
setCaptureActivity(com.journeyapps.barcodescanner.CaptureActivity::class.java)
|
setCaptureActivity(com.journeyapps.barcodescanner.CaptureActivity::class.java)
|
||||||
}
|
}
|
||||||
barcodeLauncher.launch(options)
|
barcodeLauncher.launch(options)
|
||||||
|
|||||||
+2
@@ -42,6 +42,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import com.zhushenwudi.lovelivemusicplayer.i18n.tr
|
import com.zhushenwudi.lovelivemusicplayer.i18n.tr
|
||||||
|
import com.zhushenwudi.lovelivemusicplayer.native.util.applyScreenOrientationPolicy
|
||||||
import com.zhushenwudi.lovelivemusicplayer.platform.WebViewAdBlock
|
import com.zhushenwudi.lovelivemusicplayer.platform.WebViewAdBlock
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -56,6 +57,7 @@ class WebViewActivity : ComponentActivity() {
|
|||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
applyScreenOrientationPolicy()
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
val url = intent.getStringExtra(EXTRA_URL).orEmpty()
|
val url = intent.getStringExtra(EXTRA_URL).orEmpty()
|
||||||
val title = intent.getStringExtra(EXTRA_TITLE)
|
val title = intent.getStringExtra(EXTRA_TITLE)
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.zhushenwudi.lovelivemusicplayer.native.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
|
|
||||||
|
private const val LARGE_SCREEN_MIN_SMALLEST_WIDTH_DP = 600
|
||||||
|
|
||||||
|
/** 手机固定竖屏;平板和展开后达到大屏阈值的设备遵循系统旋转设置。 */
|
||||||
|
fun Activity.applyScreenOrientationPolicy() {
|
||||||
|
val isLargeScreen = resources.configuration.smallestScreenWidthDp >=
|
||||||
|
LARGE_SCREEN_MIN_SMALLEST_WIDTH_DP
|
||||||
|
val targetOrientation = if (isLargeScreen) {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
|
} else {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
|
if (requestedOrientation != targetOrientation) {
|
||||||
|
requestedOrientation = targetOrientation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 扫码组件使用同一设备分类,避免手机进入扫码页后重新开放旋转。 */
|
||||||
|
fun Activity.isLargeScreenDevice(): Boolean =
|
||||||
|
resources.configuration.smallestScreenWidthDp >= LARGE_SCREEN_MIN_SMALLEST_WIDTH_DP
|
||||||
@@ -167,8 +167,6 @@
|
|||||||
<key>UISupportedInterfaceOrientations</key>
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
</array>
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
<array>
|
<array>
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ targets:
|
|||||||
- remote-notification
|
- remote-notification
|
||||||
UISupportedInterfaceOrientations:
|
UISupportedInterfaceOrientations:
|
||||||
- UIInterfaceOrientationPortrait
|
- UIInterfaceOrientationPortrait
|
||||||
- UIInterfaceOrientationLandscapeLeft
|
|
||||||
- UIInterfaceOrientationLandscapeRight
|
|
||||||
"UISupportedInterfaceOrientations~ipad":
|
"UISupportedInterfaceOrientations~ipad":
|
||||||
- UIInterfaceOrientationPortrait
|
- UIInterfaceOrientationPortrait
|
||||||
- UIInterfaceOrientationLandscapeLeft
|
- UIInterfaceOrientationLandscapeLeft
|
||||||
|
|||||||
Reference in New Issue
Block a user