diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-09-24 20:33:01 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-09-24 20:33:01 +0200 |
commit | 7cf31ad64589d956e02a1c751192d583fd5c8cc4 (patch) | |
tree | c15f46b04514e0a9ae6bbac2fd9119287568ffc7 /src/main/java/de | |
parent | 93b3596ab17c8f655a81892faa4d56c03014d2ad (diff) |
unified share with menu
Diffstat (limited to 'src/main/java/de')
5 files changed, 47 insertions, 50 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java index 2dc8d191a..21f830a5c 100644 --- a/src/main/java/de/pixart/messenger/Config.java +++ b/src/main/java/de/pixart/messenger/Config.java @@ -40,6 +40,7 @@ public final class Config { public static final String BUG_REPORTS = "bugs@pix-art.de"; public static final String inviteUserURL = "https://jabber.pix-art.de/i/"; + public static final String inviteMUCURL = "https://jabber.pix-art.de/j/"; public static final String XMPP_IP = BuildConfig.XMPP_IP; // set to null means disable public static final Integer[] XMPP_Ports = BuildConfig.XMPP_Ports; // set to null means disable diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 7e45afa6d..77f571433 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -311,8 +311,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.onSubjectEdited); } break; - case R.id.action_share: - shareUri(); + case R.id.action_share_http: + shareLink(true); + break; + case R.id.action_share_uri: + shareLink(false); break; case R.id.action_save_as_bookmark: saveAsBookmark(); @@ -333,11 +336,15 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } @Override - protected String getShareableUri() { + protected String getShareableUri(boolean http) { if (mConversation != null) { - return "xmpp:" + mConversation.getJid().toBareJid().toString() + "?join"; + if (http) { + return Config.inviteMUCURL + mConversation.getJid().toBareJid(); + } else { + return "xmpp:" + mConversation.getJid().toBareJid() + "?join"; + } } else { - return ""; + return null; } } diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index e440aa554..0cf8a2919 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -249,9 +249,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } @Override - protected String getShareableUri() { + protected String getShareableUri(boolean http) { + final String prefix = http ? Config.inviteUserURL : "xmpp:"; if (contact != null) { - return "xmpp:" + contact.getJid().toBareJid().toString(); + return prefix + contact.getJid().toBareJid().toString(); } else { return ""; } @@ -331,8 +332,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp case android.R.id.home: finish(); break; - case R.id.action_share: - shareUri(); + case R.id.action_share_http: + shareLink(true); + break; + case R.id.action_share_uri: + shareLink(false); break; case R.id.action_delete_contact: builder.setTitle(getString(R.string.action_delete_contact)) diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index a7b0d994a..8ada0f1e7 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -499,11 +499,11 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } @Override - protected String getShareableUri() { + protected String getShareableUri(boolean http) { if (mAccount != null) { - return mAccount.getShareableUri(); + return http ? mAccount.getShareableLink() : mAccount.getShareableUri(); } else { - return ""; + return null; } } @@ -597,7 +597,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat public boolean onCreateOptionsMenu(final Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.editaccount, menu); - final MenuItem showQrCode = menu.findItem(R.id.action_show_qr_code); final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list); final MenuItem reconnect = menu.findItem(R.id.mgmt_account_reconnect); final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more); @@ -608,8 +607,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat final MenuItem changePresence = menu.findItem(R.id.action_change_presence); final MenuItem actionShare = menu.findItem(R.id.action_share); final MenuItem shareBarcode = menu.findItem(R.id.action_share_barcode); - final MenuItem shareHttp = menu.findItem(R.id.action_share_http); - final MenuItem shareUri = menu.findItem(R.id.action_share_uri); final MenuItem announcePGP = menu.findItem(R.id.mgmt_account_announce_pgp); renewCertificate.setVisible(mAccount != null && mAccount.getPrivateKeyAlias() != null); @@ -627,7 +624,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else { announcePGP.setVisible(false); reconnect.setVisible(false); - showQrCode.setVisible(false); showBlocklist.setVisible(false); showMoreInfo.setVisible(false); changePassword.setVisible(false); @@ -635,8 +631,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat changePresence.setVisible(false); actionShare.setVisible(false); shareBarcode.setVisible(false); - shareHttp.setVisible(false); - shareUri.setVisible(false); } if (mAccount != null) { @@ -820,19 +814,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } } - private void shareLink(boolean http) { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - String text; - if (http) { - text = mAccount.getShareableLink(); - } 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(this, mAccount)); diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 82cd46b51..e5b894322 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -1036,6 +1036,10 @@ public abstract class XmppActivity extends Activity { } protected String getShareableUri() { + return getShareableUri(false); + } + + protected String getShareableUri(boolean http) { return null; } @@ -1059,17 +1063,16 @@ public abstract class XmppActivity extends Activity { startActivity(intent); } - protected void shareUri() { - String uri = getShareableUri(); + protected void shareLink(boolean http) { + String uri = getShareableUri(http); if (uri == null || uri.isEmpty()) { return; } - Intent shareIntent = new Intent(); - shareIntent.setAction(Intent.ACTION_SEND); - shareIntent.putExtra(Intent.EXTRA_TEXT, getShareableUri()); - shareIntent.setType("text/plain"); + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, getShareableUri(http)); try { - startActivity(Intent.createChooser(shareIntent, getText(R.string.share_uri_with))); + startActivity(Intent.createChooser(intent, getText(R.string.share_uri_with))); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.no_application_to_share_uri, Toast.LENGTH_SHORT).show(); } @@ -1111,19 +1114,20 @@ public abstract class XmppActivity extends Activity { } protected void showQrCode() { - String uri = getShareableUri(); - if (uri != null) { - Point size = new Point(); - getWindowManager().getDefaultDisplay().getSize(size); - final int width = (size.x < size.y ? size.x : size.y); - Bitmap bitmap = BarcodeProvider.create2dBarcodeBitmap(uri, 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(); + final String uri = getShareableUri(); + if (uri == null || uri.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(uri, 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(); } protected Account extractAccount(Intent intent) { |