1
0
mirror of https://github.com/etesync/android synced 2024-12-23 23:18:46 +00:00

Tasks: move the opentasks install button to the menu.

It was quite ugly having it there.
This commit is contained in:
Tom Hacohen 2019-02-25 15:26:14 +00:00
parent 4cc664ee6c
commit 130cea18ce
4 changed files with 28 additions and 42 deletions

View File

@ -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<LinearLayout>(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
}

View File

@ -131,26 +131,6 @@
android:indeterminate="true"
android:visibility="gone" />
<LinearLayout
android:id="@+id/taskdav_install_button"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="8dp"
android:paddingRight="12dp"
android:paddingBottom="8dp">
<TextView
android:text="@string/account_click_install_tasks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<com.etesync.syncadapter.ui.widget.MaximizedListView
android:id="@+id/tasklists"
android:layout_width="match_parent"

View File

@ -9,6 +9,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/install_opentasks"
android:visible="false"
android:title="@string/install_opentasks"/>
<item android:id="@+id/create_tasklist"
android:title="@string/create_tasklist"/>

View File

@ -281,6 +281,7 @@
<string name="create_calendar_display_name_hint">My Calendar</string>
<string name="create_tasklist">Create task list</string>
<string name="create_tasklist_display_name_hint">My Task List</string>
<string name="install_opentasks">Install OpenTasks</string>
<string name="edit_collection">Edit collection</string>
<string name="create_collection_color">Set the calendar\'s color</string>
<string name="create_collection_creating">Creating collection</string>