unified share with menu
This commit is contained in:
parent
93b3596ab1
commit
7cf31ad645
8 changed files with 84 additions and 64 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -5,14 +5,18 @@
|
|||
android:icon="?attr/icon_share"
|
||||
android:showAsAction="always">
|
||||
<menu>
|
||||
<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: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_show_qr_code"
|
||||
android:title="@string/show_qr_code" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
@ -22,11 +26,6 @@
|
|||
android:title="@string/change_presence"
|
||||
android:icon="@drawable/ic_new_releases_white_24dp" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/show_qr_code" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_show_block_list"
|
||||
android:showAsAction="always"
|
||||
|
|
|
@ -12,7 +12,19 @@
|
|||
android:icon="?attr/icon_share"
|
||||
android:showAsAction="always"
|
||||
android:orderInCategory="15"
|
||||
android:title="@string/share_uri_with" />
|
||||
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"
|
||||
|
|
Reference in a new issue