mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Automatic updates for plugins defaults to true and made the loading bar smaller.
This commit is contained in:
+1
-1
@@ -100,7 +100,7 @@ class SourcePluginDescriptor {
|
|||||||
@FormField(R.string.check_for_updates_setting, FieldForm.TOGGLE, R.string.check_for_updates_setting_description, -1)
|
@FormField(R.string.check_for_updates_setting, FieldForm.TOGGLE, R.string.check_for_updates_setting_description, -1)
|
||||||
var checkForUpdates: Boolean = true;
|
var checkForUpdates: Boolean = true;
|
||||||
@FormField(R.string.automatic_update_setting, FieldForm.TOGGLE, R.string.automatic_update_setting_description, 0)
|
@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)
|
@FormField(R.string.visibility, "group", R.string.enable_where_this_plugins_content_are_visible, 2)
|
||||||
var tabEnabled = TabEnabled();
|
var tabEnabled = TabEnabled();
|
||||||
|
|||||||
@@ -31,47 +31,37 @@ class StateUpdate {
|
|||||||
private set
|
private set
|
||||||
@Volatile var uiError: String? = null
|
@Volatile var uiError: String? = null
|
||||||
private set
|
private set
|
||||||
@Volatile var uiDismissed: Boolean = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
val onUiChanged = Event0()
|
val onUiChanged = Event0()
|
||||||
|
|
||||||
fun setUiAvailable(version: Int) {
|
fun setUiAvailable(version: Int) {
|
||||||
val transitioned = uiState != UpdateUiState.AVAILABLE
|
|
||||||
uiState = UpdateUiState.AVAILABLE
|
uiState = UpdateUiState.AVAILABLE
|
||||||
uiVersion = version
|
uiVersion = version
|
||||||
uiError = null
|
uiError = null
|
||||||
if (transitioned) uiDismissed = false
|
|
||||||
onUiChanged.emit()
|
onUiChanged.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUiDownloading(version: Int, progress: Int, indeterminate: Boolean) {
|
fun setUiDownloading(version: Int, progress: Int, indeterminate: Boolean) {
|
||||||
val transitioned = uiState != UpdateUiState.DOWNLOADING
|
|
||||||
uiState = UpdateUiState.DOWNLOADING
|
uiState = UpdateUiState.DOWNLOADING
|
||||||
uiVersion = version
|
uiVersion = version
|
||||||
uiProgress = progress
|
uiProgress = progress
|
||||||
uiIndeterminate = indeterminate
|
uiIndeterminate = indeterminate
|
||||||
uiError = null
|
uiError = null
|
||||||
if (transitioned) uiDismissed = false
|
|
||||||
onUiChanged.emit()
|
onUiChanged.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUiReady(version: Int, apkFile: File) {
|
fun setUiReady(version: Int, apkFile: File) {
|
||||||
val transitioned = uiState != UpdateUiState.READY
|
|
||||||
uiState = UpdateUiState.READY
|
uiState = UpdateUiState.READY
|
||||||
uiVersion = version
|
uiVersion = version
|
||||||
uiApkFile = apkFile
|
uiApkFile = apkFile
|
||||||
uiError = null
|
uiError = null
|
||||||
if (transitioned) uiDismissed = false
|
|
||||||
onUiChanged.emit()
|
onUiChanged.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUiFailed(version: Int, error: String?) {
|
fun setUiFailed(version: Int, error: String?) {
|
||||||
val transitioned = uiState != UpdateUiState.FAILED
|
|
||||||
uiState = UpdateUiState.FAILED
|
uiState = UpdateUiState.FAILED
|
||||||
uiVersion = version
|
uiVersion = version
|
||||||
uiError = error
|
uiError = error
|
||||||
if (transitioned) uiDismissed = false
|
|
||||||
onUiChanged.emit()
|
onUiChanged.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,12 +72,6 @@ class StateUpdate {
|
|||||||
uiIndeterminate = true
|
uiIndeterminate = true
|
||||||
uiApkFile = null
|
uiApkFile = null
|
||||||
uiError = null
|
uiError = null
|
||||||
uiDismissed = false
|
|
||||||
onUiChanged.emit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun dismissUi() {
|
|
||||||
uiDismissed = true
|
|
||||||
onUiChanged.emit()
|
onUiChanged.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,9 @@ class UpdateBannerView : LinearLayout {
|
|||||||
private val _root: FrameLayout
|
private val _root: FrameLayout
|
||||||
private val _iconUpdate: ImageView
|
private val _iconUpdate: ImageView
|
||||||
private val _textTitle: TextView
|
private val _textTitle: TextView
|
||||||
private val _textBody: TextView
|
|
||||||
private val _progressBar: ProgressBar
|
private val _progressBar: ProgressBar
|
||||||
private val _buttonAction: FrameLayout
|
private val _buttonAction: FrameLayout
|
||||||
private val _textAction: TextView
|
private val _textAction: TextView
|
||||||
private val _buttonClose: ImageView
|
|
||||||
|
|
||||||
private val _scope: CoroutineScope?
|
private val _scope: CoroutineScope?
|
||||||
|
|
||||||
@@ -45,15 +43,9 @@ class UpdateBannerView : LinearLayout {
|
|||||||
_root = findViewById(R.id.root)
|
_root = findViewById(R.id.root)
|
||||||
_iconUpdate = findViewById(R.id.icon_update)
|
_iconUpdate = findViewById(R.id.icon_update)
|
||||||
_textTitle = findViewById(R.id.text_title)
|
_textTitle = findViewById(R.id.text_title)
|
||||||
_textBody = findViewById(R.id.text_body)
|
|
||||||
_progressBar = findViewById(R.id.update_banner_progress)
|
_progressBar = findViewById(R.id.update_banner_progress)
|
||||||
_buttonAction = findViewById(R.id.button_action)
|
_buttonAction = findViewById(R.id.button_action)
|
||||||
_textAction = findViewById(R.id.text_action)
|
_textAction = findViewById(R.id.text_action)
|
||||||
_buttonClose = findViewById(R.id.button_close)
|
|
||||||
|
|
||||||
_buttonClose.setOnClickListener {
|
|
||||||
StateUpdate.instance.dismissUi()
|
|
||||||
}
|
|
||||||
|
|
||||||
_buttonAction.setOnClickListener {
|
_buttonAction.setOnClickListener {
|
||||||
onActionClicked()
|
onActionClicked()
|
||||||
@@ -96,17 +88,6 @@ class UpdateBannerView : LinearLayout {
|
|||||||
Logger.w(TAG, "Retry start service failed", t)
|
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 -> {
|
UpdateUiState.AVAILABLE -> {
|
||||||
if (st.uiVersion == 0) return
|
if (st.uiVersion == 0) return
|
||||||
val intent = Intent(context, UpdateDownloadService::class.java).apply {
|
val intent = Intent(context, UpdateDownloadService::class.java).apply {
|
||||||
@@ -118,6 +99,7 @@ class UpdateBannerView : LinearLayout {
|
|||||||
Logger.w(TAG, "Download start service failed", t)
|
Logger.w(TAG, "Download start service failed", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UpdateUiState.DOWNLOADING -> {}
|
||||||
UpdateUiState.NONE -> {}
|
UpdateUiState.NONE -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +107,7 @@ class UpdateBannerView : LinearLayout {
|
|||||||
private fun refresh() {
|
private fun refresh() {
|
||||||
val st = StateUpdate.instance
|
val st = StateUpdate.instance
|
||||||
val gateOpen = Settings.instance.autoUpdate.shouldBackgroundDownload
|
val gateOpen = Settings.instance.autoUpdate.shouldBackgroundDownload
|
||||||
val visible = gateOpen && !st.uiDismissed && st.uiState != UpdateUiState.NONE
|
val visible = gateOpen && st.uiState != UpdateUiState.NONE
|
||||||
|
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
_root.visibility = View.GONE
|
_root.visibility = View.GONE
|
||||||
@@ -135,41 +117,31 @@ class UpdateBannerView : LinearLayout {
|
|||||||
|
|
||||||
when (st.uiState) {
|
when (st.uiState) {
|
||||||
UpdateUiState.AVAILABLE -> {
|
UpdateUiState.AVAILABLE -> {
|
||||||
_textTitle.text = "Update available (v${st.uiVersion})"
|
_textTitle.text = "Update v${st.uiVersion}"
|
||||||
_textBody.text = "A new Grayjay version is available."
|
|
||||||
_textBody.visibility = View.VISIBLE
|
|
||||||
_progressBar.visibility = View.GONE
|
_progressBar.visibility = View.GONE
|
||||||
_textAction.text = "Download"
|
_textAction.text = "Download"
|
||||||
_buttonAction.visibility = View.VISIBLE
|
_buttonAction.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
UpdateUiState.DOWNLOADING -> {
|
UpdateUiState.DOWNLOADING -> {
|
||||||
_textTitle.text = "Downloading update (v${st.uiVersion})"
|
|
||||||
if (st.uiIndeterminate) {
|
if (st.uiIndeterminate) {
|
||||||
_textBody.text = "Starting download…"
|
_textTitle.text = "Downloading v${st.uiVersion}"
|
||||||
_progressBar.isIndeterminate = true
|
_progressBar.isIndeterminate = true
|
||||||
} else {
|
} else {
|
||||||
_textBody.text = "${st.uiProgress}% downloaded"
|
_textTitle.text = "Downloading v${st.uiVersion} - ${st.uiProgress}%"
|
||||||
_progressBar.isIndeterminate = false
|
_progressBar.isIndeterminate = false
|
||||||
_progressBar.progress = st.uiProgress
|
_progressBar.progress = st.uiProgress
|
||||||
}
|
}
|
||||||
_textBody.visibility = View.VISIBLE
|
|
||||||
_progressBar.visibility = View.VISIBLE
|
_progressBar.visibility = View.VISIBLE
|
||||||
_textAction.text = "Cancel"
|
_buttonAction.visibility = View.GONE
|
||||||
_buttonAction.visibility = View.VISIBLE
|
|
||||||
}
|
}
|
||||||
UpdateUiState.READY -> {
|
UpdateUiState.READY -> {
|
||||||
_textTitle.text = "Update v${st.uiVersion} ready"
|
_textTitle.text = "Ready v${st.uiVersion}"
|
||||||
_textBody.text = "Tap install to apply the update."
|
|
||||||
_textBody.visibility = View.VISIBLE
|
|
||||||
_progressBar.visibility = View.GONE
|
_progressBar.visibility = View.GONE
|
||||||
_textAction.text = "Install"
|
_textAction.text = "Install"
|
||||||
_buttonAction.visibility = View.VISIBLE
|
_buttonAction.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
UpdateUiState.FAILED -> {
|
UpdateUiState.FAILED -> {
|
||||||
_textTitle.text = "Update 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
|
_progressBar.visibility = View.GONE
|
||||||
_textAction.text = "Retry"
|
_textAction.text = "Retry"
|
||||||
_buttonAction.visibility = View.VISIBLE
|
_buttonAction.visibility = View.VISIBLE
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
android:paddingEnd="12dp"
|
android:paddingEnd="12dp"
|
||||||
android:background="@drawable/background_pill"
|
android:background="@drawable/background_pill"
|
||||||
android:layout_marginEnd="6dp"
|
android:layout_marginEnd="6dp"
|
||||||
android:layout_marginTop="17dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:id="@+id/root">
|
android:id="@+id/root">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -1,94 +1,72 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/root">
|
android:id="@+id/root">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/background_16_round_4dp"
|
android:background="@drawable/background_16_round_4dp"
|
||||||
android:paddingLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:paddingTop="10dp"
|
android:layout_marginTop="6dp"
|
||||||
android:paddingRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:paddingBottom="10dp"
|
android:layout_marginBottom="0dp"
|
||||||
android:layout_margin="10dp">
|
android:minHeight="40dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:paddingBottom="6dp">
|
||||||
|
|
||||||
<ImageView android:id="@+id/icon_update"
|
<ImageView android:id="@+id/icon_update"
|
||||||
android:layout_width="20dp"
|
android:layout_width="18dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="18dp"
|
||||||
android:src="@drawable/ic_update"
|
android:src="@drawable/ic_update"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginRight="10dp"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
android:alpha="0.9"
|
||||||
app:layout_constraintTop_toTopOf="@id/text_title"
|
android:importantForAccessibility="no" />
|
||||||
app:layout_constraintBottom_toBottomOf="@id/text_title" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/text_title"
|
<TextView android:id="@+id/text_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="Downloading update v123"
|
android:layout_weight="1"
|
||||||
|
tools:text="Downloading v123 - 42%"
|
||||||
android:fontFamily="@font/inter_semibold"
|
android:fontFamily="@font/inter_semibold"
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
app:layout_constraintLeft_toRightOf="@id/icon_update"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintRight_toLeftOf="@id/button_close" />
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/button_close"
|
|
||||||
android:layout_width="32dp"
|
|
||||||
android:layout_height="32dp"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:src="@drawable/ic_close"
|
|
||||||
android:contentDescription="@string/dismiss"
|
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/text_body"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:text="42% downloaded"
|
|
||||||
android:fontFamily="@font/inter_light"
|
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="#9D9D9D"
|
android:textColor="@color/white"
|
||||||
android:layout_marginTop="2dp"
|
android:ellipsize="end"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
android:maxLines="1" />
|
||||||
app:layout_constraintRight_toLeftOf="@id/button_close"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/text_title" />
|
|
||||||
|
|
||||||
<ProgressBar android:id="@+id/update_banner_progress"
|
<ProgressBar android:id="@+id/update_banner_progress"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="0dp"
|
android:layout_width="78dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="4dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="4dp"
|
||||||
android:max="100"
|
android:max="100"
|
||||||
|
android:progressDrawable="@drawable/progress_update_banner"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
tools:visibility="visible" />
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/text_body" />
|
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/button_action"
|
<FrameLayout android:id="@+id/button_action"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="28dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:background="@drawable/background_button_primary_round_4dp"
|
android:background="@drawable/background_button_primary_round_4dp">
|
||||||
app:layout_constraintTop_toBottomOf="@id/update_banner_progress"
|
|
||||||
app:layout_constraintRight_toRightOf="parent">
|
|
||||||
|
|
||||||
<TextView android:id="@+id/text_action"
|
<TextView android:id="@+id/text_action"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
tools:text="Install"
|
tools:text="Install"
|
||||||
android:fontFamily="@font/inter_regular"
|
android:fontFamily="@font/inter_regular"
|
||||||
android:textSize="14sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:paddingTop="10dp"
|
android:paddingLeft="13dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingRight="13dp" />
|
||||||
android:paddingLeft="20dp"
|
|
||||||
android:paddingRight="20dp" />
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user