Workaround for default intent chooser bug

pull/146/head
M66B 6 years ago
parent 4e16d46280
commit cba925d207

@ -828,7 +828,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuInvite() {
startActivityForResult(getIntentInvite(), REQUEST_INVITE);
startActivityForResult(Helper.getChooser(this, getIntentInvite()), REQUEST_INVITE);
}
private void onMenuOtherApps() {
@ -1279,7 +1279,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (create.resolveActivity(getPackageManager()) == null)
Snackbar.make(getVisibleView(), R.string.title_no_saf, Snackbar.LENGTH_LONG).show();
else
startActivityForResult(create, REQUEST_ATTACHMENT);
startActivityForResult(Helper.getChooser(this, create), REQUEST_ATTACHMENT);
}
private void onDecrypt(Intent intent) {

@ -1133,14 +1133,16 @@ public class FragmentAccount extends FragmentEx {
Log.i(Helper.TAG, "Select account");
Provider provider = (Provider) spProvider.getSelectedItem();
if (provider.type != null)
startActivityForResult(newChooseAccountIntent(
null,
null,
new String[]{provider.type},
null,
null,
null,
null), ActivitySetup.REQUEST_CHOOSE_ACCOUNT);
startActivityForResult(
Helper.getChooser(getContext(), newChooseAccountIntent(
null,
null,
new String[]{provider.type},
null,
null,
null,
null)),
ActivitySetup.REQUEST_CHOOSE_ACCOUNT);
}
private void setColor(int color) {

@ -246,7 +246,7 @@ public class FragmentCompose extends FragmentEx {
if (pick.resolveActivity(getContext().getPackageManager()) == null)
Snackbar.make(view, R.string.title_no_contacts, Snackbar.LENGTH_LONG).show();
else
startActivityForResult(pick, request);
startActivityForResult(Helper.getChooser(getContext(), pick), request);
}
};
@ -554,7 +554,7 @@ public class FragmentCompose extends FragmentEx {
if (intent.resolveActivity(pm) == null)
Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG).show();
else
startActivityForResult(intent, ActivityCompose.REQUEST_IMAGE);
startActivityForResult(Helper.getChooser(getContext(), intent), ActivityCompose.REQUEST_IMAGE);
}
private void onMenuAttachment() {
@ -565,7 +565,7 @@ public class FragmentCompose extends FragmentEx {
if (intent.resolveActivity(pm) == null)
Snackbar.make(view, R.string.title_no_saf, Snackbar.LENGTH_LONG).show();
else
startActivityForResult(intent, ActivityCompose.REQUEST_ATTACHMENT);
startActivityForResult(Helper.getChooser(getContext(), intent), ActivityCompose.REQUEST_ATTACHMENT);
}
private void onMenuAddresses() {

@ -218,7 +218,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.title_advanced_sound));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, sound == null ? null : Uri.parse(sound));
startActivityForResult(intent, ActivitySetup.REQUEST_SOUND);
startActivityForResult(Helper.getChooser(getContext(), intent), ActivitySetup.REQUEST_SOUND);
}
});

@ -500,7 +500,7 @@ public class FragmentSetup extends FragmentEx {
private void onMenuExport() {
if (Helper.isPro(getContext()))
try {
startActivityForResult(getIntentExport(), ActivitySetup.REQUEST_EXPORT);
startActivityForResult(Helper.getChooser(getContext(), getIntentExport()), ActivitySetup.REQUEST_EXPORT);
} catch (Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
@ -513,7 +513,7 @@ public class FragmentSetup extends FragmentEx {
private void onMenuImport() {
try {
startActivityForResult(getIntentImport(), ActivitySetup.REQUEST_IMPORT);
startActivityForResult(Helper.getChooser(getContext(), getIntentImport()), ActivitySetup.REQUEST_IMPORT);
} catch (Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}

@ -122,6 +122,14 @@ public class Helper {
}
}
static Intent getChooser(Context context, Intent intent) {
PackageManager pm = context.getPackageManager();
if (pm.queryIntentActivities(intent, 0).size() == 1)
return intent;
else
return Intent.createChooser(intent, context.getString(R.string.title_select_app));
}
static Intent getIntentPrivacy() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://email.faircode.eu/privacy/"));

@ -346,6 +346,7 @@
<string name="title_hint_sync">Downloading messages can take some time, depending on the speed of the provider, internet connection and device and on the number of messages. While downloading messages the app might respond slower.</string>
<string name="title_open_link">Open link</string>
<string name="title_select_app">Select app</string>
<string name="title_updated">There is an update to version %1$s available</string>
<string name="title_issue">Do you have a question or problem?</string>
<string name="title_yes">Yes</string>

Loading…
Cancel
Save