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 0000000..f8972fc
Binary files /dev/null and b/res/drawable/btn_check_buttonless_off.png differ
diff --git a/res/drawable/btn_check_buttonless_on.png b/res/drawable/btn_check_buttonless_on.png
new file mode 100644
index 0000000..a10a37a
Binary files /dev/null and b/res/drawable/btn_check_buttonless_on.png differ
diff --git a/res/layout/entry_row.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;
+ return mDb.update(DATABASE_DELIVERY_ENTRY_TABLE, content, KEY_DELIVERY_ENTRY_ROWID +"="+entryId , null) > 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);