Add a button for installing OpenTasks if not already installed.

pull/71/head
Tom Hacohen 5 years ago
parent bbbfbffe59
commit 1aed0106cd

@ -13,6 +13,7 @@ import android.accounts.AccountManager
import android.app.LoaderManager
import android.content.*
import android.content.ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.IBinder
@ -38,6 +39,7 @@ import com.etesync.syncadapter.resource.LocalCalendar
import com.etesync.syncadapter.ui.setup.SetupUserInfoFragment
import com.etesync.syncadapter.utils.HintManager
import com.etesync.syncadapter.utils.ShowcaseBuilder
import com.etesync.syncadapter.utils.packageInstalled
import tourguide.tourguide.ToolTip
import java.util.logging.Level
@ -101,6 +103,29 @@ 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)
}
}
// load CardDAV/CalDAV journals
loaderManager.initLoader(0, intent.extras, this)

@ -128,8 +128,28 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone" />
<LinearLayout
android:id="@+id/taskdav_install_button"
android:visibility="gone"
android:indeterminate="true"/>
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"

@ -115,6 +115,7 @@
<string name="account_delete_collection_last_title">Can\'t delete last collection</string>
<string name="account_delete_collection_last_text">Deleting the last collection is not allowed, please create a new one if you\'d like to delete this one.</string>
<string name="account_showcase_view_collection">You can click on an item to view the collection. From there you can view the journal, import, and much more...</string>
<string name="account_click_install_tasks">Click here to install OpenTasks!</string>
<string name="show_fingperprint_title">My Fingerprint</string>

Loading…
Cancel
Save