|
@@ -24,6 +24,7 @@ package uk.co.md87.android.contexthome.modules;
|
24
|
24
|
|
25
|
25
|
import android.content.ContentUris;
|
26
|
26
|
import android.content.Context;
|
|
27
|
+import android.content.Intent;
|
27
|
28
|
import android.database.Cursor;
|
28
|
29
|
import android.net.Uri;
|
29
|
30
|
import android.provider.Contacts;
|
|
@@ -54,7 +55,8 @@ public class SmsModule implements Module {
|
54
|
55
|
layout.setOrientation(LinearLayout.VERTICAL);
|
55
|
56
|
|
56
|
57
|
final Cursor cursor = context.getContentResolver().query(INBOX_URI,
|
57
|
|
- new String[] { "_id", "date", "body", "address" }, null, null, "date DESC");
|
|
58
|
+ new String[] { "thread_id", "date", "body", "address" }, null, null, "date DESC");
|
|
59
|
+ final int idIndex = cursor.getColumnIndex("thread_id");
|
58
|
60
|
final int bodyIndex = cursor.getColumnIndex("body");
|
59
|
61
|
final int addressIndex = cursor.getColumnIndex("address");
|
60
|
62
|
|
|
@@ -67,7 +69,8 @@ public class SmsModule implements Module {
|
67
|
69
|
final String body = cursor.getString(bodyIndex);
|
68
|
70
|
final String address = cursor.getString(addressIndex);
|
69
|
71
|
|
70
|
|
- layout.addView(getView(context, layout, body, address), params);
|
|
72
|
+ layout.addView(getView(context, layout, body, address, cursor.getLong(idIndex)),
|
|
73
|
+ params);
|
71
|
74
|
|
72
|
75
|
success = cursor.moveToNext();
|
73
|
76
|
}
|
|
@@ -77,8 +80,20 @@ public class SmsModule implements Module {
|
77
|
80
|
return layout;
|
78
|
81
|
}
|
79
|
82
|
|
80
|
|
- private View getView(Context context, ViewGroup layout, String text, String address) {
|
|
83
|
+ private View getView(final Context context, ViewGroup layout, String text,
|
|
84
|
+ String address, final long threadId) {
|
81
|
85
|
final View view = View.inflate(context, R.layout.titledimage, null);
|
|
86
|
+ view.setClickable(true);
|
|
87
|
+ view.setFocusable(true);
|
|
88
|
+ view.setOnClickListener(new View.OnClickListener() {
|
|
89
|
+
|
|
90
|
+ public void onClick(View arg0) {
|
|
91
|
+ final Intent intent = new Intent();
|
|
92
|
+ intent.setAction(Intent.ACTION_VIEW);
|
|
93
|
+ intent.setData(Uri.parse("content://mms-sms/conversations/" + threadId));
|
|
94
|
+ context.startActivity(intent);
|
|
95
|
+ }
|
|
96
|
+ });
|
82
|
97
|
|
83
|
98
|
final Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL,
|
84
|
99
|
Uri.encode(address));
|