Handle incoming intent with server and userId as payload

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2021-10-20 08:13:52 +02:00 committed by Tim Krüger (Rebase PR Action)
parent 263edbc1d0
commit 6784c08ef4
2 changed files with 25 additions and 0 deletions

View file

@ -133,6 +133,12 @@
<data android:scheme="content" /> <data android:scheme="content" />
<data android:scheme="file" /> <data android:scheme="file" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/text" />
</intent-filter>
</activity> </activity>
<activity <activity

View file

@ -64,6 +64,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import org.parceler.Parcels import org.parceler.Parcels
import java.net.URI
import javax.inject.Inject import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
@ -245,6 +246,24 @@ class MainActivity : BaseActivity(), ActionBarProvider {
} }
} }
} }
if (intent.action == Intent.ACTION_VIEW &&
intent.extras?.get("server") != null &&
intent.extras?.get("userId") != null
) {
val baseUrl = intent.extras?.get("server") as URI // intent.extras.getString("server") is empty?!
val user = intent.extras?.get("userId") as String
if (userUtils.currentUser?.baseUrl?.endsWith(baseUrl.toString()) == true && user.isNotEmpty()) {
startConversation(user)
} else {
Snackbar.make(
binding.controllerContainer,
R.string.nc_phone_book_integration_account_not_found,
Snackbar.LENGTH_LONG
).show()
}
}
} }
private fun startConversation(userId: String) { private fun startConversation(userId: String) {