Added whitelisting link domains

This commit is contained in:
M66B 2020-04-22 15:07:22 +02:00
parent 1f6db48f41
commit 1212e936eb
3 changed files with 28 additions and 2 deletions

View File

@ -3763,7 +3763,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false; return false;
boolean confirm_links = prefs.getBoolean("confirm_links", true); boolean confirm_links = prefs.getBoolean("confirm_links", true);
if (confirm_links) { boolean confirm_link =
!"https".equals(uri.getScheme()) || TextUtils.isEmpty(uri.getHost()) ||
prefs.getBoolean(uri.getHost() + ".confirm_link", true);
if (confirm_links && confirm_link) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable("uri", uri); args.putParcelable("uri", uri);
args.putString("title", title); args.putString("title", title);
@ -5302,6 +5305,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait); final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
final TextView tvHost = dview.findViewById(R.id.tvHost); final TextView tvHost = dview.findViewById(R.id.tvHost);
final TextView tvOwner = dview.findViewById(R.id.tvOwner); final TextView tvOwner = dview.findViewById(R.id.tvOwner);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final Group grpDifferent = dview.findViewById(R.id.grpDifferent); final Group grpDifferent = dview.findViewById(R.id.grpDifferent);
final Group grpOwner = dview.findViewById(R.id.grpOwner); final Group grpOwner = dview.findViewById(R.id.grpOwner);
@ -5403,7 +5407,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
}); });
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putBoolean(uri.getHost() + ".confirm_link", !isChecked).apply();
}
});
tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance()); tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance());
cbNotAgain.setText(getContext().getString(R.string.title_no_ask_for_again, uri.getHost()));
cbNotAgain.setVisibility(
"https".equals(uri.getScheme()) && !TextUtils.isEmpty(uri.getHost())
? View.VISIBLE : View.GONE);
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
grpOwner.setVisibility(View.GONE); grpOwner.setVisibility(View.GONE);

View File

@ -404,7 +404,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
for (String option : RESET_QUESTIONS) for (String option : RESET_QUESTIONS)
editor.remove(option); editor.remove(option);
for (String key : prefs.getAll().keySet()) for (String key : prefs.getAll().keySet())
if (key.endsWith(".show_full") || key.endsWith(".show_images")) if (key.endsWith(".show_full") || key.endsWith(".show_images") || key.endsWith(".confirm_link"))
editor.remove(key); editor.remove(key);
editor.apply(); editor.apply();
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show(); ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();

View File

@ -169,6 +169,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHost" /> app:layout_constraintTop_toBottomOf="@id/tvHost" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_ask_for_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwner" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpDifferent" android:id="@+id/grpDifferent"
android:layout_width="0dp" android:layout_width="0dp"