From 5bfb7f34774054b9e5f9d3823309327550a7e348 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 28 Nov 2022 18:57:04 +0600 Subject: [PATCH] 887-Open_WebCalendarManager_from_drawer issue: https://gitlab.e.foundation/e/os/backlog/-/issues/887 --- .../davdroid/ui/OseAccountsDrawerHandler.kt | 21 +++++++++++++++++++ app/src/main/res/drawable/ic_calendar.xml | 10 +++++++++ .../res/menu/activity_accounts_drawer.xml | 5 +++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 37 insertions(+) create mode 100644 app/src/main/res/drawable/ic_calendar.xml diff --git a/app/src/main/java/at/bitfire/davdroid/ui/OseAccountsDrawerHandler.kt b/app/src/main/java/at/bitfire/davdroid/ui/OseAccountsDrawerHandler.kt index 368908788..c0038233a 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/OseAccountsDrawerHandler.kt +++ b/app/src/main/java/at/bitfire/davdroid/ui/OseAccountsDrawerHandler.kt @@ -5,10 +5,13 @@ package at.bitfire.davdroid.ui import android.app.Activity +import android.content.ComponentName import android.content.Intent import android.view.MenuItem import at.bitfire.davdroid.R +import at.bitfire.davdroid.log.Logger import at.bitfire.davdroid.ui.webdav.WebdavMountsActivity +import java.util.logging.Level import javax.inject.Inject /** @@ -16,13 +19,31 @@ import javax.inject.Inject */ class OseAccountsDrawerHandler @Inject constructor(): BaseAccountsDrawerHandler() { + companion object { + private const val WEB_CAL_MANAGER_PACKAGE = "foundation.e.webcalendarmanager" + private const val WEB_CAL_MANAGER_MAIN_ACTIVITY = "at.bitfire.icsdroid.ui.CalendarListActivity" + } + override fun onNavigationItemSelected(activity: Activity, item: MenuItem) { when (item.itemId) { R.id.nav_webdav_mounts -> activity.startActivity(Intent(activity, WebdavMountsActivity::class.java)) + R.id.nav_open_webcalmanager -> + openWebCalManager(activity) else -> super.onNavigationItemSelected(activity, item) } } + private fun openWebCalManager(activity: Activity) { + try { + val intent = Intent(Intent.ACTION_MAIN) + intent.component = + ComponentName(WEB_CAL_MANAGER_PACKAGE, WEB_CAL_MANAGER_MAIN_ACTIVITY) + activity.startActivity(intent) + } catch (e: Exception) { + Logger.log.log(Level.SEVERE, "Failed to open WebCalendarManager", e) + } + } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_calendar.xml b/app/src/main/res/drawable/ic_calendar.xml new file mode 100644 index 000000000..0c97102c1 --- /dev/null +++ b/app/src/main/res/drawable/ic_calendar.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/menu/activity_accounts_drawer.xml b/app/src/main/res/menu/activity_accounts_drawer.xml index 45d324f44..fc8482e35 100644 --- a/app/src/main/res/menu/activity_accounts_drawer.xml +++ b/app/src/main/res/menu/activity_accounts_drawer.xml @@ -18,6 +18,11 @@ android:id="@+id/nav_webdav_mounts" android:icon="@drawable/ic_storage" android:title="@string/webdav_mounts_title" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 18ff3c134..758ab12a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -144,6 +144,7 @@ Please install an email client Please install a Web browser Settings + Web Calendar Manager News & updates Tools External links -- GitLab