aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-24 21:03:21 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-24 21:03:21 +0100
commitdfaf8f40c59eb27d4f4e67aabb04b64ff7b043be (patch)
treed3aa93dc40a0036e0536af218c8821553f9c13c2 /src/main/java/de/pixart/messenger/ui
parent5d4d04b2a448b594ebb1f75ee80e8bcf90762cf1 (diff)
added share button to account details
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java31
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java29
2 files changed, 33 insertions, 27 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 617e0e6d5..7e3417a6e 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -46,6 +46,7 @@ import de.pixart.messenger.R;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession;
import de.pixart.messenger.entities.Account;
+import de.pixart.messenger.services.BarcodeProvider;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.services.XmppConnectionService.OnAccountUpdate;
import de.pixart.messenger.services.XmppConnectionService.OnCaptchaRequested;
@@ -719,6 +720,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
case R.id.action_server_info_show_more:
changeMoreTableVisibility(!item.isChecked());
break;
+ case R.id.action_share_barcode:
+ shareBarcode();
+ break;
+ case R.id.action_share_http:
+ shareLink(true);
+ break;
+ case R.id.action_share_uri:
+ shareLink(false);
+ break;
case R.id.action_change_password_on_server:
gotoChangePassword(null);
break;
@@ -738,6 +748,27 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
return super.onOptionsItemSelected(item);
}
+ private void shareLink(boolean http) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ String text;
+ if (http) {
+ text = Config.inviteUserURL+mAccount.getJid().toBareJid().toString();
+ } else {
+ text = mAccount.getShareableUri();
+ }
+ intent.putExtra(Intent.EXTRA_TEXT,text);
+ startActivity(Intent.createChooser(intent, getText(R.string.share_with)));
+ }
+
+ private void shareBarcode() {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.putExtra(Intent.EXTRA_STREAM, BarcodeProvider.getUriForAccount(mAccount));
+ 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) {
mMoreTable.setVisibility(visible ? View.VISIBLE : View.GONE);
}
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index e6a252c93..e0fdd3169 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -43,7 +43,6 @@ import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.util.Pair;
import android.view.MenuItem;
import android.view.View;
@@ -54,10 +53,8 @@ import android.widget.Toast;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
-import com.google.zxing.WriterException;
import com.google.zxing.aztec.AztecWriter;
import com.google.zxing.common.BitMatrix;
-import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import net.java.otr4j.session.SessionID;
@@ -80,6 +77,7 @@ import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presences;
import de.pixart.messenger.services.AvatarService;
+import de.pixart.messenger.services.BarcodeProvider;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.services.XmppConnectionService.XmppConnectionBinder;
import de.pixart.messenger.utils.CryptoHelper;
@@ -1104,7 +1102,7 @@ public abstract class XmppActivity extends Activity {
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
final int width = (size.x < size.y ? size.x : size.y);
- Bitmap bitmap = createQrCodeBitmap(uri, width);
+ Bitmap bitmap = BarcodeProvider.createAztecBitmap(uri, width);
ImageView view = new ImageView(this);
view.setImageBitmap(bitmap);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -1113,29 +1111,6 @@ public abstract class XmppActivity extends Activity {
}
}
- protected Bitmap createQrCodeBitmap(String input, int size) {
- try {
- final AztecWriter AZTEC_WRITER = new AztecWriter();
- final Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
- hints.put(EncodeHintType.ERROR_CORRECTION, 10);
- final BitMatrix result = AZTEC_WRITER.encode(input, BarcodeFormat.AZTEC, size, size, hints);
- final int width = result.getWidth();
- final int height = result.getHeight();
- final int[] pixels = new int[width * height];
- for (int y = 0; y < height; y++) {
- final int offset = y * width;
- for (int x = 0; x < width; x++) {
- pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT;
- }
- }
- final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
- return bitmap;
- } catch (final Exception e) {
- return null;
- }
- }
-
protected Account extractAccount(Intent intent) {
String jid = intent != null ? intent.getStringExtra(EXTRA_ACCOUNT) : null;
try {