Ver código fonte

SMS clickability

master
Chris Smith 14 anos atrás
pai
commit
95f1bc7194

BIN
code/ContextHome/dist/ContextHome.apk Ver arquivo


+ 2
- 2
code/ContextHome/src/uk/co/md87/android/contexthome/ContextHome.java Ver arquivo

@@ -62,10 +62,10 @@ public class ContextHome extends Activity {
62 62
     private void initLayout() {
63 63
         layout.removeAllViews();
64 64
 
65
-        int i = 0;
65
+        int i = 1;
66 66
         for (Module module : modules) {
67 67
             final LayoutParams params = new LayoutParams(MODULE_PARAMS);
68
-            params.weight = (float) ++i / 10;
68
+            params.weight = ++i > 3 ? (float) i / 11 : 1;
69 69
             layout.addView(module.getView(this, i), params);
70 70
         }
71 71
     }

+ 18
- 3
code/ContextHome/src/uk/co/md87/android/contexthome/modules/SmsModule.java Ver arquivo

@@ -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));

+ 3
- 4
code/PlacesDisplay/src/uk/co/md87/android/placesdisplay/JourneysOverlay.java Ver arquivo

@@ -26,16 +26,15 @@ import android.content.Context;
26 26
 import android.database.Cursor;
27 27
 import android.graphics.Canvas;
28 28
 import android.graphics.Paint;
29
-import android.graphics.Path;
30 29
 import android.graphics.Point;
31
-import android.util.Log;
30
+
32 31
 import com.google.android.maps.MapView;
33 32
 import com.google.android.maps.Overlay;
34 33
 import com.google.android.maps.OverlayItem;
35
-import java.util.ArrayList;
34
+
36 35
 import java.util.HashMap;
37
-import java.util.List;
38 36
 import java.util.Map;
37
+
39 38
 import uk.co.md87.android.contextapi.ContextApi;
40 39
 import uk.co.md87.android.contextapi.ContextApi.Journeys.ColumnNames;
41 40
 

Carregando…
Cancelar
Salvar