From 6233edefd40329c94df1e9a82326354192206384 Mon Sep 17 00:00:00 2001 From: C10udburst <18114966+C10udburst@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:27:25 +0200 Subject: [PATCH] in-app updater changes --- .github/workflows/prerelease.yml | 8 ---- .vscode/settings.json | 3 +- app/build.gradle | 7 +++- app/src/main/AndroidManifest.xml | 2 + .../cloudstream3/utils/InAppUpdater.kt | 23 +++++++---- app/src/main/res/layout/main_settings.xml | 41 +++++++++++++++---- app/src/main/res/values-pl/strings.xml | 2 + app/src/main/res/values/strings.xml | 3 +- app/src/main/res/xml/settings_updates.xml | 2 +- 9 files changed, 61 insertions(+), 30 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index ca96829d..71301e25 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -31,14 +31,6 @@ jobs: distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Set checks for prerelease updates to true by default - run: | - sed -i "s/R\.string\.prerelease_update_key), false))/R\.string\.prerelease_update_key), true))/" app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt - - name: Update prerelease_commit_hash - run: | - COMMIT_HASH="$(git log -1 --format='%H')" - sed -i "s/unknown_prerelease<\/string>/$COMMIT_HASH<\/string>/g" app/src/main/res/values/strings.xml - - name: Fetch keystore id: fetch_keystore run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index 6c2ff60b..7282979a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "githubPullRequests.ignoredPullRequestBranches": [ "master" - ] + ], + "java.configuration.updateBuildConfiguration": "interactive" } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 24602533..1e3e9b99 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,7 +13,6 @@ if (allFilesFromDir != null) { prerelaseStoreFile = allFilesFromDir.first() } - android { testOptions { unitTests.returnDefaultValues = true @@ -42,6 +41,9 @@ android { resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix ?: ""}" + resValue "string", "commit_hash", + ("git rev-parse --short HEAD".execute().text.trim() ?: "") + buildConfigField("String", "BUILDDATE", "new java.text.SimpleDateFormat(\"yyyy-MM-dd HH:mm\").format(new java.util.Date(" + System.currentTimeMillis() + "L));") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -57,6 +59,7 @@ android { // minifyEnabled false // shrinkResources false // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // resValue "bool", "is_prerelease", "false" // } prerelease { applicationIdSuffix ".prerelease" @@ -67,11 +70,13 @@ android { minifyEnabled false shrinkResources false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + resValue "bool", "is_prerelease", "true" } debug { debuggable true applicationIdSuffix ".debug" proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + resValue "bool", "is_prerelease", "true" } } compileOptions { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 45d30a35..a91ea706 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -40,6 +40,8 @@ android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" /> + + - rel.prerelease + rel.prerelease || rel.tag_name == "pre-release" } - val foundAsset = found?.assets?.getOrNull(0) + val foundAsset = found?.assets?.filter { it -> + it.content_type == "application/vnd.android.package-archive" + }?.getOrNull(0) val tagResponse = parseJson(app.get(tagUrl, headers = headers).text) + Log.d(LOG_TAG, "Fetched GitHub tag: ${tagResponse.github_object.sha.take(8)}") + val shouldUpdate = - (getString(R.string.prerelease_commit_hash) != tagResponse.github_object.sha) + (getString(R.string.commit_hash) != tagResponse.github_object.sha.take(8)) return@runBlocking if (foundAsset != null) { Update( @@ -183,6 +186,8 @@ class InAppUpdater { } private fun Activity.downloadUpdate(url: String): Boolean { + Log.d(LOG_TAG, "Downloading update: ${url}") + val downloadManager = getSystemService()!! val request = DownloadManager.Request(Uri.parse(url)) diff --git a/app/src/main/res/layout/main_settings.xml b/app/src/main/res/layout/main_settings.xml index 71cad53e..8b49f8fd 100644 --- a/app/src/main/res/layout/main_settings.xml +++ b/app/src/main/res/layout/main_settings.xml @@ -104,14 +104,39 @@ android:nextFocusUp="@id/settings_updates" android:text="@string/extensions" /> - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index fa77e734..ae2c4066 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -429,4 +429,6 @@ %d na 10 Inne Wideo + Zobacz repozytoria społeczności + Publiczna lista diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36303c1f..a33e2b35 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -20,7 +20,6 @@ video_buffer_length_key video_buffer_clear_key video_buffer_disk_key - unknown_prerelease use_system_brightness_key swipe_enabled_key playback_speed_enabled_key @@ -600,6 +599,6 @@ Disabled: %d Not downloaded: %d Add a repository to install site extensions - View public repositories + View community repositories Public list diff --git a/app/src/main/res/xml/settings_updates.xml b/app/src/main/res/xml/settings_updates.xml index 39fc92d4..eaceb785 100644 --- a/app/src/main/res/xml/settings_updates.xml +++ b/app/src/main/res/xml/settings_updates.xml @@ -43,7 +43,7 @@ android:icon="@drawable/ic_baseline_developer_mode_24" android:summary="@string/uprereleases_settings_des" android:title="@string/uprereleases_settings" - app:defaultValue="false" + app:defaultValue="@bool/is_prerelease" app:key="@string/prerelease_update_key" />