Skip to content

Commit

Permalink
Androapp 4924 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvmmacamo2 authored and andresmr committed Feb 8, 2023
1 parent d41def8 commit b8bd267
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 140 deletions.
2 changes: 1 addition & 1 deletion app/src/main/assets/paperwork.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildTime":"2022-09-05 11:46","gitSha":"2e9f4fe2b"}
{"buildTime":"2022-09-06 11:39","gitSha":"414bbf7a2"}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,15 +19,10 @@ open class BaseViewModel @Inject constructor(
private val preferenceProvider: PreferenceProvider,
private val schedulerProvider: BaseSchedulerProvider
) : ViewModel() {
val lastSyncDate: LiveData<String> = MutableLiveData(
preferenceProvider.getString(Constants.LAST_DATA_SYNC_DATE)
)
private val _showGuide: MutableLiveData<Boolean> = MutableLiveData(false)
val showGuide: LiveData<Boolean>
get() = _showGuide

val appVersion: LiveData<String> = MutableLiveData(getAppVersion())

/**
* Evaluates the quantity assigned to the StockItem
*
Expand Down Expand Up @@ -68,6 +61,4 @@ open class BaseViewModel @Inject constructor(
}

fun isVoiceInputEnabled(prefKey: String) = preferenceProvider.getBoolean(prefKey, false)

private fun getAppVersion() = "v" + BuildConfig.VERSION_NAME
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -73,7 +73,6 @@ class HomeViewModel @Inject constructor(
private val _toolbarSubtitle = MutableLiveData<String>()
val toolbarSubtitle: LiveData<String> get() = _toolbarSubtitle


init {
loadFacilities()
loadDestinations()
Expand Down Expand Up @@ -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"
}
}
}
10 changes: 2 additions & 8 deletions stock-managment/src/main/res/layout-w600dp/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<TextView
Expand Down Expand Up @@ -320,14 +320,8 @@
android:text="@string/proceed"
app:icon="@drawable/arrow_forward"
app:iconGravity="textEnd"
app:layout_constraintBottom_toTopOf="@id/home_footer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<!-- Footer -->
<include
android:id="@+id/home_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@
app:drawableTopCompat="@drawable/ic_empty_list" />
</androidx.constraintlayout.widget.ConstraintLayout>

<!-- Footer -->
<include
android:id="@+id/stock_items_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />

<!-- Floating Button -->
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
Expand Down
10 changes: 2 additions & 8 deletions stock-managment/src/main/res/layout-w840dp/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,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">

<TextView
Expand Down Expand Up @@ -316,14 +316,8 @@
android:text="@string/proceed"
app:icon="@drawable/arrow_forward"
app:iconGravity="textEnd"
app:layout_constraintBottom_toTopOf="@id/home_footer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<!-- Footer -->
<include
android:id="@+id/home_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@
app:drawableTopCompat="@drawable/ic_empty_list" />
</androidx.constraintlayout.widget.ConstraintLayout>

<!-- Footer -->
<include
android:id="@+id/stock_items_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />

<!-- Floating Button -->
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
Expand Down
11 changes: 2 additions & 9 deletions stock-managment/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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">

<TextView
Expand Down Expand Up @@ -318,15 +318,8 @@
android:text="@string/proceed"
app:icon="@drawable/arrow_forward"
app:iconGravity="textEnd"
app:layout_constraintBottom_toTopOf="@id/home_footer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<!-- Footer -->
<include
android:id="@+id/home_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
6 changes: 0 additions & 6 deletions stock-managment/src/main/res/layout/activity_manage_stock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@
app:drawableTopCompat="@drawable/ic_empty_list" />
</androidx.constraintlayout.widget.ConstraintLayout>

<!-- Footer -->
<include
android:id="@+id/stock_items_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />

<!-- Floating Button -->
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@
tools:listitem="@layout/review_stock_item_entry" />
</androidx.constraintlayout.widget.ConstraintLayout>

<!-- Footer -->
<include
android:id="@+id/stock_items_footer"
layout="@layout/footer"
app:lastSyncDate="@{viewModel.lastSyncDate}"
app:appVersion="@{viewModel.appVersion}" />


<!-- Floating Button -->
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
Expand Down
65 changes: 0 additions & 65 deletions stock-managment/src/main/res/layout/footer.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b8bd267

Please sign in to comment.