diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java index e98f5bba3a..4ff0c2fb08 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java @@ -328,25 +328,6 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { } }); - spOpenWith.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - Package pkg = (Package) parent.getAdapter().getItem(position); - prefs.edit() - .putString("open_with_pkg", pkg.name) - .putBoolean("open_with_tabs", pkg.tabs) - .apply(); - } - - @Override - public void onNothingSelected(AdapterView parent) { - prefs.edit() - .remove("open_with_pkg") - .remove("open_with_tabs") - .apply(); - } - }); - View.OnClickListener onMore = new View.OnClickListener() { @Override public void onClick(View v) { @@ -634,9 +615,18 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { @Override public void onClick(DialogInterface dialog, int which) { Uri uri = Uri.parse(etLink.getText().toString()); + boolean tabs = prefs.getBoolean("open_with_tabs", true); + Package pkg = (Package) spOpenWith.getSelectedItem(); Log.i("Open link uri=" + uri + " with=" + pkg); - boolean tabs = (pkg != null && pkg.tabs); + if (pkg != null) { + tabs = pkg.tabs; + prefs.edit() + .putString("open_with_pkg", pkg.name) + .putBoolean("open_with_tabs", pkg.tabs) + .apply(); + } + Helper.view(context, uri, !tabs, !tabs); } })