mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Deep link handler prototype
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
214689bc0d
commit
bcb1262064
2 changed files with 85 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
}
|
28
src/main/java/com/nextcloud/client/files/DeepLinkHandler.kt
Normal file
28
src/main/java/com/nextcloud/client/files/DeepLinkHandler.kt
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue