Added whois UI

pull/209/head
M66B 2 years ago
parent 09cb257e40
commit a052dd1ded

@ -78,6 +78,7 @@ import androidx.preference.PreferenceManager;
import java.net.IDN; import java.net.IDN;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -93,6 +94,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
private TextView tvOwnerRemark; private TextView tvOwnerRemark;
private TextView tvHost; private TextView tvHost;
private TextView tvOwner; private TextView tvOwner;
private Button btnWhois;
private Group grpOwner; private Group grpOwner;
private Button btnSettings; private Button btnSettings;
private Button btnDefault; private Button btnDefault;
@ -185,6 +187,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
tvHost = dview.findViewById(R.id.tvHost); tvHost = dview.findViewById(R.id.tvHost);
tvOwner = dview.findViewById(R.id.tvOwner); tvOwner = dview.findViewById(R.id.tvOwner);
grpOwner = dview.findViewById(R.id.grpOwner); grpOwner = dview.findViewById(R.id.grpOwner);
btnWhois = dview.findViewById(R.id.btnWhois);
btnSettings = dview.findViewById(R.id.btnSettings); btnSettings = dview.findViewById(R.id.btnSettings);
btnDefault = dview.findViewById(R.id.btnDefault); btnDefault = dview.findViewById(R.id.btnDefault);
tvReset = dview.findViewById(R.id.tvReset); tvReset = dview.findViewById(R.id.tvReset);
@ -393,6 +396,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
protected void onExecuted(Bundle args, Pair<InetAddress, IPInfo.Organization> data) { protected void onExecuted(Bundle args, Pair<InetAddress, IPInfo.Organization> data) {
tvHost.setText(data.first.toString()); tvHost.setText(data.first.toString());
tvOwner.setText(data.second.name == null ? "?" : data.second.name); tvOwner.setText(data.second.name == null ? "?" : data.second.name);
ApplicationEx.getMainHandler().post(new Runnable() { ApplicationEx.getMainHandler().post(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -414,6 +418,46 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance()); tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance());
btnWhois.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putParcelable("uri", uri);
new SimpleTask<String>() {
@Override
protected String onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
String host = UriHelper.getRootDomain(context, UriHelper.getHost(uri));
if (TextUtils.isEmpty(host))
throw new UnknownHostException("Host unknown " + uri);
args.putString("host", host);
return Whois.get(host);
}
@Override
protected void onExecuted(Bundle args, String whois) {
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_whois, null);
final TextView tvHost = dview.findViewById(R.id.tvHost);
final TextView tvWhois = dview.findViewById(R.id.tvWhois);
tvHost.setText(args.getString("host"));
tvWhois.setText(whois);
new AlertDialog.Builder(getContext())
.setView(dview)
.setPositiveButton(android.R.string.ok, null)
.show();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentDialogOpenLink.this, args, "link:whois");
}
});
btnSettings.setOnClickListener(new View.OnClickListener() { btnSettings.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -679,6 +723,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
tvOwnerRemark.setVisibility(show ? View.VISIBLE : View.GONE); tvOwnerRemark.setVisibility(show ? View.VISIBLE : View.GONE);
grpOwner.setVisibility(View.GONE); grpOwner.setVisibility(View.GONE);
btnWhois.setVisibility(show && !BuildConfig.PLAY_STORE_RELEASE ? View.VISIBLE : View.GONE);
btnSettings.setVisibility(show ? View.VISIBLE : View.GONE); btnSettings.setVisibility(show ? View.VISIBLE : View.GONE);
btnDefault.setVisibility(show && n ? View.VISIBLE : View.GONE); btnDefault.setVisibility(show && n ? View.VISIBLE : View.GONE);
tvReset.setVisibility(show ? View.VISIBLE : View.GONE); tvReset.setVisibility(show ? View.VISIBLE : View.GONE);

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,11h2v2h-2v2h2v2h-2v2h8L20,9h-8v2zM16,11h2v2h-2v-2zM16,15h2v2h-2v-2z"
android:strokeAlpha="0.3"
android:fillAlpha="0.3"/>
<path
android:fillColor="@android:color/white"
android:pathData="M12,7L12,3L2,3v18h20L22,7L12,7zM6,19L4,19v-2h2v2zM6,15L4,15v-2h2v2zM6,11L4,11L4,9h2v2zM6,7L4,7L4,5h2v2zM10,19L8,19v-2h2v2zM10,15L8,15v-2h2v2zM10,11L8,11L8,9h2v2zM10,7L8,7L8,5h2v2zM20,19h-8v-2h2v-2h-2v-2h2v-2h-2L12,9h8v10zM16,11h2v2h-2zM16,15h2v2h-2z"/>
</vector>

@ -309,6 +309,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHost" /> app:layout_constraintTop_toBottomOf="@id/tvHost" />
<Button
android:id="@+id/btnWhois"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_domain_24"
android:drawablePadding="6dp"
android:text="@string/title_whois"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwner" />
<Button <Button
android:id="@+id/btnSettings" android:id="@+id/btnSettings"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -319,7 +331,7 @@
android:drawablePadding="6dp" android:drawablePadding="6dp"
android:text="@string/title_setup" android:text="@string/title_setup"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwner" /> app:layout_constraintTop_toBottomOf="@id/btnWhois" />
<Button <Button
android:id="@+id/btnDefault" android:id="@+id/btnDefault"
@ -340,12 +352,12 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_open_in_new_12" android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp" android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:focusable="false" android:focusable="false"
android:text="@string/title_reset_open" android:text="@string/title_reset_open"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink" android:textColor="?android:attr/textColorLink"
android:textIsSelectable="true" android:textIsSelectable="true"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnDefault" /> app:layout_constraintTop_toBottomOf="@id/btnDefault" />

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.faircode.email.ScrollViewEx xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="24dp"
android:scrollbarStyle="outsideOverlay">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvCaption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_domain_24"
android:drawablePadding="6dp"
android:text="@string/title_whois"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvHost"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:fontFamily="monospace"
android:text="Whois"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaption" />
<TextView
android:id="@+id/tvWhois"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:fontFamily="monospace"
android:text="Whois"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHost" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

@ -1926,6 +1926,7 @@
<string name="title_check_owner">Check owner</string> <string name="title_check_owner">Check owner</string>
<string name="title_remark_owner">Information will be retrieved from <a href="https://ipinfo.io/">ipinfo.io</a></string> <string name="title_remark_owner">Information will be retrieved from <a href="https://ipinfo.io/">ipinfo.io</a></string>
<string name="title_ip_owner">Owner IP address</string> <string name="title_ip_owner">Owner IP address</string>
<string name="title_whois" translatable="false">Whois</string>
<string name="title_default_apps">Default apps</string> <string name="title_default_apps">Default apps</string>
<string name="title_reset_open">Set or clear default apps</string> <string name="title_reset_open">Set or clear default apps</string>
<string name="title_select_app">Select app</string> <string name="title_select_app">Select app</string>

Loading…
Cancel
Save