aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt23
1 files changed, 7 insertions, 16 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
index e311415..5f6a3fe 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
@@ -1,13 +1,12 @@
1package org.pacien.tincapp.activities 1package org.pacien.tincapp.activities
2 2
3import android.app.Activity
4import android.content.ActivityNotFoundException
5import android.content.Intent 3import android.content.Intent
6import android.net.Uri
7import android.os.Bundle 4import android.os.Bundle
8import android.support.annotation.StringRes 5import android.support.annotation.StringRes
9import android.support.v7.app.AlertDialog 6import android.support.v7.app.AlertDialog
10import android.view.View 7import android.view.View
8import com.google.zxing.integration.android.IntentIntegrator
9import com.google.zxing.integration.android.IntentResult
11import java8.util.concurrent.CompletableFuture 10import java8.util.concurrent.CompletableFuture
12import kotlinx.android.synthetic.main.base.* 11import kotlinx.android.synthetic.main.base.*
13import kotlinx.android.synthetic.main.dialog_encrypt_decrypt_keys.view.* 12import kotlinx.android.synthetic.main.dialog_encrypt_decrypt_keys.view.*
@@ -26,8 +25,6 @@ import java.util.regex.Pattern
26 */ 25 */
27class ConfigureActivity : BaseActivity() { 26class ConfigureActivity : BaseActivity() {
28 companion object { 27 companion object {
29 private const val REQUEST_SCAN = 0
30 private const val SCAN_PROVIDER = "com.google.zxing.client.android"
31 private val NETWORK_NAME_PATTERN = Pattern.compile("^[^\\x00/]*$") 28 private val NETWORK_NAME_PATTERN = Pattern.compile("^[^\\x00/]*$")
32 } 29 }
33 30
@@ -36,8 +33,10 @@ class ConfigureActivity : BaseActivity() {
36 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 33 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
37 super.onActivityResult(requestCode, resultCode, data) 34 super.onActivityResult(requestCode, resultCode, data)
38 35
39 if (requestCode == REQUEST_SCAN && resultCode == Activity.RESULT_OK) 36 IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
40 joinDialog?.invitation_url?.setText(data!!.getStringExtra("SCAN_RESULT").trim()) 37 ?.let(IntentResult::getContents)
38 ?.let(String::trim)
39 ?.let { joinDialog?.invitation_url?.setText(it) }
41 } 40 }
42 41
43 override fun onCreate(savedInstanceState: Bundle?) { 42 override fun onCreate(savedInstanceState: Bundle?) {
@@ -48,15 +47,7 @@ class ConfigureActivity : BaseActivity() {
48 } 47 }
49 48
50 fun scanCode(@Suppress("UNUSED_PARAMETER") v: View) { 49 fun scanCode(@Suppress("UNUSED_PARAMETER") v: View) {
51 try { 50 IntentIntegrator(this).initiateScan()
52 startActivityForResult(Intent("$SCAN_PROVIDER.SCAN"), REQUEST_SCAN)
53 } catch (e: ActivityNotFoundException) {
54 AlertDialog.Builder(this).setTitle(R.string.action_scan_qr_code)
55 .setMessage(R.string.message_no_qr_code_scanner)
56 .setPositiveButton(R.string.action_install) { _, _ ->
57 startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$SCAN_PROVIDER")))
58 }.setNegativeButton(R.string.action_cancel, { _, _ -> Unit }).show()
59 }
60 } 51 }
61 52
62 fun openGenerateConfDialog(@Suppress("UNUSED_PARAMETER") v: View) { 53 fun openGenerateConfDialog(@Suppress("UNUSED_PARAMETER") v: View) {