Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feature/account-export
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/xinto/mauth/ui/screen/home/component/HomeScaffold.kt
  • Loading branch information
X1nto committed Nov 10, 2024
2 parents 0073309 + fc524c0 commit f369b4e
Show file tree
Hide file tree
Showing 20 changed files with 479 additions and 246 deletions.
32 changes: 26 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ android {
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi" +
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api" +
"-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi"

freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:stabilityConfigurationPath=" +
"${projectDir.absolutePath}/compose_stability.conf"
)

val buildDir = layout.buildDirectory.asFile.get().absolutePath
if (project.findProperty("composeCompilerReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${buildDir}/compose_compiler"
)
}
if (project.findProperty("composeCompilerMetrics") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${buildDir}/compose_compiler"
)
}
}

buildFeatures {
Expand All @@ -55,7 +75,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion = "1.5.10"
kotlinCompilerExtensionVersion = "1.5.12"
}

packaging {
Expand Down Expand Up @@ -83,13 +103,13 @@ ksp {
}

dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.core:core-ktx:1.13.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.activity:activity-compose:1.9.0")

val composeBom = platform("androidx.compose:compose-bom:2024.03.00")
val composeBom = platform("androidx.compose:compose-bom:2024.04.01")
implementation(composeBom)
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.material:material-icons-extended")
Expand All @@ -101,7 +121,7 @@ dependencies {
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

val cameraxVersion = "1.3.2"
val cameraxVersion = "1.3.3"
implementation("androidx.camera:camera-core:$cameraxVersion")
implementation("androidx.camera:camera-camera2:$cameraxVersion")
implementation("androidx.camera:camera-view:$cameraxVersion")
Expand All @@ -115,7 +135,7 @@ dependencies {
implementation("androidx.biometric:biometric:1.1.0")
implementation("androidx.security:security-crypto-ktx:1.1.0-alpha06")

implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("androidx.datastore:datastore-preferences:1.1.0")

implementation("dev.olshevski.navigation:reimagined:1.5.0")

Expand Down
1 change: 1 addition & 0 deletions app/compose_stability.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.enums.EnumEntries

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class AccountRepository(

private fun DomainAccountInfo.toEntityAccount(): EntityAccount {
return EntityAccount(
id = id ?: UUID.randomUUID(),
id = id,
icon = icon,
secret = secret,
label = label,
Expand All @@ -168,7 +168,7 @@ class AccountRepository(
type = type,
digits = digits.toInt(),
period = period.toInt(),
createDateMillis = createdMillis ?: System.currentTimeMillis()
createDateMillis = createdMillis
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.UUID
@Immutable
@Parcelize
data class DomainAccountInfo(
val id: UUID?,
val id: UUID,
val icon: Uri?,
val label: String,
val issuer: String,
Expand All @@ -21,7 +21,7 @@ data class DomainAccountInfo(
val digits: String,
val counter: String,
val period: String,
val createdMillis: Long?
val createdMillis: Long
) : Parcelable {

fun isValid(): Boolean {
Expand All @@ -34,19 +34,20 @@ data class DomainAccountInfo(
}

companion object {
val DEFAULT = DomainAccountInfo(
id = null,
icon = null,
label = "",
issuer = "",
secret = "",
algorithm = OtpDigest.SHA1,
type = OtpType.TOTP,
digits = "6",
counter = "0",
period = "30",
createdMillis = null
)
fun new(): DomainAccountInfo {
return DomainAccountInfo(
id = UUID.randomUUID(),
icon = null,
label = "",
issuer = "",
secret = "",
algorithm = OtpDigest.SHA1,
type = OtpType.TOTP,
digits = "6",
counter = "0",
period = "30",
createdMillis = System.currentTimeMillis()
)
}
}

}
7 changes: 4 additions & 3 deletions app/src/main/java/com/xinto/mauth/domain/otp/OtpRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ class OtpRepository(
fun parseUriToAccountInfo(uri: String): DomainAccountInfo? {
return when (val parseResult = otpUriParser.parseOtpUri(uri)) {
is OtpUriParserResult.Success -> {
DomainAccountInfo.DEFAULT.copy(
val default = DomainAccountInfo.new()
default.copy(
label = parseResult.data.label,
issuer = parseResult.data.issuer,
secret = parseResult.data.secret,
algorithm = parseResult.data.algorithm,
type = parseResult.data.type,
digits = parseResult.data.digits.toString(),
counter = parseResult.data.counter?.toString() ?: DomainAccountInfo.DEFAULT.counter,
period = parseResult.data.period?.toString() ?: DomainAccountInfo.DEFAULT.period,
counter = parseResult.data.counter?.toString() ?: default.counter,
period = parseResult.data.period?.toString() ?: default.period,
)
}
is OtpUriParserResult.Failure -> null
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/xinto/mauth/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ class MainActivity : FragmentActivity() {
is MauthDestination.Home -> {
HomeScreen(
onAddAccountManually = {
navigator.navigate(MauthDestination.AddAccount(
DomainAccountInfo.DEFAULT))
navigator.navigate(
MauthDestination.AddAccount(DomainAccountInfo.new())
)
},
onAddAccountViaScanning = {
navigator.navigate(MauthDestination.QrScanner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.xinto.mauth.ui.component
import android.app.Activity
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
Expand All @@ -15,15 +14,10 @@ import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSiz
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp

/**
* @param actions Aligned respective to the top appbar (3-dot menu last)
Expand All @@ -48,7 +42,7 @@ fun ResponsiveAppBarScaffold(
TopAppBar(
title = appBarTitle,
actions = {
actions(Arrangement.Start)
actions(Arrangement.Reverse)
},
scrollBehavior = scrollBehavior
)
Expand All @@ -61,18 +55,9 @@ fun ResponsiveAppBarScaffold(
},
bottomBar = {
if (sizeClass.widthSizeClass != WindowWidthSizeClass.Expanded) {
val currentDirection = LocalLayoutDirection.current
val newDirection by remember {
derivedStateOf {
when (currentDirection) {
LayoutDirection.Ltr -> LayoutDirection.Rtl
LayoutDirection.Rtl -> LayoutDirection.Ltr
}
}
}
BottomAppBar(
actions = {
actions(Arrangement.Reverse)
actions(Arrangement.Start)
},
floatingActionButton = floatingActionButton
)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/xinto/mauth/ui/component/TwoPaneCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -42,7 +42,7 @@ fun TwoPaneCard(
visible = expanded,
) {
Column {
Divider(Modifier.padding(vertical = 12.dp))
HorizontalDivider(Modifier.padding(vertical = 12.dp))
bottomContent()
}
}
Expand Down
Loading

0 comments on commit f369b4e

Please sign in to comment.