diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-24 15:16:01 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-24 20:27:38 +0200 |
commit | 0f42bf000de81473ba13a5bbd542e5099e8bea05 (patch) | |
tree | a32e50a8bd441aa33d1c86367d11b2a49b9f47e2 | |
parent | 4989e137b815a8648400dd355bc71092a44218d6 (diff) |
introduced share button in contact details. remove show qr
6 files changed, 23 insertions, 33 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 70878a734..fa6c79ece 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -484,15 +484,6 @@ public class Contact implements ListItem, Blockable { return getOption(Options.FROM) && getOption(Options.TO); } - public String getShareableUri() { - if (getOtrFingerprints().size() >= 1) { - String otr = getOtrFingerprints().get(0); - return "xmpp:" + getJid().toBareJid().toString() + "?otr-fingerprint=" + otr; - } else { - return "xmpp:" + getJid().toBareJid().toString(); - } - } - @Override public boolean isBlocked() { return getAccount().isBlocked(this); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 9f3602ffb..ed8a7255f 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -283,7 +283,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } break; case R.id.action_share: - share(); + shareUri(); break; case R.id.action_save_as_bookmark: saveAsBookmark(); @@ -312,18 +312,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } } - private void share() { - Intent shareIntent = new Intent(); - shareIntent.setAction(Intent.ACTION_SEND); - shareIntent.putExtra(Intent.EXTRA_TEXT, getShareableUri()); - shareIntent.setType("text/plain"); - try { - startActivity(Intent.createChooser(shareIntent, getText(R.string.share_uri_with))); - } catch (ActivityNotFoundException e) { - Toast.makeText(this, R.string.no_application_to_share_uri, Toast.LENGTH_SHORT).show(); - } - } - @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark); diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index d87b47dd5..b7b76c3c5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -183,7 +183,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd @Override protected String getShareableUri() { if (contact != null) { - return contact.getShareableUri(); + return "xmpp:"+contact.getJid().toBareJid().toString(); } else { return ""; } @@ -255,6 +255,9 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd case android.R.id.home: finish(); break; + case R.id.action_share: + shareUri(); + break; case R.id.action_delete_contact: builder.setTitle(getString(R.string.action_delete_contact)) .setMessage( diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 31bf27a1b..602486c05 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -8,6 +8,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ClipboardManager; import android.content.ComponentName; @@ -1121,6 +1122,22 @@ public abstract class XmppActivity extends Activity { startActivity(Intent.createChooser(intent, getString(R.string.invite_contact))); } + protected void shareUri() { + String uri = getShareableUri(); + 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"); + try { + startActivity(Intent.createChooser(shareIntent, getText(R.string.share_uri_with))); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, R.string.no_application_to_share_uri, Toast.LENGTH_SHORT).show(); + } + } + @Override public void onResume() { super.onResume(); diff --git a/src/main/res/menu/contact_details.xml b/src/main/res/menu/contact_details.xml index 7879eaea1..7fba3a4bd 100644 --- a/src/main/res/menu/contact_details.xml +++ b/src/main/res/menu/contact_details.xml @@ -12,19 +12,14 @@ android:id="@+id/action_share" android:icon="?attr/icon_share" android:showAsAction="always" - android:orderInCategory="10" + android:orderInCategory="15" android:title="@string/share_uri_with"/> <item android:id="@+id/action_delete_contact" - android:icon="?attr/icon_discard" android:orderInCategory="10" android:showAsAction="never" android:title="@string/action_delete_contact"/> - <item - android:id="@+id/action_show_qr_code" - android:title="@string/show_qr_code" - android:showAsAction="never" /> <item android:id="@+id/action_block" diff --git a/src/main/res/menu/muc_details.xml b/src/main/res/menu/muc_details.xml index bd809a9f4..5ee463de5 100644 --- a/src/main/res/menu/muc_details.xml +++ b/src/main/res/menu/muc_details.xml @@ -15,10 +15,6 @@ android:title="@string/share_uri_with"/> <item - android:id="@+id/action_show_qr_code" - android:showAsAction="never" - android:title="@string/show_qr_code"/> - <item android:id="@+id/action_save_as_bookmark" android:orderInCategory="80" android:showAsAction="never" |