aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <xmpp-dev@marcschink.de>2017-12-10 11:44:10 +0100
committerAndroid Development <you@example.com>2017-12-10 14:58:51 +0100
commit3c6024276355a85d88b0ff56d74506a4ee2bc856 (patch)
treee6cf8e76631fef4d4c240c37d89f7ddc91e5a643
parentcf3159e5aff2b0516ade21d00be7f564f7b0f07e (diff)
StartConversationActivity: Scan QR codes via UriHandlerActivity
-rw-r--r--src/main/AndroidManifest.xml1
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java23
-rw-r--r--src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java26
3 files changed, 31 insertions, 19 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 2791463..8677eff 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -60,7 +60,6 @@
<activity
android:name=".ui.UriHandlerActivity"
android:label="foobar"
- android:theme="@android:style/Theme.NoDisplay"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index e8bd498..ec3dd34 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -55,9 +55,6 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
-import com.google.zxing.integration.android.IntentIntegrator;
-import com.google.zxing.integration.android.IntentResult;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -644,7 +641,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showCreateConferenceDialog();
return true;
case R.id.action_scan_qr_code:
- new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC","QR_CODE"));
+ Intent intent = new Intent(this, UriHandlerActivity.class);
+ intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
+ startActivity(intent);
+ finish();
return true;
case R.id.action_hide_offline:
mHideOfflineContacts = !item.isChecked();
@@ -682,20 +682,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
- if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) {
- IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
- if (scanResult != null && scanResult.getFormatName() != null) {
- String data = scanResult.getContents();
- Invite invite = new Invite(data);
- if (xmppConnectionServiceBound) {
- invite.invite();
- } else if (invite.getJid() != null) {
- this.mPendingInvite = invite;
- } else {
- this.mPendingInvite = null;
- }
- }
- } else if (resultCode == RESULT_OK) {
+ if (resultCode == RESULT_OK) {
if (xmppConnectionServiceBound) {
this.mPostponedActivityResult = null;
if (requestCode == REQUEST_CREATE_CONFERENCE) {
diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
index 7f7e0b3..cb1b659 100644
--- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java
@@ -4,10 +4,16 @@ import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
+import com.google.zxing.integration.android.IntentIntegrator;
+import com.google.zxing.integration.android.IntentResult;
+
+import java.util.Arrays;
+
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.jid.Jid;
public class UriHandlerActivity extends Activity {
+ public static final String ACTION_SCAN_QR_CODE = "scan_qr_code";
@Override
public void onStart() {
@@ -57,8 +63,28 @@ public class UriHandlerActivity extends Activity {
case Intent.ACTION_VIEW:
case Intent.ACTION_SENDTO:
handleUri(data.getData());
+ break;
+ case ACTION_SCAN_QR_CODE:
+ new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC", "QR_CODE"));
+ return;
+ }
+
+ finish();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) {
+ IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode,
+ intent);
+
+ if (scanResult != null && scanResult.getFormatName() != null) {
+ String data = scanResult.getContents();
+ handleUri(Uri.parse(data));
+ }
}
finish();
+ super.onActivityResult(requestCode, requestCode, intent);
}
}