Compare commits

...

56 Commits

Author SHA1 Message Date
Mathieu Maret ea638da2d5 Add indonesian translation 2016-05-03 17:47:59 +02:00
Mathieu Maret 8351879996 update to version 2.7 2016-03-16 10:28:20 +01:00
Mathieu Maret 43fcca414c Fix progress dialog when no number are provided
A first dialog show up telling that you have to enter some phone
number, but the dialog for message progress never disapear

Fix Issue #1
2016-03-16 10:15:56 +01:00
Mathieu Maret 60bc4f64d2 Add the presentation image 2014-11-07 11:04:39 +01:00
Mathieu Maret 0d75d84795 Add Russian translation and publish v2.6 2014-11-07 11:03:18 +01:00
Mathieu Maret c0e7794f1f user reports that send multipart message may need READ_PHONE_STATE 2013-09-11 16:11:52 +02:00
Mathieu Maret 787f738cb7 Update version number to 2.4 2013-09-11 15:33:29 +02:00
Mathieu Maret 294c4669c6 Add missing files 2013-09-11 15:33:03 +02:00
Mathieu Maret a5e55bb72d Fix lint issues 2013-09-11 15:32:24 +02:00
Mathieu Maret d32829784a Get message status for delivery report from pdu 2013-09-11 15:05:12 +02:00
Mathieu Maret 5e5fd482cf Fix compilation issue 2013-09-11 14:51:42 +02:00
Mathieu Maret 95783c14b6 Code simplifcation 2013-09-11 14:16:00 +02:00
Mathieu Maret 6190c47524 Save pref for delivery reports 2012-11-09 14:28:57 +01:00
Mathieu Maret 5bdea2addc Code alignement 2012-11-09 14:28:31 +01:00
Mathieu Maret f516231b9c Code cleaning and reformating 2012-11-06 10:35:01 +01:00
Mathieu Maret 95bb2d1651 Use Content Provider for delivery reports. This should fix issue when trying to access locked database 2012-11-05 18:05:48 +01:00
Mathieu Maret 2205f64ce5 Correct accent on french words 2012-11-05 18:04:15 +01:00
Mathieu Maret c1cb2a357a Version2.2 2012-10-15 17:04:11 +02:00
Mathieu Maret 636b60071c Add Arabic Translation thanks to Khalid EL BOUKHARI 2012-10-15 17:03:35 +02:00
Mathieu Maret b4c836d48e Remove space from number 2012-10-15 16:57:55 +02:00
Mathieu Maret 3cfab63465 Add missing words for german translation 2012-10-05 11:31:32 +02:00
Mathieu Maret ae4b9c9ed4 2.1 Release 2012-10-05 11:24:46 +02:00
Mathieu Maret bf00fb48c6 Bug Fix: Crash on preparing delivery reports 2012-10-05 11:23:23 +02:00
Mathieu Maret a4faf1dc43 Add italian translation thanks to Egidio Pignatelli 2012-10-05 11:22:14 +02:00
Mathieu Maret 51088047f7 2.0 Release 2012-10-04 10:00:33 +02:00
Mathieu Maret 1e2023088a UI improvement
Use google color
Use thin separator between buttons
2012-10-03 14:34:59 +02:00
Mathieu Maret 8c0decf6e8 UI improvement
Add icons from Android4 for adding user or group
2012-10-03 11:00:58 +02:00
Mathieu Maret 6100d8a757 Fix layout width for list children 2012-10-02 13:29:03 +02:00
Mathieu Maret be02add3be 1.9 Release 2012-10-02 12:22:34 +02:00
Mathieu Maret cb5428f67c Fiw layout for Android4.0 and Simplify some code 2012-09-27 22:31:15 +02:00
Mathieu Maret 1573577752 Add missing configuration file 2011-11-17 17:56:34 +01:00
Mathieu Maret 44ee6144f1 update build.xml 2011-11-17 15:21:50 +01:00
Mathieu Maret fa2b141893 Update version number 2011-10-30 02:13:32 +02:00
Mathieu Maret 05837b1990 Close progress windows when canceling "more 50" messages 2011-10-30 02:02:34 +02:00
Mathieu Maret 4bd0390444 Use ressource instead of string 2011-10-30 01:57:40 +02:00
Mathieu Maret f83001f0ba Do not display "X messages send" message when sending cancelled 2011-10-30 01:18:11 +02:00
Mathieu Maret 33ece37bba Open/close database ASAP 2011-10-30 01:17:17 +02:00
Mathieu Maret 1119047891 Add missing close 2011-10-30 01:16:33 +02:00
Mathieu Maret 7b8a2c9638 Update TODO list 2011-07-29 15:38:31 +02:00
Mathieu Maret 420f1c303b Remove DeliveryDbAdapter global definition and use
DbAdapter only use when sending message. Si the DB is less often locked
2011-07-29 14:55:17 +02:00
Mathieu Maret 1ddedcc67b Prepare delivery id before sending text message. Should prevent some crash 2011-07-25 01:00:48 +02:00
Mathieu Maret b0a3e0959f Add Portuguese Translation 2011-07-20 23:46:12 +02:00
Mathieu Maret 71cbef584d Add German Version Thanks to Timon!
That's why OpenSource is soo fantastic !
2011-06-02 00:14:31 +02:00
Mathieu Maret 1011f62cc6 Add build.properties file for signing package 2011-05-30 10:34:49 +02:00
Mathieu Maret f2a689ebda Version update 2011-03-01 22:25:21 +01:00
Mathieu Maret 45a7023730 Remove logs. +Stop sending messages when application quit 2011-03-01 22:25:00 +01:00
Mathieu Maret 452941a009 Smiley when writing message 2011-03-01 22:24:21 +01:00
Mathieu Maret a52c9ec70e Add file for ant building 2011-02-16 14:01:10 +01:00
Mathieu Maret 38f2fa1222 Add Group support 2011-01-10 11:39:18 +01:00
Mathieu Maret f51212fa08 missing files for package renam...
Its too late to code....!
2010-12-12 03:06:07 +01:00
Mathieu Maret 15b84aab16 Rename Package 2010-12-12 02:36:52 +01:00
Mathieu Maret f6b464ce5f tipo mistake for trad files 2010-12-12 02:31:27 +01:00
Mathieu Maret d601eb348d UI improvement when lots of messages are sent
And the langage associated
2010-12-12 02:28:33 +01:00
Mathieu Maret b4600cd8ec Add + to add icon 2010-12-10 22:46:49 +01:00
Mathieu Maret a6d28099bb Add Todo List 2010-12-10 22:36:44 +01:00
Mathieu Maret 465b131420 Contacts, Progress Dialog, No Group, Integration
- Using Android 2.0 API for contacts lookup
- Progress dialogue with progress bar when sending SMS
- Desactive Group as they are not using Android2.0 API (Sync and so on...)
- Every SMS sent are registrer in the sysem DB so they are available for the
MMS App
2010-12-10 22:31:06 +01:00
59 changed files with 2046 additions and 1444 deletions

View File

@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,7 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.openwide.android" android:versionName="1.1.5" android:versionCode="9">
<application android:label="@string/app_name" android:icon="@drawable/multisms">
package="com.hectorone.multismssender" android:versionName="2.8" android:versionCode="18">
<uses-sdk android:minSdkVersion="5" />
<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>
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<application android:label="@string/app_name" android:icon="@drawable/multisms"
android:allowBackup="true" >
<activity android:name=".MultiSmsSender" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -13,17 +21,14 @@
<activity android:name="GroupEditActivity"></activity>
<activity android:name="SelectDeliveryActivity"></activity>
<activity android:name="ListEntryActivity"></activity>
<receiver android:name=".MessageReceiver" android:enabled="true" >
<receiver android:name="MessageReceiver" android:enabled="true" >
<intent-filter>
<action android:name="com.openwide.android.SMS_RECEIVED"/>
<data android:mimeType="com.openwide.android.item/entry"/>
<action android:name="com.hectorone.multismssender.SMS_RECEIVED"/>
<data android:mimeType="vnd.android.cursor.item/vnd.com.hectorone.multismssender.provider.entry"/>
</intent-filter>
</receiver>
<provider android:authorities="com.openwide.android" android:name="EntryContentProvider"></provider>
<provider android:authorities="com.hectorone.multismssender.provider" android:name=".DeliveryDbAdapter"></provider>
</application>
<uses-sdk android:minSdkVersion="3" />
<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>

5
TODO Normal file
View File

@ -0,0 +1,5 @@
Envoie de Fichier -> MMS
Group Google
Utiliser des préférences pour les accusés de reception/L'integration de SMS dans la MMS App
Have nicer graphics ...
Update to Android 4+

2
build.properties Normal file
View File

@ -0,0 +1,2 @@
key.store=/home/mathieu/Android/Keys/KeyOpenWide
key.alias=openwide

85
build.xml Normal file
View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MultiSmsSender" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<loadproperties srcFile="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

10
local.properties Normal file
View File

@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/opt/android-sdk

BIN
misc/presentation.xcf Normal file

Binary file not shown.

View File

@ -1,11 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
#
# This file must be checked in Version Control Systems.
#
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3
target=android-8

BIN
res/drawable-hdpi/accept.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
res/drawable-hdpi/add_group.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
res/drawable-hdpi/add_person.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
res/drawable-mdpi/accept.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
res/drawable-mdpi/add_group.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
res/drawable-mdpi/add_person.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 608 B

View File

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 721 B

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
res/drawable-xhdpi/accept.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/drawable-xhdpi/add_group.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
res/drawable-xhdpi/add_person.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -3,7 +3,7 @@
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:choiceMode="singleChoice" />
android:layout_height="wrap_content" android:choiceMode="singleChoice" android:fillViewport="true" />
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/nodelivery" />

View File

@ -2,8 +2,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:choiceMode="singleChoice" />
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:choiceMode="singleChoice" android:fillViewport="true" />
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/nodelivery" />

View File

@ -2,7 +2,9 @@
<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">
<ImageView android:id="@+id/delivered" android:layout_width="wrap_content"
<ImageView android:id="@+id/delivered"
android:contentDescription="@string/delivery"
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"

View File

@ -3,7 +3,7 @@
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:choiceMode="multipleChoice" />
android:layout_height="wrap_content" android:choiceMode="multipleChoice" android:fillViewport="true" />
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/nogroups" />

View File

@ -6,20 +6,37 @@
android:layout_gravity="center_vertical" android:gravity="center_horizontal"
android:orientation="horizontal" android:layout_width="fill_parent">
<Button android:background="@drawable/ic_launcher_contacts"
<LinearLayout android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical" android:layout_width="wrap_content">
<Button android:background="@drawable/add_person"
android:id="@+id/contacts" android:layout_height="wrap_content"
android:layout_width="wrap_content"></Button>
android:layout_width="wrap_content" android:padding="3dp" ></Button>
<View android:layout_width="fill_parent" android:layout_height="1dp" android:layout_margin="3dp" android:background="#EBEBEB"/>
<Button android:background="@drawable/add_group"
android:id="@+id/groups" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:padding="3dp"></Button>
</LinearLayout>
<EditText android:id="@+id/numbers" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:hint="@string/to"
android:maxLines="2" />
<EditText
android:id="@+id/numbers"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="@string/to"
android:inputType="phone"
android:lines="2"
android:maxLines="2" />
</LinearLayout>
<EditText android:id="@+id/editor" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:autoText="true"
android:capitalize="sentences" android:layout_weight="1"
android:hint="@string/entermessage">
android:layout_height="0dip"
android:layout_weight="1"
android:hint="@string/entermessage"
android:nextFocusRight="@+id/send"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="2000">
<requestFocus />
</EditText>

View File

@ -2,9 +2,33 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<Button android:text="@string/ok" android:id="@+id/okContacts" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
<ListView android:id="@+id/android:list" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:choiceMode="multipleChoice" />
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:background="#0099CC" >
<Button
android:id="@+id/okContacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/accept"
android:text="@string/ok"
android:background="#0099CC"
android:textColor="#FFFFFF"
android:paddingRight="10dp"
>
</Button>
<View android:layout_height="fill_parent" android:layout_width="1dp" android:layout_margin="2dp" android:background="#33B5E5"/>
<!-- <LinearLayout
android:layout_height="fill_parent"
android:layout_width="1dp"
android:background="#EEEEEE" android:margin="" >
</LinearLayout>-->
</LinearLayout>
<ListView android:id="@+id/android:list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:choiceMode="multipleChoice" android:fillViewport="true" />
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/nocontacts" />

View File

@ -1,16 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox android:id="@+id/CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical">
android:id="@+id/row_background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
</CheckBox>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:padding="5dip"
/>
<TextView
android:id="@+id/phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:padding="5dip"
/>
</LinearLayout>
<TextView android:id="@+id/name" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/phone" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

34
res/values-ar/strings.xml Executable file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- By Khalid EL BOUKHARI -->
<resources>
<string name="app_name">(رسائل قصيرة متعددة) Multi Sms</string>
<string name="send">إرسال</string>
<string name="add">إضافة</string>
<string name="contacts">جهات الاتصال</string>
<string name="ok">موافق</string>
<string name="cancel">إلغاء</string>
<string name="nocontacts"> لا جهات الاتصال</string>
<string name="nogroups">!! لا توجد مجموعات</string>
<string name="sending">&#8230;إرسال رسالة</string>
<string name="wait">&#8230;الرجاء الانتظار ريث الإرسال</string>
<string name="entermessage">أدخل رسالتك</string>
<string name="entergroupname">اسم المجموعة</string>
<string name="to">إلى</string>
<string name="refresh">تحديث</string>
<string name="remove_all">إزالة جميع</string>
<string name="remove">محو</string>
<string name="add_group">إضافة مجموعة</string>
<string name="delivery">إقرار بالإستلام</string>
<string name="nodelivery">لا إقرار بالإستلام </string>
<string name="enabledelivery">طلب إقرار بالإستلام </string>
<string name="create_group">إنشاء مجموعة</string>
<string name="remove_group">حذف هذه المجموعة</string>
<string name="edit_group">تحرير هذه المجموعة</string>
<string name="noName">لا إسم</string>
<string name="select_all">إختيار الكل</string>
<string name="deselect_all"> حذف إختيار الكل </string>
<string name="message_sent">البريد المرسل</string>
<string name="enter_number">إدخال رقم أو استخدام رمز الاتصال</string>
<string name="warning_many_message">أنت على وشك إرسال أكثر من 50 رسالة في وقت واحد، وهذا يمكن أن يسبب خطأ من شأنه أن يتلف التطبيق،لذا سيتم إرسال الرسائل 50 تلو الأخرى مع وقفة بين كل مجموعة. هل ترغب في الاستمرار؟</string>
<string name="more_message">مستعد ل 50 رسالة إضافية؟</string>
</resources>

34
res/values-de/strings.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- By moorhuhn -->
<resources>
<string name="app_name">Multi Sms</string>
<string name="send">Senden</string>
<string name="add">Hinzufügen</string>
<string name="contacts">Kontakte</string>
<string name="ok">Ok</string>
<string name="cancel">Abbrechen</string>
<string name="nocontacts">Keine Kontakte!!</string>
<string name="nogroups">Keine Gruppen!!</string>
<string name="sending">Sende Nachricht&#8230;</string>
<string name="wait">Please wait while sending&#8230;</string>
<string name="entermessage">Geben Sie Ihre Nachricht ein</string>
<string name="entergroupname">Geben Sie einen Gruppennamen ein</string>
<string name="nodelivery">Keine Zustellungsberichte verfügbar</string>
<string name="enabledelivery">Zustellungsberichte aktivieren</string>
<string name="to">An</string>
<string name="refresh">Aktualisieren</string>
<string name="remove_all">Alle entfernen</string>
<string name="remove">Entfernen</string>
<string name="add_group">Von Gruppe hinzufügen</string>
<string name="delivery">Zustellungsberichte</string>
<string name="create_group">Eine neue Gruppe erstellen</string>
<string name="remove_group">Diese Gruppe entfernen</string>
<string name="edit_group">Diese Gruppe bearbeiten</string>
<string name="noName">kein Name</string>
<string name="select_all">Alle auswählen</string>
<string name="deselect_all">Alle abwählen</string>
<string name="message_sent">Nachricht(en) gesendet</string>
<string name="enter_number">Eine Telefonnummer eingeben oder einen Kontakt auswählen</string>
<string name="warning_many_message">Sie sind im Begriff mehr als 50 Nachrichten zu senden. Weil es einen Android Fehler verursachen würde, der die Anwendung beenden würde, werden sie als Stück von 50 mit einer Pause dazwischen gesendet. Wollen Sie fortfahren?</string>
<string name="more_message">Sind Sie bereit für 50 weitere Nachrichten?</string>
</resources>

View File

@ -5,10 +5,11 @@
<string name="add">Ajouter</string>
<string name="contacts">Contacts</string>
<string name="ok">Ok</string>
<string name="cancel">Annuler</string>
<string name="nocontacts">Pas de contacts!!</string>
<string name="nogroups">Pas de groupes!!</string>
<string name="sending">Envoie d\'un message...</string>
<string name="wait">Veuillez patienter pendant l\'envoie...</string>
<string name="sending">Envoie d\'un message&#8230;</string>
<string name="wait">Veuillez patienter pendant l\'envoie&#8230;</string>
<string name="entermessage">Saisissez votre message</string>
<string name="entergroupname">Nom du groupe</string>
<string name="to">À</string>
@ -16,10 +17,10 @@
<string name="remove_all">Tout supprimer</string>
<string name="remove">Supprimer</string>
<string name="add_group">Ajouter un groupe</string>
<string name="delivery">Accusé de récéption</string>
<string name="nodelivery">Aucun accusé de récéption</string>
<string name="delivery">Accusé de réception</string>
<string name="nodelivery">Aucun accusé de réception</string>
<string name="enabledelivery">Accusé de récéption</string>
<string name="create_group">Créer un group</string>
<string name="create_group">Créer un groupe</string>
<string name="remove_group">Supprimer ce groupe</string>
<string name="edit_group">Editer ce groupe</string>
<string name="noName">noName</string>
@ -27,4 +28,6 @@
<string name="deselect_all">DeSelectionner tout</string>
<string name="message_sent">Message(s) envoyé(s)</string>
<string name="enter_number">Entrez un numero ou utilisez l\'icone de contact</string>
<string name="warning_many_message">Vous etes sur le point d\'envoyer plus de 50 messages d\'un coup. Comme cela peut produire une erreur android qui ferait planter l\'application, les messages vont etre envoyés par paquet de 50 avec une pause entre chaque paquet. Voulez vous continuer ?</string>
<string name="more_message">Prêt pour 50 messages de plus?</string>
</resources>

33
res/values-in/strings.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Multi Sms</string>
<string name="send">Kirim</string>
<string name="add">Tambahkan</string>
<string name="contacts">Kontak</string>
<string name="ok">Oke</string>
<string name="cancel">Batalkan</string>
<string name="nocontacts">Tidak ada kontak!!</string>
<string name="nogroups">Tidak ada grup!!</string>
<string name="sending">Mengirim Pesan&#8230;</string>
<string name="wait">Silahkan tunggu, sedang mengirim pesan&#8230;</string>
<string name="entermessage">Ketikkan pesan anda</string>
<string name="entergroupname">Ketikkan nama grup</string>
<string name="nodelivery">Laporan kiriman tidak tersedia</string>
<string name="enabledelivery">Aktifkan Laporan Pengiriman</string>
<string name="to">ke</string>
<string name="refresh">Menyegarkan</string>
<string name="remove_all">Hapus semua</string>
<string name="remove">Hapus</string>
<string name="add_group">Tambahkan dari grup</string>
<string name="delivery">Laporan pengiriman</string>
<string name="create_group">Membuat grup baru</string>
<string name="remove_group">Hapus grup ini</string>
<string name="edit_group">Perbaiki grup ini</string>
<string name="noName">Tidak ada nama</string>
<string name="select_all">Pilih semua</string>
<string name="deselect_all">Hapus semua pilihan</string>
<string name="message_sent">Pesan terkirim</string>
<string name="enter_number">Masukkan nomor tujuan atau gunakan ikon kontak</string>
<string name="warning_many_message">Anda akan mengirim lebih dari 50 pesan. Hal ini mungkin akan menyebabkan kesalahan pada sistem android yang mnungkin menyebabkan aplikasi gagal,aplikasi akan mengirim 50 pesan satu per satu dengan jeda tiap pesan. Anda ingin melanjutkan ?</string>
<string name="more_message">Anda siap dengan 50 pesan?</string>
</resources>

34
res/values-it/strings.xml Executable file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- By Egidio Pignatelli -->
<resources>
<string name="app_name">Multi Sms</string>
<string name="send">Invia</string>
<string name="add">Aggiungi</string>
<string name="contacts">Contatti</string>
<string name="ok">Ok</string>
<string name="cancel">Annulla</string>
<string name="nocontacts">Nessun contatto!!</string>
<string name="nogroups">Nessun gruppo!!</string>
<string name="sending">Invio i messaggi&#8230;</string>
<string name="wait">Invio in corso. Prego, attendi&#8230;</string>
<string name="entermessage">Scrivi il messaggio</string>
<string name="entergroupname">Scrivi il nome del Gruppo</string>
<string name="nodelivery">Nessuna ricevuta di ritorno disponibile</string>
<string name="enabledelivery">Abilita ricevute di ritorno</string>
<string name="to">A</string>
<string name="refresh">Aggiorna</string>
<string name="remove_all">Rimuovi tutto</string>
<string name="remove">Rimuovi</string>
<string name="add_group">Aggiungi da un gruppo</string>
<string name="delivery">Ricevute di ritorno</string>
<string name="create_group">Crea un nuovo gruppo</string>
<string name="remove_group">Cancella questo gruppo</string>
<string name="edit_group">Modifica questo gruppo</string>
<string name="noName">Nessun Nome</string>
<string name="select_all">Seleziona tutto</string>
<string name="deselect_all">Deseleziona tutto</string>
<string name="message_sent">Messaggi inviati</string>
<string name="enter_number">Scrivi un numero di telefono, o usa le icone dei contatti</string>
<string name="warning_many_message">Stai per spedire piu\' di 50 messaggi. Dato che questo potrebbe mandare Android in errore, causando il blocco di questa applicazione, i messaggi saranno inviati a blocchi di 50, con una pausa dopo ogni blocco. Vuoi proseguire?</string>
<string name="more_message">Sei pronto per i prossimi 50 messaggi?</string>
</resources>

34
res/values-pt/strings.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- By Jose de Ângelis -->
<resources>
<string name="app_name">Multi Sms</string>
<string name="send">Enviar</string>
<string name="add">Add</string>
<string name="contacts">Contatos</string>
<string name="ok">Ok</string>
<string name="cancel">Cancelar</string>
<string name="nocontacts">Nenhum Contato!!</string>
<string name="nogroups">Nenhum Grupo!!</string>
<string name="sending">Enviando Mensagem&#8230;</string>
<string name="wait">Por favor aguarde&#8230;</string>
<string name="entermessage">Digite sua Mensagem</string>
<string name="entergroupname">Digite o Nome do Grupo</string>
<string name="nodelivery">Entrega indisponível</string>
<string name="enabledelivery">Desabilitar aviso de entrega</string>
<string name="to">Para</string>
<string name="refresh">Recarregar</string>
<string name="remove_all">Remover Todos</string>
<string name="remove">Remover</string>
<string name="add_group">Add Para o Grupo</string>
<string name="delivery">Informações de Entrega</string>
<string name="create_group">Criar Novo Grupo</string>
<string name="remove_group">Remover este Grupo</string>
<string name="edit_group">Editar Este Grupo</string>
<string name="noName">Nenhum Nome</string>
<string name="select_all">Selecionar Todos</string>
<string name="deselect_all">Apagar Todos</string>
<string name="message_sent">Messagen(s) enviadas</string>
<string name="enter_number">Digite o número ou selecione o contato através do ícone</string>
<string name="warning_many_message">Você está prestes a enviar mais de 50 mensagens, isso poderá causar um erro no aplicativo, ocorrerá uma pausa entre o envio das mensagens. Deseja continuar o envio?</string>
<string name="more_message">Você está pronto para 50 mensagens mais?</string>
</resources>

33
res/values-ru/strings.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Multi Sms</string>
<string name="send">Отправить</string>
<string name="add">Добавить</string>
<string name="contacts">Контакты</string>
<string name="ok">OK</string>
<string name="cancel">Отмена</string>
<string name="nocontacts">Нет контактов!!</string>
<string name="nogroups">Нет групп!!</string>
<string name="sending">Отправка сообщения&#8230;</string>
<string name="wait">Подождите, пока отправится&#8230;</string>
<string name="entermessage">Введите сообщение</string>
<string name="entergroupname">Введите Имя группы</string>
<string name="nodelivery">Нет доступных отчётов о доставке</string>
<string name="enabledelivery">Включить отчёт о доставке</string>
<string name="to">Кому</string>
<string name="refresh">Обновить</string>
<string name="remove_all">Удалить Все</string>
<string name="remove">Удалить</string>
<string name="add_group">Добавить из Группы</string>
<string name="delivery">Отчёты о доставке</string>
<string name="create_group">Создать новую группу</string>
<string name="remove_group">Удалить эту группу</string>
<string name="edit_group">Изменить эту группу</string>
<string name="noName">нет Имени</string>
<string name="select_all">Выбрать все</string>
<string name="deselect_all">Ничего не выбирать</string>
<string name="message_sent">Сообщение(я) отправлены</string>
<string name="enter_number">Введите номет телефона или нажмите иконку контактов</string>
<string name="warning_many_message">Вы пытаетесь отправить больше 50 сообщений. Поскольку это может привести к ошибке Android или завершению приложения, они будут отправлены группами по 50 сообщений с паузой между группами. Хотите продолжить?</string>
<string name="more_message">Вы готовы к отправке более 50 сообщений?</string>
</resources>

View File

@ -4,11 +4,12 @@
<string name="send">Send</string>
<string name="add">Add</string>
<string name="contacts">Contacts</string>
<string name="ok">Ok</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="nocontacts">No Contacts!!</string>
<string name="nogroups">No Groups!!</string>
<string name="sending">Sending message...</string>
<string name="wait">Please wait while sending...</string>
<string name="sending">Sending message&#8230;</string>
<string name="wait">Please wait while sending&#8230;</string>
<string name="entermessage">Enter your message</string>
<string name="entergroupname">Enter Group Name</string>
<string name="nodelivery">No delivery reports available</string>
@ -27,4 +28,6 @@
<string name="deselect_all">Deselect all</string>
<string name="message_sent">Message(s) sent</string>
<string name="enter_number">Enter a phone number or use the contact icon</string>
</resources>
<string name="warning_many_message">You are about to sent more than 50 Messages. As it may produce an Android error that may crash the application, they will be send by chunk of 50 with a pause between each chunk. Do you want to continue ?</string>
<string name="more_message">Are you ready for 50 more messages?</string>
</resources>

View File

@ -0,0 +1,348 @@
package com.hectorone.multismssender;
import java.util.HashMap;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.provider.UserDictionary.Words;
import android.text.TextUtils;
import android.util.Log;
public class DeliveryDbAdapter extends ContentProvider {
public static final String PROVIDER_NAME = "com.hectorone.multismssender.provider";
public static final Uri CONTENT_DELIVERY_URI = Uri.parse("content://"
+ PROVIDER_NAME + "/delivery");
public static final Uri CONTENT_MESSAGE_URI = Uri.parse("content://"
+ PROVIDER_NAME + "/message");
private static final int ENTRIES = 1;
private static final int ENTRY_ID = 2;
private static final int MESSAGES = 3;
private static final int MESSAGES_ID = 4;
private static final UriMatcher uriMatcher;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(PROVIDER_NAME, "delivery" , ENTRIES);
uriMatcher.addURI(PROVIDER_NAME, "delivery/#", ENTRY_ID);
uriMatcher.addURI(PROVIDER_NAME, "message" , MESSAGES);
uriMatcher.addURI(PROVIDER_NAME, "message/#" , MESSAGES_ID);
}
public static final String KEY_DELIVERY_ENTRY_ROWID = "_id";
public static final String KEY_DELIVERY_ENTRY_NAME = "name";
public static final String KEY_DELIVERY_ENTRY_NUMBER = "number";
public static final String KEY_DELIVERY_ENTRY_DELIVERED = "delivered";
public static final String KEY_DELIVERY_ENTRY_MESSAGE_ID = "message_id";
public static final String KEY_MESSAGE_ROWID = "_id";
public static final String KEY_MESSAGE_NAME = "name";
public static final String KEY_MESSAGE_DATE = "date";
private static final String TAG = "deliveryDbAdapter";
private DeliveryDbHelper mDbHelper;
// private SQLiteDatabase mDb;
/**
* Database creation sql statement
*/
public static final String DATABASE_NAME = "delivery";
public static final String DATABASE_DELIVERY_ENTRY_TABLE = "delivery_entry";
public static final String DATABASE_MESSAGE_TABLE = "message";
public static final String DATABASE_DELIVERY_ENTRY_CREATE = "create table "
+ DATABASE_DELIVERY_ENTRY_TABLE + " (" + KEY_DELIVERY_ENTRY_ROWID
+ " integer primary key autoincrement, " + KEY_DELIVERY_ENTRY_NAME
+ " text not null," + KEY_DELIVERY_ENTRY_NUMBER + " text not null,"
+ KEY_DELIVERY_ENTRY_DELIVERED + " integer,"
+ KEY_DELIVERY_ENTRY_MESSAGE_ID + " integer);";
public static final String DATABASE_DELIVERY_CREATE = "create table "
+ DATABASE_MESSAGE_TABLE + " (" + KEY_MESSAGE_ROWID
+ " integer primary key autoincrement, " + KEY_MESSAGE_NAME
+ " text not null," + KEY_MESSAGE_DATE + " text not null);";
public static final int DATABASE_VERSION = 4;
private static HashMap<String, String> sDeliveryProjectionMap;
private static HashMap<String, String> sMessageProjectionMap;
static {
sDeliveryProjectionMap = new HashMap<String, String>();
sMessageProjectionMap = new HashMap<String, String>();
sDeliveryProjectionMap.put(KEY_DELIVERY_ENTRY_ROWID,
KEY_DELIVERY_ENTRY_ROWID);
sDeliveryProjectionMap.put(KEY_DELIVERY_ENTRY_NAME,
KEY_DELIVERY_ENTRY_NAME);
sDeliveryProjectionMap.put(KEY_DELIVERY_ENTRY_NUMBER,
KEY_DELIVERY_ENTRY_NUMBER);
sDeliveryProjectionMap.put(KEY_DELIVERY_ENTRY_DELIVERED,
KEY_DELIVERY_ENTRY_DELIVERED);
sDeliveryProjectionMap.put(KEY_DELIVERY_ENTRY_MESSAGE_ID,
KEY_DELIVERY_ENTRY_MESSAGE_ID);
sMessageProjectionMap.put(KEY_MESSAGE_ROWID, KEY_MESSAGE_ROWID);
sMessageProjectionMap.put(KEY_MESSAGE_NAME , KEY_MESSAGE_NAME);
sMessageProjectionMap.put(KEY_MESSAGE_DATE , KEY_MESSAGE_DATE);
}
private static class DeliveryDbHelper extends SQLiteOpenHelper {
DeliveryDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_DELIVERY_ENTRY_CREATE);
db.execSQL(DATABASE_DELIVERY_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_DELIVERY_ENTRY_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_MESSAGE_TABLE);
onCreate(db);
}
}
// *********************** Content Provider ****************************************
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
SQLiteDatabase db = mDbHelper.getWritableDatabase();
int count;
switch (uriMatcher.match(uri)) {
case ENTRIES:
count = db.delete(DATABASE_DELIVERY_ENTRY_TABLE, selection,
selectionArgs);
break;
case ENTRY_ID: {
String id = uri.getPathSegments().get(1);
count = db.delete(
DATABASE_DELIVERY_ENTRY_TABLE,
KEY_DELIVERY_ENTRY_ROWID
+ "="
+ id
+ (!TextUtils.isEmpty(selection) ? " AND ("
+ selection + ')' : ""), selectionArgs);
break;
}
case MESSAGES:
count = db.delete(DATABASE_MESSAGE_TABLE, selection, selectionArgs);
break;
case MESSAGES_ID: {
String id = uri.getPathSegments().get(1);
count = db.delete(DATABASE_DELIVERY_ENTRY_TABLE, KEY_MESSAGE_ROWID
+ "="
+ id
+ (!TextUtils.isEmpty(selection) ? " AND (" + selection
+ ')' : ""), selectionArgs);
break;
}
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return count;
}
@Override
public String getType(Uri uri) {
switch (uriMatcher.match(uri)) {
case ENTRIES:
return "vnd.android.cursor.dir/vnd." + PROVIDER_NAME + ".entry";
case ENTRY_ID:
return "vnd.android.cursor.item/vnd." + PROVIDER_NAME + ".entry";
case MESSAGES:
return "vnd.android.cursor.dir/vnd." + PROVIDER_NAME + ".message";
case MESSAGES_ID:
return "vnd.android.cursor.item/vnd." + PROVIDER_NAME + ".message";
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
}
@Override
public Uri insert(Uri uri, ContentValues values) {
ContentValues initialValues;
if (values != null) {
initialValues = new ContentValues(values);
} else {
initialValues = new ContentValues();
}
switch (uriMatcher.match(uri)) {
case ENTRIES: {
if (initialValues.containsKey(KEY_DELIVERY_ENTRY_NAME) == false) {
throw new SQLException(KEY_DELIVERY_ENTRY_NAME
+ " must be specified");
}
if (initialValues.containsKey(KEY_DELIVERY_ENTRY_NUMBER) == false) {
throw new SQLException(KEY_DELIVERY_ENTRY_NUMBER
+ " must be specified");
}
if (initialValues.containsKey(KEY_DELIVERY_ENTRY_MESSAGE_ID) == false) {
throw new SQLException(KEY_DELIVERY_ENTRY_MESSAGE_ID
+ " must be specified");
}
initialValues.put(KEY_DELIVERY_ENTRY_DELIVERED, 0);
SQLiteDatabase db = mDbHelper.getWritableDatabase();
long rowId = db.insert(DATABASE_DELIVERY_ENTRY_TABLE, null,
initialValues);
if (rowId > 0) {
Uri newUri = ContentUris.withAppendedId(CONTENT_DELIVERY_URI,
rowId);
getContext().getContentResolver().notifyChange(newUri, null);
return newUri;
}
throw new SQLException("Failed to insert row into " + uri);
}
case MESSAGES: {
if (initialValues.containsKey(KEY_MESSAGE_NAME) == false) {
throw new SQLException(KEY_MESSAGE_NAME + " must be specified");
}
if (initialValues.containsKey(KEY_MESSAGE_DATE) == false) {
throw new SQLException(KEY_MESSAGE_DATE + " must be specified");
}
SQLiteDatabase db = mDbHelper.getWritableDatabase();
long rowId = db.insert(DATABASE_MESSAGE_TABLE, null, initialValues);
if (rowId > 0) {
Uri newUri = ContentUris.withAppendedId(CONTENT_MESSAGE_URI,
rowId);
getContext().getContentResolver().notifyChange(newUri, null);
return newUri;
}
throw new SQLException("Failed to insert row into " + uri);
}
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
}
@Override
public boolean onCreate() {
mDbHelper = new DeliveryDbHelper(getContext());
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch (uriMatcher.match(uri)) {
case ENTRIES:
qb.setTables(DATABASE_DELIVERY_ENTRY_TABLE);
qb.setProjectionMap(sDeliveryProjectionMap);
break;
case ENTRY_ID:
qb.setTables(DATABASE_DELIVERY_ENTRY_TABLE);
qb.setProjectionMap(sDeliveryProjectionMap);
qb.appendWhere(KEY_DELIVERY_ENTRY_ROWID + "="
+ uri.getPathSegments().get(1));
break;
case MESSAGES:
qb.setTables(DATABASE_MESSAGE_TABLE);
qb.setProjectionMap(sMessageProjectionMap);
break;
case MESSAGES_ID:
qb.setTables(DATABASE_MESSAGE_TABLE);
qb.setProjectionMap(sMessageProjectionMap);
qb.appendWhere(KEY_MESSAGE_ROWID + "="
+ uri.getPathSegments().get(1));
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
// Run the query
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor c = qb.query(db, projection, selection, selectionArgs, null,
null, sortOrder);
// Tell the cursor what uri to watch, so it knows when its source data
// changes
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
SQLiteDatabase db = mDbHelper.getWritableDatabase();
int count;
switch (uriMatcher.match(uri)) {
case ENTRIES:
count = db.update(DATABASE_DELIVERY_ENTRY_TABLE, values, selection,
selectionArgs);
break;
case ENTRY_ID: {
String id = uri.getPathSegments().get(1);
count = db.update(DATABASE_DELIVERY_ENTRY_TABLE, values, Words._ID
+ "="
+ id
+ (!TextUtils.isEmpty(selection) ? " AND (" + selection
+ ')' : ""), selectionArgs);
break;
}
case MESSAGES:
count = db.update(DATABASE_MESSAGE_TABLE, values, selection,
selectionArgs);
break;
case MESSAGES_ID: {
String id = uri.getPathSegments().get(1);
count = db.update(DATABASE_MESSAGE_TABLE, values, Words._ID
+ "="
+ id
+ (!TextUtils.isEmpty(selection) ? " AND (" + selection
+ ')' : ""), selectionArgs);
break;
}
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return count;
}
}

View File

@ -1,4 +1,4 @@
package com.openwide.android;
package com.hectorone.multismssender;
import java.util.HashSet;
@ -7,13 +7,16 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Phones;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.SimpleCursorAdapter;
public class GroupEditActivity extends ListActivity {
@ -28,40 +31,49 @@ public class GroupEditActivity extends ListActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_group_list);
mGroupNameText = (EditText) findViewById(R.id.groupName);
Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, Phones.NAME);
// Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null,
// null, Phones.NAME);
Cursor c = getContentResolver().query(
Data.CONTENT_URI,
new String[] { Data._ID, Data.MIMETYPE, Phone.NUMBER,
Phone.TYPE, Phone.LABEL, Contacts.DISPLAY_NAME },
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", null,
Contacts.DISPLAY_NAME);
startManagingCursor(c);
String[] mSelected = {};
mDb = new GroupsDbAdapter(this);
mDb.open();
Long groupId;
Bundle extras = getIntent().getExtras();
groupId = extras != null ? extras.getLong(SelectGroupActivity.PARAM_GROUP_ID): null;
groupId = extras != null ? extras
.getLong(SelectGroupActivity.PARAM_GROUP_ID) : null;
if (groupId != null) {
Cursor groupNameCursor = mDb.fetchGroup(groupId);
String groupName = groupNameCursor.getString(groupNameCursor.getColumnIndex(GroupsDbAdapter.KEY_GROUP_NAME));
startManagingCursor(groupNameCursor);
String groupName = groupNameCursor.getString(groupNameCursor
.getColumnIndex(GroupsDbAdapter.KEY_GROUP_NAME));
mGroupNameText.setText(groupName);
Cursor numbers = mDb.fetchPhonesFromGroup(groupId);
startManagingCursor(numbers);
numbers.moveToFirst();
int phoneNumIdx = numbers.getColumnIndex(Phones.NUMBER);
int phoneNumIdx = numbers.getColumnIndex(Phone.NUMBER);
mSelected = new String[numbers.getCount()];
for(int i = 0; i < numbers.getCount(); i++) {
for (int i = 0; i < numbers.getCount(); i++) {
mSelected[i] = numbers.getString(phoneNumIdx);
numbers.moveToNext();
}
mGid = groupId;
}
mAdpater = new GroupDataListAdapter(this, R.layout.number_row, c, new String[] {
Phones.NAME, Phones.NUMBER
}, new int[] {R.id.name, R.id.phone}, mSelected);
mAdpater = new GroupDataListAdapter(this, R.layout.number_row, c,
new String[] { Contacts.DISPLAY_NAME, Phone.NUMBER },
new int[] { R.id.name, R.id.phone }, mSelected);
setListAdapter(mAdpater);
Button ok = (Button) findViewById(R.id.okGroups);
@ -78,32 +90,44 @@ public class GroupEditActivity extends ListActivity {
});
}
protected void onDestroy() {
mDb.close();
super.onDestroy();
protected void onStart() {
//Log.d("GroupEdit", "---onStart");
mDb.open();
super.onStart();
}
protected void onResume() {
//Log.d("GroupEdit", "---onResume");
super.onResume();
}
protected void onStop() {
//Log.d("GroupEdit", "---OnStop");
mDb.close();
super.onStop();
}
private void createGroup() {
if (mGid == null) {
if (mGid == null) {
String name = mGroupNameText.getText().toString();
if(name.equals("")) {
if (name.equals("")) {
name = getResources().getString(R.string.noName);
}
mGid = mDb.createGroup(name);
}
}
private void reNameGroup() {
if (mGid != null) {
if (mGid != null) {
String name = mGroupNameText.getText().toString();
if(name.equals("")) {
if (name.equals("")) {
name = getResources().getString(R.string.noName);
}
mDb.updateGroup(mGid, name);
}
}
public class GroupDataListAdapter extends SimpleCursorAdapter{
public class GroupDataListAdapter extends SimpleCursorAdapter {
public HashSet<String> selected;
int nameidx;
@ -114,11 +138,11 @@ public class GroupEditActivity extends ListActivity {
public GroupDataListAdapter(Context context, int layout, Cursor c,
String[] from, int[] to, String[] rawSelected) {
super(context, layout, c, from, to);
nameidx = c.getColumnIndex(Phones.NAME);
numberidx = c.getColumnIndex(Phones.NUMBER);
idIdx = c.getColumnIndex(Phones._ID);
mContext = context;
selected = new HashSet<String>();
nameidx = c.getColumnIndex(Contacts.DISPLAY_NAME);
numberidx = c.getColumnIndex(Phone.NUMBER);
idIdx = c.getColumnIndex(Data._ID);
mContext = context;
selected = new HashSet<String>();
for (int i = 0; i < rawSelected.length; i++) {
selected.add(rawSelected[i].trim());
}
@ -126,47 +150,56 @@ public class GroupEditActivity extends ListActivity {
public View getView(int position, View convertView, ViewGroup parent) {
Cursor c = getCursor();
startManagingCursor(c);
c.moveToPosition(position);
String name = c.getString(nameidx);
String number = c.getString(numberidx);
long id = c.getLong(idIdx);
ContactRow contact;
if (convertView == null) {
contact = new ContactRow(mContext);
}else {
contact = (ContactRow) convertView;
}
contact.display(name, number, selected.contains(number), id);
contact.mSelectedCheckBox.setOnClickListener(new addNumberToGroupClickListener(contact));
String contactNumber = c.getString(numberidx);
long id = c.getLong(idIdx);
View v = super.getView(position, convertView, parent);
LinearLayout background = (LinearLayout) v
.findViewById(R.id.row_background);
CheckBox checkbox = (CheckBox) v.findViewById(R.id.CheckBox);
checkbox.setOnClickListener(new addNumberToGroupClickListener(id));
checkbox.setChecked(selected.contains(contactNumber));
background.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CheckBox checkbox = (CheckBox) v
.findViewById(R.id.CheckBox);
checkbox.performClick();
}
});
return v;
return contact;
}
}
private class addNumberToGroupClickListener implements OnClickListener{
ContactRow mContact;
public addNumberToGroupClickListener(ContactRow mContact) {
private class addNumberToGroupClickListener implements OnClickListener {
Long mId;
public addNumberToGroupClickListener(Long id) {
super();
this.mContact = mContact;
this.mId = id;
}
public void onClick(View v) {
CheckBox cBox = (CheckBox)v;
CheckBox cBox = (CheckBox) v;
createGroup();
long phoneId = mContact.mId;
if(cBox.isChecked()) {
mDb.addPhoneToGroup(mGid, phoneId);
}else {
mDb.removePhoneToGroup(mGid, phoneId);
if (cBox.isChecked()) {
mDb.addPhoneToGroup(mGid, mId);
} else {
mDb.removePhoneToGroup(mGid, mId);
}
}
}
}

View File

@ -0,0 +1,231 @@
package com.hectorone.multismssender;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.util.Log;
/**
* Simple groups database access helper class. Defines the basic CRUD operations
* for the group add example, and gives the ability to list all groups as well
* as retrieve or modify a specific group.
*
*/
public class GroupsDbAdapter {
public static final String KEY_GROUP_NAME = "name";
public static final String KEY_GROUP_ROWID = "_id";
public static final String KEY_GROUP_TO_PHONE_ROWID = "_id";
public static final String KEY_GROUP_TO_PHONE_GROUPID = "gid";
public static final String KEY_GROUP_TO_PHONE_PHONEID = "pid";
private static final String TAG = "groupsDbAdapter";
private GroupDbHelper mDbHelper;
private SQLiteDatabase mDb;
/**
* Database creation sql statement
*/
private static final String DATABASE_GROUP_CREATE = "create table groups (_id integer primary key autoincrement, "
+ "name text not null);";
private static final String DATABASE_GROUP_TO_PHONE_CREATE = "create table group_TO_PHONE (_id integer primary key autoincrement, "
+ "gid integer not null, pid integer not null);";
private static final String DATABASE_NAME = "dataGroup";
private static final String DATABASE_GROUP_TABLE = "groups";
private static final String DATABASE_GROUP_TO_PHONE_TABLE = "group_TO_PHONE";
private static final int DATABASE_VERSION = 4;
private final Context mCtx;
private static class GroupDbHelper extends SQLiteOpenHelper {
GroupDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_GROUP_CREATE);
db.execSQL(DATABASE_GROUP_TO_PHONE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS groups");
db.execSQL("DROP TABLE IF EXISTS group_TO_PHONE");
onCreate(db);
}
}
/**
* Constructor - takes the context to allow the database to be
* opened/created
*
* @param ctx
* the Context within which to work
*/
public GroupsDbAdapter(Context ctx) {
this.mCtx = ctx;
}
/**
* Open the groups database. If it cannot be opened, try to create a new
* instance of the database. If it cannot be created, throw an exception to
* signal the failure
*
* @return this (self reference, allowing this to be chained in an
* initialization call)
* @throws SQLException
* if the database could be neither opened or created
*/
public GroupsDbAdapter open() throws SQLException {
mDbHelper = new GroupDbHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
return this;
}
public void close() {
mDbHelper.close();
}
/**
* Create a new group using the name provided. If the group is successfully
* created return the new rowId for that group, otherwise return a -1 to
* indicate failure.
*
* @param name
* the name of the group
*/
public long createGroup(String name) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_NAME, name);
return mDb.insert(DATABASE_GROUP_TABLE, null, initialValues);
}
/**
* Delete the group with the given rowId
*
* @param rowId
* id of group to delete
* @return true if deleted, false otherwise
*/
public boolean deleteGroup(long rowId) {
return mDb.delete(DATABASE_GROUP_TABLE, KEY_GROUP_ROWID + "=" + rowId,
null) > 0
&& mDb.delete(DATABASE_GROUP_TO_PHONE_TABLE,
KEY_GROUP_TO_PHONE_GROUPID + "=" + rowId, null) > 0;
}
/**
* Return a Cursor over the list of all groups in the database
*
* @return Cursor over all groups
*/
public Cursor fetchAllGroups() {
return mDb.query(DATABASE_GROUP_TABLE, new String[] { KEY_GROUP_ROWID,
KEY_GROUP_NAME }, null, null, null, null, KEY_GROUP_NAME);
}
/**
* Return a Cursor positioned at the group that matches the given rowId
*
* @param rowId
* id of group to retrieve
* @return Cursor positioned to matching group, if found
* @throws SQLException
* if group could not be found/retrieved
*/
public Cursor fetchGroup(long rowId) throws SQLException {
Cursor mCursor =
mDb.query(true, DATABASE_GROUP_TABLE, new String[] { KEY_GROUP_ROWID,
KEY_GROUP_NAME }, KEY_GROUP_ROWID + "=" + rowId, null, null,
null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
/**
* @param rowId
* id of group to update
* @param name
* value to set group name to
*/
public boolean updateGroup(long rowId, String name) {
ContentValues args = new ContentValues();
args.put(KEY_GROUP_NAME, name);
return mDb.update(DATABASE_GROUP_TABLE, args, KEY_GROUP_ROWID + "="
+ rowId, null) > 0;
}
public Cursor fetchPhonesFromGroup(long groupId) {
Cursor mCursor = mDb.query(true, DATABASE_GROUP_TO_PHONE_TABLE,
new String[] { KEY_GROUP_TO_PHONE_PHONEID },
KEY_GROUP_TO_PHONE_GROUPID + "=" + groupId, null, null, null,
null, null);
Cursor userCursor = null;
int phoneIdIdx = mCursor.getColumnIndex(KEY_GROUP_TO_PHONE_PHONEID);
if (mCursor != null) {
userCursor = mCtx.getContentResolver()
.query(Data.CONTENT_URI,
new String[] { Data._ID, Data.MIMETYPE,
Phone.NUMBER, Phone.TYPE, Phone.LABEL,
Contacts.DISPLAY_NAME },
Data._ID + " IN "
+ cursorToStringList(mCursor, phoneIdIdx),
null, Contacts.DISPLAY_NAME);
}
mCursor.close();
return userCursor;
}
public long addPhoneToGroup(long groupId, long phoneId) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_TO_PHONE_GROUPID, groupId);
initialValues.put(KEY_GROUP_TO_PHONE_PHONEID, phoneId);
return mDb.insert(DATABASE_GROUP_TO_PHONE_TABLE, null, initialValues);
}
public boolean removePhoneToGroup(long groupId, long phoneId) {
return mDb.delete(DATABASE_GROUP_TO_PHONE_TABLE,
KEY_GROUP_TO_PHONE_GROUPID + "=" + groupId + " AND "
+ KEY_GROUP_TO_PHONE_PHONEID + "=" + phoneId, null) > 0;
}
public String cursorToStringList(Cursor cursor, int columnIdx) {
cursor.moveToFirst();
String list = "( ";
while (!cursor.isAfterLast()) {
list += cursor.getString(columnIdx);
if (!cursor.isLast()) {
list += " , ";
}
cursor.moveToNext();
}
list += " )";
return list;
}
}

View File

@ -1,4 +1,4 @@
package com.openwide.android;
package com.hectorone.multismssender;
import android.app.ListActivity;
import android.content.Context;
@ -15,95 +15,96 @@ public class ListEntryActivity extends ListActivity {
DeliveryDbAdapter mDbHelper;
Long mDeliveryId;
public static final int REFRESH_ID = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.entry_list);
Bundle extras = getIntent().getExtras();
mDeliveryId = extras != null ? extras.getLong(SelectDeliveryActivity.PARAM_DELIVERY_ID): null;
mDbHelper = new DeliveryDbAdapter(this);
mDbHelper.open();
mDeliveryId = extras != null ? extras
.getLong(SelectDeliveryActivity.PARAM_DELIVERY_ID) : null;
fillData();
registerForContextMenu(getListView());
}
public void fillData() {
Cursor deliveryCursor = mDbHelper.fetchAllEntry(mDeliveryId);
Cursor deliveryCursor = getContentResolver().query(
DeliveryDbAdapter.CONTENT_DELIVERY_URI,
null,
DeliveryDbAdapter.KEY_DELIVERY_ENTRY_MESSAGE_ID + " = "
+ mDeliveryId, null, null);
startManagingCursor(deliveryCursor);
String[] from = new String[]{DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME, DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER };
String[] from = new String[] {
DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME,
DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER };
int[] to = new int[]{R.id.name, R.id.number};
int[] to = new int[] { R.id.name, R.id.number };
EntryCursorAdapter notes =
new EntryCursorAdapter(this, R.layout.entry_row, deliveryCursor, from, to);
EntryCursorAdapter notes = new EntryCursorAdapter(this,
R.layout.entry_row, deliveryCursor, from, to);
setListAdapter(notes);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
mDbHelper.close();
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, REFRESH_ID,0, R.string.refresh);
menu.add(0, REFRESH_ID, 0, R.string.refresh);
return true;
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId()) {
switch (item.getItemId()) {
case REFRESH_ID:
fillData();
return true;
}
return super.onContextItemSelected(item);
}
private class EntryCursorAdapter extends SimpleCursorAdapter{
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);
// TODO this.getCursor()
this.c = c;
deliveredIdx = c.getColumnIndex(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED);
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);
ImageView image = (ImageView) v.findViewById(R.id.delivered);
c.moveToPosition(position);
int delivered = c.getInt(deliveredIdx);
if(delivered != 0) {
if (delivered != 0) {
image.setImageResource(R.drawable.btn_check_buttonless_on);
}else {
} else {
image.setImageResource(R.drawable.btn_check_buttonless_off);
}
return v;
}
}
}

View File

@ -0,0 +1,42 @@
package com.hectorone.multismssender;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.telephony.SmsMessage;
public class MessageReceiver extends BroadcastReceiver{
public static final String MESSAGE_RECEIVED = "com.hectorone.multismssender.SMS_RECEIVED";
public static final String ANDROID_MESSAGE_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
public static final String DEBUG_TAG = "-------MessageReceiver--------";
@Override
public void onReceive(Context context, Intent intent) {
if (MESSAGE_RECEIVED.equals(intent.getAction())) {
//Log.d(DEBUG_TAG, "SMS_RECEIVED");
Uri entryURI = intent.getData();
if (entryURI != null){
byte[] pdu = intent.getByteArrayExtra("pdu");
//createFromPdu (byte[] pdu) will be deprecated.
//Use following instead
//String format = intent.getStringExtra("format");
//SmsMessage message = SmsMessage.createFromPdu(pdu, format);
SmsMessage message = SmsMessage.createFromPdu(pdu);
if(message.getStatus()== 0) {
ContentValues values = new ContentValues(1);
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED, 1);
context.getContentResolver().update(entryURI, values, null, null);
}
}
}
}
}

View File

@ -0,0 +1,591 @@
package com.hectorone.multismssender;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.ContactsContract.PhoneLookup;
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
public class MultiSmsSender extends Activity {
private Button mAddButton;
private Button mAddGroupButton;
private Button mSend;
private TextView mContacts;
private TextView mEditor;
private CheckBox mDeliveryCheckBox;
private ProgressDialog mSendingDialog;
public static final int ACTIVITY_EDIT = 0;
public static final int ACTIVITY_ADD_GROUP = 1;
public static final int ACTIVITY_DELIVERY = 2;
private static final int INSERT_ID = Menu.FIRST;
public static final int MANY_MESSAGE = 50;
private static final int DIALOG_PROGRESS = 0;
private static final int DIALOG_FINISHED = 1;
private static final int DIALOG_NONUMBER = 2;
private static final int DIALOG_MANYMESSAGE = 3;
private static final int DIALOG_STARTWAIT = 4;
private static final int DIALOG_PROGRESS_CANCEL = 5;
private static final int SENDING_DIALOG_KEY = 6;
public static final String PARAM_NUMBERS_LIST = "param number list";
public static final String PARAM_FLUSH = "param flush";
public static final String PARAM_ENTRY_ID = "entry_id";
public static final String PREF_NAME = "com.hectorone.multismssender.pref";
public static final String PREF_USE_DELIVERY = "use_delivery";
public static final String DEBUG_TAG="MultiSmsSender";
private boolean appli_running = true;
MessageSenderThread mThreadSender;
private boolean mManyMessageContinue;
final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
int type = msg.getData().getInt("ORIGIN");
switch (type) {
case DIALOG_PROGRESS: {
int total = msg.getData().getInt("total");
mSendingDialog.setProgress(total);
}
break;
case DIALOG_PROGRESS_CANCEL: {
mSendingDialog.cancel();
}
break;
case DIALOG_FINISHED: {
int total = msg.getData().getInt("total");
new AlertDialog.Builder(MultiSmsSender.this)
.setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
})
.setMessage(
total
+ " "
+ getResources().getString(
R.string.message_sent)).show();
break;
}
case DIALOG_NONUMBER: {
new AlertDialog.Builder(MultiSmsSender.this)
.setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
})
.setMessage(
getResources().getString(R.string.enter_number))
.show();
break;
}
case DIALOG_MANYMESSAGE: {
new AlertDialog.Builder(MultiSmsSender.this)
.setMessage(
getResources().getString(
R.string.warning_many_message))
.setCancelable(false)
.setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
synchronized (MultiSmsSender.this) {
MultiSmsSender.this.notify();
mManyMessageContinue = true;
}
dialog.dismiss();
}
})
.setNegativeButton(
getResources().getString(R.string.cancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
synchronized (MultiSmsSender.this) {
MultiSmsSender.this.notify();
mManyMessageContinue = false;
}
dialog.dismiss();
}
}).show();
break;
}
case DIALOG_STARTWAIT: {
new AlertDialog.Builder(MultiSmsSender.this)
.setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
synchronized (MultiSmsSender.this) {
MultiSmsSender.this.notify();
}
dialog.dismiss();
}
})
.setMessage(
getResources().getString(R.string.more_message))
.show();
break;
}
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mAddButton = (Button) findViewById(R.id.contacts);
mAddGroupButton = (Button) findViewById(R.id.groups);
mSend = (Button) findViewById(R.id.send);
mContacts = (TextView) findViewById(R.id.numbers);
mEditor = (TextView) findViewById(R.id.editor);
mDeliveryCheckBox = (CheckBox) findViewById(R.id.deliveryCheckBox);
mContacts.setImeOptions(EditorInfo.IME_ACTION_NEXT);
// mEditor.setImeOptions(EditorInfo.IME_ACTION_DONE);
mAddButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectNumbers();
}
});
mAddGroupButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
display_group_list();
}
});
mSend.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(SENDING_DIALOG_KEY);
mThreadSender = new MessageSenderThread(mHandler);
mThreadSender.start();
}
});
//delivery preference
SharedPreferences settings = getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
boolean deliveryEnabled = settings.getBoolean(PREF_USE_DELIVERY, false);
mDeliveryCheckBox.setChecked(deliveryEnabled);
mDeliveryCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences settings = getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
settings.edit().putBoolean(PREF_USE_DELIVERY, isChecked);
//TODO prefer apply() to commit() since API 9
settings.edit().commit();
}
});
}
public void selectNumbers() {
// startActivityForResult(new Intent(Intent.ACTION_PICK,
// People.CONTENT_URI), 0);
Intent i = new Intent(this, PhoneNumberSelection.class);
String rawNumbers = mContacts.getText().toString();
String[] numbers = rawNumbers.split(",");
i.putExtra(PARAM_NUMBERS_LIST, numbers);
startActivityForResult(i, ACTIVITY_EDIT);
}
private class MessageSenderThread extends Thread {
Handler mHandler;
public MessageSenderThread(Handler h) {
mHandler = h;
}
public synchronized void run() {
super.run();
sendMessage(mHandler);
}
}
public long createMessageId(String messageName, int messageNbPart) {
ContentValues values = new ContentValues(2);
values.put(DeliveryDbAdapter.KEY_MESSAGE_NAME, messageName);
values.put(DeliveryDbAdapter.KEY_MESSAGE_DATE, DateFormat
.getDateInstance().format(new Date()));
return Long.parseLong(getContentResolver()
.insert(DeliveryDbAdapter.CONTENT_MESSAGE_URI, values)
.getPathSegments().get(1));
}
public long createEntryId(String number, long messageId) {
ContentValues values = new ContentValues(3);
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NAME,
nameFromNumber(getContentResolver(), number));
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_NUMBER,
number);
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_MESSAGE_ID,
messageId);
return Long.parseLong(getContentResolver()
.insert(DeliveryDbAdapter.CONTENT_DELIVERY_URI,
values).getPathSegments().get(1));
}
public void sendMessage(Handler handler) {
SmsManager manager = SmsManager.getDefault();
String message = mEditor.getText().toString();
HashMap<String, Long> deliveryIdMap = new HashMap<String, Long>();
mManyMessageContinue = true;
if("".equals(message)) {
{
displayDialog(handler, DIALOG_PROGRESS_CANCEL,null);
}
return;
}
String[] numbers = mContacts.getText().toString().split(",");
ArrayList<String> phoneNumberConform = new ArrayList<String>();
int size = numbers.length;
boolean haveDeliveryReports = mDeliveryCheckBox.isChecked();
long messageId = -1;
ArrayList<String> messages = manager.divideMessage(message);
int messageCount = messages.size();
if (haveDeliveryReports) {
messageId = createMessageId(
message.substring(0, Math.min(30, message.length()))
.replace('\n', ' ')
, messageCount);
}
// Check if numbers are correct and prepare deliveryId
for (int i = 0; i < size; i++) {
String newN = numbers[i].trim();
newN = newN.replace(" ", "");
if (!newN.equals("")
&& PhoneNumberUtils.isWellFormedSmsAddress(newN)
&& !phoneNumberConform.contains(newN)) {
phoneNumberConform.add(newN);
if (haveDeliveryReports) {
long entryId = createEntryId(newN, messageId);
deliveryIdMap.put(newN, entryId);
}
}
}
numbers = new String[size];
numbers = phoneNumberConform.toArray(numbers);
size = phoneNumberConform.size();
if (size != 0) {
if (size > MANY_MESSAGE) {
{
displayDialog(handler, DIALOG_MANYMESSAGE, null);
}
synchronized (MultiSmsSender.this) {
try {
MultiSmsSender.this.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (mManyMessageContinue) {
int message_sent = 0;
int chunk_max = Math.min(MANY_MESSAGE, size);
do {
if (message_sent > 0) {
displayDialog(handler, DIALOG_STARTWAIT, null);
synchronized (MultiSmsSender.this) {
try {
MultiSmsSender.this.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// Log.d(DEBUG_TAG,
// "size is"+size+" message_sent "+message_sent+" max"+chunk_max);
for (int i = message_sent; i < chunk_max; i++) {
message_sent++;
String newN = numbers[i];
Message msg = handler.obtainMessage();
Bundle b = new Bundle();
b.putInt("ORIGIN", DIALOG_PROGRESS);
b.putInt("total", (i * 100) / size);
msg.setData(b);
handler.sendMessage(msg);
ArrayList<PendingIntent> deliveryIntents = null;
ArrayList<PendingIntent> sentIntents = null;
if (haveDeliveryReports) {
deliveryIntents = new ArrayList<PendingIntent>(
messageCount);
sentIntents = new ArrayList<PendingIntent>(
messageCount);
// Add to the Google MMS app
ContentValues values = new ContentValues();
values.put("address", newN);
values.put("body", message);
getContentResolver().insert(
Uri.parse("content://sms/sent"), values);
long entryId = deliveryIdMap.get(newN);
// Log.d(DEBUG_TAG,
// "entry is "+entryId+" to number"+newN);
for (int j = 0; j < messageCount; j++) {
if (j == (messageCount - 1)) {
Uri entryURI = Uri
.withAppendedPath(
DeliveryDbAdapter.CONTENT_DELIVERY_URI,
"" + entryId);
Intent intent = new Intent(
MessageReceiver.MESSAGE_RECEIVED,
entryURI, this,
MessageReceiver.class);
deliveryIntents.add(PendingIntent
.getBroadcast(this, 0, intent, 0));
} else {
deliveryIntents.add(null);
}
}
}
manager.sendMultipartTextMessage(newN, null, messages,
sentIntents, deliveryIntents);
}
chunk_max = Math.min(message_sent + MANY_MESSAGE, size);
} while (((size - message_sent) > 0) && appli_running);
Message msg = handler.obtainMessage();
Bundle b = new Bundle();
b.putInt("ORIGIN", DIALOG_FINISHED);
b.putInt("total", phoneNumberConform.size());
msg.setData(b);
handler.sendMessage(msg);
}
displayDialog(handler, DIALOG_PROGRESS_CANCEL, null);
} else {
displayDialog(handler, DIALOG_PROGRESS_CANCEL,null);
displayDialog(handler, DIALOG_NONUMBER, null);
}
}
private void displayDialog(Handler handler, int dialogId,
HashMap<String, Integer> params) {
Message msg = handler.obtainMessage();
Bundle b = new Bundle();
b.putInt("ORIGIN", dialogId);
if (params != null) {
for (String paramName : params.keySet()) {
b.putInt(paramName, params.get(paramName));
}
}
msg.setData(b);
handler.sendMessage(msg);
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case SENDING_DIALOG_KEY: {
mSendingDialog = new ProgressDialog(this);
mSendingDialog.setTitle(R.string.sending);
mSendingDialog.setMessage(getResources().getString(R.string.wait));
mSendingDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mSendingDialog.setCancelable(false);
return mSendingDialog;
}
}
return null;
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case ACTIVITY_ADD_GROUP:
case ACTIVITY_EDIT:
if (intent != null) {
String[] numbers = intent.getExtras().getStringArray(
PARAM_NUMBERS_LIST);
boolean flush = intent.getExtras().getBoolean(PARAM_FLUSH);
String string = "";
HashSet<String> res = new HashSet<String>();
for (int i = 0; i < numbers.length; i++) {
String newN = numbers[i].trim();
if (!newN.equals("")) {
res.add(newN);
}
}
if (!flush) {
String oldContactsString = mContacts.getText().toString();
String[] oldContacts = oldContactsString.split(",");
for (int i = 0; i < oldContacts.length; i++) {
String newN = oldContacts[i].trim();
if (!newN.equals("")) {
res.add(newN);
}
}
}
for (String number : res) {
string += number + ", ";
}
mContacts.setText(string);
}
break;
default:
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID, 0, R.string.add_group);
menu.add(0, INSERT_ID + 1, 0, R.string.delivery);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case INSERT_ID:
display_group_list();
return true;
case INSERT_ID + 1:
display_delivery_list();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
protected void onDestroy() {
appli_running = false;
super.onDestroy();
}
public void display_group_list() {
Intent i = new Intent(this, SelectGroupActivity.class);
startActivityForResult(i, ACTIVITY_ADD_GROUP);
}
public void display_delivery_list() {
Intent i = new Intent(this, SelectDeliveryActivity.class);
startActivityForResult(i, ACTIVITY_DELIVERY);
}
// *********************** HELPER ****************************************
public String nameFromNumber(ContentResolver resolver, String number) {
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(number));
Cursor c = null;
try {
c = resolver.query(uri, new String[] { PhoneLookup.DISPLAY_NAME },
null, null, null);
} catch (Exception e) {
return "";
}
if (c != null) {
c.moveToFirst();
if (c.isFirst()) {
return c.getString(c.getColumnIndex(PhoneLookup.DISPLAY_NAME));
} else {
return "";
}
}
return "";
}
}

View File

@ -0,0 +1,210 @@
package com.hectorone.multismssender;
import java.util.HashSet;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
public class PhoneNumberSelection extends ListActivity {
PhoneDataListAdapter mAdpater;
HashSet<String> mSelectedSet;
private static final int INSERT_ID = Menu.FIRST;
private static final int SELECT_ALL_ID = Menu.FIRST + 1;
private static final int DESELECT_ALL_ID = Menu.FIRST + 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.number_list);
String[] selected;
selected = savedInstanceState != null ? savedInstanceState
.getStringArray(MultiSmsSender.PARAM_NUMBERS_LIST) : null;
if (selected == null) {
Bundle extras = getIntent().getExtras();
selected = extras != null ? extras
.getStringArray(MultiSmsSender.PARAM_NUMBERS_LIST) : null;
}
mSelectedSet = new HashSet<String>();
for (int i = 0; i < selected.length; i++) {
mSelectedSet.add(selected[i].trim());
}
fillData();
Button ok = (Button) findViewById(R.id.okContacts);
ok.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent();
String[] numbers = new String[mSelectedSet.size()];
mSelectedSet.toArray(numbers);
Bundle bundle = new Bundle();
bundle.putStringArray(MultiSmsSender.PARAM_NUMBERS_LIST,
numbers);
bundle.putBoolean(MultiSmsSender.PARAM_FLUSH, true);
i.putExtras(bundle);
setResult(RESULT_OK, i);
finish();
}
});
}
private void fillData() {
Cursor c = getContentResolver().query(
Data.CONTENT_URI,
new String[] { Data._ID, Data.MIMETYPE, Phone.NUMBER,
Phone.TYPE, Phone.LABEL, Contacts.DISPLAY_NAME },
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", null,
Contacts.DISPLAY_NAME);
startManagingCursor(c);
mAdpater = new PhoneDataListAdapter(this, R.layout.number_row, c,
new String[] { Contacts.DISPLAY_NAME, Phone.NUMBER },
new int[] { R.id.name, R.id.phone }, mSelectedSet);
setListAdapter(mAdpater);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, SELECT_ALL_ID, 0, R.string.select_all);
menu.add(0, DESELECT_ALL_ID, 0, R.string.deselect_all);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case INSERT_ID:
display_group_list();
return true;
case SELECT_ALL_ID:
/*
* Cursor c = getContentResolver().query(Phones.CONTENT_URI, null,
* null, null, Phones.NAME); int numberIdx =
* c.getColumnIndex(Phones.NUMBER);
*/
Cursor c = getContentResolver().query(
Data.CONTENT_URI,
new String[] { Data._ID, Data.MIMETYPE, Phone.NUMBER,
Phone.TYPE, Phone.LABEL, Contacts.DISPLAY_NAME },
Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", null,
null);
int numberIdx = c.getColumnIndex(Phone.NUMBER);
startManagingCursor(c);
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {
mSelectedSet.add(c.getString(numberIdx));
c.moveToNext();
}
fillData();
return true;
case DESELECT_ALL_ID:
mSelectedSet = new HashSet<String>();
fillData();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
public void display_group_list() {
Intent i = new Intent(this, SelectGroupActivity.class);
startActivityForResult(i, MultiSmsSender.ACTIVITY_ADD_GROUP);
}
public class PhoneDataListAdapter extends SimpleCursorAdapter {
public PhoneDataListAdapter(Context context, int layout, Cursor c,
String[] from, int[] to, HashSet<String> selected) {
super(context, layout, c, from, to);
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
LinearLayout background = (LinearLayout) v
.findViewById(R.id.row_background);
String contactNumber = ((TextView) v.findViewById(R.id.phone))
.getText().toString();
CheckBox checkbox = (CheckBox) v.findViewById(R.id.CheckBox);
checkbox.setOnClickListener(new addNumberToSelectedClickListener(
contactNumber));
checkbox.setChecked(mSelectedSet.contains(contactNumber));
background.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CheckBox checkbox = (CheckBox) v
.findViewById(R.id.CheckBox);
checkbox.performClick();
}
});
return v;
}
}
private class addNumberToSelectedClickListener implements OnClickListener {
String contactNumber;
public addNumberToSelectedClickListener(String contact) {
this.contactNumber = contact;
}
public void onClick(View v) {
CheckBox checkBox = (CheckBox) v;
if (checkBox.isChecked()) {
mSelectedSet.add(contactNumber);
} else {
mSelectedSet.remove(contactNumber);
}
}
}
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (intent != null) {
String[] numbers = intent.getExtras().getStringArray(
MultiSmsSender.PARAM_NUMBERS_LIST);
for (int i = 0; i < numbers.length; i++) {
mSelectedSet.add(numbers[i]);
}
fillData();
}
}
}

View File

@ -1,64 +1,59 @@
package com.openwide.android;
package com.hectorone.multismssender;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.AdapterView.AdapterContextMenuInfo;
public class SelectDeliveryActivity extends ListActivity {
DeliveryDbAdapter mDbHelper;
public static final int DELETE_ID = Menu.FIRST;
public static final int DELETE_ID = Menu.FIRST;
public static final int DELETE_ALL_ID = Menu.FIRST + 1;
public static final int REFRESH_ID = Menu.FIRST + 2;
public static final String PARAM_DELIVERY_ID = "param_delivery_id";
public static final int REFRESH_ID = Menu.FIRST + 2;
public static final String PARAM_DELIVERY_ID = "param_delivery_id";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.delivery_list);
mDbHelper = new DeliveryDbAdapter(this);
mDbHelper.open();
fillData();
registerForContextMenu(getListView());
}
protected void onDestroy() {
mDbHelper.close();
super.onDestroy();
}
public void fillData() {
Cursor deliveryCursor = mDbHelper.fetchAllDeliveries();
Cursor deliveryCursor = getContentResolver().query(
DeliveryDbAdapter.CONTENT_MESSAGE_URI, null, null, null, null);
startManagingCursor(deliveryCursor);
String[] from = new String[]{DeliveryDbAdapter.KEY_DELIVERY_DATE, DeliveryDbAdapter.KEY_DELIVERY_NAME };
String[] from = new String[] { DeliveryDbAdapter.KEY_MESSAGE_DATE,
DeliveryDbAdapter.KEY_MESSAGE_NAME };
int[] to = new int[]{R.id.date, R.id.name};
int[] to = new int[] { R.id.date, R.id.name };
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.delivery_row, deliveryCursor, from, to);
SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.delivery_row, deliveryCursor, from, to);
setListAdapter(notes);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, DELETE_ALL_ID,0, R.string.remove_all);
menu.add(0, DELETE_ALL_ID, 0, R.string.remove_all);
return true;
}
@ -69,14 +64,15 @@ public class SelectDeliveryActivity extends ListActivity {
menu.add(0, DELETE_ID, 0, R.string.remove);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId()) {
switch (item.getItemId()) {
case DELETE_ID:
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
mDbHelper.deleteDelivery(info.id);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
getContentResolver().delete(DeliveryDbAdapter.CONTENT_MESSAGE_URI,
DeliveryDbAdapter.KEY_MESSAGE_ROWID + "=" + info.id, null);
fillData();
return true;
}
@ -85,15 +81,16 @@ public class SelectDeliveryActivity extends ListActivity {
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
switch (item.getItemId()) {
case DELETE_ALL_ID:
mDbHelper.deleteAllDeliveries();
getContentResolver().delete(DeliveryDbAdapter.CONTENT_MESSAGE_URI,
null, null);
fillData();
return true;
}
}
return super.onMenuItemSelected(featureId, item);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent i = new Intent(this, ListEntryActivity.class);

View File

@ -1,35 +1,33 @@
package com.openwide.android;
package com.hectorone.multismssender;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Phones;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.AdapterView.AdapterContextMenuInfo;
public class SelectGroupActivity extends ListActivity{
public class SelectGroupActivity extends ListActivity {
GroupsDbAdapter mDbHelper;
public static final int DELETE_ID = Menu.FIRST;
public static final int EDIT_ID = Menu.FIRST + 1;
public static final int CREATE_ID = Menu.FIRST + 2;
public static final int DELETE_ID = Menu.FIRST;
public static final int EDIT_ID = Menu.FIRST + 1;
public static final int CREATE_ID = Menu.FIRST + 2;
public static final String PARAM_GROUP_ID = "gid";
public static final String PARAM_GROUP_ID = "gid";
public static final int ACTIVITY_EDIT_GROUP = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
//Log.d("SelectGroup", "***Create");
super.onCreate(savedInstanceState);
setContentView(R.layout.group_list);
mDbHelper = new GroupsDbAdapter(this);
@ -37,33 +35,36 @@ public class SelectGroupActivity extends ListActivity{
fillData();
registerForContextMenu(getListView());
}
protected void onDestroy() {
mDbHelper.close();
super.onDestroy();
protected void onStart() {
//Log.d("SelectGroup", "***onStart");
mDbHelper.open();
super.onStart();
}
protected void onStop() {
//Log.d("SelectGroup", "***onStop");
mDbHelper.close();
super.onStop();
}
public void fillData() {
Cursor groupsCursor = mDbHelper.fetchAllGroups();
startManagingCursor(groupsCursor);
String[] from = new String[]{GroupsDbAdapter.KEY_GROUP_NAME};
String[] from = new String[] { GroupsDbAdapter.KEY_GROUP_NAME };
int[] to = new int[]{R.id.groupNameTextView};
int[] to = new int[] { R.id.groupNameTextView };
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.group_row, groupsCursor, from, to);
SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.group_row, groupsCursor, from, to);
setListAdapter(notes);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, CREATE_ID,0, R.string.create_group);
menu.add(0, CREATE_ID, 0, R.string.create_group);
return true;
}
@ -80,7 +81,7 @@ public class SelectGroupActivity extends ListActivity{
super.onListItemClick(l, v, position, id);
Cursor phonesListCursor = mDbHelper.fetchPhonesFromGroup(id);
startManagingCursor(phonesListCursor);
int phoneNumberIdx = phonesListCursor.getColumnIndex(Phones.NUMBER);
int phoneNumberIdx = phonesListCursor.getColumnIndex(Phone.NUMBER);
String[] res = new String[phonesListCursor.getCount()];
phonesListCursor.moveToFirst();
for (int i = 0; i < res.length; i++) {
@ -88,7 +89,7 @@ public class SelectGroupActivity extends ListActivity{
phonesListCursor.moveToNext();
}
Intent i = new Intent();
Bundle bundle = new Bundle();
@ -97,17 +98,19 @@ public class SelectGroupActivity extends ListActivity{
setResult(RESULT_OK, i);
finish();
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId()) {
switch (item.getItemId()) {
case DELETE_ID:
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
mDbHelper.deleteGroup(info.id);
fillData();
return true;
case EDIT_ID:
AdapterContextMenuInfo infoEdit = (AdapterContextMenuInfo) item.getMenuInfo();
AdapterContextMenuInfo infoEdit = (AdapterContextMenuInfo) item
.getMenuInfo();
editGroup(infoEdit.id);
return true;
}
@ -116,11 +119,11 @@ public class SelectGroupActivity extends ListActivity{
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
switch (item.getItemId()) {
case CREATE_ID:
editGroup(null);
return true;
}
}
return super.onMenuItemSelected(featureId, item);
}

View File

@ -1,70 +0,0 @@
package com.openwide.android;
import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ContactRow extends LinearLayout {
CheckBox mSelectedCheckBox;
TextView mNameTextView;
TextView mNumberView;
LinearLayout mInfoLayout;
Long mId;
public ContactRow(Context context) {
super(context);
mSelectedCheckBox = new CheckBox(context);
mInfoLayout = new LinearLayout(context);
mNameTextView = new TextView(context);
mNumberView = new TextView(context);
mNameTextView.setTextSize(30,0);
mNumberView.setTextSize(18,0);
mSelectedCheckBox.setText("");
mSelectedCheckBox.setFocusable(false);
this.addView(mSelectedCheckBox, new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT));
mInfoLayout.setOrientation(LinearLayout.VERTICAL);
mInfoLayout.addView(mNameTextView, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
mInfoLayout.addView(mNumberView, new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
this.addView(mInfoLayout, new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT));
this.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSelectedCheckBox.performClick();
}
});
}
public void display(String name, String number, boolean isSelected) {
mNameTextView.setText(name);
mNumberView.setText(number);
mSelectedCheckBox.setChecked(isSelected);
}
public void display(String name, String number, boolean isSelected, long id) {
display( name, number, isSelected);
mId = id;
}
}

View File

@ -1,255 +0,0 @@
package com.openwide.android;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.provider.Contacts.Phones;
import android.util.Log;
public class DeliveryDbAdapter {
public static final String KEY_DELIVERY_ENTRY_ROWID = "_id";
public static final String KEY_DELIVERY_ENTRY_NAME = "name";
public static final String KEY_DELIVERY_ENTRY_NUMBER = "number";
public static final String KEY_DELIVERY_ENTRY_DELIVERED = "delivered";
public static final String KEY_DELIVERY_ENTRY_DELIVERY_ID = "delivery_id";
public static final String KEY_DELIVERY_ROWID = "_id";
public static final String KEY_DELIVERY_NAME = "name";
public static final String KEY_DELIVERY_DATE = "date";
private static final String TAG = "deliveryDbAdapter";
private DeliveryDbHelper mDbHelper;
private SQLiteDatabase mDb;
/**
* Database creation sql statement
*/
public static final String DATABASE_NAME = "data";
public static final String DATABASE_DELIVERY_ENTRY_TABLE = "delivery_entry";
public static final String DATABASE_DELIVERY_TABLE = "delivery";
public static final String DATABASE_DELIVERY_ENTRY_CREATE = "create table "
+ DATABASE_DELIVERY_ENTRY_TABLE
+ " ("+KEY_DELIVERY_ENTRY_ROWID+" integer primary key autoincrement, "
+ KEY_DELIVERY_ENTRY_NAME + " text not null,"
+ KEY_DELIVERY_ENTRY_NUMBER + " text not null,"
+ KEY_DELIVERY_ENTRY_DELIVERED + " integer,"
+ KEY_DELIVERY_ENTRY_DELIVERY_ID + " integer);";
public static final String DATABASE_DELIVERY_CREATE = "create table "
+ DATABASE_DELIVERY_TABLE
+ " (" + KEY_DELIVERY_ROWID + " integer primary key autoincrement, "
+ KEY_DELIVERY_NAME + " text not null,"
+ KEY_DELIVERY_DATE + " text not null);";
public static final int DATABASE_VERSION = 3;
private final Context mCtx;
private static class DeliveryDbHelper extends SQLiteOpenHelper {
DeliveryDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_DELIVERY_ENTRY_CREATE);
db.execSQL(DATABASE_DELIVERY_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_DELIVERY_ENTRY_TABLE);
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_DELIVERY_TABLE);
onCreate(db);
}
}
/**
* Constructor - takes the context to allow the database to be
* opened/created
*
* @param ctx
* the Context within which to work
*/
public DeliveryDbAdapter(Context ctx) {
this.mCtx = ctx;
}
/**
* Open the groups database. If it cannot be opened, try to create a new
* instance of the database. If it cannot be created, throw an exception to
* signal the failure
*
* @return this (self reference, allowing this to be chained in an
* initialization call)
* @throws SQLException if the database could be neither opened or created
*/
public DeliveryDbAdapter open() throws SQLException {
mDbHelper = new DeliveryDbHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
return this;
}
public void close() {
mDbHelper.close();
}
// ********************************* ENTRY FUNCTION ***********************
/**
* Create a new entry using the name provided. If the entry is
* successfully created return the new rowId for that entry, otherwise return
* a -1 to indicate failure.
*
* @param name the name of the entry
* @param date the date of the entry
* @param deliveryID the deliveryID of the entry
*/
public long createEntry(String name, String number, long deliveryID) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_DELIVERY_ENTRY_NAME, name);
initialValues.put(KEY_DELIVERY_ENTRY_NUMBER, number);
initialValues.put(KEY_DELIVERY_ENTRY_DELIVERY_ID, deliveryID);
initialValues.put(KEY_DELIVERY_ENTRY_DELIVERED, 0);
return mDb.insert(DATABASE_DELIVERY_ENTRY_TABLE, null, initialValues);
}
/**
* Delete the entry with the given rowId
*
* @param rowId id of entry to delete
* @return true if deleted, false otherwise
*/
public boolean deleteEntry(long rowId) {
return mDb.delete(DATABASE_DELIVERY_ENTRY_TABLE, KEY_DELIVERY_ENTRY_ROWID + "=" + rowId, null) > 0 ;
}
/**
* Delete all the entries where the delivery_id is the given deliveryId
*
* @param deliveryId id of the delivery
* @return true if deleted, false otherwise
*/
public boolean deleteAllEntry(long deliveryId) {
return mDb.delete(DATABASE_DELIVERY_ENTRY_TABLE, KEY_DELIVERY_ENTRY_DELIVERY_ID + "=" + deliveryId, null) > 0 ;
}
/**
* Return a Cursor over the list of all entry in the database associated with the given delivery_id
*
* @param deliveryId id of the entry
* @return Cursor over all entries
*/
public Cursor fetchAllEntry(long deliveryId) {
return mDb.query(DATABASE_DELIVERY_ENTRY_TABLE, new String[] {KEY_DELIVERY_ENTRY_ROWID, KEY_DELIVERY_ENTRY_NAME, KEY_DELIVERY_ENTRY_NUMBER, KEY_DELIVERY_ENTRY_DELIVERED}, KEY_DELIVERY_ENTRY_DELIVERY_ID + "=" + deliveryId, null, null, null , KEY_DELIVERY_ENTRY_NAME);
}
/**
* Return a Cursor over the list of all entry in the database associated with the given delivery_id
*
* @param mDeliveryId id of the entry
* @return Cursor over all entries
*/
public Cursor fetchEntry(long entryId) {
Cursor cursor =
mDb.query(true, DATABASE_DELIVERY_ENTRY_TABLE, new String[] {KEY_DELIVERY_ENTRY_ROWID, KEY_DELIVERY_ENTRY_NAME, KEY_DELIVERY_ENTRY_NUMBER, KEY_DELIVERY_ENTRY_DELIVERED}, KEY_DELIVERY_ENTRY_DELIVERY_ID + "=" + entryId, null,
null, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
}
public boolean setEntryDelivered(long entryId) {
ContentValues content = new ContentValues();
content.put(KEY_DELIVERY_ENTRY_DELIVERED, 1);
return mDb.update(DATABASE_DELIVERY_ENTRY_TABLE, content, KEY_DELIVERY_ENTRY_ROWID +"="+entryId , null) > 0;
}
// ************************* DELIVERY *************************************
/**
* Create a new delivery using the name provided. If the delivery is
* successfully created return the new rowId for that delivery, otherwise return
* a -1 to indicate failure.
*
* @param name the name of the delivery
* @param date the date of the delivery
*/
public long createDelivery(String name, String date) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_DELIVERY_NAME, name);
initialValues.put(KEY_DELIVERY_DATE, date);
return mDb.insert(DATABASE_DELIVERY_TABLE, null, initialValues);
}
/**
* Delete the delivery with the given rowId and all entry associated
*
* @param rowId id of entry to delete
* @return true if deleted, false otherwise
*/
public boolean deleteDelivery(long rowId) {
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
*
* @param mDeliveryId id of the delivery
* @return Cursor over all delivery
*/
public Cursor fetchAllDeliveries() {
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) {
Uri contactUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(number));
Cursor c = mCtx.getContentResolver().query(contactUri, new String[] { Phones.DISPLAY_NAME }, null, null, null);
if(c != null) {
c.moveToFirst();
if(c.isFirst()) {
return c.getString(c.getColumnIndex(Phones.DISPLAY_NAME));
}else {
return "";
}
}
return "";
}
}

View File

@ -1,78 +0,0 @@
package com.openwide.android;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;
/**
*
* This class is not very usefull... It have been created so we can set Uri for deliveryEntry in the database.
* Thanks to this, sending a SMS (function sendMultipartTextMessage in MultiSmsSender) with a PendingIntent for delivery reports will use different Intent (Intent i = new Intent(message, uri))
* so PendingIntent.getBroadcast() will return different PendingIntent
*
* @author mathieu
*
*/
public class EntryContentProvider extends ContentProvider{
public static final String PROVIDER_NAME="com.openwide.android";
public static final Uri CONTENT_URI =
Uri.parse("content://"+PROVIDER_NAME+ "/entries");
private static final int ENTRIES = 1;
private static final int ENTRY_ID = 2;
private static final UriMatcher uriMatcher;
static{
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(PROVIDER_NAME, "entries", ENTRIES);
uriMatcher.addURI(PROVIDER_NAME, "entries/#", ENTRY_ID);
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public String getType(Uri uri) {
switch (uriMatcher.match(uri)){
case ENTRIES:
return "com.openwide.android.dir/entry ";
case ENTRY_ID:
return "com.openwide.android.item/entry ";
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public boolean onCreate() {
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
return null;
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
return 0;
}
}

View File

@ -1,225 +0,0 @@
/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.openwide.android;
import android.content.ContentValues;
import android.content.Context;
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;
/**
* Simple groups database access helper class. Defines the basic CRUD operations
* for the group add example, and gives the ability to list all groups as well as
* retrieve or modify a specific group.
*
*/
public class GroupsDbAdapter {
public static final String KEY_GROUP_NAME = "name";
public static final String KEY_GROUP_ROWID = "_id";
public static final String KEY_GROUP_TO_PHONE_ROWID = "_id";
public static final String KEY_GROUP_TO_PHONE_GROUPID = "gid";
public static final String KEY_GROUP_TO_PHONE_PHONEID = "pid";
private static final String TAG = "groupsDbAdapter";
private GroupDbHelper mDbHelper;
private SQLiteDatabase mDb;
/**
* Database creation sql statement
*/
private static final String DATABASE_GROUP_CREATE =
"create table groups (_id integer primary key autoincrement, "
+ "name text not null);";
private static final String DATABASE_GROUP_TO_PHONE_CREATE =
"create table group_TO_PHONE (_id integer primary key autoincrement, "
+ "gid integer not null, pid integer not null);";
private static final String DATABASE_NAME = "dataGroup";
private static final String DATABASE_GROUP_TABLE = "groups";
private static final String DATABASE_GROUP_TO_PHONE_TABLE = "group_TO_PHONE";
private static final int DATABASE_VERSION = 4;
private final Context mCtx;
private static class GroupDbHelper extends SQLiteOpenHelper {
GroupDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_GROUP_CREATE);
db.execSQL(DATABASE_GROUP_TO_PHONE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS groups");
db.execSQL("DROP TABLE IF EXISTS group_TO_PHONE");
onCreate(db);
}
}
/**
* Constructor - takes the context to allow the database to be
* opened/created
*
* @param ctx the Context within which to work
*/
public GroupsDbAdapter(Context ctx) {
this.mCtx = ctx;
}
/**
* Open the groups database. If it cannot be opened, try to create a new
* instance of the database. If it cannot be created, throw an exception to
* signal the failure
*
* @return this (self reference, allowing this to be chained in an
* initialization call)
* @throws SQLException if the database could be neither opened or created
*/
public GroupsDbAdapter open() throws SQLException {
mDbHelper = new GroupDbHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
return this;
}
public void close() {
mDbHelper.close();
}
/**
* Create a new group using the name provided. If the group is
* successfully created return the new rowId for that group, otherwise return
* a -1 to indicate failure.
*
* @param name the name of the group
*/
public long createGroup(String name) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_NAME, name);
return mDb.insert(DATABASE_GROUP_TABLE, null, initialValues);
}
/**
* Delete the group with the given rowId
*
* @param rowId id of group to delete
* @return true if deleted, false otherwise
*/
public boolean deleteGroup(long rowId) {
return mDb.delete(DATABASE_GROUP_TABLE, KEY_GROUP_ROWID + "=" + rowId, null) > 0 && mDb.delete(DATABASE_GROUP_TO_PHONE_TABLE, KEY_GROUP_TO_PHONE_GROUPID + "=" + rowId, null) > 0;
}
/**
* Return a Cursor over the list of all groups in the database
*
* @return Cursor over all groups
*/
public Cursor fetchAllGroups() {
return mDb.query(DATABASE_GROUP_TABLE, new String[] {KEY_GROUP_ROWID, KEY_GROUP_NAME}, null, null, null, null, KEY_GROUP_NAME);
}
/**
* Return a Cursor positioned at the group that matches the given rowId
*
* @param rowId id of group to retrieve
* @return Cursor positioned to matching group, if found
* @throws SQLException if group could not be found/retrieved
*/
public Cursor fetchGroup(long rowId) throws SQLException {
Cursor mCursor =
mDb.query(true, DATABASE_GROUP_TABLE, new String[] {KEY_GROUP_ROWID, KEY_GROUP_NAME}, KEY_GROUP_ROWID + "=" + rowId, null,
null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
/**
* @param rowId id of group to update
* @param name value to set group name to
*/
public boolean updateGroup(long rowId, String name) {
ContentValues args = new ContentValues();
args.put(KEY_GROUP_NAME, name);
return mDb.update(DATABASE_GROUP_TABLE, args, KEY_GROUP_ROWID + "=" + rowId, null) > 0;
}
public Cursor fetchPhonesFromGroup(long groupId) {
Cursor mCursor = mDb.query(true, DATABASE_GROUP_TO_PHONE_TABLE, new String[] {KEY_GROUP_TO_PHONE_PHONEID}, KEY_GROUP_TO_PHONE_GROUPID + "=" + groupId, null, null, null, null, null);
Cursor userCursor = null;
int phoneIdIdx = mCursor.getColumnIndex(KEY_GROUP_TO_PHONE_PHONEID);
if(mCursor != null) {
userCursor = mCtx.getContentResolver().query(Phones.CONTENT_URI, null, "Phones."+ Phones._ID +" IN "+ cursorToStringList(mCursor, phoneIdIdx), null, Phones.NAME);
}
return userCursor;
}
public long addPhoneToGroup(long groupId, long phoneId ) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_GROUP_TO_PHONE_GROUPID, groupId);
initialValues.put(KEY_GROUP_TO_PHONE_PHONEID, phoneId);
return mDb.insert(DATABASE_GROUP_TO_PHONE_TABLE, null, initialValues);
}
public boolean removePhoneToGroup(long groupId, long phoneId) {
return mDb.delete(DATABASE_GROUP_TO_PHONE_TABLE, KEY_GROUP_TO_PHONE_GROUPID + "=" + groupId+ " AND "+ KEY_GROUP_TO_PHONE_PHONEID + "=" + phoneId, null) > 0;
}
public String cursorToStringList(Cursor cursor, int columnIdx) {
cursor.moveToFirst();
String list = "( ";
while(!cursor.isAfterLast()) {
list += cursor.getString(columnIdx);
if(!cursor.isLast()) {
list += " , ";
}
cursor.moveToNext();
}
list +=" )";
return list;
}
}

View File

@ -1,42 +0,0 @@
package com.openwide.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
public class MessageReceiver extends BroadcastReceiver{
public static final String MESSAGE_RECEIVED = "com.openwide.android.SMS_RECEIVED";
public static final String ANDROID_MESSAGE_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
public static final String DEBUG_TAG="-------MessageReceiver--------";
@Override
public void onReceive(Context context, Intent intent) {
if (MESSAGE_RECEIVED.equals(intent.getAction())) {
Log.d(DEBUG_TAG, "SMS_RECEIVED");
Long entryId;
//Bundle extras = intent.getExtras();
//entryId = extras != null ? extras.getLong(MultiSmsSender.PARAM_ENTRY_ID): null;
Uri entryURI = intent.getData();
String entryStr = entryURI.getLastPathSegment();
entryId = Long.parseLong(entryStr);
//byte[] pdu = (byte[]) intent.getByteArrayExtra("pdu");
//SmsMessage message = SmsMessage.createFromPdu(pdu);
//int status = message.getStatus();
if(entryId != null) {
DeliveryDbAdapter mDbHelper = new DeliveryDbAdapter(context);
mDbHelper.open();
mDbHelper.setEntryDelivered(entryId);
mDbHelper.close();
}
}
}
}

View File

@ -1,286 +0,0 @@
package com.openwide.android;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
public class MultiSmsSender extends Activity {
private Button mAddButton;
private Button mSend;
private TextView mContacts;
private TextView mEditor;
private CheckBox mDeliveryCheckBox;
private DeliveryDbAdapter mDbHelper;
private ProgressDialog mSendingDialog;
public static final int ACTIVITY_EDIT = 0;
public static final int ACTIVITY_ADD_GROUP = 1;
public static final int ACTIVITY_DELIVERY = 2;
private static final int SENDING_DIALOG_KEY = 0;
private static final int INSERT_ID = Menu.FIRST;
public static final String PARAM_NUMBERS_LIST = "param number list";
public static final String PARAM_FLUSH = "param flush";
public static final String PARAM_ENTRY_ID = "entry_id";
public static final String DEBUG_TAG="MultiSmsSender";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mDbHelper = new DeliveryDbAdapter(this);
mDbHelper.open();
mAddButton = (Button) findViewById(R.id.contacts);
mSend = (Button) findViewById(R.id.send);
mContacts = (TextView) findViewById(R.id.numbers);
mEditor = (TextView) findViewById(R.id.editor);
mDeliveryCheckBox = (CheckBox) findViewById(R.id.deliveryCheckBox);
mContacts.setImeOptions(EditorInfo.IME_ACTION_NEXT);
mEditor.setImeOptions(EditorInfo.IME_ACTION_DONE);
mAddButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectNumbers();
}
});
mSend.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
sendMessage();
}
});
}
public void selectNumbers() {
Intent i = new Intent(this, PhoneNumberSelection.class);
String rawNumbers = mContacts.getText().toString();
String[] numbers = rawNumbers.split(",");
i.putExtra(PARAM_NUMBERS_LIST, numbers);
startActivityForResult(i, ACTIVITY_EDIT);
}
public void sendMessage() {
MySMSManager manager = new MySMSManager();
String message = mEditor.getText().toString();
if("".equals(message)) {
return;
}
String[] numbers = mContacts.getText().toString().split(",");
HashSet<String> allreadySend = new HashSet<String>();
int size = numbers.length;
boolean haveDeliveryReports = mDeliveryCheckBox.isChecked();
long deliveryId = -1;
ArrayList<String> messages = manager.divideMessage(message);
int messageCount = messages.size();
//showDialog(SENDING_DIALOG_KEY);
mSendingDialog = new ProgressDialog(this);
mSendingDialog.setTitle(R.string.sending);
mSendingDialog.setMessage(getResources().getString(R.string.wait));
mSendingDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mSendingDialog.setIndeterminate(true);
mSendingDialog.setCancelable(false);
mSendingDialog.setMax(size);
mSendingDialog.show();
if (haveDeliveryReports) {
deliveryId = mDbHelper.createDelivery(message.substring(0, Math.min(30, message
.length())).replace('\n', ' '), DateFormat.getDateInstance()
.format(new Date()));
}
if (numbers.length != 0) {
for (int i = 0; i < numbers.length; i++) {
String newN = numbers[i].trim();
if (!newN.equals("")
&& PhoneNumberUtils.isWellFormedSmsAddress(newN)) {
mSendingDialog.setProgress(i / size);
if (!allreadySend.contains(newN)) {
allreadySend.add(newN);
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>(messageCount);
ArrayList<PendingIntent> sentIntents = null;
if (haveDeliveryReports) {
long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId);
Log.d(DEBUG_TAG, "entry is "+entryId);
for (int j = 0; j < messageCount; j++) {
Uri entryURI = Uri.withAppendedPath(EntryContentProvider.CONTENT_URI, ""+entryId);
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED,entryURI, this, MessageReceiver.class);
//intent.putExtra(PARAM_ENTRY_ID, entryId);
deliveryIntents.add(PendingIntent.getBroadcast(
this, 0, intent, 0));
}
}
manager.sendMultipartTextMessage(newN, null, messages, sentIntents, deliveryIntents );
}
}
}
mSendingDialog.dismiss();
new AlertDialog.Builder(this).setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).setMessage(
allreadySend.size() + " "
+ getResources().getString(R.string.message_sent))
.show();
} else {
new AlertDialog.Builder(this).setPositiveButton(
getResources().getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).setMessage(
getResources().getString(R.string.enter_number)).show();
}
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case SENDING_DIALOG_KEY: {
mSendingDialog = new ProgressDialog(this);
mSendingDialog.setTitle(R.string.sending);
mSendingDialog.setMessage(getResources().getString(R.string.wait));
mSendingDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mSendingDialog.setIndeterminate(true);
mSendingDialog.setCancelable(false);
return mSendingDialog;
}
}
return null;
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case ACTIVITY_ADD_GROUP:
case ACTIVITY_EDIT:
if (intent != null) {
String[] numbers = intent.getExtras().getStringArray(
PARAM_NUMBERS_LIST);
boolean flush = intent.getExtras().getBoolean(PARAM_FLUSH);
String string = "";
HashSet<String> res = new HashSet<String>();
for (int i = 0; i < numbers.length; i++) {
String newN = numbers[i].trim();
if (!newN.equals("")) {
res.add(newN);
}
}
if (!flush) {
String oldContactsString = mContacts.getText().toString();
String[] oldContacts = oldContactsString.split(",");
for (int i = 0; i < oldContacts.length; i++) {
String newN = oldContacts[i].trim();
if (!newN.equals("")) {
res.add(newN);
}
}
}
for (String number : res) {
string += number + ", ";
}
mContacts.setText(string);
}
break;
default:
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID, 0, R.string.add_group);
menu.add(0, INSERT_ID + 1, 0, R.string.delivery);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case INSERT_ID:
display_group_list();
return true;
case INSERT_ID + 1:
display_delivery_list();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
protected void onDestroy() {
mDbHelper.close();
super.onDestroy();
}
public void display_group_list() {
Intent i = new Intent(this, SelectGroupActivity.class);
startActivityForResult(i, ACTIVITY_ADD_GROUP);
}
public void display_delivery_list() {
Intent i = new Intent(this, SelectDeliveryActivity.class);
startActivityForResult(i, ACTIVITY_DELIVERY);
}
}

View File

@ -1,77 +0,0 @@
package com.openwide.android;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import android.app.PendingIntent;
import android.os.Build;
import android.util.Log;
public class MySMSManager {
private static Object manager;
private static Method getDefault;
private static Method divide;
private static Method sendMutlipart;
public MySMSManager() {
if(manager == null) {
String className;
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if (sdkVersion <= 3) { //CUPCAKE
Log.d("MultiSMSSender", "Cupcake version");
className = "android.telephony.gsm.SmsManager";
} else {
Log.d("MultiSMSSender", "version > Cupcake");
className = "android.telephony.SmsManager";
}
try {
Class clazz =
Class.forName(className);
Object[] paramInvoke = new Object[0];
Class[] signGetDefault = new Class[]{};
Class<String>[] signDivide = new Class[] {String.class};
Class[] signSend = new Class[] {String.class, String.class, ArrayList.class, ArrayList.class, ArrayList.class};
getDefault = clazz.getMethod("getDefault", signGetDefault);
divide = clazz.getMethod("divideMessage", signDivide);
sendMutlipart = clazz.getMethod("sendMultipartTextMessage", signSend);
manager = getDefault.invoke(null, paramInvoke);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public ArrayList<String> divideMessage(String text){
Object[] param = new Object[1];
param[0] = text;
try {
return (ArrayList<String>)divide.invoke(manager, param);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
public void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents ) {
Object[] param = new Object[5];
param[0] = destinationAddress;
param[1] = scAddress;
param[2] = parts;
param[3] = sentIntents;
param[4] = deliveryIntents;
try {
sendMutlipart.invoke(manager, param);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}

View File

@ -1,205 +0,0 @@
package com.openwide.android;
import java.util.HashSet;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Phones;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.SimpleCursorAdapter;
public class PhoneNumberSelection extends ListActivity
{
PhoneDataListAdapter mAdpater;
HashSet<String> mSelectedSet;
private static final int INSERT_ID = Menu.FIRST;
private static final int SELECT_ALL_ID = Menu.FIRST + 1;
private static final int DESELECT_ALL_ID = Menu.FIRST + 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.number_list);
String[] selected;
selected = savedInstanceState != null ? savedInstanceState.getStringArray(MultiSmsSender.PARAM_NUMBERS_LIST ) : null;
if (selected == null) {
Bundle extras = getIntent().getExtras();
selected = extras != null ? extras.getStringArray(MultiSmsSender.PARAM_NUMBERS_LIST ) : null;
}
mSelectedSet = new HashSet<String>();
for (int i = 0; i < selected.length; i++) {
mSelectedSet.add(selected[i].trim());
}
fillData();
Button ok = (Button) findViewById(R.id.okContacts);
ok.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent();
String [] numbers = new String[mSelectedSet.size()];
mSelectedSet.toArray(numbers);
Bundle bundle = new Bundle();
bundle.putStringArray(MultiSmsSender.PARAM_NUMBERS_LIST, numbers);
bundle.putBoolean(MultiSmsSender.PARAM_FLUSH, true);
i.putExtras(bundle);
setResult(RESULT_OK, i);
finish();
}
});
}
private void fillData() {
Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, Phones.NAME);
startManagingCursor(c);
mAdpater = new PhoneDataListAdapter(this, R.layout.number_row, c, new String[] {
Phones.NAME, Phones.NUMBER
}, new int[] {R.id.name, R.id.phone}, mSelectedSet);
setListAdapter(mAdpater);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID,0, R.string.add_group);
menu.add(0, SELECT_ALL_ID, 0, R.string.select_all);
menu.add(0, DESELECT_ALL_ID, 0, R.string.deselect_all);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case INSERT_ID:
display_group_list();
return true;
case SELECT_ALL_ID:
Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, Phones.NAME);
int numberIdx = c.getColumnIndex(Phones.NUMBER);
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {
mSelectedSet.add(c.getString(numberIdx));
c.moveToNext();
}
fillData();
return true;
case DESELECT_ALL_ID:
mSelectedSet = new HashSet<String>();
fillData();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
public void display_group_list(){
Intent i = new Intent(this, SelectGroupActivity.class);
startActivityForResult(i, MultiSmsSender.ACTIVITY_ADD_GROUP);
}
/*@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
l.getItemAtPosition(position);
}*/
/*@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putStringArray(MultiSmsSender.PARAM_NUMBERS_LIST, (String[] )mAdpater.selected.toArray());
}
@Override
protected void onPause() {
super.onPause();
}*/
public class PhoneDataListAdapter extends SimpleCursorAdapter{
int nameidx;
int numberidx;
Context mContext;
public PhoneDataListAdapter(Context context, int layout, Cursor c,
String[] from, int[] to, HashSet<String> selected) {
super(context, layout, c, from, to);
nameidx = c.getColumnIndex(Phones.NAME);
numberidx = c.getColumnIndex(Phones.NUMBER);
mContext = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
Cursor c = getCursor();
c.moveToPosition(position);
String name = c.getString(nameidx);
String number = c.getString(numberidx);
ContactRow contact;
if (convertView == null) {
contact = new ContactRow(mContext);
}else {
contact = (ContactRow) convertView;
}
contact.display(name, number, mSelectedSet.contains(number));
contact.mSelectedCheckBox.setOnClickListener(new addNumberToSelectedClickListener(contact));
return contact;
}
}
private class addNumberToSelectedClickListener implements OnClickListener{
ContactRow contact;
public addNumberToSelectedClickListener(ContactRow contact) {
this.contact = contact;
}
public void onClick(View v) {
CheckBox checkBox = (CheckBox)v;
if(checkBox.isChecked()) {
mSelectedSet.add(contact.mNumberView.getText().toString());
}else {
mSelectedSet.remove(contact.mNumberView.getText().toString());
}
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if(intent != null) {
String [] numbers = intent.getExtras().getStringArray(MultiSmsSender.PARAM_NUMBERS_LIST);
for (int i = 0; i < numbers.length; i++) {
mSelectedSet.add(numbers[i]);
}
fillData();
}
}
}