mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
SendFilesDialog: Show error if no app can send multiple files
Otherwise an empty bottom fragment shows up, which is not good UX Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
93d7c7f9f7
commit
61f8115d79
2 changed files with 11 additions and 3 deletions
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
import com.nextcloud.client.utils.IntentUtil;
|
import com.nextcloud.client.utils.IntentUtil;
|
||||||
|
@ -82,8 +83,14 @@ public class SendFilesDialog extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
// populate send apps
|
// populate send apps
|
||||||
Intent sendIntent = IntentUtil.createSendIntent(requireContext(), files);
|
Intent sendIntent = IntentUtil.createSendIntent(requireContext(), files);
|
||||||
|
List<ResolveInfo> matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0);
|
||||||
|
if (matches.isEmpty()) {
|
||||||
|
Toast.makeText(getContext(), R.string.no_send_app, Toast.LENGTH_SHORT).show();
|
||||||
|
dismiss();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
List<SendButtonData> sendButtonDataList = setupSendButtonData(sendIntent);
|
List<SendButtonData> sendButtonDataList = setupSendButtonData(matches);
|
||||||
|
|
||||||
SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent);
|
SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent);
|
||||||
|
|
||||||
|
@ -108,11 +115,11 @@ public class SendFilesDialog extends BottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<SendButtonData> setupSendButtonData(Intent sendIntent) {
|
private List<SendButtonData> setupSendButtonData(List<ResolveInfo> matches) {
|
||||||
Drawable icon;
|
Drawable icon;
|
||||||
SendButtonData sendButtonData;
|
SendButtonData sendButtonData;
|
||||||
CharSequence label;
|
CharSequence label;
|
||||||
List<ResolveInfo> matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0);
|
|
||||||
List<SendButtonData> sendButtonDataList = new ArrayList<>(matches.size());
|
List<SendButtonData> sendButtonDataList = new ArrayList<>(matches.size());
|
||||||
for (ResolveInfo match : matches) {
|
for (ResolveInfo match : matches) {
|
||||||
icon = match.loadIcon(requireActivity().getPackageManager());
|
icon = match.loadIcon(requireActivity().getPackageManager());
|
||||||
|
|
|
@ -1006,4 +1006,5 @@
|
||||||
<string name="file_list_empty_unified_search_no_results">No results found for your query</string>
|
<string name="file_list_empty_unified_search_no_results">No results found for your query</string>
|
||||||
<string name="file_list_empty_gallery">Found no images or videos</string>
|
<string name="file_list_empty_gallery">Found no images or videos</string>
|
||||||
<string name="error_creating_file_from_template">Error creating file from template</string>
|
<string name="error_creating_file_from_template">Error creating file from template</string>
|
||||||
|
<string name="no_send_app">No app available for sending the selected files</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue