aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-10-01 15:31:21 +0200
committerChristian Schneppe <christian@pix-art.de>2018-10-01 15:31:21 +0200
commitbb53d7cef6b19e7089ca4d15de32f11ae09f50aa (patch)
treed0eaf2e0be639f15951b56df1d056780bb9ba5b1 /src/main/java/de/pixart/messenger/ui
parent682ad186640051aa65ad8b5c272394e217a4f8ff (diff)
add shortcut for QR-Code scanning in profile
fixes #190
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index be4222e78..681e561c9 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -9,6 +9,8 @@ import android.content.IntentSender;
import android.content.SharedPreferences;
import android.databinding.DataBindingUtil;
import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -834,7 +836,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/png");
startActivity(Intent.createChooser(intent, getText(R.string.share_with)));
-
}
private void changeMoreTableVisibility(boolean visible) {
@@ -1097,6 +1098,22 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
Toast.LENGTH_SHORT).show();
}
});
+ this.binding.actionShowQrCode.setVisibility(View.VISIBLE);
+ this.binding.actionShowQrCode.setOnClickListener(v -> {
+ if (otrFingerprint == null || otrFingerprint.isEmpty()) {
+ return;
+ }
+ Point size = new Point();
+ getWindowManager().getDefaultDisplay().getSize(size);
+ final int width = (size.x < size.y ? size.x : size.y);
+ Bitmap bitmap = BarcodeProvider.create2dBarcodeBitmap(otrFingerprint, width);
+ ImageView view = new ImageView(this);
+ view.setBackgroundColor(Color.WHITE);
+ view.setImageBitmap(bitmap);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setView(view);
+ builder.create().show();
+ });
} else {
this.binding.otrFingerprintBox.setVisibility(View.GONE);
}
@@ -1113,6 +1130,22 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.axolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2)));
this.binding.actionCopyAxolotlToClipboard.setVisibility(View.VISIBLE);
this.binding.actionCopyAxolotlToClipboard.setOnClickListener(v -> copyOmemoFingerprint(ownAxolotlFingerprint));
+ this.binding.actionShowAxoloqrCode.setVisibility(View.VISIBLE);
+ this.binding.actionShowAxoloqrCode.setOnClickListener(v -> {
+ if (otrFingerprint == null || otrFingerprint.isEmpty()) {
+ return;
+ }
+ Point size = new Point();
+ getWindowManager().getDefaultDisplay().getSize(size);
+ final int width = (size.x < size.y ? size.x : size.y);
+ Bitmap bitmap = BarcodeProvider.create2dBarcodeBitmap(ownAxolotlFingerprint, width);
+ ImageView view = new ImageView(this);
+ view.setBackgroundColor(Color.WHITE);
+ view.setImageBitmap(bitmap);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setView(view);
+ builder.create().show();
+ });
} else {
this.binding.axolotlFingerprintBox.setVisibility(View.GONE);
}