[iitcm] workaround for Samsung devices
This commit is contained in:
parent
dfab0d1e04
commit
0fabfb6894
@ -36,12 +36,7 @@ class IntentAdapter extends ArrayAdapter<Intent> {
|
||||
|
||||
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 @@ class IntentAdapter extends ArrayAdapter<Intent> {
|
||||
addAll(intents);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,12 +78,8 @@ public class IntentComparator implements Comparator<Intent> {
|
||||
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 class IntentComparator implements Comparator<Intent> {
|
||||
: name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
throw new IllegalArgumentException("Got an intent not generated by IntentGenerator!\n"
|
||||
+ "Intent:\n" + intent.toString() + "\n"
|
||||
+ "Extras:\n" + intent.getExtras().toString());
|
||||
// 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";
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
public static boolean isDefault(final Intent intent) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user