show host in file size checker

This commit is contained in:
Daniel Gultsch 2016-03-04 21:30:34 +01:00
parent 09d87965fb
commit e9b4a2a021
2 changed files with 15 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import android.widget.TextView;
import android.widget.Toast;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import java.util.regex.Matcher;
@ -625,7 +626,19 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (message.bodyIsHeart()) {
displayHeartMessage(viewHolder, message.getBody().trim());
} else if (message.treatAsDownloadable() == Message.Decision.MUST) {
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
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()));
} catch (Exception e) {
displayDownloadableMessage(viewHolder,
message,
activity.getString(R.string.check_x_filesize,
UIHelper.getFileDescriptionString(activity, message)));
}
} else {
displayTextMessage(viewHolder, message, darkBackground);
}

View File

@ -344,6 +344,7 @@
<string name="checking_x">Checking %s on HTTP host</string>
<string name="not_connected_try_again">You are not connected. Try again later</string>
<string name="check_x_filesize">Check %s size</string>
<string name="check_x_filesize_on_host">Check %1$s size on %2$s</string>
<string name="message_options">Message options</string>
<string name="copy_text">Copy text</string>
<string name="copy_original_url">Copy original URL</string>