diff --git a/README.md b/README.md
index afd04e1..7ecb84e 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ Safe Box is an easy to use, secure app which will store all your data in a super
+
diff --git a/app/build.gradle b/app/build.gradle
index d691912..adf8a02 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -21,9 +21,9 @@ android {
applicationId "com.andryoga.safebox"
minSdkVersion 23
targetSdkVersion 30
- versionCode 6
+ versionCode 7
// majorVersion.minorVersion.dbVersion.fixVersion
- versionName "1.4.4.0"
+ versionName "1.5.4.0"
//room.incremental: Enables Gradle incremental annotation processor
//room.expandProjection: Configures Room to rewrite queries such that their top star projection is expanded to only contain the columns defined in the DAO method return type.
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/MainActivity.kt b/app/src/main/java/com/andryoga/safebox/ui/view/MainActivity.kt
index 057e639..c53086d 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/MainActivity.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/MainActivity.kt
@@ -74,6 +74,8 @@ class MainActivity : AppCompatActivity() {
drawerLayout = binding.drawerLayout
binding.lifecycleOwner = this
+ setSupportActionBar(findViewById(R.id.my_toolbar))
+
// top level navigation for which back button should not appear
appBarConfiguration = AppBarConfiguration(
drawerLayoutTopLevelNavigationIds,
@@ -150,7 +152,15 @@ class MainActivity : AppCompatActivity() {
fun setSupportActionBarVisibility(isVisible: Boolean) {
Timber.i("setting support action bar visibility to $isVisible")
- if (isVisible) supportActionBar?.show() else supportActionBar?.hide()
+ if (isVisible) {
+ supportActionBar?.show()
+ binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
+ } else {
+ supportActionBar?.hide()
+ // doing below so that even sliding from screen start to end
+ // doesn't open the drawer
+ binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
+ }
}
// this is directly called from xml so view input param is required
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoFragment.kt
index 07ddcd4..f37d6f5 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoFragment.kt
@@ -1,9 +1,8 @@
package com.andryoga.safebox.ui.view.home.child.all
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
+import androidx.appcompat.widget.SearchView
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
@@ -48,8 +47,10 @@ class AllInfoFragment : Fragment() {
savedInstanceState: Bundle?
): View {
Timber.i("on create view of all info fragment")
+ setHasOptionsMenu(true)
return ComposeView(requireContext()).apply {
setContent {
+ val searchTextFilter by viewModel.searchTextFilter.collectAsState()
val listData by viewModel.allData.collectAsState(
initial = Resource.loading(
emptyList()
@@ -64,11 +65,12 @@ class AllInfoFragment : Fragment() {
}
UserDataList(
listResource = listData,
+ searchTextFilter = searchTextFilter,
onItemClick = { onListItemClick(it) },
onDeleteItemClick = { viewModel.onDeleteItemClick(it) }
)
}
- AddNewDataFab() {
+ AddNewDataFab {
findNavController()
.navigate(R.id.action_nav_all_info_to_addNewUserPersonalDataDialogFragment)
}
@@ -89,6 +91,22 @@ class AllInfoFragment : Fragment() {
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.home_info_screen, menu)
+ val searchView = menu.findItem(R.id.action_search).actionView as SearchView
+
+ searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
+ override fun onQueryTextSubmit(query: String?): Boolean {
+ return false
+ }
+
+ override fun onQueryTextChange(newText: String?): Boolean {
+ viewModel.setSearchText(newText)
+ return true
+ }
+ })
+ }
+
private fun onListItemClick(item: UserListItemData) {
val id = item.id
Timber.i("clicked $id - ${item.type.name}")
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoViewModel.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoViewModel.kt
index 7872608..5c4d3f8 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoViewModel.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/all/AllInfoViewModel.kt
@@ -22,9 +22,12 @@ class AllInfoViewModel @Inject constructor(
private val secureNoteDataRepository: SecureNoteDataRepository,
private val backupMetadataRepository: BackupMetadataRepository
) : ViewModel() {
- private val _isBackupPathSet = MutableStateFlow(true)
+ private val _isBackupPathSet = MutableStateFlow(true)
val isBackupPathSet: StateFlow = _isBackupPathSet
+ private val _searchTextFilter = MutableStateFlow(null)
+ val searchTextFilter: StateFlow = _searchTextFilter
+
init {
viewModelScope.launch(Dispatchers.IO) {
backupMetadataRepository.getBackupMetadata().collect {
@@ -158,6 +161,10 @@ class AllInfoViewModel @Inject constructor(
}
}
+ fun setSearchText(searchText: String?) {
+ _searchTextFilter.value = searchText
+ }
+
// This method is for test purpose only
// should never be called in production code
fun insertDummyData() {
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoFragment.kt
index ae10f37..d6aba65 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoFragment.kt
@@ -1,9 +1,8 @@
package com.andryoga.safebox.ui.view.home.child.bankAccountInfo
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
+import androidx.appcompat.widget.SearchView
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -30,9 +29,10 @@ class BankAccountInfoFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
+ setHasOptionsMenu(true)
return ComposeView(requireContext()).apply {
-
setContent {
+ val searchTextFilter by viewModel.searchTextFilter.collectAsState()
val listData by viewModel.listData.collectAsState(
initial = Resource.loading(
emptyList()
@@ -41,10 +41,11 @@ class BankAccountInfoFragment : Fragment() {
BasicSafeBoxTheme {
UserDataList(
listResource = listData,
+ searchTextFilter = searchTextFilter,
onItemClick = { onListItemClick(it) },
onDeleteItemClick = { viewModel.onDeleteItemClick(it) }
)
- AddNewDataFab() {
+ AddNewDataFab {
findNavController()
.navigate(R.id.action_nav_bank_account_info_to_addNewUserPersonalDataDialogFragment)
}
@@ -53,6 +54,22 @@ class BankAccountInfoFragment : Fragment() {
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.home_info_screen, menu)
+ val searchView = menu.findItem(R.id.action_search).actionView as SearchView
+
+ searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
+ override fun onQueryTextSubmit(query: String?): Boolean {
+ return false
+ }
+
+ override fun onQueryTextChange(newText: String?): Boolean {
+ viewModel.setSearchText(newText)
+ return true
+ }
+ })
+ }
+
private fun onListItemClick(item: UserListItemData) {
Timber.i("clicked ${item.id}")
findNavController().navigate(
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoViewModel.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoViewModel.kt
index 3763a9f..3ce1f2e 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoViewModel.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankAccountInfo/BankAccountInfoViewModel.kt
@@ -8,10 +8,7 @@ import com.andryoga.safebox.ui.common.UserDataType
import com.andryoga.safebox.ui.view.home.child.common.UserListItemData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.transform
+import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -19,6 +16,10 @@ import javax.inject.Inject
class BankAccountInfoViewModel @Inject constructor(
private val bankAccountDataRepository: BankAccountDataRepository
) : ViewModel() {
+
+ private val _searchTextFilter = MutableStateFlow(null)
+ val searchTextFilter: StateFlow = _searchTextFilter
+
val listData = flow>> {
bankAccountDataRepository
.getAllBankAccountData()
@@ -48,4 +49,8 @@ class BankAccountInfoViewModel @Inject constructor(
bankAccountDataRepository.deleteBankAccountDataByKey(key)
}
}
+
+ fun setSearchText(searchText: String?) {
+ _searchTextFilter.value = searchText
+ }
}
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoFragment.kt
index eb94e19..55e5c99 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoFragment.kt
@@ -1,9 +1,8 @@
package com.andryoga.safebox.ui.view.home.child.bankCardInfo
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
+import androidx.appcompat.widget.SearchView
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -30,9 +29,10 @@ class BankCardInfoFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
+ setHasOptionsMenu(true)
return ComposeView(requireContext()).apply {
-
setContent {
+ val searchTextFilter by viewModel.searchTextFilter.collectAsState()
val listData by viewModel.listData.collectAsState(
initial = Resource.loading(
emptyList()
@@ -41,10 +41,11 @@ class BankCardInfoFragment : Fragment() {
BasicSafeBoxTheme {
UserDataList(
listResource = listData,
+ searchTextFilter = searchTextFilter,
onItemClick = { onListItemClick(it) },
onDeleteItemClick = { viewModel.onDeleteItemClick(it) }
)
- AddNewDataFab() {
+ AddNewDataFab {
findNavController()
.navigate(R.id.action_nav_bank_card_info_to_addNewUserPersonalDataDialogFragment)
}
@@ -53,6 +54,22 @@ class BankCardInfoFragment : Fragment() {
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.home_info_screen, menu)
+ val searchView = menu.findItem(R.id.action_search).actionView as SearchView
+
+ searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
+ override fun onQueryTextSubmit(query: String?): Boolean {
+ return false
+ }
+
+ override fun onQueryTextChange(newText: String?): Boolean {
+ viewModel.setSearchText(newText)
+ return true
+ }
+ })
+ }
+
private fun onListItemClick(item: UserListItemData) {
Timber.i("clicked ${item.id}")
findNavController().navigate(
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoViewModel.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoViewModel.kt
index 7bfcac9..c4138ab 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoViewModel.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/bankCardInfo/BankCardInfoViewModel.kt
@@ -8,10 +8,7 @@ import com.andryoga.safebox.ui.common.UserDataType
import com.andryoga.safebox.ui.view.home.child.common.UserListItemData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.transform
+import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -19,6 +16,10 @@ import javax.inject.Inject
class BankCardInfoViewModel @Inject constructor(
private val bankCardDataRepository: BankCardDataRepository
) : ViewModel() {
+
+ private val _searchTextFilter = MutableStateFlow(null)
+ val searchTextFilter: StateFlow = _searchTextFilter
+
val listData = flow>> {
bankCardDataRepository
.getAllBankCardData()
@@ -48,4 +49,8 @@ class BankCardInfoViewModel @Inject constructor(
bankCardDataRepository.deleteBankCardDataByKey(key)
}
}
+
+ fun setSearchText(searchText: String?) {
+ _searchTextFilter.value = searchText
+ }
}
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/common/UserDataCompose.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/common/UserDataCompose.kt
index f81b6cb..6e37242 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/common/UserDataCompose.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/common/UserDataCompose.kt
@@ -43,6 +43,7 @@ private val typeToTextMap = mapOf(
@Composable
fun UserDataList(
listResource: Resource>,
+ searchTextFilter: String?,
onItemClick: (item: UserListItemData) -> Unit,
onDeleteItemClick: (id: UserListItemData) -> Unit
) {
@@ -58,8 +59,15 @@ fun UserDataList(
}
}
Status.SUCCESS -> {
- // In success state, if there was no data then show empty view other show list of data
- val list = listResource.data
+ // In success state, if there was no data then show empty view otherwise show list of data
+ val list = if (searchTextFilter == null) {
+ listResource.data
+ } else {
+ listResource.data?.filter {
+ it.title.contains(searchTextFilter, ignoreCase = true) ||
+ it.subTitle?.contains(searchTextFilter, ignoreCase = true) == true
+ }
+ }
if (list.isNullOrEmpty()) {
EmptyUserData()
} else {
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoFragment.kt
index e58f38e..4228088 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoFragment.kt
@@ -1,9 +1,8 @@
package com.andryoga.safebox.ui.view.home.child.loginInfo
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
+import androidx.appcompat.widget.SearchView
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -30,8 +29,10 @@ class LoginInfoFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
+ setHasOptionsMenu(true)
return ComposeView(requireContext()).apply {
setContent {
+ val searchTextFilter by viewModel.searchTextFilter.collectAsState()
val listData by viewModel.listData.collectAsState(
initial = Resource.loading(
emptyList()
@@ -40,10 +41,11 @@ class LoginInfoFragment : Fragment() {
BasicSafeBoxTheme {
UserDataList(
listResource = listData,
+ searchTextFilter = searchTextFilter,
onItemClick = { onListItemClick(it) },
onDeleteItemClick = { viewModel.onDeleteItemClick(it) }
)
- AddNewDataFab() {
+ AddNewDataFab {
findNavController()
.navigate(R.id.action_nav_login_info_to_addNewUserPersonalDataDialogFragment)
}
@@ -52,6 +54,22 @@ class LoginInfoFragment : Fragment() {
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.home_info_screen, menu)
+ val searchView = menu.findItem(R.id.action_search).actionView as SearchView
+
+ searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
+ override fun onQueryTextSubmit(query: String?): Boolean {
+ return false
+ }
+
+ override fun onQueryTextChange(newText: String?): Boolean {
+ viewModel.setSearchText(newText)
+ return true
+ }
+ })
+ }
+
private fun onListItemClick(item: UserListItemData) {
Timber.i("clicked ${item.id}")
findNavController().navigate(
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoViewModel.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoViewModel.kt
index 3cb5910..1709e9c 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoViewModel.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/loginInfo/LoginInfoViewModel.kt
@@ -8,10 +8,7 @@ import com.andryoga.safebox.ui.common.UserDataType
import com.andryoga.safebox.ui.view.home.child.common.UserListItemData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.transform
+import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -19,6 +16,10 @@ import javax.inject.Inject
class LoginInfoViewModel @Inject constructor(
private val loginDataRepository: LoginDataRepository
) : ViewModel() {
+
+ private val _searchTextFilter = MutableStateFlow(null)
+ val searchTextFilter: StateFlow = _searchTextFilter
+
val listData = flow>> {
loginDataRepository
.getAllLoginData()
@@ -48,4 +49,8 @@ class LoginInfoViewModel @Inject constructor(
loginDataRepository.deleteLoginDataByKey(key)
}
}
+
+ fun setSearchText(searchText: String?) {
+ _searchTextFilter.value = searchText
+ }
}
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteInfoFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteInfoFragment.kt
index c3a1f28..ebf2ac2 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteInfoFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteInfoFragment.kt
@@ -1,9 +1,8 @@
package com.andryoga.safebox.ui.view.home.child.secureNoteInfo
import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
+import androidx.appcompat.widget.SearchView
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -30,8 +29,10 @@ class SecureNoteInfoFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
+ setHasOptionsMenu(true)
return ComposeView(requireContext()).apply {
setContent {
+ val searchTextFilter by viewModel.searchTextFilter.collectAsState()
val listData by viewModel.listData.collectAsState(
initial = Resource.loading(
emptyList()
@@ -40,10 +41,11 @@ class SecureNoteInfoFragment : Fragment() {
BasicSafeBoxTheme {
UserDataList(
listResource = listData,
+ searchTextFilter = searchTextFilter,
onItemClick = { onListItemClick(it) },
onDeleteItemClick = { viewModel.onDeleteItemClick(it) }
)
- AddNewDataFab() {
+ AddNewDataFab {
findNavController()
.navigate(R.id.action_nav_secure_note_info_to_addNewUserPersonalDataDialogFragment)
}
@@ -52,6 +54,22 @@ class SecureNoteInfoFragment : Fragment() {
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.home_info_screen, menu)
+ val searchView = menu.findItem(R.id.action_search).actionView as SearchView
+
+ searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
+ override fun onQueryTextSubmit(query: String?): Boolean {
+ return false
+ }
+
+ override fun onQueryTextChange(newText: String?): Boolean {
+ viewModel.setSearchText(newText)
+ return true
+ }
+ })
+ }
+
private fun onListItemClick(item: UserListItemData) {
Timber.i("clicked ${item.id}")
findNavController().navigate(
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteViewModel.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteViewModel.kt
index e62ccc0..0bf0f34 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteViewModel.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/child/secureNoteInfo/SecureNoteViewModel.kt
@@ -8,10 +8,7 @@ import com.andryoga.safebox.ui.common.UserDataType
import com.andryoga.safebox.ui.view.home.child.common.UserListItemData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.flow.flowOn
-import kotlinx.coroutines.flow.transform
+import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -19,6 +16,10 @@ import javax.inject.Inject
class SecureNoteViewModel @Inject constructor(
private val secureNoteDataRepository: SecureNoteDataRepository
) : ViewModel() {
+
+ private val _searchTextFilter = MutableStateFlow(null)
+ val searchTextFilter: StateFlow = _searchTextFilter
+
val listData = flow>> {
secureNoteDataRepository
.getAllSecureNoteData()
@@ -48,4 +49,8 @@ class SecureNoteViewModel @Inject constructor(
secureNoteDataRepository.deleteSecureNoteDataByKey(key)
}
}
+
+ fun setSearchText(searchText: String?) {
+ _searchTextFilter.value = searchText
+ }
}
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankAccount/BankAccountDataFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankAccount/BankAccountDataFragment.kt
index b8346eb..cc44795 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankAccount/BankAccountDataFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankAccount/BankAccountDataFragment.kt
@@ -76,10 +76,6 @@ class BankAccountDataFragment : Fragment() {
binding.loading
)
Status.SUCCESS -> {
- CommonSnackbar.showSuccessSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
- getString(R.string.snackbar_common_data_saved)
- )
hideSoftKeyboard(requireActivity())
findNavController().navigateUp()
}
@@ -89,7 +85,7 @@ class BankAccountDataFragment : Fragment() {
binding.loading
)
CommonSnackbar.showErrorSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
+ requireActivity().findViewById(R.id.drawer_layout),
getString(R.string.snackbar_common_error_saving_data)
)
hideSoftKeyboard(requireActivity())
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankCard/BankCardDataFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankCard/BankCardDataFragment.kt
index 418d1dd..71d095e 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankCard/BankCardDataFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/bankCard/BankCardDataFragment.kt
@@ -88,10 +88,6 @@ class BankCardDataFragment : Fragment() {
binding.loading
)
Status.SUCCESS -> {
- CommonSnackbar.showSuccessSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
- getString(R.string.snackbar_common_data_saved)
- )
hideSoftKeyboard(requireActivity())
findNavController().navigateUp()
}
@@ -101,7 +97,7 @@ class BankCardDataFragment : Fragment() {
binding.loading
)
CommonSnackbar.showErrorSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
+ requireActivity().findViewById(R.id.drawer_layout),
getString(R.string.snackbar_common_error_saving_data)
)
hideSoftKeyboard(requireActivity())
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/login/LoginDataFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/login/LoginDataFragment.kt
index a1bfd76..d3682d8 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/login/LoginDataFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/login/LoginDataFragment.kt
@@ -13,7 +13,6 @@ import com.andryoga.safebox.R
import com.andryoga.safebox.common.Utils
import com.andryoga.safebox.databinding.LoginDataFragmentBinding
import com.andryoga.safebox.ui.common.CommonSnackbar.showErrorSnackbar
-import com.andryoga.safebox.ui.common.CommonSnackbar.showSuccessSnackbar
import com.andryoga.safebox.ui.common.RequiredFieldValidator
import com.andryoga.safebox.ui.common.Resource
import com.andryoga.safebox.ui.common.Status
@@ -75,17 +74,13 @@ class LoginDataFragment : Fragment() {
when (resource.status) {
Status.LOADING -> switchVisibility(binding.saveBtn, binding.loading)
Status.SUCCESS -> {
- showSuccessSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
- getString(R.string.snackbar_common_data_saved)
- )
hideSoftKeyboard(requireActivity())
findNavController().navigateUp()
}
Status.ERROR -> {
switchVisibility(binding.saveBtn, binding.loading)
showErrorSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
+ requireActivity().findViewById(R.id.drawer_layout),
getString(R.string.snackbar_common_error_saving_data)
)
hideSoftKeyboard(requireActivity())
diff --git a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/secureNote/SecureNoteDataFragment.kt b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/secureNote/SecureNoteDataFragment.kt
index 399e95d..a853447 100644
--- a/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/secureNote/SecureNoteDataFragment.kt
+++ b/app/src/main/java/com/andryoga/safebox/ui/view/home/dataDetails/secureNote/SecureNoteDataFragment.kt
@@ -75,10 +75,6 @@ class SecureNoteDataFragment : Fragment() {
binding.loading
)
Status.SUCCESS -> {
- CommonSnackbar.showSuccessSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
- getString(R.string.snackbar_common_data_saved)
- )
hideSoftKeyboard(requireActivity())
findNavController().navigateUp()
}
@@ -88,7 +84,7 @@ class SecureNoteDataFragment : Fragment() {
binding.loading
)
CommonSnackbar.showErrorSnackbar(
- activity!!.findViewById(R.id.drawer_layout),
+ requireActivity().findViewById(R.id.drawer_layout),
getString(R.string.snackbar_common_error_saving_data)
)
hideSoftKeyboard(requireActivity())
diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml
new file mode 100644
index 0000000..e2dd96c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_search.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4c87d42..a3b1564 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,19 +6,36 @@
+ android:layout_height="match_parent">
+
+
+
+
+
+ android:measureAllChildren="true"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior">
+
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
index a6d5b87..ae0209b 100644
--- a/app/src/main/res/values-night/themes.xml
+++ b/app/src/main/res/values-night/themes.xml
@@ -1,6 +1,6 @@
-
-