Skip to content

Commit

Permalink
finish adapting install ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Feb 6, 2024
1 parent f0b83bb commit ed03128
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class StepRunner : KoinComponent {
inline fun <reified T : Step> getStep(): T {
val step = steps.asSequence()
.filterIsInstance<T>()
.filter { it.state == StepState.Success }
.filter { it.state.isFinished }
.firstOrNull()

if (step == null) {
Expand All @@ -37,8 +37,8 @@ abstract class StepRunner : KoinComponent {

// Add delay for human psychology and
// better group visibility in UI (the active group can change way too fast)
if (!preferences.devMode && step.durationMs < 1000) {
delay(1000L - step.durationMs)
if (!preferences.devMode && step.durationMs < 500) {
delay(500L - step.durationMs)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class DownloadStep : Step(), KoinComponent {
}

is DownloadManager.Result.Cancelled ->
state = StepState.Cancelled
state = StepState.Error
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ abstract class Step {
val (error, executionTimeMs) = measureTimedValue {
try {
execute(container)
state = StepState.Success

if (state != StepState.Skipped)
state = StepState.Success

null
} catch (t: Throwable) {
state = StepState.Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ enum class StepState {
Running,
Success,
Error,
Skipped,
Cancelled, // TODO: something like the discord dnd sign except its not red, but gray maybe
Skipped;

val isFinished: Boolean
get() = this == Success || this == Error || this == Skipped
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.app.Application
import android.app.DownloadManager
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.util.Log
import androidx.annotation.StringRes
import androidx.core.content.getSystemService
import com.aliucord.manager.BuildConfig
Expand Down Expand Up @@ -40,10 +42,16 @@ class DownloadManager(application: Application) {
.setTitle("Aliucord Manager")
.setDescription("Downloading ${out.name}...")
.setDestinationUri(Uri.fromFile(out))
.setAllowedOverMetered(true)
.setAllowedOverRoaming(true)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.addRequestHeader("User-Agent", "Aliucord Manager/${BuildConfig.VERSION_NAME}")
.apply {
// Disable gzip on emulator due to https compression bug
println(Build.PRODUCT)
// if (Build.PRODUCT == "google_sdk") {
Log.i(BuildConfig.TAG, "Disabling DownloadManager compression")
addRequestHeader("Accept-Encoding", null)
// }
}
.let(downloadManager::enqueue)

// Repeatedly request download state until it is finished
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ class InstallModel(
val gitChanges = if (BuildConfig.GIT_LOCAL_CHANGES || BuildConfig.GIT_LOCAL_COMMITS) "(Changes present)" else ""
val soc = if (Build.VERSION.SDK_INT >= 31) (Build.SOC_MANUFACTURER + ' ' + Build.SOC_MODEL) else "Unknown"

return """
val header = """
Aliucord Manager v${BuildConfig.VERSION_NAME}
Built from commit ${BuildConfig.GIT_COMMIT} on ${BuildConfig.GIT_BRANCH} $gitChanges
Running Android ${Build.VERSION.RELEASE}, API level ${Build.VERSION.SDK_INT}
Supported ABIs: ${Build.SUPPORTED_ABIS.joinToString()}
Device: ${Build.MANUFACTURER} - ${Build.MODEL} (${Build.DEVICE})
SOC: $soc
${Log.getStackTraceString(stacktrace)}
""".trimIndent()

return header + "\n\n" + Log.getStackTraceString(stacktrace)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.aliucord.manager.R
import com.aliucord.manager.installer.steps.StepGroup
import com.aliucord.manager.ui.components.back
import com.aliucord.manager.ui.components.dialogs.InstallerAbortDialog
import com.aliucord.manager.ui.components.installer.InstallGroup
import com.aliucord.manager.ui.screens.install.components.StepGroupCard

class InstallScreen : Screen {
override val key = "Install"
Expand Down Expand Up @@ -97,11 +97,11 @@ class InstallScreen : Screen {

model.installSteps?.let { groupedSteps ->
for ((group, steps) in groupedSteps.entries) key(group) {
InstallGroup(
StepGroupCard(
name = stringResource(group.localizedName),
isCurrent = group == expandedGroup,
onClick = remember { { expandedGroup = group } },
subSteps = steps,
isExpanded = expandedGroup == group,
onExpand = { expandedGroup = group },
)
}
}
Expand Down
Loading

0 comments on commit ed03128

Please sign in to comment.