diff --git a/androidApp/release/output-metadata.json b/androidApp/release/output-metadata.json new file mode 100644 index 0000000..14f9103 --- /dev/null +++ b/androidApp/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "dev.haroldjose.familysharedlist.android", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0", + "outputFile": "androidApp-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index a3a780b..1ee504a 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -8,13 +8,14 @@ - + > diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity.kt index 1bff3ad..9214ed1 100644 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity.kt +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity.kt @@ -8,7 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.* import androidx.compose.ui.Modifier import dev.haroldjose.familysharedlist.AndroidPlatform -import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigationView +import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigatorView +import org.koin.compose.koinInject class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -22,7 +23,7 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - NavigationView() + NavigatorView(viewModel = koinInject()) } } } diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity_bkp.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity_bkp.kt deleted file mode 100644 index 7d8d12c..0000000 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/app/MainActivity_bkp.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* -package dev.haroldjose.familysharedlist.android.app - -import android.content.pm.ApplicationInfo -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import dev.haroldjose.familysharedlist.AndroidPlatform -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.ui.Modifier - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - AndroidPlatform.androidContextForKmm = this - AndroidPlatform.isDebuggable = (0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) - setContent { - MyApplicationTheme { - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background - ) { - NavigationView() - } - } - } - } -}*/ diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/dependencyInjection/AndroidModule.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/dependencyInjection/AndroidModule.kt index 5f6a26f..6d3729e 100644 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/dependencyInjection/AndroidModule.kt +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/dependencyInjection/AndroidModule.kt @@ -2,6 +2,8 @@ package dev.haroldjose.familysharedlist.android.dependencyInjection import dev.haroldjose.familysharedlist.android.presentationLayer.pages.familyList.FamilyListViewModel import dev.haroldjose.familysharedlist.android.presentationLayer.pages.familyList.IFamilyListViewModel +import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.INavigatorViewModel +import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigatorViewModel import dev.haroldjose.familysharedlist.android.presentationLayer.pages.quickInsertList.IQuickInsertListViewModel import dev.haroldjose.familysharedlist.android.presentationLayer.pages.quickInsertList.QuickInsertListViewModel import dev.haroldjose.familysharedlist.android.presentationLayer.pages.settings.ISettingsViewModel @@ -15,4 +17,5 @@ val androidModule = module { factoryOf(::SettingsViewModel) bind ISettingsViewModel::class factoryOf(::FamilyListViewModel) bind IFamilyListViewModel::class factoryOf(::QuickInsertListViewModel) bind IQuickInsertListViewModel::class + factoryOf(::NavigatorViewModel) bind INavigatorViewModel::class } \ No newline at end of file diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/INavigatorViewModel.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/INavigatorViewModel.kt new file mode 100644 index 0000000..c2a4886 --- /dev/null +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/INavigatorViewModel.kt @@ -0,0 +1,5 @@ +package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator + +interface INavigatorViewModel { + suspend fun checkIfNeedToCreateNewAccount() +} \ No newline at end of file diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigationView.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorView.kt similarity index 95% rename from androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigationView.kt rename to androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorView.kt index 87d1f93..587f458 100644 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigationView.kt +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorView.kt @@ -3,7 +3,6 @@ package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigato import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview import androidx.navigation.NavHostController -import androidx.navigation.Navigator import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController @@ -17,7 +16,9 @@ import dev.haroldjose.familysharedlist.android.presentationLayer.pages.settings. import org.koin.compose.koinInject @Composable -fun NavigationView() { +fun NavigatorView( + viewModel: INavigatorViewModel +) { val navController: NavHostController = rememberNavController() NavHost(navController = navController, startDestination = ViewRouter.QUICK_INSERT.value) { composable(ViewRouter.FAMILY_LIST.value) { @@ -63,7 +64,7 @@ private enum class ViewRouter(val value: String) { @Composable fun FamilyListPage_Preview() { MyApplicationTheme { - NavigationView() + NavigatorView(viewModel = NavigatorViewModelMock()) } } diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorViewModel.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorViewModel.kt new file mode 100644 index 0000000..3cb8e02 --- /dev/null +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/navigator/NavigatorViewModel.kt @@ -0,0 +1,15 @@ +package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator + +import dev.haroldjose.familysharedlist.domainLayer.usecases.account.GetOrCreateAccountFromLocalUuidUseCase + +class NavigatorViewModel( + private val getOrCreateAccountFromLocalUuidUseCase: GetOrCreateAccountFromLocalUuidUseCase, +): INavigatorViewModel { + override suspend fun checkIfNeedToCreateNewAccount() { + getOrCreateAccountFromLocalUuidUseCase.execute() + } +} + +class NavigatorViewModelMock(): INavigatorViewModel { + override suspend fun checkIfNeedToCreateNewAccount() {} +} \ No newline at end of file diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListPage.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListPage.kt index 347f0ee..4d4d8fe 100644 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListPage.kt +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListPage.kt @@ -4,9 +4,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField @@ -16,7 +14,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview @@ -57,8 +54,7 @@ fun QuickInsertListPage( keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.None, autoCorrect = true, - keyboardType = KeyboardType.Text, - imeAction = ImeAction.Done + keyboardType = KeyboardType.Text ), ) } diff --git a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListViewModel.kt b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListViewModel.kt index aa04978..ab455b4 100644 --- a/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListViewModel.kt +++ b/androidApp/src/main/java/dev/haroldjose/familysharedlist/android/presentationLayer/pages/quickInsertList/QuickInsertListViewModel.kt @@ -18,13 +18,17 @@ class QuickInsertListViewModel( if (text.isEmpty()) return - val listOfItem = text.lines().map { item -> + val listOfItem = text.lines().mapNotNull { item -> //extrai os numeros val quantityStr = item.filter { it.isDigit() }.toIntOrNull() //extrai o nome val name = item.filter { !it.isDigit() } - return@map FamilyListModel( + + if (name.isEmpty()) + return@mapNotNull null + + return@mapNotNull FamilyListModel( name = name.ifEmpty { item }, isPrioritized = true, quantity = quantityStr ?: 1 diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml new file mode 100644 index 0000000..d10ccb4 --- /dev/null +++ b/androidApp/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Family List + \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/dev/haroldjose/familysharedlist/domainLayer/usecases/account/GetOrCreateAccountFromLocalUuidUseCase.kt b/shared/src/commonMain/kotlin/dev/haroldjose/familysharedlist/domainLayer/usecases/account/GetOrCreateAccountFromLocalUuidUseCase.kt index 83d916b..533aeb5 100644 --- a/shared/src/commonMain/kotlin/dev/haroldjose/familysharedlist/domainLayer/usecases/account/GetOrCreateAccountFromLocalUuidUseCase.kt +++ b/shared/src/commonMain/kotlin/dev/haroldjose/familysharedlist/domainLayer/usecases/account/GetOrCreateAccountFromLocalUuidUseCase.kt @@ -48,14 +48,8 @@ class GetOrCreateAccountFromLocalUuidUseCase( private fun getOrCreateUuid(): String { //try to get local UUID - val accountUuid = keyValueStorageRepository.getString( - key = KeyValueStorageRepositoryEnum.ACCOUNT_UUID - ) - - accountUuid?.let { - if (it.isNotEmpty()) { - return it - } + keyValueStorageRepository.getString(key = KeyValueStorageRepositoryEnum.ACCOUNT_UUID)?.let { + if (it.isNotEmpty()) return it } //Generate new Account UUID for this device