Deep link handler prototype

Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
Chris Narkiewicz 2020-05-23 23:32:18 +01:00 committed by tobiasKaminsky
parent 214689bc0d
commit bcb1262064
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,57 @@
package com.nextcloud.client.files
import org.junit.Test
class DeepLinkHandlerTest {
@Test
fun valid_uri_can_be_handled_by_one_user() {
// GIVEN
// uri matching allowed pattern
// one user can open the file
// WHEN
// deep link is handled
// THEN
// file is opened immediately
}
@Test
fun valid_uri_can_be_handled_by_multiple_users() {
// GIVEN
// uri matching allowed pattern
// multiple users can open the file
// WHEN
// deep link is handled
// THEN
// user chooser dialog is opened
}
@Test
fun valid_uri_cannot_be_handled_by_any_user() {
// GIVEN
// uri matching allowed pattern
// no user can open given uri
// WHEN
// deep link is handled
// THEN
// deep link is ignored
}
@Test
fun invalid_uri_is_ignored() {
// GIVEN
// file uri does not match allowed pattern
// WHEN
// deep link is handled
// THEN
// deep link is ignored
}
}

View file

@ -0,0 +1,28 @@
package com.nextcloud.client.files
import android.content.Context
import android.net.Uri
import com.nextcloud.client.account.User
import com.nextcloud.client.account.UserAccountManager
class DeepLinkHandler(
private val context: Context,
private val userAccountManager: UserAccountManager,
private val onUserChoiceRequired: (users: List<User>, fileId: String)->Unit
) {
/**
* Open deep link.
*
* If deep link can be opened immediately, new activity is launched.
* If link can be handled by multiple users, [onUserChoiceRequired] callback
* is invoked with list of matching users.
*
* @param uri Deep link received in incoming [Intent]
* @return true if deep link can be handled
*/
fun openDeepLink(uri: Uri): Boolean {
throw NotImplementedError()
}
}