2nd Test for delevery reports
This commit is contained in:
parent
88c3ae121d
commit
4e92cc6c1e
@ -12,14 +12,16 @@
|
||||
<activity android:name=".PhoneNumberSelection"></activity>
|
||||
<activity android:name="SelectGroupActivity"></activity>
|
||||
<activity android:name="GroupEditActivity"></activity>
|
||||
<activity android:name="SelectDeliveryActivity"></activity>
|
||||
<activity android:name="ListEntryActivity"></activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
|
||||
<activity android:name="SelectDeliveryActivity"></activity>
|
||||
<activity android:name="ListEntryActivity"></activity>
|
||||
<receiver android:name="MessageReceiver" android:exported="false" ></receiver>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
|
||||
<supports-screens android:smallScreens="true"
|
||||
android:anyDensity="true" />
|
||||
|
||||
|
||||
<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.RECEIVE_SMS"></uses-permission>
|
||||
|
||||
</manifest>
|
BIN
res/drawable/btn_check_buttonless_off.png
Normal file
BIN
res/drawable/btn_check_buttonless_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 608 B |
BIN
res/drawable/btn_check_buttonless_on.png
Normal file
BIN
res/drawable/btn_check_buttonless_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 721 B |
@ -2,7 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||
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" />
|
||||
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical">
|
||||
<TextView android:id="@+id/name" android:layout_width="wrap_content"
|
||||
|
@ -6,6 +6,7 @@ import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.provider.Contacts.Phones;
|
||||
import android.util.Log;
|
||||
|
||||
public class DeliveryDbAdapter {
|
||||
@ -178,12 +179,11 @@ public class DeliveryDbAdapter {
|
||||
}
|
||||
|
||||
public boolean setEntryDelivered(long entryId) {
|
||||
ContentValues content = new ContentValues(1);
|
||||
ContentValues content = new ContentValues();
|
||||
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 *************************************
|
||||
|
||||
@ -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 "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class MultiSmsSender extends Activity {
|
||||
if (haveDeliveryReports) {
|
||||
|
||||
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++) {
|
||||
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user