[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);
|
final Intent item = getItem(position);
|
||||||
|
|
||||||
try {
|
view.setText(IntentGenerator.getTitle(item));
|
||||||
view.setText(IntentGenerator.getTitle(item));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
view.setText("unknown");
|
|
||||||
Log.w(e);
|
|
||||||
}
|
|
||||||
view.setCompoundDrawablePadding((int) getContext().getResources().getDimension(R.dimen.icon_margin));
|
view.setCompoundDrawablePadding((int) getContext().getResources().getDimension(R.dimen.icon_margin));
|
||||||
|
|
||||||
// get icon and scale it manually to ensure that all have the same size
|
// get icon and scale it manually to ensure that all have the same size
|
||||||
|
@ -78,12 +78,8 @@ public class IntentComparator implements Comparator<Intent> {
|
|||||||
if (lCount < rCount) return 1;
|
if (lCount < rCount) return 1;
|
||||||
|
|
||||||
// still no order. fall back to alphabetical order
|
// still no order. fall back to alphabetical order
|
||||||
try {
|
order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs));
|
||||||
order = IntentGenerator.getTitle(lhs).compareTo(IntentGenerator.getTitle(rhs));
|
if (order != 0) return order;
|
||||||
if (order != 0) return order;
|
|
||||||
} catch(IllegalArgumentException e) {
|
|
||||||
Log.w(e);
|
|
||||||
}
|
|
||||||
order = lComponent.getPackageName().compareTo(rComponent.getPackageName());
|
order = lComponent.getPackageName().compareTo(rComponent.getPackageName());
|
||||||
if (order != 0) return order;
|
if (order != 0) return order;
|
||||||
|
|
||||||
|
@ -36,12 +36,22 @@ public class IntentGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTitle(final Intent intent) throws IllegalArgumentException {
|
public static String getTitle(final Intent intent) {
|
||||||
if (intent.hasExtra(EXTRA_FLAG_TITLE)) return intent.getStringExtra(EXTRA_FLAG_TITLE);
|
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"
|
// Samsung WiFi Direct Sharing seems to not provide a title.
|
||||||
+ "Intent:\n" + intent.toString() + "\n"
|
// Not directly reproducible without having a Samsung device.
|
||||||
+ "Extras:\n" + intent.getExtras().toString());
|
|
||||||
|
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) {
|
public static boolean isDefault(final Intent intent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user