unified share with menu. fixes #2630
This commit is contained in:
parent
dbd489cbcb
commit
acc78145db
|
@ -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 "";
|
||||
return "xmpp:"+mConversation.getJid().toBareJid()+"?join";
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,8 +1063,10 @@ public abstract class XmppActivity extends Activity {
|
|||
}
|
||||
|
||||
protected void showQrCode() {
|
||||
String uri = getShareableUri();
|
||||
if (uri!=null) {
|
||||
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);
|
||||
|
@ -1073,7 +1078,6 @@ public abstract class XmppActivity extends Activity {
|
|||
builder.setView(view);
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
|
||||
protected Account extractAccount(Intent intent) {
|
||||
String jid = intent != null ? intent.getStringExtra(EXTRA_ACCOUNT) : null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_contact"
|
||||
|
@ -11,9 +11,21 @@
|
|||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="?attr/icon_share"
|
||||
android:showAsAction="always"
|
||||
android:orderInCategory="15"
|
||||
android:title="@string/share_uri_with"/>
|
||||
android:showAsAction="always"
|
||||
android:title="@string/share_uri_with">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/action_share_uri"
|
||||
android:title="@string/share_as_uri"/>
|
||||
<item
|
||||
android:id="@+id/action_share_http"
|
||||
android:title="@string/share_as_http"/>
|
||||
<item
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:title="@string/show_qr_code"/>
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/action_delete_contact"
|
||||
android:orderInCategory="10"
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/action_share"
|
||||
android:title="@string/share_uri_with"
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="?attr/icon_share"
|
||||
android:showAsAction="always">
|
||||
android:showAsAction="always"
|
||||
android:title="@string/share_uri_with">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/action_share_uri"
|
||||
android:title="@string/share_as_uri"/>
|
||||
<item
|
||||
android:id="@+id/action_share_http"
|
||||
android:title="@string/share_as_http"/>
|
||||
<item
|
||||
android:id="@+id/action_share_barcode"
|
||||
android:title="@string/share_as_barcode"/>
|
||||
<item
|
||||
android:id="@+id/action_share_uri"
|
||||
android:title="@string/share_as_uri"/>
|
||||
<item android:id="@+id/action_share_http"
|
||||
android:title="@string/share_as_http"/>
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:title="@string/show_qr_code"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_change_presence"
|
||||
android:icon="@drawable/ic_announcement_white_24dp"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/change_presence"
|
||||
android:icon="@drawable/ic_announcement_white_24dp"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/show_qr_code"/>
|
||||
android:title="@string/change_presence"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_show_block_list"
|
||||
|
|
|
@ -7,12 +7,25 @@
|
|||
android:orderInCategory="10"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/action_edit_subject"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="?attr/icon_share"
|
||||
android:showAsAction="always"
|
||||
android:orderInCategory="15"
|
||||
android:title="@string/share_uri_with"/>
|
||||
android:showAsAction="always"
|
||||
android:title="@string/share_uri_with">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/action_share_uri"
|
||||
android:title="@string/share_as_uri"/>
|
||||
<item
|
||||
android:id="@+id/action_share_http"
|
||||
android:title="@string/share_as_http"/>
|
||||
<item
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:title="@string/show_qr_code"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save_as_bookmark"
|
||||
|
|
Loading…
Reference in New Issue