diff --git a/app/build.gradle b/app/build.gradle index c4430676f9..93efbb542f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1610 - versionName "0.16.10" + versionCode 1611 + versionName "0.16.11" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt index fddabd189a..f5ff30daeb 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt @@ -1,11 +1,13 @@ package org.ole.planet.myplanet.ui.enterprises import android.content.DialogInterface +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.DatePicker +import androidx.annotation.RequiresApi import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.LinearLayoutManager import com.borax12.materialdaterangepicker.date.DatePickerDialog @@ -76,21 +78,29 @@ class FinanceFragment : BaseTeamFragment() { private fun showDatePickerDialog() { val now = Calendar.getInstance() - DatePickerDialog.newInstance({ _: DatePickerDialog?, year: Int, monthOfYear: Int, dayOfMonth: Int, yearEnd: Int, monthOfYearEnd: Int, dayOfMonthEnd: Int -> - val start = Calendar.getInstance() - val end = Calendar.getInstance() - start[year, monthOfYear] = dayOfMonth - end[yearEnd, monthOfYearEnd] = dayOfMonthEnd - list = fRealm.where(RealmMyTeam::class.java).equalTo("teamId", teamId) - .equalTo("docType", "transaction") - .between("date", start.timeInMillis, end.timeInMillis).sort("date", Sort.DESCENDING) - .findAll() - updatedFinanceList(list as RealmResults) - }, now[Calendar.YEAR], now[Calendar.MONTH], now[Calendar.DAY_OF_MONTH]).show( - requireActivity().fragmentManager, "" + + val dpd = DatePickerDialog.newInstance( + { _: DatePickerDialog?, year: Int, monthOfYear: Int, dayOfMonth: Int, yearEnd: Int, monthOfYearEnd: Int, dayOfMonthEnd: Int -> + val start = Calendar.getInstance() + val end = Calendar.getInstance() + start[year, monthOfYear] = dayOfMonth + end[yearEnd, monthOfYearEnd] = dayOfMonthEnd + val list = fRealm.where(RealmMyTeam::class.java) + .equalTo("teamId", teamId) + .equalTo("docType", "transaction") + .between("date", start.timeInMillis, end.timeInMillis) + .sort("date", Sort.DESCENDING) + .findAll() + updatedFinanceList(list) + }, + now[Calendar.YEAR], + now[Calendar.MONTH], + now[Calendar.DAY_OF_MONTH] ) + dpd.show(requireActivity().fragmentManager, "DATE_PICKER") } + @RequiresApi(Build.VERSION_CODES.O) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (user?.isManager() == true || user?.isLeader() == true) { @@ -123,6 +133,7 @@ class FinanceFragment : BaseTeamFragment() { if (total >= 0) fragmentFinanceBinding.balanceCaution.visibility = View.GONE } + @RequiresApi(Build.VERSION_CODES.O) private fun addTransaction() { AlertDialog.Builder(requireActivity()).setView(setUpAlertUi()).setTitle(R.string.add_transaction) .setPositiveButton("Submit") { _: DialogInterface?, _: Int ->