From 4e92cc6c1e4d6d39f785a520c23207d1e763e97a Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Mon, 25 Jan 2010 17:58:12 +0100 Subject: [PATCH] 2nd Test for delevery reports --- AndroidManifest.xml | 12 +++-- res/drawable/btn_check_buttonless_off.png | Bin 0 -> 608 bytes res/drawable/btn_check_buttonless_on.png | Bin 0 -> 721 bytes res/layout/entry_row.xml | 2 +- .../openwide/android/DeliveryDbAdapter.java | 30 ++++++++++-- src/com/openwide/android/GroupsDbAdapter.java | 2 + .../openwide/android/ListEntryActivity.java | 43 ++++++++++++++++-- src/com/openwide/android/MultiSmsSender.java | 2 +- .../android/SelectDeliveryActivity.java | 3 +- 9 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 res/drawable/btn_check_buttonless_off.png create mode 100644 res/drawable/btn_check_buttonless_on.png diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 779d405..6e6e66d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -12,14 +12,16 @@ - - - - + + + + + - + + \ No newline at end of file diff --git a/res/drawable/btn_check_buttonless_off.png b/res/drawable/btn_check_buttonless_off.png new file mode 100644 index 0000000000000000000000000000000000000000..f8972fc458f22599dc97503835503ea4b378bd81 GIT binary patch literal 608 zcmV-m0-ybfP)Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy7<5HgbW?9;ba!ELWdKlNX>N2bPDNB8b~7$BH8Ae8p8x;>x=BPq zR9Hvtl}}E>Kp4eIh#R9(3$zG=60|88gcM`{m@X{~*KiKP30QIrj=&8#0!QHp@Ln=a zYE#;R)P%VjGs zU>^(jpb~TowbtwPaJSoCo*QUl!6BpxP<1>W4*(+U`kb&Z=mrZ{T-WVxw_AeRd4fus zraf;q8-hAeF$u;)=5FYD+K5(khd(q|s}(`CF!8KtfiGhFZ5W20K#PL7x%zxQCx}Yj z><9kv0x3`f`W%f$uQ9+lP<1ky^a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xml b/res/layout/entry_row.xml index a3765eb..d75aeea 100644 --- a/res/layout/entry_row.xml +++ b/res/layout/entry_row.xml @@ -2,7 +2,7 @@ - 0; } - - + // ************************* DELIVERY ************************************* @@ -216,6 +216,11 @@ public class DeliveryDbAdapter { return mDb.delete(DATABASE_DELIVERY_TABLE, KEY_DELIVERY_ROWID + "=" + rowId, null) > 0 && deleteAllEntry(rowId) ; } + + public void deleteAllDeliveries() { + mDb.delete(DATABASE_DELIVERY_TABLE, null, null); + mDb.delete(DATABASE_DELIVERY_ENTRY_TABLE, null, null) ; + } /** * Return a Cursor over the list of all deliveries in the database @@ -227,7 +232,22 @@ public class DeliveryDbAdapter { return mDb.query(DATABASE_DELIVERY_TABLE, new String[] {KEY_DELIVERY_ROWID, KEY_DELIVERY_NAME, KEY_DELIVERY_DATE}, null, null, null, null , KEY_DELIVERY_DATE); } - + // *********************** HELPER **************************************** + + + public String nameFromNumber(String number) { + Cursor c1 = mCtx.getContentResolver().query(Phones.CONTENT_URI, new String[] { Phones.NUMBER }, null, null, null); + Cursor c = mCtx.getContentResolver().query(Phones.CONTENT_URI, new String[] { Phones.NUMBER }, Phones.NUMBER +"="+number, null, null); + if(c != null) { + c.moveToFirst(); + if(c.isFirst()) { + return c.getString(c.getColumnIndex(Phones.NAME)); + }else { + return ""; + } + } + return ""; + } diff --git a/src/com/openwide/android/GroupsDbAdapter.java b/src/com/openwide/android/GroupsDbAdapter.java index af3bcde..001e54e 100755 --- a/src/com/openwide/android/GroupsDbAdapter.java +++ b/src/com/openwide/android/GroupsDbAdapter.java @@ -23,6 +23,7 @@ import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.Contacts.Phones; +import android.provider.ContactsContract.CommonDataKinds.Phone; import android.util.Log; /** @@ -194,6 +195,7 @@ public class GroupsDbAdapter { } return userCursor; } + public long addPhoneToGroup(long groupId, long phoneId ) { ContentValues initialValues = new ContentValues(); diff --git a/src/com/openwide/android/ListEntryActivity.java b/src/com/openwide/android/ListEntryActivity.java index 8259390..95447e3 100644 --- a/src/com/openwide/android/ListEntryActivity.java +++ b/src/com/openwide/android/ListEntryActivity.java @@ -1,8 +1,12 @@ package com.openwide.android; import android.app.ListActivity; +import android.content.Context; import android.database.Cursor; import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.SimpleCursorAdapter; public class ListEntryActivity extends ListActivity { @@ -28,12 +32,12 @@ public class ListEntryActivity extends ListActivity { startManagingCursor(deliveryCursor); - String[] from = new String[]{DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME, DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER, DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED }; + String[] from = new String[]{DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME, DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER }; - int[] to = new int[]{R.id.name, R.id.number, R.id.delivered}; + int[] to = new int[]{R.id.name, R.id.number}; - SimpleCursorAdapter notes = - new SimpleCursorAdapter(this, R.layout.entry_row, deliveryCursor, from, to); + EntryCursorAdapter notes = + new EntryCursorAdapter(this, R.layout.entry_row, deliveryCursor, from, to); setListAdapter(notes); } @@ -48,5 +52,36 @@ public class ListEntryActivity extends ListActivity { mDbHelper.close(); super.onDestroy(); } + + private class EntryCursorAdapter extends SimpleCursorAdapter{ + Cursor c; + int deliveredIdx; + + public EntryCursorAdapter(Context context, int layout, Cursor c, + String[] from, int[] to) { + super(context, layout, c, from, to); + this.c = c; + deliveredIdx = c.getColumnIndex(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED); + } + + + + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View v = super.getView(position, convertView, parent); + ImageView image = (ImageView)v.findViewById(R.id.delivered); + + c.moveToPosition(position); + int delivered = c.getInt(deliveredIdx); + if(delivered != 0) { + image.setImageResource(R.drawable.btn_check_buttonless_on); + }else { + image.setImageResource(R.drawable.btn_check_buttonless_off); + } + + return v; + } + } } diff --git a/src/com/openwide/android/MultiSmsSender.java b/src/com/openwide/android/MultiSmsSender.java index aa1925d..086281b 100644 --- a/src/com/openwide/android/MultiSmsSender.java +++ b/src/com/openwide/android/MultiSmsSender.java @@ -130,7 +130,7 @@ public class MultiSmsSender extends Activity { if (haveDeliveryReports) { sentIntents = new ArrayList(messageCount); - long entryId = mDbHelper.createEntry("", newN, deliveryId); + long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId); for (int j = 0; j < messageCount; j++) { Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class); diff --git a/src/com/openwide/android/SelectDeliveryActivity.java b/src/com/openwide/android/SelectDeliveryActivity.java index a9b573e..36f0221 100644 --- a/src/com/openwide/android/SelectDeliveryActivity.java +++ b/src/com/openwide/android/SelectDeliveryActivity.java @@ -87,7 +87,8 @@ public class SelectDeliveryActivity extends ListActivity { public boolean onMenuItemSelected(int featureId, MenuItem item) { switch(item.getItemId()) { case DELETE_ALL_ID: - //TODO + mDbHelper.deleteAllDeliveries(); + fillData(); return true; } return super.onMenuItemSelected(featureId, item);