Skip to content

Commit

Permalink
[FIX] Fixed a minor Bug in MainActivity
Browse files Browse the repository at this point in the history
[FEAT] Added progress tracking in Gallery from MainActivity.inAppUpdateProgress
  • Loading branch information
iZakirSheikh committed Sep 15, 2024
1 parent 2b08c97 commit 1652713
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "com.googol.android.apps.photos"
minSdk = 24
targetSdk = 35
versionCode = 19
versionName = "0.1.0-dev19"
versionCode = 20
versionName = "0.1.0-dev2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/zs/gallery/Gallery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ fun Gallery(
toastHostState = toastHostState,
hideNavigationBar = !requiresNavBar,
background = AppTheme.colors.background,
progress = activity.inAppUpdateProgress,
// Set up the navigation bar using the NavBar composable
navBar = {
NavigationBar(
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/zs/gallery/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.content.res.Configuration
import android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_STRONG
import android.hardware.biometrics.BiometricManager.Authenticators.DEVICE_CREDENTIAL
import android.hardware.biometrics.BiometricPrompt
import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback
import android.os.Build
import android.os.Bundle
import android.os.CancellationSignal
Expand All @@ -37,7 +38,9 @@ import androidx.compose.material.icons.outlined.Downloading
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
Expand Down Expand Up @@ -123,7 +126,8 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
private val toastHostState: ToastHostState by inject()
private val preferences: Preferences by inject()
private var navController: NavHostController? = null
private val inAppUpdateProgress = mutableFloatStateOf(Float.NaN)
var inAppUpdateProgress by mutableFloatStateOf(Float.NaN)
private set

/**
* Timestamp (mills) indicating when the app last went to the background.
Expand Down Expand Up @@ -236,7 +240,7 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
object : BiometricPrompt.AuthenticationCallback() {
// Implement callback methods for authentication events (success, error, etc.)
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) {
showPlatformToast("Authentication Successful! Welcome back.")
showPlatformToast("Authentication Successful!")
onAuthenticated()
}

Expand Down Expand Up @@ -387,11 +391,6 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
flow1.combine(flow2) { _, _ -> enableEdgeToEdge() }
.launchIn(scope = lifecycleScope)
lifecycleScope.launch { launchUpdateFlow() }
if (isAuthenticationRequired)
lifecycleScope.launch {
delay(1000)
unlock()
}
}

override fun launchUpdateFlow(report: Boolean) {
Expand All @@ -408,7 +407,7 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
total == downloaded -> Float.NaN
else -> downloaded / total.toFloat()
}
inAppUpdateProgress.floatValue = progress
inAppUpdateProgress = progress
}

is AppUpdateResult.Downloaded -> {
Expand Down Expand Up @@ -525,6 +524,7 @@ class MainActivity : ComponentActivity(), SystemFacade, NavController.OnDestinat
navController.navigate(RouteLockScreen()) {
launchSingleTop = true
}
unlock()
}
this@MainActivity.navController = navController
onDispose {
Expand Down
4 changes: 3 additions & 1 deletion foundation/src/main/java/com/zs/foundation/AppTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.times
import androidx.core.graphics.ColorUtils
import com.primex.core.BlueLilac
import com.primex.core.MetroGreen
import com.primex.core.MetroGreen2
import com.primex.core.OrientRed
import com.primex.core.Rose
import com.primex.core.SepiaBrown
import com.primex.core.SignalWhite
import com.primex.core.TrafficYellow
import com.primex.core.UmbraGrey
Expand Down Expand Up @@ -416,7 +418,7 @@ fun AppTheme(
fontFamily: FontFamily = FontFamily.Default,
content: @Composable () -> Unit
) {
val accent = if (!isLight) Color.TrafficYellow else Color.BlueLilac
val accent = if (!isLight) Color.TrafficYellow else Color.SepiaBrown
val background by animateColorAsState(
targetValue = if (!isLight) Color(0xFF0E0E0F) else applyTonalElevation(
accent,
Expand Down

0 comments on commit 1652713

Please sign in to comment.