diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-26 22:56:17 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-26 22:56:17 +0200 |
commit | a554be18a60380d624fc9c65416368775cba9bae (patch) | |
tree | be455ef73e0c047a47bd71651382f2d22dd115ab /src/main/java/de/pixart/messenger/ui/adapter | |
parent | 369e48c2203a694088156574dd7c7044f68e907b (diff) |
add support for S3 file transfers
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 92c937053..0c2238cdb 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -67,6 +67,7 @@ import de.pixart.messenger.entities.DownloadableFile; import de.pixart.messenger.entities.Message; import de.pixart.messenger.entities.Message.FileParams; import de.pixart.messenger.entities.Transferable; +import de.pixart.messenger.http.P1S3UrlStreamHandler; import de.pixart.messenger.persistance.FileBackend; import de.pixart.messenger.services.AudioPlayer; import de.pixart.messenger.services.MessageArchiveService; @@ -99,13 +100,10 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie private static final int SENT = 0; private static final int RECEIVED = 1; private static final int STATUS = 2; - private static final int DATE_SEPARATOR = 3; boolean isResendable = false; - private List<String> highlightedTerm = null; - private static final Linkify.TransformFilter WEBURL_TRANSFORM_FILTER = (matcher, url) -> { if (url == null) { return null; @@ -118,24 +116,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } }; - private static String removeTrailingBracket(final String url) { - int numOpenBrackets = 0; - for (char c : url.toCharArray()) { - if (c == '(') { - ++numOpenBrackets; - } else if (c == ')') { - --numOpenBrackets; - } - } - if (numOpenBrackets != 0 && url.charAt(url.length() - 1) == ')') { - return url.substring(0, url.length() - 1); - } else { - return url; - } - } - private static final Linkify.MatchFilter WEBURL_MATCH_FILTER = (cs, start, end) -> start < 1 || (cs.charAt(start - 1) != '@' && cs.charAt(start - 1) != '.' && !cs.subSequence(Math.max(0, start - 3), start).equals("://")); - private static final Linkify.MatchFilter XMPPURI_MATCH_FILTER = (s, start, end) -> { XmppUri uri = new XmppUri(s.subSequence(start, end).toString()); return uri.isJidValid(); @@ -143,7 +124,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie private final XmppActivity activity; private final ListSelectionManager listSelectionManager = new ListSelectionManager(); - public final AudioPlayer audioPlayer; + private final AudioPlayer audioPlayer; + private List<String> highlightedTerm = null; private DisplayMetrics metrics; private OnContactPictureClicked mOnContactPictureClickedListener; private OnContactPictureLongClicked mOnContactPictureLongClickedListener; @@ -158,6 +140,22 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie updatePreferences(); } + private static String removeTrailingBracket(final String url) { + int numOpenBrackets = 0; + for (char c : url.toCharArray()) { + if (c == '(') { + ++numOpenBrackets; + } else if (c == ')') { + --numOpenBrackets; + } + } + if (numOpenBrackets != 0 && url.charAt(url.length() - 1) == ')') { + return url.substring(0, url.length() - 1); + } else { + return url; + } + } + public static boolean cancelPotentialWork(Message message, ImageView imageView) { final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); @@ -183,6 +181,12 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie return null; } + private static void resetClickListener(View... views) { + for (View view : views) { + view.setOnClickListener(null); + } + } + public void flagScreenOn() { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } @@ -957,11 +961,18 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } else if (message.treatAsDownloadable()) { try { URL url = new URL(message.getBody()); - displayDownloadableMessage(viewHolder, - message, - activity.getString(R.string.check_x_filesize_on_host, - UIHelper.getFileDescriptionString(activity, message), - url.getHost())); + if (P1S3UrlStreamHandler.PROTOCOL_NAME.equalsIgnoreCase(url.getProtocol())) { + displayDownloadableMessage(viewHolder, + message, + activity.getString(R.string.check_x_filesize, + UIHelper.getFileDescriptionString(activity, message))); + } else { + displayDownloadableMessage(viewHolder, + message, + activity.getString(R.string.check_x_filesize_on_host, + UIHelper.getFileDescriptionString(activity, message), + url.getHost())); + } } catch (Exception e) { displayDownloadableMessage(viewHolder, message, @@ -999,12 +1010,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie return view; } - private static void resetClickListener(View... views) { - for (View view : views) { - view.setOnClickListener(null); - } - } - private void promptOpenKeychainInstall(View view) { activity.showInstallPgpDialog(); } |