Suppress organization if undetermined

pull/156/head
M66B 6 years ago
parent 70568c0e1c
commit 3dbbff1fb5

@ -112,6 +112,7 @@ import org.jsoup.nodes.Element;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -2175,14 +2176,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
final EditText etLink = view.findViewById(R.id.etLink); final EditText etLink = view.findViewById(R.id.etLink);
TextView tvInsecure = view.findViewById(R.id.tvInsecure); TextView tvInsecure = view.findViewById(R.id.tvInsecure);
final TextView tvOwner = view.findViewById(R.id.tvOwner); final TextView tvOwner = view.findViewById(R.id.tvOwner);
Group grpOwner = view.findViewById(R.id.grpOwner); final Group grpOwner = view.findViewById(R.id.grpOwner);
tvTitle.setText(title); tvTitle.setText(title);
tvTitle.setVisibility(TextUtils.isEmpty(title) ? View.GONE : View.VISIBLE); tvTitle.setVisibility(TextUtils.isEmpty(title) ? View.GONE : View.VISIBLE);
etLink.setText(_uri.toString()); etLink.setText(_uri.toString());
tvInsecure.setVisibility("http".equals(_uri.getScheme()) ? View.VISIBLE : View.GONE); tvInsecure.setVisibility("http".equals(_uri.getScheme()) ? View.VISIBLE : View.GONE);
grpOwner.setVisibility(paranoid ? View.VISIBLE : View.GONE); grpOwner.setVisibility(View.GONE);
if (paranoid) { if (paranoid) {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -2192,6 +2193,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
protected void onPreExecute(Bundle args) { protected void onPreExecute(Bundle args) {
tvOwner.setText("…"); tvOwner.setText("…");
grpOwner.setVisibility(View.VISIBLE);
} }
@Override @Override
@ -2207,12 +2209,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
tvOwner.setText(ex.getMessage()); if (ex instanceof UnknownHostException)
grpOwner.setVisibility(View.GONE);
else
tvOwner.setText(ex.getMessage());
} }
}.execute(context, owner, args, "link:domain"); }.execute(context, owner, args, "link:domain");
} }
new DialogBuilderLifecycle(context, owner) new DialogBuilderLifecycle(context, owner)
.setView(view) .setView(view)
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {

@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -41,13 +42,13 @@ public class IPInfo {
MailTo email = MailTo.parse(uri.toString()); MailTo email = MailTo.parse(uri.toString());
String to = email.getTo(); String to = email.getTo();
if (to == null || !to.contains("@")) if (to == null || !to.contains("@"))
return null; throw new UnknownHostException();
String host = to.substring(to.indexOf('@') + 1); String host = to.substring(to.indexOf('@') + 1);
return getOrganization(host); return getOrganization(host);
} else { } else {
String host = uri.getHost(); String host = uri.getHost();
if (host == null) if (host == null)
return null; throw new UnknownHostException();
return getOrganization(host); return getOrganization(host);
} }
} }

Loading…
Cancel
Save