[Android] Display the auto update on Android TV
Nicolas Pomepuy
git at videolan.org
Fri Jun 28 09:11:53 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jun 27 13:55:59 2024 +0200| [edbf86edd942878d924cef75ede2396730e216b3] | committer: Nicolas Pomepuy
Display the auto update on Android TV
> https://code.videolan.org/videolan/vlc-android/commit/edbf86edd942878d924cef75ede2396730e216b3
---
application/resources/src/main/res/values/attrs.xml | 1 +
.../java/org/videolan/television/ui/MainTvActivity.kt | 17 +++++++++++++++++
application/vlc-android/res/layout/dialog_update.xml | 13 +++++++------
application/vlc-android/res/values/styles.xml | 5 +++++
.../src/org/videolan/vlc/gui/MainActivity.kt | 2 +-
.../src/org/videolan/vlc/gui/dialogs/UpdateDialog.kt | 2 --
.../vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt | 2 +-
7 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/application/resources/src/main/res/values/attrs.xml b/application/resources/src/main/res/values/attrs.xml
index 274998b138..82cae68c95 100644
--- a/application/resources/src/main/res/values/attrs.xml
+++ b/application/resources/src/main/res/values/attrs.xml
@@ -80,6 +80,7 @@
<attr name="about_text_primary" format="color" />
<attr name="widget_preview_rounded_bg" format="reference" />
<attr name="swipe_refresh_background" format="reference|color" />
+ <attr name="dialogButtonStyle" format="reference" />
<!--Main Icons-->
<attr name="gridview_progressbar" format="reference" />
diff --git a/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt b/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
index 35c1045a92..dd235493b4 100644
--- a/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
@@ -27,16 +27,24 @@ import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.widget.ProgressBar
+import androidx.core.os.bundleOf
+import androidx.lifecycle.lifecycleScope
+import kotlinx.coroutines.launch
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.television.R
import org.videolan.television.ui.browser.BaseTvActivity
+import org.videolan.tools.KEY_SHOW_UPDATE
import org.videolan.tools.RESULT_RESCAN
import org.videolan.tools.RESULT_RESTART
import org.videolan.tools.RESULT_RESTART_APP
+import org.videolan.tools.Settings
import org.videolan.vlc.ScanProgress
import org.videolan.vlc.StartActivity
+import org.videolan.vlc.gui.dialogs.UPDATE_URL
+import org.videolan.vlc.gui.dialogs.UpdateDialog
import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate
import org.videolan.vlc.reloadLibrary
+import org.videolan.vlc.util.AutoUpdate
import org.videolan.vlc.util.LifecycleAwareScheduler
import org.videolan.vlc.util.SchedulerCallback
import org.videolan.vlc.util.Util
@@ -70,6 +78,15 @@ class MainTvActivity : BaseTvActivity(), StoragePermissionsDelegate.CustomAction
val fragmentManager = supportFragmentManager
browseFragment = fragmentManager.findFragmentById(R.id.browse_fragment) as MainTvFragment
progressBar = findViewById(R.id.tv_main_progress)
+ lifecycleScope.launch {
+ if (!Settings.getInstance(this at MainTvActivity).getBoolean(KEY_SHOW_UPDATE, true)) return at launch
+ AutoUpdate.checkUpdate(this at MainTvActivity.application) {
+ val updateDialog = UpdateDialog().apply {
+ arguments = bundleOf(UPDATE_URL to it)
+ }
+ updateDialog.show(supportFragmentManager, "fragment_update")
+ }
+ }
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
diff --git a/application/vlc-android/res/layout/dialog_update.xml b/application/vlc-android/res/layout/dialog_update.xml
index a4219093ac..20df7edeee 100644
--- a/application/vlc-android/res/layout/dialog_update.xml
+++ b/application/vlc-android/res/layout/dialog_update.xml
@@ -40,7 +40,7 @@
android:layout_height="match_parent">
- <ImageView
+ <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -81,7 +81,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
- android:layout_marginTop="24dp"
+ android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:padding="8dp"
android:text="@string/update_text"
@@ -95,6 +95,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
+ android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:text="@string/never_ask_again"
app:layout_constraintEnd_toEndOf="parent"
@@ -103,11 +104,11 @@
<Button
android:id="@+id/open_in_browser"
- style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
+ style="?attr/dialogButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
- android:layout_marginTop="32dp"
+ android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:text="@string/open_in_browser"
app:layout_constraintEnd_toStartOf="@+id/download"
@@ -115,11 +116,11 @@
<Button
android:id="@+id/download"
- style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
+ style="?attr/dialogButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
- android:layout_marginTop="32dp"
+ android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="@string/install"
diff --git a/application/vlc-android/res/values/styles.xml b/application/vlc-android/res/values/styles.xml
index bd6a99a29a..333f5cd955 100644
--- a/application/vlc-android/res/values/styles.xml
+++ b/application/vlc-android/res/values/styles.xml
@@ -76,6 +76,7 @@
<item name="fast_scroller_handle">@drawable/fastscroller_handle</item>
<item name="primary_focus">@color/orange_800_transparent_20</item>
<item name="swipe_refresh_background">?attr/background_default</item>
+ <item name="dialogButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Dialog</item>
<item name="gridview_progressbar">@drawable/gridview_progressbar</item>
<item name="progress_mini_player">@drawable/progress_mini_player</item>
@@ -191,6 +192,9 @@
</style>
<style name="Theme.VLC.Black" parent="Theme.VLC.Black.7" />
+ <style name="Theme.VLC.Black.BottomSheet">
+ <item name="dialogButtonStyle">@style/Widget.Leanback.DetailsActionButtonStyle</item>
+ </style>
<style name="Theme.VLC.Material.TV" parent="Theme.VLC.Black" >
<item name="android:background">@color/tv_card_content_darker</item>
</style>
@@ -264,6 +268,7 @@
<item name="fast_scroller_handle">@drawable/fastscroller_handle_black</item>
<item name="primary_focus">@color/orange_500_transparent_20</item>
<item name="swipe_refresh_background">?attr/background_default_darker</item>
+ <item name="dialogButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Dialog</item>
<item name="gridview_progressbar">@drawable/gridview_progressbar_w</item>
<item name="progress_mini_player">@drawable/progress_mini_player_black</item>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
index 2211bfb6e3..e35a9b4242 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -122,8 +122,8 @@ class MainActivity : ContentActivity(),
}
lifecycleScope.launch {
+ if (!settings.getBoolean(KEY_SHOW_UPDATE, true)) return at launch
AutoUpdate.checkUpdate(this at MainActivity.application) {
- if (!settings.getBoolean(KEY_SHOW_UPDATE, true)) return at checkUpdate
val updateDialog = UpdateDialog().apply {
arguments = bundleOf(UPDATE_URL to it)
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/UpdateDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/UpdateDialog.kt
index f2f5cc7bf3..07e2f71bc2 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/UpdateDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/UpdateDialog.kt
@@ -35,9 +35,7 @@ import android.view.ViewGroup
import androidx.core.net.toUri
import androidx.lifecycle.lifecycleScope
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
-import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
import org.videolan.tools.KEY_SHOW_UPDATE
import org.videolan.tools.Settings
import org.videolan.tools.putSingle
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
index c4f97142c9..14c502bb4d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VLCBottomSheetDialogFragment.kt
@@ -21,7 +21,7 @@ abstract class VLCBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
if (Settings.showTvUi) {
- requireActivity().setTheme(R.style.Theme_VLC_Black)
+ requireActivity().setTheme(R.style.Theme_VLC_Black_BottomSheet)
}
super.onCreate(savedInstanceState)
}
More information about the Android
mailing list