2nd Test for delevery reports
This commit is contained in:
parent
88c3ae121d
commit
4e92cc6c1e
@ -13,13 +13,15 @@
|
||||
<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="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,13 +179,12 @@ 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 *************************************
|
||||
|
||||
|
||||
@ -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
|
||||
*
|
||||
@ -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);
|
||||
}
|
||||
|
||||
// *********************** 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;
|
||||
|
||||
/**
|
||||
@ -195,6 +196,7 @@ public class GroupsDbAdapter {
|
||||
return userCursor;
|
||||
}
|
||||
|
||||
|
||||
public long addPhoneToGroup(long groupId, long phoneId ) {
|
||||
ContentValues initialValues = new ContentValues();
|
||||
initialValues.put(KEY_GROUP_TO_PHONE_GROUPID, groupId);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -49,4 +53,35 @@ public class ListEntryActivity extends ListActivity {
|
||||
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