forked from mirror/monocles_chat_clean
Add wownero
I think the regex is too broad but no one seems to know what it should be (cherry picked from commit 13066f53b074415aaccf39bac93b0aa4beaa843f)
This commit is contained in:
parent
5815e2c1c8
commit
daac695094
6 changed files with 22 additions and 1 deletions
|
@ -1452,7 +1452,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
public synchronized Uri wholeIsKnownURI() {
|
||||
if (wholeIsKnownURI != null) return wholeIsKnownURI;
|
||||
|
||||
if (Patterns.BITCOIN_URI.matcher(body).matches() ||Patterns.BITCOINCASH_URI.matcher(body).matches() || Patterns.MONERO_URI.matcher(body).matches()) {
|
||||
if (Patterns.BITCOIN_URI.matcher(body).matches() ||Patterns.BITCOINCASH_URI.matcher(body).matches() || Patterns.MONERO_URI.matcher(body).matches() || Patterns.WOWNERO_URI.matcher(body).matches()) {
|
||||
wholeIsKnownURI = Uri.parse(body.replace(":", "://")); // hack to make query parser work
|
||||
}
|
||||
|
||||
|
|
|
@ -862,6 +862,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
|||
binding.command.setText(uri.getSchemeSpecificPart());
|
||||
binding.command.setCompoundDrawablesRelativeWithIntrinsicBounds(getDrawable(R.drawable.monero_24dp), null, null, null);
|
||||
binding.command.setCompoundDrawablePadding(20);
|
||||
} else if (uri.getScheme().equals("wownero")) {
|
||||
binding.command.setText(uri.getSchemeSpecificPart());
|
||||
binding.command.setCompoundDrawablesRelativeWithIntrinsicBounds(getDrawable(R.drawable.wownero_24dp), null, null, null);
|
||||
binding.command.setCompoundDrawablePadding(20);
|
||||
} else if (uri.getScheme().equals("https") && "liberapay.com".equals(uri.getHost())) {
|
||||
binding.command.setText(uri.getPath().substring(1));
|
||||
binding.command.setCompoundDrawablesRelativeWithIntrinsicBounds(getDrawable(R.drawable.liberapay), null, null, null);
|
||||
|
|
|
@ -958,6 +958,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
final var formattedAmount = amount == null || amount.equals("") ? "" : amount + " ";
|
||||
viewHolder.download_button.setIconResource(R.drawable.monero_24dp);
|
||||
viewHolder.download_button.setText("Send " + formattedAmount + "Monero");
|
||||
} else if ("wownero".equals(uri.getScheme())) {
|
||||
final var amount = uri.getQueryParameter("tx_amount");
|
||||
final var formattedAmount = amount == null || amount.equals("") ? "" : amount + " ";
|
||||
viewHolder.download_button.setIconResource(R.drawable.wownero_24dp);
|
||||
viewHolder.download_button.setText("Send " + formattedAmount + "Wownero");
|
||||
}
|
||||
viewHolder.download_button.setOnClickListener(v -> new FixedURLSpan(message.getRawBody()).onClick(v));
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ public class MyLinkify {
|
|||
Linkify.addLinks(body, Patterns.BITCOIN_URI, "bitcoin");
|
||||
Linkify.addLinks(body, Patterns.BITCOINCASH_URI, "bitcoincash");
|
||||
Linkify.addLinks(body, Patterns.MONERO_URI, "monero");
|
||||
Linkify.addLinks(body, Patterns.WOWNERO_URI, "wownero");
|
||||
Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);
|
||||
if (includeGeo) {
|
||||
Linkify.addLinks(body, GeoHelper.GEO_URI, "geo");
|
||||
|
|
|
@ -51,6 +51,12 @@ public class Patterns {
|
|||
+ "\\;\\/\\?\\@\\&\\=\\#\\~\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])"
|
||||
+ "|(?:\\%[a-fA-F0-9]{2}))+)?");
|
||||
|
||||
public static final Pattern WOWNERO_URI = Pattern
|
||||
.compile("wownero\\:(?:W(?:[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{96}|[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{106}|[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{187}))(?:\\?(?:(?:["
|
||||
+ Patterns.GOOD_IRI_CHAR
|
||||
+ "\\;\\/\\?\\@\\&\\=\\#\\~\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])"
|
||||
+ "|(?:\\%[a-fA-F0-9]{2}))+)?");
|
||||
|
||||
/**
|
||||
* Regular expression to match all IANA top-level domains.
|
||||
* List accurate as of 2011/07/18. List taken from:
|
||||
|
|
5
src/monocleschat/res/drawable/wownero_24dp.xml
Normal file
5
src/monocleschat/res/drawable/wownero_24dp.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:viewportHeight="64"
|
||||
android:viewportWidth="64" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M31.9688,0.0098C19.9011,-0.1508 8.1217,7.1798 3.0735,18.1663 -2.2328,28.9726 -0.6281,42.6852 7.0388,51.9692 15.026,62.1059 29.4616,66.5382 41.7216,62.4024 52.0868,59.2157 60.3535,50.3646 62.9549,39.8544 66.0949,28.1323 61.8558,14.7945 52.2861,7.2515 46.602,2.6114 39.3062,0.0118 31.9688,0.0098ZM31.6426,4.0371c11.0041,-0.2735 21.7835,6.5962 26.0566,16.7637 -4.8997,0 -9.7995,0 -14.6992,0 0,4.8997 0,9.7995 0,14.6992 -3.6664,-3.4671 -7.3374,-6.9293 -11,-10.4004 -3.6802,3.4857 -7.3323,7.001 -11,10.5 0,-4.9329 0,-9.8659 0,-14.7988 -4.8665,0 -9.7331,0 -14.5996,0C10.644,10.9076 20.8644,4.0895 31.6426,4.0371ZM5.3008,23.5c4.3333,0 8.6667,0 13,0 0,6.1335 0,12.2669 0,18.4004 4.5996,-4.3665 9.1992,-8.7331 13.7988,-13.0996 4.5332,4.3665 9.0664,8.7331 13.5996,13.0996 0.0338,-6.1335 0.0677,-12.2669 0.1016,-18.4004 4.2995,0 8.599,0 12.8984,0C62.7719,35.7018 57.0261,50.2591 45.652,56.317 34.9867,62.505 20.4032,60.3729 11.9474,51.4015 4.8494,44.2134 2.1985,33.1187 5.3008,23.5ZM7.4004,26.3008c-3.0513,11.5564 3.796,24.4466 14.7823,28.9002 9.9523,4.4252 22.5015,1.2903 29.2567,-7.2381 4.9427,-5.919 6.8619,-14.1527 5.1602,-21.662 -2.6999,0 -5.3997,0 -8.0996,0 0,7.3333 0,14.6667 0,22 -5.4441,-5.2244 -10.9314,-10.4033 -16.4004,-15.6016 -5.5045,5.1958 -11.0469,10.3516 -16.5,15.6016 0,-7.3333 0,-14.6667 0,-22 -2.7331,0 -5.4661,0 -8.1992,0z"/>
|
||||
</vector>
|
Loading…
Reference in a new issue