Просмотр исходного кода

1.AGP升级到8.6.0(没有手动替换config文件,如有BUG,需手动改为传统写法)
2.替换播放器为EXO播放器

JaycePC месяцев назад: 11
Родитель
Сommit
e6d23609b4

+ 4 - 6
HttpCoreLibrary/build.gradle

@@ -4,14 +4,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion env.compileSdkVersion
-    buildToolsVersion env.buildToolsVersion
+    compileSdk 34
 
     defaultConfig {
-        minSdkVersion env.minSdkVersion
-        targetSdkVersion env.targetSdkVersion
-        versionCode 1
-        versionName "1.0"
+        minSdkVersion 21
+        targetSdkVersion 34
 
         consumerProguardFiles "consumer-rules.pro"
     }
@@ -29,6 +26,7 @@ android {
     kotlinOptions {
         jvmTarget = '1.8'
     }
+    namespace 'com.rc.httpcore'
 }
 
 dependencies {

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

@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.rc.httpcore">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 
 </manifest>

+ 4 - 6
RcCore/build.gradle

@@ -4,14 +4,11 @@ plugins {
 }
 
 android {
-    compileSdkVersion env.compileSdkVersion
-    buildToolsVersion env.buildToolsVersion
+    compileSdk 34
 
     defaultConfig {
-        minSdkVersion env.minSdkVersion
-        targetSdkVersion env.targetSdkVersion
-        versionCode 1
-        versionName "1.0"
+        minSdkVersion 21
+        targetSdkVersion 34
 
         consumerProguardFiles "consumer-rules.pro"
     }
@@ -32,6 +29,7 @@ android {
     buildFeatures{
         viewBinding = true
     }
+    namespace 'com.rc.core'
 
 }
 

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

@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.rc.core">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 
 </manifest>

+ 6 - 6
app/build.gradle

@@ -4,13 +4,12 @@ plugins {
 }
 
 android {
-    compileSdkVersion env.compileSdkVersion
-    buildToolsVersion env.buildToolsVersion
+    compileSdk 34
 
     defaultConfig {
         applicationId env.applicationId
-        minSdkVersion env.minSdkVersion
-        targetSdkVersion env.targetSdkVersion
+        minSdkVersion 21
+        targetSdkVersion 34
         versionCode env.versionCode
         versionName env.versionName
 
@@ -59,6 +58,7 @@ android {
     viewBinding {
         enabled = true
     }
+    namespace 'com.dlc.exam'
     applicationVariants.all { variant ->
 //        variant.getPackageApplication().outputDirectory = new File("${rootDir.absolutePath}/Apk")
         variant.outputs.all {
@@ -96,8 +96,6 @@ dependencies {
     implementation dep.eventbus
     implementation dep.bgaZxing
 
-    implementation 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
-
     // CameraX core library using the camera2 implementation
     def camerax_version = "1.0.1"
     // The following line is optional, as the core library is included indirectly by camera-camera2
@@ -112,4 +110,6 @@ dependencies {
 
     implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
 
+    implementation 'com.google.android.exoplayer:exoplayer:2.18.1'
+
 }

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

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    package="com.dlc.exam">
+    xmlns:tools="http://schemas.android.com/tools">
 
     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
     <uses-permission android:name="android.permission.INSTALL_PACKAGES" />
@@ -46,7 +45,9 @@
         tools:targetApi="m">
 
 
-        <receiver android:name=".broadcast.BootBroadcastReceiver">
+        <receiver
+            android:name=".broadcast.BootBroadcastReceiver"
+            android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
 
@@ -179,7 +180,9 @@
                 android:resource="@xml/file_paths_public" />
         </provider>
 
-        <receiver android:name=".receiver.OpenApkReceiver">
+        <receiver android:name=".receiver.OpenApkReceiver"
+            android:exported="true"
+            >
             <intent-filter>
                 <action android:name="android.intent.action.PACKAGE_REPLACED" />
 

+ 6 - 40
app/src/main/java/com/dlc/exam/ExamApp.kt

@@ -26,8 +26,6 @@ import com.rc.httpcore.config.ConfigCore
 import com.rc.httpcore.config.ConfigFactory
 import com.rc.httpcore.vo.response.LearnLoginVo
 import com.tencent.bugly.crashreport.CrashReport
-import com.tencent.smtt.sdk.QbSdk
-import com.tencent.smtt.sdk.QbSdk.PreInitCallback
 
 /**
  * info
@@ -38,7 +36,7 @@ class ExamApp : Application() {
 
     companion object {
         @JvmField
-        var sLearnLoginVo : LearnLoginVo? = null
+        var sLearnLoginVo: LearnLoginVo? = null
     }
 
     override fun onCreate() {
@@ -56,7 +54,6 @@ class ExamApp : Application() {
         // 初始化讯飞语音引擎
         initIflytek()
 
-        initX5()
     }
 
     private fun initHttpConfig() {
@@ -71,7 +68,11 @@ class ExamApp : Application() {
             .registerReceiver(object : BroadcastReceiver() {
                 override fun onReceive(context: Context?, intent: Intent?) {
                     if (!topActivityIsSplashActivity()) {
-                        Toast.makeText(applicationContext, "登录过期,请重新登录", Toast.LENGTH_SHORT).show()
+                        Toast.makeText(
+                            applicationContext,
+                            "登录过期,请重新登录",
+                            Toast.LENGTH_SHORT
+                        ).show()
                         mUiHandler.sendEmptyMessageAtTime(1, 1500)
                     }
                 }
@@ -137,39 +138,4 @@ class ExamApp : Application() {
 //        CrashReport.initCrashReport(this, Constants.Bugly.APP_ID, true)
         CrashReport.initCrashReport(this, Constants.Bugly.APP_ID, false)
     }
-
-    private fun initX5() {
-        // TBS服务
-//        HashMap map = new HashMap();
-//        map.put(TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER, true);
-//        map.put(TbsCoreSettings.TBS_SETTINGS_USE_DEXLOADER_SERVICE, true);
-//        QbSdk.initTbsSettings(map);
-//
-//        QbSdk.setDownloadWithoutWifi(true);
-
-        QbSdk.initX5Environment(this, object : QbSdk.PreInitCallback {
-            override fun onCoreInitFinished() {
-                Log.i("LabApp", "onCoreInitFinished")
-            }
-
-            override fun onViewInitFinished(b: Boolean) {
-                // 加载x5内核成功返回值为true,否则返回false,加载失败会调用系统的webview
-                Log.i("LabApp", "x5初始化结果===$b")
-            }
-        })
-//        val cb: PreInitCallback = object : PreInitCallback {
-//            override fun onViewInitFinished(b: Boolean) {
-//                //x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。
-//                Log.d("app", " onViewInitFinished is $b")
-//            }
-//
-//            override fun onCoreInitFinished() {
-//                // TODO Auto-generated method stub
-//            }
-//        }
-//
-//        //x5内核初始化接口
-//        QbSdk.initX5Environment(this, cb)
-    }
-
 }

+ 2 - 2
app/src/main/java/com/dlc/exam/ui/MainActivity.kt

@@ -111,10 +111,10 @@ class MainActivity : BaseCountDownActivity<ActivityMainBinding>(), TitleBar.Titl
 
     private fun dispatchMenuClicked(menuClass: Class<out BaseCountDownActivity<out ViewBinding>>) {
         mMenuClass = menuClass
-        if (isLogin()) {
+//        if (isLogin()) {
             val intent = Intent(this, mMenuClass)
             startActivity(intent)
-        }
+//        }
     }
 
     private fun isLogin(): Boolean {

+ 21 - 9
app/src/main/java/com/dlc/exam/ui/learn/LearnDetailActivity.kt

@@ -16,6 +16,8 @@ import com.dlc.exam.common.CommonUtils
 import com.dlc.exam.databinding.ActivityLearnDetailBinding
 import com.dlc.exam.ui.common.BaseCountDownActivity
 import com.dlc.exam.ui.learn.test.ClassTestActivity
+import com.google.android.exoplayer2.ExoPlayer
+import com.google.android.exoplayer2.MediaItem
 import com.rc.core.log.RcLog
 import com.rc.core.util.EscapeUnescape
 import com.rc.core.util.VideoFullScreenWebChromeClient
@@ -44,6 +46,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
     private var mRelearn = false
     private var mVideoDraggable = false // 视频是否可以拖拽
     private var mAssessStatus = false // 是否需要课后考核
+    private var exoPlayer: ExoPlayer? = null
 
     companion object {
         const val WHAT_LEARN_COUNT_DOWN = 1
@@ -51,6 +54,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
 
     override fun onResume() {
         super.onResume()
+        exoPlayer?.play()
     }
 
     override fun initViews(savedInstanceState: Bundle?) {
@@ -64,6 +68,10 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
         mVideoDraggable = intent.getBooleanExtra("videoDraggable", false)
         mAssessStatus = intent.getBooleanExtra("assessStatus", false)
 
+        exoPlayer = ExoPlayer.Builder(this).build()
+        viewBinding.styledPlayerView.player = exoPlayer
+        viewBinding.styledPlayerView.useController = false
+
         Jzvd.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
         Jzvd.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
 
@@ -150,7 +158,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                 viewBinding.progressbar.visibility = View.VISIBLE
                 viewBinding.unknownFile.visibility = View.INVISIBLE
                 viewBinding.imageContent.visibility = View.INVISIBLE
-                viewBinding.jzVideo.visibility = View.INVISIBLE
+                viewBinding.styledPlayerView.visibility = View.INVISIBLE
                 var s = if (mCurrentChapter.chapterData.startsWith("http")) {
                     mCurrentChapter.chapterData
                 } else {
@@ -172,7 +180,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                 viewBinding.progressbar.visibility = View.GONE
                 viewBinding.unknownFile.visibility = View.GONE
                 viewBinding.imageContent.visibility = View.GONE
-                viewBinding.jzVideo.visibility = View.VISIBLE
+                viewBinding.styledPlayerView.visibility = View.VISIBLE
 
                 var url = if (mCurrentChapter.chapterData.startsWith("http")) {
                     mCurrentChapter.chapterData
@@ -183,9 +191,12 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                     //                        mCurrentChapter.title)
                 }
 //                showToast("视频地址:" + HttpConfig.API_BASE_URL + mCurrentChapter.chapterData)
-                viewBinding.jzVideo.setUp(url, mCurrentChapter.title)
-                viewBinding.jzVideo.setDraggable(mVideoDraggable)
-                viewBinding.jzVideo.startVideoAfterPreloading()
+                val mediaItem = MediaItem.fromUri(url)
+                exoPlayer?.let {
+                    it.setMediaItem(mediaItem)
+                    it.prepare()
+                    it.play()
+                }
 
 //                viewBinding.webView.loadUrl(str)
 //                viewBinding.webView.loadUrl(mCurrentChapter.chapterData)
@@ -209,7 +220,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                 viewBinding.progressbar.visibility = View.INVISIBLE
                 viewBinding.unknownFile.visibility = View.INVISIBLE
                 viewBinding.imageContent.visibility = View.VISIBLE
-                viewBinding.jzVideo.visibility = View.INVISIBLE
+                viewBinding.styledPlayerView.visibility = View.INVISIBLE
 //                var s = if (mCurrentChapter.chapterData.startsWith("http")) {
 //                    mCurrentChapter.chapterData
 //                } else {
@@ -228,7 +239,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                 viewBinding.progressbar.visibility = View.VISIBLE
                 viewBinding.unknownFile.visibility = View.INVISIBLE
                 viewBinding.imageContent.visibility = View.INVISIBLE
-                viewBinding.jzVideo.visibility = View.INVISIBLE
+                viewBinding.styledPlayerView.visibility = View.INVISIBLE
                 viewBinding.webView.loadDataWithBaseURL(
                     null,
                     EscapeUnescape.unescape(mCurrentChapter.chapterData),
@@ -243,7 +254,7 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
                 viewBinding.progressbar.visibility = View.INVISIBLE
                 viewBinding.unknownFile.visibility = View.VISIBLE
                 viewBinding.imageContent.visibility = View.INVISIBLE
-                viewBinding.jzVideo.visibility = View.INVISIBLE
+                viewBinding.styledPlayerView.visibility = View.INVISIBLE
             }
         }
     }
@@ -299,13 +310,14 @@ class LearnDetailActivity : BaseCountDownActivity<ActivityLearnDetailBinding>()
     override fun onPause() {
         RcLog.info("onPause=======================================")
         super.onPause()
-        Jzvd.releaseAllVideos()
+        exoPlayer?.pause()
     }
 
     override fun onDestroy() {
         mLearnCountDownHandler.removeMessages(WHAT_LEARN_COUNT_DOWN)
         mLearnCountDownHandler.removeCallbacksAndMessages(null)
         super.onDestroy()
+        exoPlayer?.release()
     }
 
     override fun onBackPressed() {

+ 2 - 0
app/src/main/java/com/dlc/exam/ui/login/StudentCardFragment.kt

@@ -80,6 +80,8 @@ class StudentCardFragment : RcBaseFragment<FragmentStudentCardBinding>() {
                                 as? FaceMatchingFragment
                             ?: FaceMatchingFragment.newInstance(FaceMatchingFragment.TYPE_LOGIN,
                                 username)
+
+
                     fragment.arguments = Bundle().apply {
                         putInt("type", FaceMatchingFragment.TYPE_LOGIN)
                         putString("username", username)

+ 13 - 9
app/src/main/res/layout/activity_learn_detail.xml

@@ -159,15 +159,19 @@
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
 
-        <com.dlc.exam.ui.widget.ExamJzvdStd
-            android:id="@+id/jzVideo"
-            android:layout_width="0dp"
-            android:layout_height="0dp"
-            android:visibility="invisible"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent" />
+        <com.google.android.exoplayer2.ui.StyledPlayerView
+            android:id="@+id/styledPlayerView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+        <!--        <com.dlc.exam.ui.widget.ExamJzvdStd-->
+        <!--            android:id="@+id/jzVideo"-->
+        <!--            android:layout_width="0dp"-->
+        <!--            android:layout_height="0dp"-->
+        <!--            android:visibility="invisible"-->
+        <!--            app:layout_constraintBottom_toBottomOf="parent"-->
+        <!--            app:layout_constraintEnd_toEndOf="parent"-->
+        <!--            app:layout_constraintStart_toStartOf="parent"-->
+        <!--            app:layout_constraintTop_toTopOf="parent" />-->
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 2 - 1
build.gradle

@@ -7,7 +7,7 @@ buildscript {
 
     apply from: 'config/config.gradle'
     dependencies {
-        classpath "com.android.tools.build:gradle:4.1.2"
+        classpath 'com.android.tools.build:gradle:8.6.0'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${env.kotlin_version}"
 
         // NOTE: Do not place your application dependencies here; they belong
@@ -20,6 +20,7 @@ allprojects {
         google()
         jcenter()
         maven { url 'https://jitpack.io' }
+        maven { url "https://maven.mozilla.org/maven2/" }
     }
 
     apply plugin: 'idea'

+ 5 - 5
config/config.gradle

@@ -2,12 +2,12 @@ ext {
 
     env = [
             jdk_version      : JavaVersion.VERSION_1_8,
-            kotlin_version   : "1.4.21",
+            kotlin_version   : '1.6.21',
 
-            compileSdkVersion: 29,
-            buildToolsVersion: '29.0.3',
-            minSdkVersion    : 21,
-            targetSdkVersion : 28,
+//            compileSdkVersion: 34,
+//            buildToolsVersion: '29.0.3',
+//            minSdkVersion    : 21,
+//            targetSdkVersion : 34,
             applicationId    : "com.dlc.exam",
             versionCode      : 110,
             versionName      : "1.1.0-alpha"

+ 4 - 1
gradle.properties

@@ -18,4 +18,7 @@ android.useAndroidX=true
 # Kotlin code style for this project: "official" or "obsolete":
 kotlin.code.style=official
 
-android.useDeprecatedNdk=true
+android.useDeprecatedNdk=true
+android.defaults.buildfeatures.buildconfig=true
+android.nonTransitiveRClass=false
+android.nonFinalResIds=false

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
 #Tue Sep 28 09:08:05 CST 2021
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
+distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.7-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME