diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 94fa7525b..c2617c72e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -291,8 +291,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(); @@ -313,11 +316,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 "https://conversations.im/j/"+ mConversation.getJid().toBareJid(); + } else { + return "xmpp:"+mConversation.getJid().toBareJid()+"?join"; + } } else { - return ""; + return null; } } diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 772f32690..3de3c4df2 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -180,9 +180,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } @Override - protected String getShareableUri() { + protected String getShareableUri(boolean http) { + final String prefix = http ? "https://conversations.im/i/" : "xmpp:"; if (contact != null) { - return "xmpp:"+contact.getJid().toBareJid().toString(); + return prefix+contact.getJid().toBareJid().toString(); } else { return ""; } @@ -263,8 +264,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/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 5d1b6cd86..96b466e72 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -492,11 +492,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; } } @@ -590,7 +590,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 showMoreInfo = menu.findItem(R.id.action_server_info_show_more); final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server); @@ -614,7 +613,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat mamPrefs.setVisible(mAccount.getXmppConnection().getFeatures().mam()); changePresence.setVisible(manuallyChangePresence()); } else { - showQrCode.setVisible(false); showBlocklist.setVisible(false); showMoreInfo.setVisible(false); changePassword.setVisible(false); @@ -785,19 +783,6 @@ 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 = 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/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index a4b7c5caf..e23dfd568 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -998,20 +998,23 @@ public abstract class XmppActivity extends Activity { } protected String getShareableUri() { + return getShareableUri(false); + } + + protected String getShareableUri(boolean http) { return null; } - 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(); } @@ -1031,7 +1034,7 @@ public abstract class XmppActivity extends Activity { @Override public void onResume() { super.onResume(); - if (this.getShareableUri()!=null) { + if (this.getShareableUri() != null) { this.registerNdefPushMessageCallback(); } } @@ -1060,19 +1063,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) { diff --git a/src/main/res/menu/contact_details.xml b/src/main/res/menu/contact_details.xml index c724a4d2f..b8d9ee64b 100644 --- a/src/main/res/menu/contact_details.xml +++ b/src/main/res/menu/contact_details.xml @@ -1,5 +1,5 @@ -