forked from recloudstream/cloudstream
in-app updater changes
This commit is contained in:
parent
d987492d01
commit
6233edefd4
9 changed files with 61 additions and 30 deletions
8
.github/workflows/prerelease.yml
vendored
8
.github/workflows/prerelease.yml
vendored
|
@ -31,14 +31,6 @@ jobs:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x 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/<string name=\"prerelease_commit_hash\" translatable=\"false\">unknown_prerelease<\/string>/<string name=\"prerelease_commit_hash\">$COMMIT_HASH<\/string>/g" app/src/main/res/values/strings.xml
|
|
||||||
|
|
||||||
- name: Fetch keystore
|
- name: Fetch keystore
|
||||||
id: fetch_keystore
|
id: fetch_keystore
|
||||||
run: |
|
run: |
|
||||||
|
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"githubPullRequests.ignoredPullRequestBranches": [
|
"githubPullRequests.ignoredPullRequestBranches": [
|
||||||
"master"
|
"master"
|
||||||
]
|
],
|
||||||
|
"java.configuration.updateBuildConfiguration": "interactive"
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@ if (allFilesFromDir != null) {
|
||||||
prerelaseStoreFile = allFilesFromDir.first()
|
prerelaseStoreFile = allFilesFromDir.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.returnDefaultValues = true
|
unitTests.returnDefaultValues = true
|
||||||
|
@ -42,6 +41,9 @@ android {
|
||||||
resValue "string", "app_version",
|
resValue "string", "app_version",
|
||||||
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
"${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));")
|
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"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
@ -57,6 +59,7 @@ android {
|
||||||
// minifyEnabled false
|
// minifyEnabled false
|
||||||
// shrinkResources false
|
// shrinkResources false
|
||||||
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
// resValue "bool", "is_prerelease", "false"
|
||||||
// }
|
// }
|
||||||
prerelease {
|
prerelease {
|
||||||
applicationIdSuffix ".prerelease"
|
applicationIdSuffix ".prerelease"
|
||||||
|
@ -67,11 +70,13 @@ android {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
shrinkResources false
|
shrinkResources false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
resValue "bool", "is_prerelease", "true"
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
debuggable true
|
debuggable true
|
||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
resValue "bool", "is_prerelease", "true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
||||||
android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" />
|
android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" />
|
||||||
|
|
||||||
|
<profileable android:shell="true" tools:targetApi="q" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.player.DownloadedPlayerActivity"
|
android:name=".ui.player.DownloadedPlayerActivity"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
||||||
|
|
|
@ -8,16 +8,13 @@ import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.BuildConfig
|
import com.lagradost.cloudstream3.BuildConfig
|
||||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
|
@ -34,6 +31,8 @@ class InAppUpdater {
|
||||||
const val GITHUB_USER_NAME = "recloudstream"
|
const val GITHUB_USER_NAME = "recloudstream"
|
||||||
const val GITHUB_REPO = "cloudstream"
|
const val GITHUB_REPO = "cloudstream"
|
||||||
|
|
||||||
|
const val LOG_TAG = "InAppUpdater"
|
||||||
|
|
||||||
// === IN APP UPDATER ===
|
// === IN APP UPDATER ===
|
||||||
data class GithubAsset(
|
data class GithubAsset(
|
||||||
@JsonProperty("name") val name: String,
|
@JsonProperty("name") val name: String,
|
||||||
|
@ -72,13 +71,13 @@ class InAppUpdater {
|
||||||
private fun Activity.getAppUpdate(): Update {
|
private fun Activity.getAppUpdate(): Update {
|
||||||
return try {
|
return try {
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
if (settingsManager.getBoolean(getString(R.string.prerelease_update_key), false)) {
|
if (settingsManager.getBoolean(getString(R.string.prerelease_update_key), resources.getBoolean(R.bool.is_prerelease))) {
|
||||||
getPreReleaseUpdate()
|
getPreReleaseUpdate()
|
||||||
} else {
|
} else {
|
||||||
getReleaseUpdate()
|
getReleaseUpdate()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println(e)
|
Log.e(LOG_TAG, Log.getStackTraceString(e))
|
||||||
Update(false, null, null, null, null)
|
Update(false, null, null, null, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,15 +158,19 @@ class InAppUpdater {
|
||||||
|
|
||||||
val found =
|
val found =
|
||||||
response.lastOrNull { rel ->
|
response.lastOrNull { rel ->
|
||||||
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 =
|
val tagResponse =
|
||||||
parseJson<GithubTag>(app.get(tagUrl, headers = headers).text)
|
parseJson<GithubTag>(app.get(tagUrl, headers = headers).text)
|
||||||
|
|
||||||
|
Log.d(LOG_TAG, "Fetched GitHub tag: ${tagResponse.github_object.sha.take(8)}")
|
||||||
|
|
||||||
val shouldUpdate =
|
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) {
|
return@runBlocking if (foundAsset != null) {
|
||||||
Update(
|
Update(
|
||||||
|
@ -183,6 +186,8 @@ class InAppUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Activity.downloadUpdate(url: String): Boolean {
|
private fun Activity.downloadUpdate(url: String): Boolean {
|
||||||
|
Log.d(LOG_TAG, "Downloading update: ${url}")
|
||||||
|
|
||||||
val downloadManager = getSystemService<DownloadManager>()!!
|
val downloadManager = getSystemService<DownloadManager>()!!
|
||||||
|
|
||||||
val request = DownloadManager.Request(Uri.parse(url))
|
val request = DownloadManager.Request(Uri.parse(url))
|
||||||
|
|
|
@ -104,14 +104,39 @@
|
||||||
android:nextFocusUp="@id/settings_updates"
|
android:nextFocusUp="@id/settings_updates"
|
||||||
android:text="@string/extensions" />
|
android:text="@string/extensions" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:gravity="center_horizontal"
|
||||||
android:gravity="center"
|
android:orientation="horizontal">
|
||||||
android:padding="10dp"
|
|
||||||
android:text="@string/app_version"
|
<TextView
|
||||||
android:textColor="?attr/textColor" />
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/app_version"
|
||||||
|
android:textColor="?attr/textColor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="•"
|
||||||
|
android:textColor="?attr/textColor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/commit_hash"
|
||||||
|
android:textColor="?attr/textColor" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -429,4 +429,6 @@
|
||||||
<string name="sync_score_format">%d na 10</string>
|
<string name="sync_score_format">%d na 10</string>
|
||||||
<string name="others">Inne</string>
|
<string name="others">Inne</string>
|
||||||
<string name="other_singular">Wideo</string>
|
<string name="other_singular">Wideo</string>
|
||||||
|
<string name="view_public_repositories_button">Zobacz repozytoria społeczności</string>
|
||||||
|
<string name="view_public_repositories_button_short">Publiczna lista</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
<string name="video_buffer_length_key" translatable="false">video_buffer_length_key</string>
|
<string name="video_buffer_length_key" translatable="false">video_buffer_length_key</string>
|
||||||
<string name="video_buffer_clear_key" translatable="false">video_buffer_clear_key</string>
|
<string name="video_buffer_clear_key" translatable="false">video_buffer_clear_key</string>
|
||||||
<string name="video_buffer_disk_key" translatable="false">video_buffer_disk_key</string>
|
<string name="video_buffer_disk_key" translatable="false">video_buffer_disk_key</string>
|
||||||
<string name="prerelease_commit_hash" translatable="false">unknown_prerelease</string>
|
|
||||||
<string name="use_system_brightness_key" translatable="false">use_system_brightness_key</string>
|
<string name="use_system_brightness_key" translatable="false">use_system_brightness_key</string>
|
||||||
<string name="swipe_enabled_key" translatable="false">swipe_enabled_key</string>
|
<string name="swipe_enabled_key" translatable="false">swipe_enabled_key</string>
|
||||||
<string name="playback_speed_enabled_key" translatable="false">playback_speed_enabled_key</string>
|
<string name="playback_speed_enabled_key" translatable="false">playback_speed_enabled_key</string>
|
||||||
|
@ -600,6 +599,6 @@
|
||||||
<string name="plugins_disabled" formatted="true">Disabled: %d</string>
|
<string name="plugins_disabled" formatted="true">Disabled: %d</string>
|
||||||
<string name="plugins_not_downloaded" formatted="true">Not downloaded: %d</string>
|
<string name="plugins_not_downloaded" formatted="true">Not downloaded: %d</string>
|
||||||
<string name="blank_repo_message">Add a repository to install site extensions</string>
|
<string name="blank_repo_message">Add a repository to install site extensions</string>
|
||||||
<string name="view_public_repositories_button">View public repositories</string>
|
<string name="view_public_repositories_button">View community repositories</string>
|
||||||
<string name="view_public_repositories_button_short">Public list</string>
|
<string name="view_public_repositories_button_short">Public list</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
android:icon="@drawable/ic_baseline_developer_mode_24"
|
android:icon="@drawable/ic_baseline_developer_mode_24"
|
||||||
android:summary="@string/uprereleases_settings_des"
|
android:summary="@string/uprereleases_settings_des"
|
||||||
android:title="@string/uprereleases_settings"
|
android:title="@string/uprereleases_settings"
|
||||||
app:defaultValue="false"
|
app:defaultValue="@bool/is_prerelease"
|
||||||
app:key="@string/prerelease_update_key" />
|
app:key="@string/prerelease_update_key" />
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/ic_baseline_construction_24"
|
android:icon="@drawable/ic_baseline_construction_24"
|
||||||
|
|
Loading…
Reference in a new issue