diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentAdapter.java b/mobile/src/com/cradle/iitc_mobile/share/IntentAdapter.java index fe6c26c15..4361a2a17 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentAdapter.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentAdapter.java @@ -36,12 +36,7 @@ public View getView(final int position, final View convertView, final ViewGroup final Intent item = getItem(position); - try { - view.setText(IntentGenerator.getTitle(item)); - } catch (IllegalArgumentException e) { - view.setText("unknown"); - Log.w(e); - } + view.setText(IntentGenerator.getTitle(item)); view.setCompoundDrawablePadding((int) getContext().getResources().getDimension(R.dimen.icon_margin)); // get icon and scale it manually to ensure that all have the same size @@ -70,4 +65,4 @@ public void setIntents(final List intents) { addAll(intents); notifyDataSetChanged(); } -} \ No newline at end of file +} diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java b/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java index 34b5560f9..533c27a6a 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentComparator.java @@ -78,12 +78,8 @@ public int compare(final Intent lhs, final Intent rhs) { if (lCount < rCount) return 1; // still no order. fall back to alphabetical order - try { - order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs)); - if (order != 0) return order; - } catch(IllegalArgumentException e) { - Log.w(e); - } + order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs)); + if (order != 0) return order; order = lComponent.getPackageName().compareTo(rComponent.getPackageName()); if (order != 0) return order; @@ -197,4 +193,4 @@ public String toString() { : name); } } -} \ No newline at end of file +} diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentGenerator.java b/mobile/src/com/cradle/iitc_mobile/share/IntentGenerator.java index c62b0c186..c9de0f033 100644 --- a/mobile/src/com/cradle/iitc_mobile/share/IntentGenerator.java +++ b/mobile/src/com/cradle/iitc_mobile/share/IntentGenerator.java @@ -36,12 +36,22 @@ public class IntentGenerator { } } - public static String getTitle(final Intent intent) throws IllegalArgumentException { - if (intent.hasExtra(EXTRA_FLAG_TITLE)) return intent.getStringExtra(EXTRA_FLAG_TITLE); + public static String getTitle(final Intent intent) { + String title = ""; + if (intent.hasExtra(EXTRA_FLAG_TITLE)) + title = intent.getStringExtra(EXTRA_FLAG_TITLE); + + // Samsung WiFi Direct Sharing seems to not provide a title. + // Not directly reproducible without having a Samsung device. + + if (title == null || "".equals(title)) { + Log.w("Intent has no title!\n" + + "Intent:\n" + intent.toUri(Intent.URI_INTENT_SCHEME) + "\n" + + "Extras:\n" + intent.getExtras().toString()); + return "unknown"; + } - throw new IllegalArgumentException("Got an intent not generated by IntentGenerator!\n" - + "Intent:\n" + intent.toString() + "\n" - + "Extras:\n" + intent.getExtras().toString()); + return title; } public static boolean isDefault(final Intent intent) {