瀏覽代碼

feat: 兼容多窗口,画中画

DoggyZhang 1 月之前
父節點
當前提交
ddecb07343

+ 6 - 4
app/src/main/AndroidManifest.xml

@@ -17,7 +17,8 @@
 
         <activity
             android:name=".MainActivity"
-            android:exported="true">
+            android:exported="true"
+            android:theme="@style/AppTheme">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
@@ -44,13 +45,14 @@
         <activity android:name=".sound.SoundActivity" />
         <activity android:name=".effect.TestAnimViewActivity" />
         <activity android:name=".zxing.ZXingActivity" />
-        <activity android:name="com.journeyapps.barcodescanner.CaptureActivity"
+        <activity
+            android:name="com.journeyapps.barcodescanner.CaptureActivity"
             android:clearTaskOnLaunch="true"
             android:screenOrientation="sensorLandscape"
             android:stateNotNeeded="true"
             android:theme="@style/zxing_CaptureTheme"
-            android:windowSoftInputMode="stateAlwaysHidden"/>
-        <activity android:name=".widget.RippleActivity"/>
+            android:windowSoftInputMode="stateAlwaysHidden" />
+        <activity android:name=".widget.RippleActivity" />
 
     </application>
 

+ 5 - 0
app/src/main/java/com/adealink/frame/MainActivity.kt

@@ -19,6 +19,7 @@ import com.adealink.frame.svga.SvgaEffectActivity
 import com.adealink.frame.svga.recyclerview.SvgaEffectRecyclerViewActivity
 import com.adealink.frame.svga.recyclerview.SvgaRecyclerViewActivity
 import com.adealink.frame.svga.viewpager.SvgaViewpagerActivity
+import com.adealink.frame.util.statusBarHeight
 import com.adealink.frame.vap.VapActivity
 import com.adealink.frame.vap.VapEffectActivity
 import com.adealink.frame.widget.RippleActivity
@@ -30,6 +31,10 @@ class MainActivity : AppCompatActivity() {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_main)
 
+        findViewById<View>(R.id.sv_root)?.setPadding(
+            0, statusBarHeight(), 0, 0
+        )
+
         findViewById<View>(R.id.tv_svga_test).setOnClickListener {
             startActivity(Intent(this, SvgaActivity::class.java))
         }

+ 1 - 0
app/src/main/res/layout/activity_main.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/sv_root"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">

+ 2 - 1
app/src/main/res/values/themes.xml

@@ -14,7 +14,8 @@
         <!-- Customize your theme here. -->
     </style>
 
-    <style name="AppTheme" parent="Theme.AppCompat">
+    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
         <item name="default_dot_style">@style/CommonRedDot</item>
+        <item name="android:windowFullscreen">true</item>
     </style>
 </resources>

+ 1 - 1
frame/bom/build.gradle

@@ -6,7 +6,7 @@ plugins {
 ext {
     GROUP_ID = 'com.wenext.android'
     ARTIFACT_ID = 'frame-bom'
-    VERSION = '6.2.12'
+    VERSION = '6.2.14'
 }
 
 dependencies {

+ 1 - 1
frame/util/build.gradle

@@ -7,7 +7,7 @@ plugins {
 ext {
     GROUP_ID = 'com.wenext.android'
     ARTIFACT_ID = 'frame-util'
-    VERSION = '6.0.8'
+    VERSION = '6.0.10'
 }
 
 if (project.FRAME_DEBUG != "true") {

+ 31 - 2
frame/util/src/main/java/com/adealink/frame/util/ScreenAutoSizeUtil.kt

@@ -6,6 +6,7 @@ import android.content.ComponentCallbacks
 import android.content.res.Configuration
 import android.content.res.Resources
 import android.os.Build
+import android.os.Bundle
 import me.jessyan.autosize.AutoSize
 import me.jessyan.autosize.AutoSizeConfig
 import me.jessyan.autosize.onAdaptListener
@@ -52,6 +53,8 @@ object ScreenAutoSizeUtil {
     //记录当前App是否需要重启
     private var mNeedRestart = false
 
+    private var mCheckNeedRestart = true
+
     /**
      * App会监听Config
      */
@@ -104,7 +107,9 @@ object ScreenAutoSizeUtil {
         //注册配置变化监听
         app.registerComponentCallbacks(object : ComponentCallbacks {
             override fun onConfigurationChanged(newConfig: Configuration) {
-                checkIfNeedRestart(newConfig)
+                if (mCheckNeedRestart) {
+                    checkIfNeedRestart(newConfig)
+                }
             }
 
             override fun onLowMemory() {
@@ -112,9 +117,33 @@ object ScreenAutoSizeUtil {
             }
         })
         AppUtil.registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacksExt {
+
+            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
+                super.onActivityCreated(activity, savedInstanceState)
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+                    if (activity.isInPictureInPictureMode) {
+                        //画中画
+                        mCheckNeedRestart = false
+                        AutoSizeConfig.getInstance().stop(activity)
+                        AutoSizeLog.w("autoSize stop adapt")
+                        return
+                    }
+                    if (activity.isInMultiWindowMode) {
+                        //多窗口
+                        mCheckNeedRestart = false
+                        AutoSizeConfig.getInstance().stop(activity)
+                        AutoSizeLog.w("autoSize stop adapt")
+                        return
+                    }
+                }
+                mCheckNeedRestart = true
+                AutoSizeConfig.getInstance().restart()
+                AutoSizeLog.w("autoSize restart")
+            }
+
             override fun onEnterForeGround() {
                 super.onEnterForeGround()
-                if (needReStart()) {
+                if (mCheckNeedRestart && needReStart()) {
                     AutoSizeLog.d("AppUtil.rebootApp()")
                     AppUtil.rebootApp()
                 }