[Android] Set buildConfig.BETA field

Geoffrey Métais git at videolan.org
Thu Aug 8 13:54:07 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Aug  7 12:07:00 2019 +0200| [020ee091012c68f9d80bbbee54c777e804f719c8] | committer: Geoffrey Métais

Set buildConfig.BETA field

(cherry picked from commit 520a9b59532ccaab0b4eeb710464e98a4deae9cb)

> https://code.videolan.org/videolan/vlc-android/commit/020ee091012c68f9d80bbbee54c777e804f719c8
---

 vlc-android/build.gradle                           | 3 ++-
 vlc-android/src/org/videolan/vlc/StartActivity.kt  | 6 ++----
 vlc-android/src/org/videolan/vlc/VLCApplication.kt | 2 +-
 vlc-android/src/org/videolan/vlc/util/AppUtils.kt  | 8 +-------
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index cdfd2295b..b7b725727 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -52,7 +52,6 @@ android {
         resValue "string", "build_time", buildTime()
         resValue "string", "build_host", hostName()
         resValue "string", "build_revision", revision()
-        resValue "bool", "is_beta", isBeta()
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         // The following argument makes the Android Test Orchestrator run its
@@ -125,6 +124,7 @@ android {
             shrinkResources false
             proguardFile 'proguard.cfg'
             kotlinOptions.freeCompilerArgs = ['-Xno-param-assertions']
+            buildConfigField "boolean", "BETA", isBeta()
         }
         signedRelease {
             initWith release
@@ -135,6 +135,7 @@ android {
             applicationIdSuffix ".debug"
             jniDebuggable true
             multiDexEnabled true
+            buildConfigField "boolean", "BETA", "false"
         }
         dev {
             initWith debug
diff --git a/vlc-android/src/org/videolan/vlc/StartActivity.kt b/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 5bf994619..02dc64aa1 100644
--- a/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -79,16 +79,14 @@ class StartActivity : FragmentActivity() {
         if (AndroidUtil.isNougatOrLater) UiTools.setLocale(this)
 
         try {
-            if (!Settings.showTvUi && AppUtils.isBeta(this) && !Settings.getInstance(this).getBoolean(BETA_WELCOME, false)) {
+            if (!Settings.showTvUi && BuildConfig.BETA && !Settings.getInstance(this).getBoolean(BETA_WELCOME, false)) {
                 val intent = Intent(this, BetaWelcomeActivity::class.java)
                 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
                 startActivityForResult(intent, SEND_CRASH_RESULT)
                 Settings.getInstance(this).edit().putBoolean(BETA_WELCOME, true).apply()
                 return
             }
-        } catch (e: Exception) {
-        }
-
+        } catch (ignored: Exception) {}
         resume()
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.kt b/vlc-android/src/org/videolan/vlc/VLCApplication.kt
index 0c77d8449..f426edbd3 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.kt
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.kt
@@ -113,7 +113,7 @@ class VLCApplication : MultiDexApplication() {
                 Dialog.setCallbacks(VLCInstance[instance], dialogCallbacks)
             })
             packageManager.setComponentEnabledSetting(ComponentName(this, SendCrashActivity::class.java),
-                    if (resources.getBoolean(R.bool.is_beta)) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
+                    if (BuildConfig.BETA) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
         }).start()
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/util/AppUtils.kt b/vlc-android/src/org/videolan/vlc/util/AppUtils.kt
index b6d99ce9d..785f65ea8 100644
--- a/vlc-android/src/org/videolan/vlc/util/AppUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/util/AppUtils.kt
@@ -4,13 +4,11 @@ import android.content.Context
 import android.os.Build
 import android.os.Environment
 import android.os.StatFs
-import org.videolan.vlc.R
-import org.videolan.vlc.VLCApplication
 
 object AppUtils {
 
     fun getVersionName(context: Context): String {
-        return context.packageManager.getPackageInfo(VLCApplication.appContext.packageName, 0).versionName
+        return context.packageManager.getPackageInfo(context.packageName, 0).versionName
     }
 
     fun getVersionCode(context: Context): Long {
@@ -19,10 +17,6 @@ object AppUtils {
         else context.packageManager.getPackageInfo(context.packageName, 0).versionCode.toLong()
     }
 
-    fun isBeta(context: Context): Boolean {
-        return context.resources.getBoolean(R.bool.is_beta)
-    }
-
     fun totalMemory(): Long {
         val statFs = StatFs(Environment.getRootDirectory().absolutePath)
         return (statFs.blockCount * statFs.blockSize).toLong()



More information about the Android mailing list