|
|
@ -31,9 +31,12 @@ import android.graphics.Typeface;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.Editable;
|
|
|
|
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
|
|
|
|
import android.text.style.ForegroundColorSpan;
|
|
|
|
import android.util.Pair;
|
|
|
|
import android.util.Pair;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
@ -155,7 +158,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|
|
|
ibDifferent.setOnClickListener(new View.OnClickListener() {
|
|
|
|
ibDifferent.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
etLink.setText(uriTitle.toString());
|
|
|
|
etLink.setText(format(uriTitle, context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -238,7 +241,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Uri uri = Uri.parse(etLink.getText().toString());
|
|
|
|
Uri uri = Uri.parse(etLink.getText().toString());
|
|
|
|
etLink.setText(secure(uri, checked).toString());
|
|
|
|
etLink.setText(format(secure(uri, checked), context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -247,7 +250,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|
|
|
cbSanitize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
cbSanitize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
|
|
etLink.setText(secure(checked ? sanitized : uri, cbSecure.isChecked()).toString());
|
|
|
|
etLink.setText(format(secure(checked ? sanitized : uri, cbSecure.isChecked()), context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -330,11 +333,11 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (host != null && !host.equals(puny)) {
|
|
|
|
if (host != null && !host.equals(puny)) {
|
|
|
|
etLink.setText(uri.buildUpon().encodedAuthority(puny).build().toString());
|
|
|
|
etLink.setText(format(uri.buildUpon().encodedAuthority(puny).build(), context));
|
|
|
|
tvLink.setText(uri.toString());
|
|
|
|
tvLink.setText(uri.toString());
|
|
|
|
tvSuspicious.setVisibility(View.VISIBLE);
|
|
|
|
tvSuspicious.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
etLink.setText(uri.toString());
|
|
|
|
etLink.setText(format(uri, context));
|
|
|
|
tvLink.setText(null);
|
|
|
|
tvLink.setText(null);
|
|
|
|
tvSuspicious.setVisibility(Helper.isSingleScript(host) ? View.GONE : View.VISIBLE);
|
|
|
|
tvSuspicious.setVisibility(Helper.isSingleScript(host) ? View.GONE : View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -479,4 +482,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
return uri;
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Spanned format(Uri uri, Context context) {
|
|
|
|
|
|
|
|
String text = uri.toString();
|
|
|
|
|
|
|
|
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
|
|
|
|
|
|
|
|
String host = uri.getHost();
|
|
|
|
|
|
|
|
if (host != null) {
|
|
|
|
|
|
|
|
int textColorLink = Helper.resolveColor(context, android.R.attr.textColorLink);
|
|
|
|
|
|
|
|
int index = text.indexOf(host);
|
|
|
|
|
|
|
|
ssb.setSpan(new ForegroundColorSpan(textColorLink), index, index + host.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ssb;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|