Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cac9ab84 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

AM: Add navigation bar changes in Account Manager

parent 21706020
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
package at.bitfire.davdroid.ui

import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import androidx.annotation.StringRes
@@ -21,8 +22,10 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.EditCalendar
import androidx.compose.material.icons.filled.Feedback
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Policy
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Storage
import androidx.compose.material3.HorizontalDivider
@@ -54,6 +57,8 @@ import androidx.core.net.toUri
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.R
import at.bitfire.davdroid.ui.webdav.WebdavMountsActivity
import foundation.e.accountmanager.ui.PrivacyPolicyActivity
import foundation.e.accountmanager.utils.AppConstants
import kotlinx.coroutines.launch
import java.net.URI

@@ -119,6 +124,14 @@ abstract class AccountsDrawerHandler {
            }
        )

        MenuEntry(
            icon = Icons.Default.Policy,
            title = stringResource(R.string.privacy_policy_title_nav),
            onClick = {
                context.startActivity(Intent(context, PrivacyPolicyActivity::class.java))
            }
        )

        if (isBeta)
            MenuEntry(
                icon = Icons.Default.Feedback,
@@ -157,6 +170,18 @@ abstract class AccountsDrawerHandler {
                context.startActivity(Intent(context, WebdavMountsActivity::class.java))
            }
        )
        MenuEntry(
            icon = Icons.Default.EditCalendar,
            title = stringResource(R.string.navigation_drawer_open_webcalmanager),
            onClick = {
                val intent = Intent(Intent.ACTION_MAIN)
                intent.component = ComponentName(
                    AppConstants.WEBCAL_MANAGER_PACKAGE,
                    AppConstants.WEBCAL_MANAGER_ACTIVITY
                )
                context.startActivity(intent)
            }
        )
    }


+6 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ open class OseAccountsDrawerHandler @Inject constructor(): AccountsDrawerHandler
        ImportantEntries(snackbarHostState)

        // News
        /*
        MenuHeading(R.string.navigation_drawer_news_updates)
        MenuEntry(
            icon = painterResource(R.drawable.mastodon),
@@ -45,11 +46,13 @@ open class OseAccountsDrawerHandler @Inject constructor(): AccountsDrawerHandler
                uriHandler.openUri(Social.fediverseUrl.toString())
            }
        )
        */

        // Tools
        Tools()

        // Support the project
        /*
        MenuHeading(R.string.navigation_drawer_support_project)
        Contribute(onContribute = {
            uriHandler.openUri(
@@ -66,9 +69,11 @@ open class OseAccountsDrawerHandler @Inject constructor(): AccountsDrawerHandler
                uriHandler.openUri(Social.discussionsUrl.toString())
            }
        )
        */


        // External links
        /*
        MenuHeading(R.string.navigation_drawer_external_links)
        MenuEntry(
            icon = Icons.Default.Home,
@@ -125,6 +130,7 @@ open class OseAccountsDrawerHandler @Inject constructor(): AccountsDrawerHandler
                )
            }
        )
        */
    }

    @Composable
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 eFoundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 *
 */
package foundation.e.accountmanager.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import foundation.e.accountmanager.utils.AppConstants
import foundation.e.accountmanager.utils.WebViewUtils


class PrivacyPolicyActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        WebViewUtils.openCustomTab(this, AppConstants.PRIVACY_POLICY_URL)
        finishAfterTransition() // Finish the activity after launching the custom tab
    }
}
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 eFoundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 *
 */
package foundation.e.accountmanager.utils

object AppConstants {
    const val WEBCAL_MANAGER_PACKAGE = "foundation.e.webcalendarmanager"
    const val WEBCAL_MANAGER_ACTIVITY = "at.bitfire.icsdroid.ui.views.CalendarListActivity"
    const val PRIVACY_POLICY_URL = "https://e.foundation/legal-notice-privacy/#account-manager"
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details.
 */

package foundation.e.accountmanager.utils

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent

object WebViewUtils {
    fun openCustomTab(context: Context, url: String) {
        val packageManager = context.packageManager
        val resolveInfo = packageManager.queryIntentActivities(
            Intent(Intent.ACTION_VIEW, Uri.parse(url)),
            PackageManager.MATCH_DEFAULT_ONLY
        )

        if (resolveInfo.isNotEmpty()) {
            val customTabsIntent = CustomTabsIntent.Builder()
                .setShowTitle(true).build()
            customTabsIntent.intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
            customTabsIntent.launchUrl(context, Uri.parse(url))
        } else {
            // Fallback to default browser
            val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
            context.startActivity(intent)
        }
    }
}
Loading