From b8bd2673f20880ca70858182dc7566a318a516d3 Mon Sep 17 00:00:00 2001 From: Miguel Vasco Macamo Date: Wed, 7 Sep 2022 03:05:08 -0700 Subject: [PATCH] Androapp 4924 (#7) --- app/src/main/assets/paperwork.json | 2 +- .../android/rtsm/ui/base/BaseViewModel.kt | 9 --- .../android/rtsm/ui/home/HomeViewModel.kt | 29 +++++---- .../main/res/layout-w600dp/activity_home.xml | 10 +-- .../layout-w600dp/activity_manage_stock.xml | 6 -- .../main/res/layout-w840dp/activity_home.xml | 10 +-- .../layout-w840dp/activity_manage_stock.xml | 6 -- .../src/main/res/layout/activity_home.xml | 11 +--- .../main/res/layout/activity_manage_stock.xml | 6 -- .../main/res/layout/activity_review_stock.xml | 7 +- .../src/main/res/layout/footer.xml | 65 ------------------- .../rtsm/viewmodels/HomeViewModelUnitTest.kt | 5 +- 12 files changed, 26 insertions(+), 140 deletions(-) delete mode 100644 stock-managment/src/main/res/layout/footer.xml diff --git a/app/src/main/assets/paperwork.json b/app/src/main/assets/paperwork.json index acf1e8b3bb..8d3ee3abad 100644 --- a/app/src/main/assets/paperwork.json +++ b/app/src/main/assets/paperwork.json @@ -1 +1 @@ -{"buildTime":"2022-09-05 11:46","gitSha":"2e9f4fe2b"} \ No newline at end of file +{"buildTime":"2022-09-06 11:39","gitSha":"414bbf7a2"} \ No newline at end of file diff --git a/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/base/BaseViewModel.kt b/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/base/BaseViewModel.kt index 7924e278e2..f3a2e69409 100644 --- a/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/base/BaseViewModel.kt +++ b/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/base/BaseViewModel.kt @@ -7,8 +7,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel import io.reactivex.disposables.Disposable import java.util.Date import javax.inject.Inject -import org.dhis2.android.rtsm.BuildConfig -import org.dhis2.android.rtsm.commons.Constants import org.dhis2.android.rtsm.data.AppConfig import org.dhis2.android.rtsm.data.RowAction import org.dhis2.android.rtsm.data.models.Transaction @@ -21,15 +19,10 @@ open class BaseViewModel @Inject constructor( private val preferenceProvider: PreferenceProvider, private val schedulerProvider: BaseSchedulerProvider ) : ViewModel() { - val lastSyncDate: LiveData = MutableLiveData( - preferenceProvider.getString(Constants.LAST_DATA_SYNC_DATE) - ) private val _showGuide: MutableLiveData = MutableLiveData(false) val showGuide: LiveData get() = _showGuide - val appVersion: LiveData = MutableLiveData(getAppVersion()) - /** * Evaluates the quantity assigned to the StockItem * @@ -68,6 +61,4 @@ open class BaseViewModel @Inject constructor( } fun isVoiceInputEnabled(prefKey: String) = preferenceProvider.getBoolean(prefKey, false) - - private fun getAppVersion() = "v" + BuildConfig.VERSION_NAME } diff --git a/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/HomeViewModel.kt b/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/HomeViewModel.kt index 6d86bdb1af..f84e73dde2 100644 --- a/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/HomeViewModel.kt +++ b/stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/HomeViewModel.kt @@ -5,6 +5,10 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.SavedStateHandle import dagger.hilt.android.lifecycle.HiltViewModel import io.reactivex.disposables.CompositeDisposable +import java.time.Instant +import java.time.LocalDateTime +import java.time.ZoneId +import javax.inject.Inject import org.dhis2.android.rtsm.R import org.dhis2.android.rtsm.commons.Constants.INTENT_EXTRA_APP_CONFIG import org.dhis2.android.rtsm.data.AppConfig @@ -21,10 +25,6 @@ import org.dhis2.android.rtsm.utils.ParcelUtils import org.dhis2.android.rtsm.utils.humanReadableDate import org.hisp.dhis.android.core.option.Option import org.hisp.dhis.android.core.organisationunit.OrganisationUnit -import java.time.Instant -import java.time.LocalDateTime -import java.time.ZoneId -import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( @@ -73,7 +73,6 @@ class HomeViewModel @Inject constructor( private val _toolbarSubtitle = MutableLiveData() val toolbarSubtitle: LiveData get() = _toolbarSubtitle - init { loadFacilities() loadDestinations() @@ -203,19 +202,21 @@ class HomeViewModel @Inject constructor( } fun setSubtitle(from: String, to: String, type: TransactionType) { - when (type) { - TransactionType.DISTRIBUTION -> if (!to.equals("", ignoreCase = true) - ) _toolbarSubtitle.value = "From $from -> To $to" - else if (!from.equals("", ignoreCase = true) - ) _toolbarSubtitle.value = "From $from" - TransactionType.DISCARD -> if (!from.equals("", ignoreCase = true) - ) _toolbarSubtitle.value = "From $from" - TransactionType.CORRECTION -> if (!from.equals( + TransactionType.DISTRIBUTION -> + if (!to.equals("", ignoreCase = true) + ) _toolbarSubtitle.value = "From $from -> To $to" + else if (!from.equals("", ignoreCase = true) + ) _toolbarSubtitle.value = "From $from" + TransactionType.DISCARD -> + if (!from.equals("", ignoreCase = true) + ) _toolbarSubtitle.value = "From $from" + TransactionType.CORRECTION -> + if (!from.equals( "", ignoreCase = true ) - ) _toolbarSubtitle.value = "${R.string.from} $from" + ) _toolbarSubtitle.value = "${R.string.from} $from" } } } diff --git a/stock-managment/src/main/res/layout-w600dp/activity_home.xml b/stock-managment/src/main/res/layout-w600dp/activity_home.xml index 792e4f02af..dd522f5b35 100644 --- a/stock-managment/src/main/res/layout-w600dp/activity_home.xml +++ b/stock-managment/src/main/res/layout-w600dp/activity_home.xml @@ -99,7 +99,7 @@ android:layout_marginRight="@dimen/content_area_lr_margin" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintBottom_toTopOf="@id/home_footer" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/toolbar"> - - \ No newline at end of file diff --git a/stock-managment/src/main/res/layout-w600dp/activity_manage_stock.xml b/stock-managment/src/main/res/layout-w600dp/activity_manage_stock.xml index 6a1ee413a5..31ed6eb8b5 100644 --- a/stock-managment/src/main/res/layout-w600dp/activity_manage_stock.xml +++ b/stock-managment/src/main/res/layout-w600dp/activity_manage_stock.xml @@ -172,12 +172,6 @@ app:drawableTopCompat="@drawable/ic_empty_list" /> - - - - \ No newline at end of file diff --git a/stock-managment/src/main/res/layout-w840dp/activity_manage_stock.xml b/stock-managment/src/main/res/layout-w840dp/activity_manage_stock.xml index 6a1ee413a5..31ed6eb8b5 100644 --- a/stock-managment/src/main/res/layout-w840dp/activity_manage_stock.xml +++ b/stock-managment/src/main/res/layout-w840dp/activity_manage_stock.xml @@ -172,12 +172,6 @@ app:drawableTopCompat="@drawable/ic_empty_list" /> - - - - - \ No newline at end of file diff --git a/stock-managment/src/main/res/layout/activity_manage_stock.xml b/stock-managment/src/main/res/layout/activity_manage_stock.xml index a517fba0c7..9426bd8a90 100644 --- a/stock-managment/src/main/res/layout/activity_manage_stock.xml +++ b/stock-managment/src/main/res/layout/activity_manage_stock.xml @@ -171,12 +171,6 @@ app:drawableTopCompat="@drawable/ic_empty_list" /> - - - - + - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/stock-managment/src/test/java/org/dhis2/android/rtsm/viewmodels/HomeViewModelUnitTest.kt b/stock-managment/src/test/java/org/dhis2/android/rtsm/viewmodels/HomeViewModelUnitTest.kt index c3e9d9eabe..7b56f6e257 100644 --- a/stock-managment/src/test/java/org/dhis2/android/rtsm/viewmodels/HomeViewModelUnitTest.kt +++ b/stock-managment/src/test/java/org/dhis2/android/rtsm/viewmodels/HomeViewModelUnitTest.kt @@ -34,7 +34,9 @@ import org.hisp.dhis.android.core.D2 import org.hisp.dhis.android.core.option.Option import org.hisp.dhis.android.core.organisationunit.OrganisationUnit import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull import org.junit.Before import org.junit.Rule import org.junit.Test @@ -474,7 +476,6 @@ class HomeViewModelUnitTest { viewModel.setFacility(facility) viewModel.setTransactionDate(getTime(now)) - val facilityName = viewModel.getData().facility.name val distributedTo = viewModel.getData().distributedTo?.name val transactionType = viewModel.getData().transactionType