Added sub option to open links by default

pull/215/head
M66B 6 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 cbSanitize = dview.findViewById(R.id.cbSanitize);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final CheckBox cbNeverAgain = dview.findViewById(R.id.cbNeverAgain);
final Spinner spOpenWith = dview.findViewById(R.id.spOpenWith);
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() {
@Override
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.setVisibility(!always_confirm && !sanitize_links && chost != null ? View.VISIBLE : View.GONE);
cbNeverAgain.setVisibility(!always_confirm && !sanitize_links ? View.VISIBLE : View.GONE);
setMore(false);
if (UriHelper.isHyperLink(uri)) {
@ -782,13 +792,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (chost != null &&
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked())
if (cbNeverAgain.getVisibility() == View.VISIBLE && cbNeverAgain.isChecked())
prefs.edit().putBoolean("confirm_links", false).apply();
else if (chost != null &&
cbNotAgain.getVisibility() == View.VISIBLE && cbNotAgain.isChecked()) {
prefs.edit()
.putBoolean(chost + ".link_view", false)
.putBoolean(chost + ".link_sanitize",
cbSanitize.getVisibility() == View.VISIBLE && cbSanitize.isChecked())
.apply();
}
Uri theUri = Uri.parse(etLink.getText().toString());
Package pkg = (Package) spOpenWith.getSelectedItem();

@ -204,6 +204,16 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/tvOpenWith"
android:layout_width="0dp"
@ -215,7 +225,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
app:layout_constraintTop_toBottomOf="@id/cbNeverAgain" />
<Spinner
android:id="@+id/spOpenWith"

Loading…
Cancel
Save