mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a7fc549afb | |||
| b345ba5ca3 |
+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)
|
||||
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();
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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">
|
||||
<LinearLayout
|
||||
@@ -36,4 +36,4 @@
|
||||
tools:text="Tag text" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,94 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/root">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/background_16_round_4dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_margin="10dp">
|
||||
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">
|
||||
|
||||
<ImageView android:id="@+id/icon_update"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:src="@drawable/ic_update"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/text_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/text_title" />
|
||||
android:layout_marginRight="10dp"
|
||||
android:alpha="0.9"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<TextView android:id="@+id/text_title"
|
||||
android:layout_width="0dp"
|
||||
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: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:textColor="#9D9D9D"
|
||||
android:layout_marginTop="2dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@id/button_close"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_title" />
|
||||
android:textColor="@color/white"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1" />
|
||||
|
||||
<ProgressBar android:id="@+id/update_banner_progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="78dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:max="100"
|
||||
android:progressDrawable="@drawable/progress_update_banner"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_body" />
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout android:id="@+id/button_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/background_button_primary_round_4dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/update_banner_progress"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:background="@drawable/background_button_primary_round_4dp">
|
||||
|
||||
<TextView android:id="@+id/text_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
tools:text="Install"
|
||||
android:fontFamily="@font/inter_regular"
|
||||
android:textSize="14sp"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/white"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp" />
|
||||
android:paddingLeft="13dp"
|
||||
android:paddingRight="13dp" />
|
||||
</FrameLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
Submodule app/src/stable/assets/sources/apple-podcasts updated: 9c65475be1...8d9dee8a49
Submodule app/src/stable/assets/sources/bilibili updated: 9186672f0f...c63c69beec
Submodule app/src/stable/assets/sources/bitchute updated: b213f91c0b...deed10c077
Submodule app/src/stable/assets/sources/crunchyroll updated: a1714790c5...499ab8b438
Submodule app/src/stable/assets/sources/curiositystream updated: 1ebf5da236...68f85a0d62
Submodule app/src/stable/assets/sources/dailymotion updated: 70f625a3bd...256b8433e0
Submodule app/src/stable/assets/sources/fosdem updated: 2231fbec11...e8fe3b4bb5
Submodule app/src/stable/assets/sources/mixcloud updated: 1b801553b3...c107d15296
Submodule app/src/stable/assets/sources/nebula updated: 090cd76dfa...84e920f378
Submodule app/src/stable/assets/sources/odysee updated: 1c7a8a4974...c6e462db9b
Submodule app/src/stable/assets/sources/patreon updated: 52154f36c2...87b168a7cb
Submodule app/src/stable/assets/sources/peertube updated: 7b52405ad0...c955d8ed56
Submodule app/src/stable/assets/sources/redbull-tv updated: 179b7a6e22...7f4317f5c7
Submodule app/src/stable/assets/sources/soundcloud updated: e785c5d8c9...8ed7c19c45
Submodule app/src/stable/assets/sources/tedtalks updated: 292e459eef...f7f31a4f9a
Submodule app/src/stable/assets/sources/twitch updated: cebdad37a3...3a46d407de
Submodule app/src/stable/assets/sources/youtube updated: fb90a44f83...746b390387
Submodule app/src/unstable/assets/sources/apple-podcasts updated: 9c65475be1...8d9dee8a49
Submodule app/src/unstable/assets/sources/bilibili updated: 9186672f0f...c63c69beec
Submodule app/src/unstable/assets/sources/bitchute updated: b213f91c0b...deed10c077
Submodule app/src/unstable/assets/sources/crunchyroll updated: a1714790c5...499ab8b438
Submodule app/src/unstable/assets/sources/curiositystream updated: 1ebf5da236...68f85a0d62
Submodule app/src/unstable/assets/sources/dailymotion updated: 70f625a3bd...256b8433e0
Submodule app/src/unstable/assets/sources/fosdem updated: 2231fbec11...e8fe3b4bb5
Submodule app/src/unstable/assets/sources/mixcloud updated: 1b801553b3...c107d15296
Submodule app/src/unstable/assets/sources/nebula updated: 090cd76dfa...84e920f378
Submodule app/src/unstable/assets/sources/odysee updated: 1c7a8a4974...c6e462db9b
Submodule app/src/unstable/assets/sources/patreon updated: 52154f36c2...87b168a7cb
Submodule app/src/unstable/assets/sources/peertube updated: 7b52405ad0...c955d8ed56
Submodule app/src/unstable/assets/sources/redbull-tv updated: 179b7a6e22...7f4317f5c7
Submodule app/src/unstable/assets/sources/soundcloud updated: e785c5d8c9...8ed7c19c45
Submodule app/src/unstable/assets/sources/tedtalks updated: 292e459eef...f7f31a4f9a
Submodule app/src/unstable/assets/sources/twitch updated: cebdad37a3...3a46d407de
Submodule app/src/unstable/assets/sources/youtube updated: fb90a44f83...746b390387
Reference in New Issue
Block a user