2nd Test for delevery reports

This commit is contained in:
Mathieu Maret 2010-01-25 17:58:12 +01:00
parent 88c3ae121d
commit 4e92cc6c1e
9 changed files with 77 additions and 17 deletions

View File

@ -13,13 +13,15 @@
<activity android:name="SelectGroupActivity"></activity> <activity android:name="SelectGroupActivity"></activity>
<activity android:name="GroupEditActivity"></activity> <activity android:name="GroupEditActivity"></activity>
<activity android:name="SelectDeliveryActivity"></activity> <activity android:name="SelectDeliveryActivity"></activity>
<activity android:name="ListEntryActivity"></activity> <activity android:name="ListEntryActivity"></activity>
</application> <receiver android:name="MessageReceiver" android:exported="false" ></receiver>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/> </application>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
<supports-screens android:smallScreens="true" <supports-screens android:smallScreens="true"
android:anyDensity="true" /> android:anyDensity="true" />
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission> <uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission> <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
</manifest> </manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:id="@+id/deliveryEntry"> android:orientation="horizontal" android:id="@+id/deliveryEntry">
<TextView android:id="@+id/delivered" android:layout_width="wrap_content" <ImageView android:id="@+id/delivered" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:id="@+id/name" android:layout_width="wrap_content" <TextView android:id="@+id/name" android:layout_width="wrap_content"

View File

@ -6,6 +6,7 @@ import android.database.Cursor;
import android.database.SQLException; import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.provider.Contacts.Phones;
import android.util.Log; import android.util.Log;
public class DeliveryDbAdapter { public class DeliveryDbAdapter {
@ -178,13 +179,12 @@ public class DeliveryDbAdapter {
} }
public boolean setEntryDelivered(long entryId) { public boolean setEntryDelivered(long entryId) {
ContentValues content = new ContentValues(1); ContentValues content = new ContentValues();
content.put(KEY_DELIVERY_ENTRY_DELIVERED, 1); content.put(KEY_DELIVERY_ENTRY_DELIVERED, 1);
return mDb.update(DATABASE_DELIVERY_ENTRY_TABLE, content, KEY_DELIVERY_ENTRY_DELIVERY_ID +"="+entryId , null) > 0; return mDb.update(DATABASE_DELIVERY_ENTRY_TABLE, content, KEY_DELIVERY_ENTRY_ROWID +"="+entryId , null) > 0;
} }
// ************************* DELIVERY ************************************* // ************************* DELIVERY *************************************
@ -217,6 +217,11 @@ public class DeliveryDbAdapter {
} }
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 * Return a Cursor over the list of all deliveries in the database
* *
@ -227,8 +232,23 @@ 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); 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 "";
}
} }

View File

@ -23,6 +23,7 @@ import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.provider.Contacts.Phones; import android.provider.Contacts.Phones;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.util.Log; import android.util.Log;
/** /**
@ -195,6 +196,7 @@ public class GroupsDbAdapter {
return userCursor; return userCursor;
} }
public long addPhoneToGroup(long groupId, long phoneId ) { public long addPhoneToGroup(long groupId, long phoneId ) {
ContentValues initialValues = new ContentValues(); ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_TO_PHONE_GROUPID, groupId); initialValues.put(KEY_GROUP_TO_PHONE_GROUPID, groupId);

View File

@ -1,8 +1,12 @@
package com.openwide.android; package com.openwide.android;
import android.app.ListActivity; import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter; import android.widget.SimpleCursorAdapter;
public class ListEntryActivity extends ListActivity { public class ListEntryActivity extends ListActivity {
@ -28,12 +32,12 @@ public class ListEntryActivity extends ListActivity {
startManagingCursor(deliveryCursor); 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 = EntryCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.entry_row, deliveryCursor, from, to); new EntryCursorAdapter(this, R.layout.entry_row, deliveryCursor, from, to);
setListAdapter(notes); setListAdapter(notes);
} }
@ -49,4 +53,35 @@ public class ListEntryActivity extends ListActivity {
super.onDestroy(); 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;
}
}
} }

View File

@ -130,7 +130,7 @@ public class MultiSmsSender extends Activity {
if (haveDeliveryReports) { if (haveDeliveryReports) {
sentIntents = new ArrayList<PendingIntent>(messageCount); sentIntents = new ArrayList<PendingIntent>(messageCount);
long entryId = mDbHelper.createEntry("", newN, deliveryId); long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId);
for (int j = 0; j < messageCount; j++) { for (int j = 0; j < messageCount; j++) {
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class); Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class);

View File

@ -87,7 +87,8 @@ public class SelectDeliveryActivity extends ListActivity {
public boolean onMenuItemSelected(int featureId, MenuItem item) { public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) { switch(item.getItemId()) {
case DELETE_ALL_ID: case DELETE_ALL_ID:
//TODO mDbHelper.deleteAllDeliveries();
fillData();
return true; return true;
} }
return super.onMenuItemSelected(featureId, item); return super.onMenuItemSelected(featureId, item);