show button on "xmpp:" uris
This commit is contained in:
parent
acf3c1f568
commit
945cea7ce5
5 changed files with 45 additions and 0 deletions
|
@ -13,6 +13,7 @@ import de.pixart.messenger.utils.CryptoHelper;
|
|||
import de.pixart.messenger.utils.GeoHelper;
|
||||
import de.pixart.messenger.utils.MimeUtils;
|
||||
import de.pixart.messenger.utils.UIHelper;
|
||||
import de.pixart.messenger.utils.XmppUri;
|
||||
import de.pixart.messenger.xmpp.jid.InvalidJidException;
|
||||
import de.pixart.messenger.xmpp.jid.Jid;
|
||||
|
||||
|
@ -492,6 +493,8 @@ public class Message extends AbstractEntity {
|
|||
!this.getBody().startsWith(ME_COMMAND) &&
|
||||
!this.bodyIsHeart() &&
|
||||
!message.bodyIsHeart() &&
|
||||
!this.bodyIsXmpp() &&
|
||||
!message.bodyIsXmpp() &&
|
||||
this.isTrusted() == message.isTrusted()
|
||||
);
|
||||
}
|
||||
|
@ -680,6 +683,10 @@ public class Message extends AbstractEntity {
|
|||
return body != null && UIHelper.HEARTS.contains(body.trim());
|
||||
}
|
||||
|
||||
public boolean bodyIsXmpp() {
|
||||
return body != null && XmppUri.isXmppUri(body.trim());
|
||||
}
|
||||
|
||||
public FileParams getFileParams() {
|
||||
FileParams params = getLegacyFileParams();
|
||||
if (params != null) {
|
||||
|
|
|
@ -313,6 +313,28 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
|||
viewHolder.messageBody.setText(span);
|
||||
}
|
||||
|
||||
private void displayXmppMessage(final ViewHolder viewHolder, final String body) {
|
||||
String contact = body.toLowerCase();
|
||||
contact = contact.split(":")[1];
|
||||
contact = contact.split("\\?")[0];
|
||||
String add_contact = activity.getString(R.string.add_to_contact_list) + " (" + contact + ")";
|
||||
viewHolder.aw_player.setVisibility(View.GONE);
|
||||
viewHolder.download_button.setVisibility(View.VISIBLE);
|
||||
viewHolder.download_button.setText(add_contact);
|
||||
viewHolder.download_button.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(body));
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
viewHolder.image.setVisibility(View.GONE);
|
||||
viewHolder.messageBody.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
private void displayTextMessage(final ViewHolder viewHolder, final Message message, boolean darkBackground) {
|
||||
if (viewHolder.download_button != null) {
|
||||
viewHolder.download_button.setVisibility(View.GONE);
|
||||
|
@ -740,6 +762,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
|||
displayLocationMessage(viewHolder,message);
|
||||
} else if (message.bodyIsHeart()) {
|
||||
displayHeartMessage(viewHolder, message.getBody().trim());
|
||||
} else if (message.bodyIsXmpp()) {
|
||||
displayXmppMessage(viewHolder, message.getBody().trim());
|
||||
} else if (message.treatAsDownloadable() == Message.Decision.MUST ||
|
||||
message.treatAsDownloadable() == Message.Decision.SHOULD) {
|
||||
try {
|
||||
|
|
|
@ -192,6 +192,12 @@ public class UIHelper {
|
|||
} else {
|
||||
return new Pair<>(context.getString(R.string.location), true);
|
||||
}
|
||||
} else if (message.bodyIsXmpp()) {
|
||||
if (message.getStatus() == Message.STATUS_RECEIVED) {
|
||||
return new Pair<>(context.getString(R.string.received_contact), true);
|
||||
} else {
|
||||
return new Pair<>(context.getString(R.string.contact), true);
|
||||
}
|
||||
} else if (message.treatAsDownloadable() == Message.Decision.MUST) {
|
||||
return new Pair<>(context.getString(R.string.x_file_offered_for_download,
|
||||
getFileDescriptionString(context,message)),true);
|
||||
|
|
|
@ -31,6 +31,11 @@ public class XmppUri {
|
|||
parse(uri);
|
||||
}
|
||||
|
||||
public static boolean isXmppUri(String uri) {
|
||||
String scheme = Uri.parse(uri).getScheme();
|
||||
return "xmpp".equalsIgnoreCase(scheme);
|
||||
}
|
||||
|
||||
protected void parse(Uri uri) {
|
||||
String scheme = uri.getScheme();
|
||||
String host = uri.getHost();
|
||||
|
|
|
@ -722,4 +722,7 @@
|
|||
<string name="data_saver_enabled_explained">Your operating system is restricting Pix-Art Messenger from accessing the Internet when in background. To receive notifications of new messages you should allow Pix-Art Messenger unrestricted access when Data saver is on.\\nPix-Art Messenger will still make an effort to save data when possible.</string>
|
||||
<string name="device_does_not_support_data_saver">Your device does not supporting disabling Data saver for Pix-Art Messenger.</string>
|
||||
<string name="navigate">Navigate to location</string>
|
||||
<string name="add_to_contact_list">Add to contact list</string>
|
||||
<string name="received_contact">Received contact</string>
|
||||
<string name="contact">Contact</string>
|
||||
</resources>
|
||||
|
|
Reference in a new issue