summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2015-09-02 09:41:40 -0700
committerdoc HD <doc.divxm@gmail.com>2015-09-03 16:08:30 +0300
commitcd253495b97ee61b22411abe3bf9f9a31b7238e8 (patch)
tree095058b7c6853f0f4b23c57833f3372d3a0e7e6b
parent62bd040fef5c2faeaa1eadcf495205adfc4c0952 (diff)
Mms: show default app icon for unresolved links
When receiving a message with some text that gets linkified, such as an email address, and there is no application to handle the intent, the wrong icon was shown. If there's no default to handle the link, show the default activity logo. Ref: CYNGNOS-568 Change-Id: I27c3017d3846ad78c0be6ceec6656d19e16d5824 Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r--src/com/android/mms/ui/MessageUtils.java48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/com/android/mms/ui/MessageUtils.java b/src/com/android/mms/ui/MessageUtils.java
index 28e57f82..632dc88f 100644
--- a/src/com/android/mms/ui/MessageUtils.java
+++ b/src/com/android/mms/ui/MessageUtils.java
@@ -69,8 +69,8 @@ import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.os.StatFs;
-import android.preference.PreferenceManager;
import android.provider.ContactsContract;
+import android.preference.PreferenceManager;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.MediaStore;
@@ -2209,31 +2209,31 @@ public class MessageUtils {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
- try {
- URLSpan span = getItem(position);
- String url = span.getURL();
- Uri uri = Uri.parse(url);
- TextView tv = (TextView) v;
- Drawable d = context.getPackageManager().getActivityIcon(
- new Intent(Intent.ACTION_VIEW, uri));
- if (d != null) {
- d.setBounds(0, 0, d.getIntrinsicHeight(),
- d.getIntrinsicHeight());
- tv.setCompoundDrawablePadding(10);
- tv.setCompoundDrawables(d, null, null, null);
- }
- String tmpUrl = null;
- if (url != null) {
- if (url.startsWith(MAIL_TO_PREFIX)) {
- url = url.substring(MAIL_TO_PREFIX.length());
- }
- tmpUrl = url.replaceAll("tel:", "");
+ URLSpan span = getItem(position);
+ String url = span.getURL();
+ Uri uri = Uri.parse(url);
+ TextView tv = (TextView) v;
+ final ResolveInfo resolveInfo = context.getPackageManager()
+ .resolveActivity(new Intent(Intent.ACTION_VIEW, uri),
+ PackageManager.MATCH_DEFAULT_ONLY);
+ Drawable d;
+ if (resolveInfo != null) {
+ d = resolveInfo.loadIcon(context.getPackageManager());
+ } else {
+ d = context.getPackageManager().getDefaultActivityIcon();
+ }
+ d.setBounds(0, 0, d.getIntrinsicHeight(),
+ d.getIntrinsicHeight());
+ tv.setCompoundDrawablePadding(10);
+ tv.setCompoundDrawables(d, null, null, null);
+ String tmpUrl = null;
+ if (url != null) {
+ if (url.startsWith(MAIL_TO_PREFIX)) {
+ url = url.substring(MAIL_TO_PREFIX.length());
}
- tv.setText(tmpUrl);
- } catch (android.content.pm.PackageManager.NameNotFoundException ex) {
- // it's ok if we're unable to set the drawable for this view - the user
- // can still use it.
+ tmpUrl = url.replaceAll("tel:", "");
}
+ tv.setText(tmpUrl);
return v;
}
};