diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt index b28c45ad..7813bfec 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt @@ -51,6 +51,8 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe internal var listCardDAV: ListView? = null internal var listTaskDAV: ListView? = null + internal val openTasksPackage = "org.dmfs.tasks" + private val onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, _ -> val list = parent as ListView val adapter = list.adapter as ArrayAdapter<*> @@ -102,28 +104,9 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe tbTaskDAV.inflateMenu(R.menu.taskdav_actions) tbTaskDAV.setOnMenuItemClickListener(this) tbTaskDAV.setTitle(R.string.settings_taskdav) - val openTasksPackage = "org.dmfs.tasks" if (!packageInstalled(this, openTasksPackage)) { - val tasksInstallButton = findViewById(R.id.taskdav_install_button) - tasksInstallButton.visibility = View.VISIBLE - tasksInstallButton.setOnClickListener { - val fdroidPackageName = "org.fdroid.fdroid" - val gplayPackageName = "com.android.vending" - val intent = Intent(Intent.ACTION_VIEW).apply { - data = Uri.parse( - "https://f-droid.org/en/packages/$openTasksPackage/") - } - if (packageInstalled(this, fdroidPackageName)) { - intent.setPackage(fdroidPackageName) - } else if (packageInstalled(this, gplayPackageName)) { - intent.apply { - data = Uri.parse( - "https://play.google.com/store/apps/details?id=$openTasksPackage") - setPackage(gplayPackageName) - } - } - startActivity(intent) - } + val tasksInstallMenuItem = tbTaskDAV.menu.findItem(R.id.install_opentasks) + tasksInstallMenuItem.setVisible(true) } // load CardDAV/CalDAV journals @@ -195,6 +178,24 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe info.type = CollectionInfo.Type.ADDRESS_BOOK startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account, info)) } + R.id.install_opentasks -> { + val fdroidPackageName = "org.fdroid.fdroid" + val gplayPackageName = "com.android.vending" + val intent = Intent(Intent.ACTION_VIEW).apply { + data = Uri.parse( + "https://f-droid.org/en/packages/$openTasksPackage/") + } + if (packageInstalled(this, fdroidPackageName)) { + intent.setPackage(fdroidPackageName) + } else if (packageInstalled(this, gplayPackageName)) { + intent.apply { + data = Uri.parse( + "https://play.google.com/store/apps/details?id=$openTasksPackage") + setPackage(gplayPackageName) + } + } + startActivity(intent) + } } return false } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 2a7b6e0d..4762dceb 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -131,26 +131,6 @@ android:indeterminate="true" android:visibility="gone" /> - - - - - - + + + android:title="@string/create_tasklist"/> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 12effa04..26d1634a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -281,6 +281,7 @@ My Calendar Create task list My Task List + Install OpenTasks Edit collection Set the calendar\'s color Creating collection