From a7fc549afba738cd869cd4c660526ca1d0fd1103 Mon Sep 17 00:00:00 2001 From: Koen J Date: Fri, 8 May 2026 17:40:57 +0200 Subject: [PATCH] Automatic updates for plugins defaults to true and made the loading bar smaller. --- .../platforms/js/SourcePluginDescriptor.kt | 2 +- .../futo/platformplayer/states/StateUpdate.kt | 18 +--- .../views/announcements/UpdateBannerView.kt | 42 ++------ app/src/main/res/layout/view_toggle_tag.xml | 4 +- .../main/res/layout/view_update_banner.xml | 96 +++++++------------ 5 files changed, 48 insertions(+), 114 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginDescriptor.kt b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginDescriptor.kt index 771e1feb..8796e95a 100644 --- a/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginDescriptor.kt +++ b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginDescriptor.kt @@ -100,7 +100,7 @@ class SourcePluginDescriptor { @FormField(R.string.check_for_updates_setting, FieldForm.TOGGLE, R.string.check_for_updates_setting_description, -1) var checkForUpdates: Boolean = true; @FormField(R.string.automatic_update_setting, FieldForm.TOGGLE, R.string.automatic_update_setting_description, 0) - var automaticUpdate: Boolean = false; + var automaticUpdate: Boolean = true; @FormField(R.string.visibility, "group", R.string.enable_where_this_plugins_content_are_visible, 2) var tabEnabled = TabEnabled(); diff --git a/app/src/main/java/com/futo/platformplayer/states/StateUpdate.kt b/app/src/main/java/com/futo/platformplayer/states/StateUpdate.kt index fc346e7a..8b33f89e 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateUpdate.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateUpdate.kt @@ -31,47 +31,37 @@ class StateUpdate { private set @Volatile var uiError: String? = null private set - @Volatile var uiDismissed: Boolean = false - private set val onUiChanged = Event0() fun setUiAvailable(version: Int) { - val transitioned = uiState != UpdateUiState.AVAILABLE uiState = UpdateUiState.AVAILABLE uiVersion = version uiError = null - if (transitioned) uiDismissed = false onUiChanged.emit() } fun setUiDownloading(version: Int, progress: Int, indeterminate: Boolean) { - val transitioned = uiState != UpdateUiState.DOWNLOADING uiState = UpdateUiState.DOWNLOADING uiVersion = version uiProgress = progress uiIndeterminate = indeterminate uiError = null - if (transitioned) uiDismissed = false onUiChanged.emit() } fun setUiReady(version: Int, apkFile: File) { - val transitioned = uiState != UpdateUiState.READY uiState = UpdateUiState.READY uiVersion = version uiApkFile = apkFile uiError = null - if (transitioned) uiDismissed = false onUiChanged.emit() } fun setUiFailed(version: Int, error: String?) { - val transitioned = uiState != UpdateUiState.FAILED uiState = UpdateUiState.FAILED uiVersion = version uiError = error - if (transitioned) uiDismissed = false onUiChanged.emit() } @@ -82,12 +72,6 @@ class StateUpdate { uiIndeterminate = true uiApkFile = null uiError = null - uiDismissed = false - onUiChanged.emit() - } - - fun dismissUi() { - uiDismissed = true onUiChanged.emit() } @@ -243,4 +227,4 @@ class StateUpdate { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/futo/platformplayer/views/announcements/UpdateBannerView.kt b/app/src/main/java/com/futo/platformplayer/views/announcements/UpdateBannerView.kt index c3d05f05..1973bd43 100644 --- a/app/src/main/java/com/futo/platformplayer/views/announcements/UpdateBannerView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/announcements/UpdateBannerView.kt @@ -29,11 +29,9 @@ class UpdateBannerView : LinearLayout { private val _root: FrameLayout private val _iconUpdate: ImageView private val _textTitle: TextView - private val _textBody: TextView private val _progressBar: ProgressBar private val _buttonAction: FrameLayout private val _textAction: TextView - private val _buttonClose: ImageView private val _scope: CoroutineScope? @@ -45,15 +43,9 @@ class UpdateBannerView : LinearLayout { _root = findViewById(R.id.root) _iconUpdate = findViewById(R.id.icon_update) _textTitle = findViewById(R.id.text_title) - _textBody = findViewById(R.id.text_body) _progressBar = findViewById(R.id.update_banner_progress) _buttonAction = findViewById(R.id.button_action) _textAction = findViewById(R.id.text_action) - _buttonClose = findViewById(R.id.button_close) - - _buttonClose.setOnClickListener { - StateUpdate.instance.dismissUi() - } _buttonAction.setOnClickListener { onActionClicked() @@ -96,17 +88,6 @@ class UpdateBannerView : LinearLayout { Logger.w(TAG, "Retry start service failed", t) } } - UpdateUiState.DOWNLOADING -> { - val intent = Intent(context, UpdateDownloadService::class.java).apply { - putExtra(UpdateDownloadService.EXTRA_VERSION, st.uiVersion) - putExtra(UpdateDownloadService.EXTRA_CANCEL, true) - } - try { - ContextCompat.startForegroundService(context, intent) - } catch (t: Throwable) { - Logger.w(TAG, "Cancel start service failed", t) - } - } UpdateUiState.AVAILABLE -> { if (st.uiVersion == 0) return val intent = Intent(context, UpdateDownloadService::class.java).apply { @@ -118,6 +99,7 @@ class UpdateBannerView : LinearLayout { Logger.w(TAG, "Download start service failed", t) } } + UpdateUiState.DOWNLOADING -> {} UpdateUiState.NONE -> {} } } @@ -125,7 +107,7 @@ class UpdateBannerView : LinearLayout { private fun refresh() { val st = StateUpdate.instance val gateOpen = Settings.instance.autoUpdate.shouldBackgroundDownload - val visible = gateOpen && !st.uiDismissed && st.uiState != UpdateUiState.NONE + val visible = gateOpen && st.uiState != UpdateUiState.NONE if (!visible) { _root.visibility = View.GONE @@ -135,41 +117,31 @@ class UpdateBannerView : LinearLayout { when (st.uiState) { UpdateUiState.AVAILABLE -> { - _textTitle.text = "Update available (v${st.uiVersion})" - _textBody.text = "A new Grayjay version is available." - _textBody.visibility = View.VISIBLE + _textTitle.text = "Update v${st.uiVersion}" _progressBar.visibility = View.GONE _textAction.text = "Download" _buttonAction.visibility = View.VISIBLE } UpdateUiState.DOWNLOADING -> { - _textTitle.text = "Downloading update (v${st.uiVersion})" if (st.uiIndeterminate) { - _textBody.text = "Starting download…" + _textTitle.text = "Downloading v${st.uiVersion}" _progressBar.isIndeterminate = true } else { - _textBody.text = "${st.uiProgress}% downloaded" + _textTitle.text = "Downloading v${st.uiVersion} - ${st.uiProgress}%" _progressBar.isIndeterminate = false _progressBar.progress = st.uiProgress } - _textBody.visibility = View.VISIBLE _progressBar.visibility = View.VISIBLE - _textAction.text = "Cancel" - _buttonAction.visibility = View.VISIBLE + _buttonAction.visibility = View.GONE } UpdateUiState.READY -> { - _textTitle.text = "Update v${st.uiVersion} ready" - _textBody.text = "Tap install to apply the update." - _textBody.visibility = View.VISIBLE + _textTitle.text = "Ready v${st.uiVersion}" _progressBar.visibility = View.GONE _textAction.text = "Install" _buttonAction.visibility = View.VISIBLE } UpdateUiState.FAILED -> { _textTitle.text = "Update failed" - val err = st.uiError - _textBody.text = if (err.isNullOrBlank()) "Could not download v${st.uiVersion}." else err - _textBody.visibility = View.VISIBLE _progressBar.visibility = View.GONE _textAction.text = "Retry" _buttonAction.visibility = View.VISIBLE diff --git a/app/src/main/res/layout/view_toggle_tag.xml b/app/src/main/res/layout/view_toggle_tag.xml index 5f285bd2..43d4f656 100644 --- a/app/src/main/res/layout/view_toggle_tag.xml +++ b/app/src/main/res/layout/view_toggle_tag.xml @@ -7,7 +7,7 @@ android:paddingEnd="12dp" android:background="@drawable/background_pill" android:layout_marginEnd="6dp" - android:layout_marginTop="17dp" + android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:id="@+id/root"> - \ No newline at end of file + diff --git a/app/src/main/res/layout/view_update_banner.xml b/app/src/main/res/layout/view_update_banner.xml index d39b6470..9ba2ce9e 100644 --- a/app/src/main/res/layout/view_update_banner.xml +++ b/app/src/main/res/layout/view_update_banner.xml @@ -1,94 +1,72 @@ - + android:layout_marginLeft="10dp" + android:layout_marginTop="6dp" + android:layout_marginRight="10dp" + android:layout_marginBottom="0dp" + android:minHeight="40dp" + android:orientation="horizontal" + android:gravity="center_vertical" + android:paddingLeft="12dp" + android:paddingTop="6dp" + android:paddingRight="8dp" + android:paddingBottom="6dp"> + android:layout_marginRight="10dp" + android:alpha="0.9" + android:importantForAccessibility="no" /> - - - - + android:textColor="@color/white" + android:ellipsize="end" + android:maxLines="1" /> + tools:visibility="visible" /> + android:layout_height="28dp" + android:layout_marginLeft="10dp" + android:background="@drawable/background_button_primary_round_4dp"> + android:paddingLeft="13dp" + android:paddingRight="13dp" /> - +