From 71e37fb9a694230a007b04911cf26c83877db8be Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 27 Aug 2020 16:55:43 +0300 Subject: [PATCH] Only allow collection owners to edit it. --- .../ui/etebase/ViewCollectionFragment.kt | 18 +++++++++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/etebase/ViewCollectionFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/etebase/ViewCollectionFragment.kt index a6f49253..eb27eb59 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/etebase/ViewCollectionFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/etebase/ViewCollectionFragment.kt @@ -15,6 +15,7 @@ import com.etesync.syncadapter.Constants import com.etesync.syncadapter.R import com.etesync.syncadapter.resource.LocalCalendar import com.etesync.syncadapter.ui.BaseActivity +import com.etesync.syncadapter.ui.EditCollectionActivity import com.etesync.syncadapter.ui.WebViewActivity import com.etesync.syncadapter.utils.HintManager import com.etesync.syncadapter.utils.ShowcaseBuilder @@ -109,11 +110,22 @@ class ViewCollectionFragment : Fragment() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { + val cachedCollection = collectionModel.value!! + when (item.itemId) { R.id.on_edit -> { - parentFragmentManager.commit { - replace(R.id.fragment_container, EditCollectionFragment(collectionModel.value!!)) - addToBackStack(EditCollectionFragment::class.java.name) + if (cachedCollection.col.accessLevel == "adm") { + parentFragmentManager.commit { + replace(R.id.fragment_container, EditCollectionFragment(cachedCollection)) + addToBackStack(EditCollectionFragment::class.java.name) + } + } else { + val dialog = AlertDialog.Builder(requireContext()) + .setIcon(R.drawable.ic_info_dark) + .setTitle(R.string.not_allowed_title) + .setMessage(R.string.edit_owner_only_anon) + .setPositiveButton(android.R.string.yes) { _, _ -> }.create() + dialog.show() } } R.id.on_manage_members -> { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9f68c15d..f43d977e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,6 +147,7 @@ Only the owner of this collection (%s) is allowed to view its members. Not Allowed Only the owner of this collection (%s) is allowed to edit it. + Only the owner of this collection is allowed to edit it. Sharing of old-style journals is not allowed. In order to share this journal, create a new one, and copy its contents over using the \"import\" dialog. If you are experiencing any issues, please contact support. Did you know? EteSync seamlessly integrates with Android, so to use it, just use your existing address book and calendar apps!\n\nFor more information, please check out the user guide.