Skip to content

Commit

Permalink
Manual Check Self Updates (#685)
Browse files Browse the repository at this point in the history
**Background**

Now we check updates only in start app

**Changes**

* Self updater now suspend and don't depend from Activity and on result
send action
* Method for support manual check self update yes/no
* VersionVM for check update, state dialog/progress
* Remove FDroid self update
* Activate Debug Options by 10 click on card, check updated – click on
text “Check Updates”
* Can not run Check updates if we're now running (with progress state)
* Fix GitHub download release
* Notification on error(if we manual check), on start

**Test plan**

Have Installed GitHub or Debug build
Go to Options -> Check Updates -> wait for loading info

---------

Co-authored-by: Nikita Kulikov <[email protected]>
  • Loading branch information
Programistich and LionZXY authored Sep 11, 2023
1 parent 1a4a9fc commit 927b05b
Show file tree
Hide file tree
Showing 42 changed files with 1,839 additions and 251 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# 1.6.5 - In progress

- [Feature] Check Self Update App in Optiond (only for github)

# 1.6.4

- [Feature] Add transparent flipper mockup
Expand All @@ -10,6 +12,7 @@
- [Feature] Add fap manifest caching
- [Feature] Not send empty report in faphub
- [Feature] Add hide app button
- [Feature] Check Self Update App in Optiond (only for github)
- [CI] Add apk artifacts to Pull Requests
- [CI] Fix failed build in merge_group
- [CI] Bump deps except Sentry-gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ object ApkConfig {
return@run SourceInstall.DEBUG
}
return@run when (providers.gradleProperty("source_install").orNull) {
"fdroid" -> SourceInstall.FDROID
"github" -> SourceInstall.GITHUB
"googleplay" -> SourceInstall.GOOGLE_PLAY
else -> SourceInstall.UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.flipperdevices.buildlogic
enum class SourceInstall {
GITHUB,
GOOGLE_PLAY,
FDROID,
UNKNOWN,
DEBUG
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fun OrangeAppBar(
modifier = Modifier
.padding(top = 11.dp, bottom = 11.dp, start = 16.dp, end = 2.dp)
.size(20.dp)
.clickableRipple(onClick = onBack),
.clickableRipple(bounded = false, onClick = onBack),
painter = painterResource(DesignSystem.drawable.ic_back),
contentDescription = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ sealed class InAppNotification {
override val durationMs = NOTIFICATION_REPORT_APP_MS
}

data class UpdateReady(
data class SelfUpdateReady(
val action: () -> Unit,
override val durationMs: Long = NOTIFICATION_UPDATE_MS
) : InAppNotification()

data class SelfUpdateStarted(
override val durationMs: Long = NOTIFICATION_UPDATE_MS
) : InAppNotification()

data class SelfUpdateError(
override val durationMs: Long = NOTIFICATION_UPDATE_MS
) : InAppNotification()

data class HiddenApp(
val action: () -> Unit,
override val durationMs: Long = NOTIFICATION_HIDE_APP_MS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import com.flipperdevices.inappnotification.api.model.InAppNotification
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationHideApp
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationReportApp
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationSavedKey
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationUpdateReady
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationSelfUpdateError
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationSelfUpdateReady
import com.flipperdevices.inappnotification.impl.composable.type.ComposableInAppNotificationSelfUpdateStarted
import kotlin.math.max

const val VISIBLE_ANIMATION_MS = 1000
Expand Down Expand Up @@ -71,14 +73,22 @@ private fun ComposableInAppNotificationCard(
ComposableInAppNotificationSavedKey(notification)
}

is InAppNotification.UpdateReady -> {
ComposableInAppNotificationUpdateReady(notification) {
is InAppNotification.SelfUpdateReady -> {
ComposableInAppNotificationSelfUpdateReady(notification) {
visibleState = false
actionClicked = true
onNotificationHidden()
}
}

is InAppNotification.SelfUpdateError -> {
ComposableInAppNotificationSelfUpdateError()
}

is InAppNotification.SelfUpdateStarted -> {
ComposableInAppNotificationSelfUpdateStarted()
}

InAppNotification.ReportApp -> ComposableInAppNotificationReportApp()
is InAppNotification.HiddenApp -> ComposableInAppNotificationHideApp(
notification = notification,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.flipperdevices.inappnotification.impl.composable.type

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.flipperdevices.core.ui.theme.FlipperThemeInternal
import com.flipperdevices.core.ui.theme.LocalTypography
import com.flipperdevices.inappnotification.impl.R

@Composable
internal fun ComposableInAppNotificationSelfUpdateError() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(12.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(id = R.drawable.pic_update_error),
contentDescription = stringResource(R.string.error_update_title),
)
Column {
Text(
text = stringResource(R.string.error_update_title),
style = LocalTypography.current.subtitleB12
)
Text(
text = stringResource(R.string.error_update_desc),
style = LocalTypography.current.subtitleR12
)
}
}
}

@Preview(
fontScale = 2.0f
)
@Composable
private fun ComposableInAppNotificationSelfUpdateErrorPreviewX2Font() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateError()
}
}

@Preview(
fontScale = 1.5f
)
@Composable
private fun ComposableInAppNotificationSelfUpdateErrorPreviewX15Font() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateError()
}
}

@Preview
@Composable
private fun ComposableInAppNotificationSelfUpdateErrorPreview() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateError()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import com.flipperdevices.inappnotification.api.model.InAppNotification
import com.flipperdevices.inappnotification.impl.R

@Composable
internal fun ComposableInAppNotificationUpdateReady(
notification: InAppNotification.UpdateReady,
internal fun ComposableInAppNotificationSelfUpdateReady(
notification: InAppNotification.SelfUpdateReady,
onClickAction: () -> Unit,
) {
Row(
Expand Down Expand Up @@ -66,8 +66,8 @@ internal fun ComposableInAppNotificationUpdateReady(
@Composable
private fun ComposableInAppNotificationUpdateReadyPreviewX2Font() {
FlipperThemeInternal {
ComposableInAppNotificationUpdateReady(
notification = InAppNotification.UpdateReady(
ComposableInAppNotificationSelfUpdateReady(
notification = InAppNotification.SelfUpdateReady(
durationMs = 0,
action = { },
),
Expand All @@ -82,8 +82,8 @@ private fun ComposableInAppNotificationUpdateReadyPreviewX2Font() {
@Composable
private fun ComposableInAppNotificationUpdateReadyPreviewX15Font() {
FlipperThemeInternal {
ComposableInAppNotificationUpdateReady(
notification = InAppNotification.UpdateReady(
ComposableInAppNotificationSelfUpdateReady(
notification = InAppNotification.SelfUpdateReady(
durationMs = 0,
action = { },
),
Expand All @@ -96,8 +96,8 @@ private fun ComposableInAppNotificationUpdateReadyPreviewX15Font() {
@Composable
private fun ComposableInAppNotificationUpdateReadyPreview() {
FlipperThemeInternal {
ComposableInAppNotificationUpdateReady(
notification = InAppNotification.UpdateReady(
ComposableInAppNotificationSelfUpdateReady(
notification = InAppNotification.SelfUpdateReady(
durationMs = 0,
action = { },
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.flipperdevices.inappnotification.impl.composable.type

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.flipperdevices.core.ui.theme.FlipperThemeInternal
import com.flipperdevices.core.ui.theme.LocalTypography
import com.flipperdevices.inappnotification.impl.R

@Composable
internal fun ComposableInAppNotificationSelfUpdateStarted() {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(12.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(id = R.drawable.pic_update_started),
contentDescription = stringResource(R.string.started_update_title),
)
Column {
Text(
text = stringResource(R.string.started_update_title),
style = LocalTypography.current.subtitleB12
)
Text(
text = stringResource(R.string.started_update_desc),
style = LocalTypography.current.subtitleR12
)
}
}
}

@Preview(
fontScale = 2.0f
)
@Composable
private fun ComposableInAppNotificationSelfUpdateStartedPreviewX2Font() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateStarted()
}
}

@Preview(
fontScale = 1.5f
)
@Composable
private fun ComposableInAppNotificationSelfUpdateStartedPreviewX15Font() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateStarted()
}
}

@Preview
@Composable
private fun ComposableInAppNotificationSelfUpdateStartedPreview() {
FlipperThemeInternal {
ComposableInAppNotificationSelfUpdateStarted()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>
<path
android:pathData="M11.999,23.331C18.259,23.331 23.333,18.257 23.333,11.997C23.333,5.738 18.259,0.664 11.999,0.664C5.74,0.664 0.666,5.738 0.666,11.997C0.666,18.257 5.74,23.331 11.999,23.331Z"
android:fillColor="#F63F3F"/>
<path
android:pathData="M12.002,17.302m-1.336,0a1.336,1.336 0,1 1,2.671 0a1.336,1.336 0,1 1,-2.671 0"
android:fillColor="#ffffff"/>
<path
android:pathData="M12.002,5.331L12.002,5.331A1.336,1.336 0,0 1,13.337 6.667L13.337,12.932A1.336,1.336 0,0 1,12.002 14.268L12.002,14.268A1.336,1.336 0,0 1,10.666 12.932L10.666,6.667A1.336,1.336 0,0 1,12.002 5.331z"
android:fillColor="#ffffff"/>
</group>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M3.182,4.204C4.773,2.632 7.59,1 11.046,1C14.493,1 17.25,2.564 18.849,4.143C20.124,5.403 21.44,7.441 21.911,9.96L21.905,9.922C22.384,9.449 23.161,9.449 23.64,9.922C24.12,10.396 24.12,11.163 23.64,11.637L21.733,13.978C21.291,14.415 20.587,14.454 20.098,14.068L17.81,11.626C17.281,11.208 17.195,10.445 17.618,9.922C18.042,9.4 18.814,9.315 19.344,9.733C18.891,8.072 17.984,6.718 17.113,5.857C15.894,4.653 13.736,3.424 11.046,3.424C8.366,3.424 6.145,4.706 4.918,5.918C3.699,7.122 2.455,9.253 2.455,11.909C2.455,14.556 3.752,16.749 4.979,17.961C6.199,19.165 8.356,20.394 11.046,20.394C11.724,20.394 12.274,20.937 12.274,21.606C12.274,22.275 11.724,22.818 11.046,22.818C7.599,22.818 4.843,21.254 3.244,19.675C1.653,18.104 -0,15.323 -0,11.909C-0,8.505 1.583,5.783 3.182,4.204ZM19.344,9.733C19.412,9.983 19.469,10.24 19.515,10.503L19.344,9.733ZM21.971,10.314C21.953,10.195 21.933,10.077 21.911,9.96L21.971,10.314Z"
android:fillColor="#589DFF"
android:fillType="evenOdd"/>
<path
android:pathData="M15,9L10.188,15L8,12.273"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#589DFF"
android:strokeLineCap="round"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ready_update_title">Flipper App Update</string>
<string name="ready_update_desc">New version is ready to install</string>
<string name="ready_update_title">Flipper Mobile App Update</string>
<string name="ready_update_desc">New app version is ready to install</string>
<string name="ready_update_button">Update</string>

<string name="saved_key_desc">saved to Archive</string>
Expand All @@ -11,4 +11,10 @@
<string name="hide_app_title">App is Hidden</string>
<string name="hide_app_desc">You won’t see this app again</string>
<string name="hide_app_btn">Undo</string>

<string name="started_update_title">Update Started…</string>
<string name="started_update_desc">Track progress in your phone`s Notification Bar</string>

<string name="error_update_title">Unable to Update</string>
<string name="error_update_desc">Сheck your internet connection or try again later</string>
</resources>
4 changes: 3 additions & 1 deletion components/selfupdater/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ plugins {

android.namespace = "com.flipperdevices.selfupdater.api"

dependencies {}
dependencies {
implementation(libs.kotlin.coroutines)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.flipperdevices.selfupdater.api

import android.app.Activity
import com.flipperdevices.selfupdater.models.SelfUpdateResult
import kotlinx.coroutines.flow.StateFlow

interface SelfUpdaterApi {
fun startCheckUpdateAsync(activity: Activity)
suspend fun startCheckUpdate(manual: Boolean = false): SelfUpdateResult

fun getInProgressState(): StateFlow<Boolean>

fun getInstallSourceName(): String

fun isSelfUpdateCanManualCheck(): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.flipperdevices.selfupdater.api

import com.flipperdevices.selfupdater.models.SelfUpdateResult

interface SelfUpdaterSourceApi {
suspend fun checkUpdate(manual: Boolean): SelfUpdateResult

fun getInstallSourceName(): String

fun isSelfUpdateCanManualCheck(): Boolean
}
Loading

0 comments on commit 927b05b

Please sign in to comment.