Added sub option to open links by default

pull/215/head
M66B 7 months ago
parent 1c8f257c10
commit b29eb3b2ad

@ -184,6 +184,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
final CheckBox cbSecure = dview.findViewById(R.id.cbSecure); final CheckBox cbSecure = dview.findViewById(R.id.cbSecure);
final CheckBox cbSanitize = dview.findViewById(R.id.cbSanitize); final CheckBox cbSanitize = dview.findViewById(R.id.cbSanitize);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final CheckBox cbNeverAgain = dview.findViewById(R.id.cbNeverAgain);
final Spinner spOpenWith = dview.findViewById(R.id.spOpenWith); final Spinner spOpenWith = dview.findViewById(R.id.spOpenWith);
ibMore = dview.findViewById(R.id.ibMore); ibMore = dview.findViewById(R.id.ibMore);
@ -350,6 +351,13 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
} }
}); });
cbNeverAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbNotAgain.setEnabled(!isChecked);
}
});
spOpenWith.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { spOpenWith.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -608,6 +616,8 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, chost)); cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, chost));
cbNotAgain.setVisibility(!always_confirm && !sanitize_links && chost != null ? View.VISIBLE : View.GONE); cbNotAgain.setVisibility(!always_confirm && !sanitize_links && chost != null ? View.VISIBLE : View.GONE);
cbNeverAgain.setVisibility(!always_confirm && !sanitize_links ? View.VISIBLE : View.GONE);
setMore(false); setMore(false);
if (UriHelper.isHyperLink(uri)) { if (UriHelper.isHyperLink(uri)) {
@ -782,13 +792,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (chost != null && if (cbNeverAgain.getVisibility() == View.VISIBLE && cbNeverAgain.isChecked())
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked()) prefs.edit().putBoolean("confirm_links", false).apply();
else if (chost != null &&
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked()) {
prefs.edit() prefs.edit()
.putBoolean(chost + ".link_view", false) .putBoolean(chost + ".link_view", false)
.putBoolean(chost + ".link_sanitize", .putBoolean(chost + ".link_sanitize",
cbSanitize.getVisibility() == View.VISIBLE && cbSanitize.isChecked()) cbSanitize.getVisibility() == View.VISIBLE && cbSanitize.isChecked())
.apply(); .apply();
}
Uri theUri = Uri.parse(etLink.getText().toString()); Uri theUri = Uri.parse(etLink.getText().toString());
Package pkg = (Package) spOpenWith.getSelectedItem(); Package pkg = (Package) spOpenWith.getSelectedItem();

@ -204,6 +204,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSanitize" /> app:layout_constraintTop_toBottomOf="@id/cbSanitize" />
<CheckBox
android:id="@+id/cbNeverAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
<TextView <TextView
android:id="@+id/tvOpenWith" android:id="@+id/tvOpenWith"
android:layout_width="0dp" android:layout_width="0dp"
@ -215,7 +225,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" /> app:layout_constraintTop_toBottomOf="@id/cbNeverAgain" />
<Spinner <Spinner
android:id="@+id/spOpenWith" android:id="@+id/spOpenWith"

Loading…
Cancel
Save