aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-27 10:04:27 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-27 10:04:27 +0100
commit7b9ced9fb752ee485b657daf6d827f311ed6e8bc (patch)
tree54d04fa44cca9bcfce6e42044a1daa983ac17084
parent975ee957b29f5ae41bf2cbb516b76fea1e42997e (diff)
WelcomeActivity: Add QR code scanner button
picked from https://github.com/siacs/Conversations/pull/2920
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/WelcomeActivity.java24
-rw-r--r--src/main/res/menu/welcome.xml11
2 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
index 0ce07dda4..2ea4fc278 100644
--- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
@@ -16,6 +16,8 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -40,6 +42,7 @@ import de.pixart.messenger.entities.Account;
import de.pixart.messenger.persistance.DatabaseBackend;
import de.pixart.messenger.persistance.FileBackend;
import de.pixart.messenger.utils.EncryptDecryptFile;
+import de.pixart.messenger.utils.MenuDoubleTabUtil;
import de.pixart.messenger.utils.XmppUri;
import static de.pixart.messenger.utils.PermissionUtils.allGranted;
@@ -124,6 +127,27 @@ public class WelcomeActivity extends XmppActivity {
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.welcome, menu);
+ MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
+ qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable());
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (MenuDoubleTabUtil.shouldIgnoreTap()) {
+ return false;
+ }
+ if (item.getItemId() == R.id.action_scan_qr_code) {
+ UriHandlerActivity.scan(this);
+ return true;
+
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
public void addInviteUri(Intent intent) {
StartConversationActivity.addInviteUri(intent, getIntent());
}
diff --git a/src/main/res/menu/welcome.xml b/src/main/res/menu/welcome.xml
new file mode 100644
index 000000000..b767dc0f4
--- /dev/null
+++ b/src/main/res/menu/welcome.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/action_scan_qr_code"
+ android:icon="?attr/icon_scan_qr_code"
+ android:title="@string/scan_qr_code"
+ app:showAsAction="always" />
+
+</menu> \ No newline at end of file