Browse Source

feat: targetSdkVersion 34

tongmengxiao 3 months ago
parent
commit
ed1569a2cd

+ 3 - 3
app/build.gradle

@@ -8,13 +8,13 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
-    buildToolsVersion "33.0.2"
+    compileSdkVersion 34
+    buildToolsVersion "34.0.0"
 
     defaultConfig {
         applicationId "com.swago.app"
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 6115
         versionName "6.1.1.5"
         multiDexEnabled true

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -21,6 +21,7 @@
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
     <uses-permission android:name="android.permission.VIBRATE"/>
     <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
+    <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"/>
     <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
     <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

+ 26 - 1
app/src/main/java/com/swago/app/SplashActivity.kt

@@ -38,7 +38,32 @@ class SplashActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_splash)
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
+            PermissionX.init(this@SplashActivity)
+                .permissions(
+                    Manifest.permission.READ_MEDIA_IMAGES,
+                    Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
+                )
+                .request { allGranted, grantedList, deniedList ->
+                    if (allGranted) {
+                        splashVm.getApiDomain()
+                        splashVm.jumpToLoginLiveData.observe(this){
+                            if (!it){
+                                ARouter.getInstance().build(ARouteConstant.Login.login).navigation()
+                                finish()
+                            }
+                        }
+                    } else {
+                        Toast.makeText(
+                            this@SplashActivity,
+                            getString(com.swago.login.R.string.these_permissions_denied)+" $deniedList",
+                            Toast.LENGTH_LONG
+                        ).show()
+                        ARouter.getInstance().build(ARouteConstant.Login.login).navigation()
+                        finish()
+                    }
+                }
+        }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
             PermissionX.init(this@SplashActivity)
                 .permissions(
                     Manifest.permission.READ_MEDIA_IMAGES,

+ 3 - 3
baseswago/build.gradle

@@ -5,12 +5,12 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
-    buildToolsVersion "33.0.2"
+    compileSdkVersion 34
+    buildToolsVersion "34.0.0"
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"
 

+ 4 - 2
baseswago/src/main/java/com/swago/baseswago/util/DianJiuUtil.kt

@@ -42,8 +42,10 @@ object DianJiuUtil {
     fun ninePatchImageDrawable(context: Context, bitmap: Bitmap, drawable: (e: NinePatchDrawable?) -> Unit) {
         bitmap.density = 480
         val chunk = bitmap.ninePatchChunk
-        if (NinePatch.isNinePatchChunk(chunk)){
-            drawable.invoke(NinePatchDrawable(context.resources,bitmap,chunk,NinePatchChunk.deserialize(chunk)?.mPaddings,null))
+        chunk?.let {
+            if (NinePatch.isNinePatchChunk(chunk)){
+                drawable.invoke(NinePatchDrawable(context.resources,bitmap,chunk,NinePatchChunk.deserialize(chunk)?.mPaddings,null))
+            }
         }
         drawable.invoke(null)
     }

+ 4 - 0
baseswago/src/main/java/com/swago/baseswago/util/FileUtil.kt

@@ -2,6 +2,7 @@ package com.swago.baseswago.util
 
 import android.app.Application
 import android.content.Context
+import android.os.Build
 import java.io.*
 import java.lang.Exception
 import java.util.*
@@ -25,6 +26,9 @@ object FileUtil {
     }
 
     fun upZipFile(zipFile: String, zipUpPath: String) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+            dalvik.system.ZipPathValidator.clearCallback()
+        }
         if (zipFile.isEmpty()) return
         if (!zipFile.endsWith(".zip")) {
             deleteFile(File(zipFile))

+ 2 - 2
home/build.gradle

@@ -5,11 +5,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"
 

+ 2 - 2
lib_country_picker/build.gradle

@@ -4,11 +4,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"
 

+ 2 - 2
login/build.gradle

@@ -5,11 +5,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"
 

+ 63 - 3
login/src/main/java/com/swago/login/LoginActivity.kt

@@ -58,7 +58,25 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
         binding.clFaceBook.setOnClickListener(object : NoDoubleClickListener() {
             override fun onClick() {
                 if (SwagoShareUtils.isInstall(this@LoginActivity,FACEBOOK)){
-                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
+                        PermissionX.init(this@LoginActivity)
+                            .permissions(
+                                Manifest.permission.READ_MEDIA_IMAGES,
+                                Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
+                            )
+                            .request { allGranted, grantedList, deniedList ->
+                                if (allGranted) {
+                                    FBLogin.login(this@LoginActivity)
+                                } else {
+                                    FBLogin.login(this@LoginActivity)
+                                    Toast.makeText(
+                                        this@LoginActivity,
+                                        getString(R.string.these_permissions_denied)+ "$deniedList",
+                                        Toast.LENGTH_LONG
+                                    ).show()
+                                }
+                            }
+                    }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
                         PermissionX.init(this@LoginActivity)
                             .permissions(
                                 Manifest.permission.READ_MEDIA_IMAGES
@@ -102,7 +120,25 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
         binding.clGoogle.setOnClickListener(object : NoDoubleClickListener() {
             override fun onClick() {
                 if (SwagoShareUtils.isInstall(this@LoginActivity,GOOGLE)) {
-                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
+                        PermissionX.init(this@LoginActivity)
+                            .permissions(
+                                Manifest.permission.READ_MEDIA_IMAGES,
+                                Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
+                            )
+                            .request { allGranted, grantedList, deniedList ->
+                                if (allGranted) {
+                                    GoogleLogin.login(this@LoginActivity)
+                                } else {
+                                    GoogleLogin.login(this@LoginActivity)
+                                    Toast.makeText(
+                                        this@LoginActivity,
+                                        getString(R.string.these_permissions_denied)+"$deniedList",
+                                        Toast.LENGTH_LONG
+                                    ).show()
+                                }
+                            }
+                    }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
                         PermissionX.init(this@LoginActivity)
                             .permissions(
                                 Manifest.permission.READ_MEDIA_IMAGES
@@ -183,7 +219,31 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
 
         binding.ivAccountLogin.setOnClickListener(object:NoDoubleClickListener(){
             override fun onClick() {
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
+                    PermissionX.init(this@LoginActivity)
+                        .permissions(
+                            Manifest.permission.READ_MEDIA_IMAGES,
+                            Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED
+                        )
+                        .request { allGranted, grantedList, deniedList ->
+                            if (allGranted) {
+                                SwagoLoading.showLoadingDialog(this@LoginActivity)
+                                val account = binding.etAccount.text.toString()
+                                val secret = binding.etSecret.text.toString()
+                                loginVm.loginByAccount(account, secret)
+                            } else {
+                                SwagoLoading.showLoadingDialog(this@LoginActivity)
+                                val account = binding.etAccount.text.toString()
+                                val secret = binding.etSecret.text.toString()
+                                loginVm.loginByAccount(account, secret)
+                                Toast.makeText(
+                                    this@LoginActivity,
+                                    getString(R.string.these_permissions_denied)+" $deniedList",
+                                    Toast.LENGTH_LONG
+                                ).show()
+                            }
+                        }
+                }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
                     PermissionX.init(this@LoginActivity)
                         .permissions(
                             Manifest.permission.READ_MEDIA_IMAGES

+ 2 - 2
room/build.gradle

@@ -6,11 +6,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"
 

+ 2 - 1
room/src/main/AndroidManifest.xml

@@ -16,7 +16,8 @@
             android:screenOrientation="portrait"/>
         <activity android:name=".music.LocalMusicActivity"
             android:screenOrientation="portrait"/>
-        <service android:name=".service.AgoraForegroundService"/>
+        <service android:name=".service.AgoraForegroundService"
+            android:foregroundServiceType="microphone|camera|mediaPlayback"/>
     </application>
 
 </manifest>

+ 5 - 5
room/src/main/java/com/swago/room/gift/ComboView.kt

@@ -135,17 +135,17 @@ class ComboView : View {
 
     }
 
-    override fun onDraw(canvas: Canvas?) {
+    override fun onDraw(canvas: Canvas) {
         super.onDraw(canvas)
         //画内圆
-        canvas?.drawCircle(centerX,centerY,dp2px(30f),innerPaint)
+        canvas.drawCircle(centerX,centerY,dp2px(30f),innerPaint)
         //画倒计时
 //        canvas?.drawPath(path,anchorPaint)
         //画缩小框
-        canvas?.drawCircle(centerX,centerY,scaleRadius,scalePaint)
+        canvas.drawCircle(centerX,centerY,scaleRadius,scalePaint)
         //画文字
-        canvas?.drawText(combo,centerX-comboRect.width()/2f,dp2px(45f),textComboPaint)
-        canvas?.drawText(time,centerX-timeRect.width()/2f,dp2px(65f),timerPaint)
+        canvas.drawText(combo,centerX-comboRect.width()/2f,dp2px(45f),textComboPaint)
+        canvas.drawText(time,centerX-timeRect.width()/2f,dp2px(65f),timerPaint)
     }
 
     private fun dp2px(value: Float): Float {

+ 10 - 1
room/src/main/java/com/swago/room/service/AgoraForegroundService.java

@@ -6,6 +6,7 @@ import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.app.Service;
 import android.content.Intent;
+import android.content.pm.ServiceInfo;
 import android.graphics.BitmapFactory;
 import android.os.Build;
 import android.os.IBinder;
@@ -96,7 +97,15 @@ public class AgoraForegroundService extends Service {
         // Build the notification.
         Notification notification = builder.build();
         // Start foreground service.
-        startForeground(1, notification);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
+            int serviceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE |
+                    ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA |
+                    ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
+            startForeground(1, notification,serviceTypes);
+        } else {
+            startForeground(1, notification);
+        }
+
     }
 
     private void stopForegroundService() {

+ 2 - 2
tuikit/build.gradle

@@ -1,10 +1,10 @@
 apply plugin: 'com.android.library'
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "5.5.892"
 

+ 2 - 2
user/build.gradle

@@ -5,11 +5,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion 33
+    compileSdkVersion 34
 
     defaultConfig {
         minSdkVersion 21
-        targetSdkVersion 33
+        targetSdkVersion 34
         versionCode 1
         versionName "1.0"