diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt index e4bb5d1..c040519 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt @@ -99,6 +99,8 @@ class FilterOptionsDialog : DialogFragment() { binding.tvEndDate.setOnClickListener { showDateRangePicker() } + dateFormat.timeZone = TimeZone.getTimeZone("UTC") + updateDateTextViews() // Initialize Asset diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt index 5b0966c..7a1f952 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/viewmodels/TransactionsViewModel.kt @@ -2,6 +2,7 @@ package cy.agorise.bitsybitshareswallet.viewmodels import android.app.Application import androidx.lifecycle.* +import com.google.android.material.datepicker.MaterialDatePicker import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail import cy.agorise.bitsybitshareswallet.models.FilterOptions import cy.agorise.bitsybitshareswallet.repositories.TransferDetailRepository @@ -11,6 +12,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.* + class TransactionsViewModel(application: Application) : AndroidViewModel(application) { companion object { const val TAG = "TransactionsViewModel" @@ -32,12 +34,19 @@ class TransactionsViewModel(application: Application) : AndroidViewModel(applica init { // Initialize the start and end dates for the FilterOptions - val calendar = Calendar.getInstance() + val calendar = getClearedUtc() + calendar.timeInMillis = MaterialDatePicker.todayInUtcMilliseconds() mFilterOptions.endDate = calendar.timeInMillis - calendar.add(Calendar.MONTH, -2) + calendar.roll(Calendar.MONTH, -2) mFilterOptions.startDate = calendar.timeInMillis } + private fun getClearedUtc(): Calendar { + val utc = Calendar.getInstance(TimeZone.getTimeZone("UTC")) + utc.clear() + return utc + } + internal fun getFilteredTransactions(userId: String): LiveData> { val currencyCode = Helper.getCoingeckoSupportedCurrency(Locale.getDefault()) transactions = mRepository.getAll(userId, currencyCode) diff --git a/app/src/main/res/layout/dialog_filter_options.xml b/app/src/main/res/layout/dialog_filter_options.xml index b20725c..efcb3a9 100644 --- a/app/src/main/res/layout/dialog_filter_options.xml +++ b/app/src/main/res/layout/dialog_filter_options.xml @@ -67,6 +67,7 @@ android:text="@string/text__date_range" android:textSize="16sp" app:layout_constraintTop_toTopOf="@id/cbDateRange" + app:layout_constraintBottom_toBottomOf="@id/cbDateRange" app:layout_constraintStart_toStartOf="parent"/> - \ No newline at end of file +