diff --git a/app/build.gradle b/app/build.gradle index 3db6685c9a..29f21ab0f1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2189 - versionName "0.21.89" + versionCode 2190 + versionName "0.21.90" 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/AdapterReports.kt b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/AdapterReports.kt index 2e18c8409c..9d62cc8685 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/AdapterReports.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/AdapterReports.kt @@ -167,7 +167,15 @@ class AdapterReports(private val context: Context, private var list: RealmResult builder.setTitle("Delete Report") .setMessage(R.string.delete_record) .setPositiveButton(R.string.ok) { _, _ -> - RealmMyTeam.deleteReport(reportId, mRealm) + mRealm.executeTransaction { realm -> + realm.where(RealmMyTeam::class.java) + .equalTo("_id", reportId) + .findFirst()?.apply { + status = "archived" + updated = true + } + } + notifyDataSetChanged() } .setNegativeButton("Cancel", null) .show() diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/ReportsFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/ReportsFragment.kt index f072e53c62..e060f44801 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/ReportsFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/ReportsFragment.kt @@ -163,9 +163,12 @@ class ReportsFragment : BaseTeamFragment() { createFileLauncher.launch(intent) } - list = mRealm.where(RealmMyTeam::class.java).equalTo("teamId", teamId) + list = mRealm.where(RealmMyTeam::class.java) + .equalTo("teamId", teamId) .equalTo("docType", "report") - .sort("date", Sort.DESCENDING).findAllAsync() + .notEqualTo("status", "archived") + .sort("date", Sort.DESCENDING) + .findAllAsync() list?.addChangeListener { results -> updatedReportsList(results) @@ -176,9 +179,12 @@ class ReportsFragment : BaseTeamFragment() { val uri = result.data?.data if (uri != null) { try { - val reports = mRealm.where(RealmMyTeam::class.java).equalTo("teamId", teamId) + val reports = mRealm.where(RealmMyTeam::class.java) + .equalTo("teamId", teamId) .equalTo("docType", "report") - .sort("date", Sort.DESCENDING).findAll() + .notEqualTo("status", "archived") + .sort("date", Sort.DESCENDING) + .findAll() val csvBuilder = StringBuilder() csvBuilder.append("${prefData.getTeamName()} Financial Report Summary\n\n") csvBuilder.append("Start Date, End Date, Created Date, Updated Date, Beginning Balance, Sales, Other Income, Wages, Other Expenses, Profit/Loss, Ending Balance\n") @@ -209,9 +215,12 @@ class ReportsFragment : BaseTeamFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - list = mRealm.where(RealmMyTeam::class.java).equalTo("teamId", teamId) + list = mRealm.where(RealmMyTeam::class.java) + .equalTo("teamId", teamId) .equalTo("docType", "report") - .sort("date", Sort.DESCENDING).findAll() + .notEqualTo("status", "archived") // Add this line + .sort("date", Sort.DESCENDING) + .findAll() updatedReportsList(list as RealmResults) } @@ -222,7 +231,7 @@ class ReportsFragment : BaseTeamFragment() { llImage?.removeAllViews() } - private fun updatedReportsList(results: RealmResults) { + fun updatedReportsList(results: RealmResults) { activity?.runOnUiThread { adapterReports = AdapterReports(requireContext(), results) adapterReports.setNonTeamMember(!isMember())