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

Commit 054f1ece authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Setup intent filter (#80)

* Add intent filter for caldav(s)://, carddav(s):// and davx5:// schemes
* Define intent-filter only for standard and gplay flavors
* Merge manifest; remove Espresso tests (further tests should be added)
* Lint

Closes bitfireAT/davx5#77
parent eaea4936
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="navigation_drawer_support_project">Support the project</string>
    <string name="nav_earn_badges">Support us with badges</string>
    <string name="nav_rate_us">Review in Google Play</string>
    <plurals name="you_earned_badges">
        <item quantity="one">You\'ve earned a badge, thank you!</item>
        <item quantity="other">You have earned %d badges, thank you!</item>
    </plurals>
    <string name="available_badges">Available badges</string>
    <string name="available_badges_empty">Sorry, there are no badges available for purchase at the moment!</string>
    <string name="what_are_badges">What are badges?</string>
    <string name="what_are_badges_title">What are badges?</string>
    <string name="what_are_badges_body">Badges are simple in-app one-time-payments. You will earn a nice little badge and with it you can support us over time.</string>
    <string name="why_badges_title">Why does DAVx5 offer feature-free badges?</string>
    <string name="why_badges_body">DAVx5 has really grown over the years! We are still actively developing new features, providing support and we always update the app for upcoming Android versions. These badges are one-time payments where you can simply show your support by buying us a coffee, or two&#8230; or 10 :-) We want to be as open as possible, so there will never-ever be any new stuff locked to in-app payment.</string>
    <string name="button_buy_badge_free">FREE</string>
    <string name="button_buy_badge_bought">Thank you!</string>
    <string name="earn_badges">Earn badges to support us!</string>
</resources>
 No newline at end of file
+11 −1
Original line number Diff line number Diff line
@@ -108,6 +108,16 @@
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:scheme="caldav"/>
                <data android:scheme="caldavs"/>
                <data android:scheme="carddav"/>
                <data android:scheme="carddavs"/>
                <data android:scheme="davx5"/>
            </intent-filter>
        </activity>

        <activity
+38 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ package at.bitfire.davdroid.ui.setup
import android.app.Application
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.Editable
import android.view.View
import android.view.ViewGroup
@@ -76,10 +77,43 @@ class DefaultLoginCredentialsModel(app: Application): AndroidViewModel(app) {
            return
        initialized = true

        // we've got initial login data
        val givenUrl = intent.getStringExtra(LoginActivity.EXTRA_URL)
        val givenUsername = intent.getStringExtra(LoginActivity.EXTRA_USERNAME)
        val givenPassword = intent.getStringExtra(LoginActivity.EXTRA_PASSWORD)
        var givenUrl: String? = null
        var givenUsername: String? = null
        var givenPassword: String? = null

        intent.data?.normalizeScheme()?.let { uri ->
            // We've got initial login data from the Intent.
            // We can't use uri.buildUpon() because this keeps the user info (it's readable, but not writable).
            val realScheme = when (uri.scheme) {
                "caldav", "carddav" -> "http"
                "caldavs", "carddavs", "davx5" -> "https"
                "http", "https" -> uri.scheme
                else -> null
            }
            if (realScheme != null) {
                val realUri = Uri.Builder()
                    .scheme(realScheme)
                    .authority(uri.host)
                    .path(uri.path)
                    .query(uri.query)
                givenUrl = realUri.build().toString()

                // extract user info
                uri.userInfo?.split(':')?.let { userInfo ->
                    givenUsername = userInfo.getOrNull(0)
                    givenPassword = userInfo.getOrNull(1)
                }
            }
        }

        // no login data from the Intent, let's look up the extras
        givenUrl ?: intent.getStringExtra(LoginActivity.EXTRA_URL)

        // always prefer username/password from the extras
        if (intent.hasExtra(LoginActivity.EXTRA_USERNAME))
            givenUsername = intent.getStringExtra(LoginActivity.EXTRA_USERNAME)
        if (intent.hasExtra(LoginActivity.EXTRA_PASSWORD))
            givenPassword = intent.getStringExtra(LoginActivity.EXTRA_PASSWORD)

        if (givenUrl != null) {
            loginWithUrlAndUsername.value = true
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import java.util.*
class LoginActivity: AppCompatActivity() {

    companion object {

        /**
         * When set, "login by URL" will be activated by default, and the URL field will be set to this value.
         * When not set, "login by email" will be activated by default.