Skip to content

Commit 318eba9

Browse files
committed
Merge branch 'develop'
2 parents c511de5 + c1b4e1d commit 318eba9

28 files changed

+159
-140
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
mavenCentral()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:0.10.4'
7+
classpath 'com.android.tools.build:gradle:0.11.+'
88
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
99
}
1010
}

changelog.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
[
2+
{
3+
"version": "v2.6.1",
4+
"date": "June 23, 2014",
5+
"features": [
6+
"Added device id ",
7+
"Removed beta tag from version number"
8+
],
9+
"bugs": [
10+
"Fixed task checking not executing",
11+
"Changed scheduler frequency time to support hour and minutes not minutes and seconds"
12+
]
13+
},
214
{
315
"version": "v2.6",
416
"date": "June 19, 2014",

release.sh

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Make a release to the SMSSync app.
4+
# TODO:: Look into making this a Gradle task
45

56
if [[ $# -lt 2 ]]
67
then
@@ -12,53 +13,28 @@ TAG_NAME=$1
1213
TAG_MESSAGE=$2
1314
DEVELOP='develop'
1415
MASTER='master'
15-
RELEASE='release'
1616
echo $TAG_MESSAGE
1717

1818
# SMSSync source code
1919
SMSSYNC='smssync'
2020

21-
# Merge release to master and develop
22-
23-
# Checkout develop branch
24-
echo "Checking out the develop branch..."
25-
git checkout $DEVELOP
26-
27-
# Merge release branch into the develop branch
28-
echo "Merging release branch into develop..."
29-
git merge $RELEASE
21+
# Merge develop branch into master
3022

3123
# Checkout master branch
3224
echo "Checking out the master branch..."
3325
git checkout $MASTER
3426

35-
# Merge release branch into master branch
36-
echo "Merging release branch into"
37-
git merge $RELEASE
27+
# Merge develop branch into master branch
28+
echo "Merging develop branch into master"
29+
git merge $DEVELOP
3830

39-
# Delete the release branch
40-
echo "Deleting local release branch..."
41-
git branch -d $RELEASE
42-
43-
# Delete remote release branch
44-
echo "Deleting remote release branch..."
45-
git push origin --delete $RELEASE
46-
47-
# Create the release tag
31+
# Create the signed release tag
4832
echo "Creating release tag $TAG_NAME ..."
49-
git tag -a $TAG_NAME -m $TAG_MESSAGE
50-
51-
# Push newly created tag to remote host
52-
echo "Pushing new tag to remote host..."
53-
git push --tags
54-
55-
# Create the release build
56-
echo "Changing directory into $SMSSYNC"
57-
pushd $SMSSYNC
33+
git tag -s $TAG_NAME -m $TAG_MESSAGE
5834

5935
# Create a release apk
6036
echo "Building a release apk"
61-
ant clean release
37+
./gradlew clean assemble
6238

6339
# Back to where we were before
6440
popd

smssync/build.gradle

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
}
2727

2828
defaultConfig {
29-
testPackageName "org.addhen.smssync.tests"
30-
packageName "org.addhen.smssync"
29+
testApplicationId "org.addhen.smssync.tests"
30+
applicationId "org.addhen.smssync"
3131
}
3232

3333
// Move the build types to build-types/<type>
@@ -54,11 +54,21 @@ android {
5454
}
5555

5656
release {
57+
if (project.hasProperty('googleAnalyticsCode')) {
58+
resValue "string", "ga_trackingId", "${googleAnalyticsCode}"
59+
} else{
60+
resValue "string", "ga_trackingId", ""
61+
}
5762
signingConfig signingConfigs.releaseSign
5863
}
5964

6065
debug {
61-
packageNameSuffix ".debug"
66+
if (project.hasProperty('googleAnalyticsCode')) {
67+
resValue "string", "ga_trackingId", "${googleAnalyticsCode}"
68+
} else{
69+
resValue "string", "ga_trackingId", ""
70+
}
71+
applicationIdSuffix ".debug"
6272
versionNameSuffix "-DEBUG"
6373
}
6474

@@ -71,8 +81,8 @@ android {
7181
}
7282

7383
defaultConfig {
74-
versionCode 21
75-
versionName "2.6"
84+
versionCode 22
85+
versionName "2.6.1"
7686
minSdkVersion 8
7787
targetSdkVersion 19
7888
}
@@ -87,19 +97,6 @@ android {
8797
}
8898

8999
android.applicationVariants.all { variant ->
90-
// add google analytics code here. This is defined in the gradle.properties file
91-
variant.mergeResources.doLast {
92-
if (project.hasProperty('googleAnalyticsCode')) {
93-
File valuesFile =
94-
file("${buildDir}/res/all/${variant.dirName}/values/values.xml")
95-
def analyticsCode = "<string name=\"ga_trackingId\">${googleAnalyticsCode}</string>"
96-
97-
String content = valuesFile.getText('UTF-8')
98-
content = content.replaceAll("<string name=\"ga_trackingId\"></string>",
99-
analyticsCode)
100-
valuesFile.write(content, 'UTF-8')
101-
}
102-
}
103100

104101
def apk = variant.outputFile;
105102

smssync/src/main/java/org/addhen/smssync/Settings.java

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.addhen.smssync;
1919

2020

21+
import org.addhen.smssync.util.Logger;
2122
import org.addhen.smssync.util.RunServicesUtil;
2223
import org.addhen.smssync.util.TimePreference;
2324
import org.addhen.smssync.util.Util;
@@ -117,8 +118,6 @@ protected void onCreate(Bundle savedInstanceState) {
117118
versionLabel.append(" ");
118119
versionLabel.append("v");
119120
versionLabel.append(versionName);
120-
versionLabel.append(" ");
121-
versionLabel.append(getString(R.string.version_status));
122121
} catch (NameNotFoundException e) {
123122
// TODO Auto-generated catch block
124123
e.printStackTrace();
@@ -301,12 +300,15 @@ protected void savePreferences() {
301300
}
302301

303302
if (!TextUtils.isEmpty(uniqueId.getText())) {
304-
uniqueIdValidate(uniqueId.getText());
305-
editor.putString("UniqueId", "");
306-
if (uniqueIdValidityStatus == 0) {
307-
editor.putString("UniqueId", uniqueId.getText());
303+
String id = Util.removeWhitespaces(uniqueId.getText().toString());
304+
editor.putString("UniqueId", id);
305+
if(!Prefs.uniqueId.equals(uniqueId.getText().toString())) {
306+
Util.logActivities(this,
307+
getString(R.string.settings_changed, uniqueId.getTitle().toString(),
308+
Prefs.uniqueId, id));
308309
}
309310
}
311+
310312
editor.commit();
311313
}
312314

@@ -344,14 +346,6 @@ protected void onDestroy() {
344346
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
345347
String key) {
346348

347-
// Unique ID
348-
if (key.equals(KEY_UNIQUE_ID)) {
349-
final String savedId = sharedPreferences.getString(KEY_UNIQUE_ID,
350-
"");
351-
if (!TextUtils.isEmpty(savedId))
352-
uniqueIdValidate(savedId);
353-
}
354-
355349
if (key.equals(KEY_ENABLE_REPLY)) {
356350

357351
if (sharedPreferences.getBoolean(KEY_ENABLE_REPLY, false)) {
@@ -500,37 +494,6 @@ public void run() {
500494
}
501495
};
502496

503-
/**
504-
* Thread to validate unique id
505-
*
506-
* @param uniqueId The Callback Url to be validated.
507-
* @return void
508-
*/
509-
public void uniqueIdValidate(final String uniqueId) {
510-
511-
Thread t = new Thread() {
512-
public void run() {
513-
514-
// validate number of digits
515-
if ((uniqueId.length() == 0) || TextUtils.isEmpty(uniqueId)) {
516-
uniqueIdValidityStatus = 1;
517-
mHandler.post(mUniqueId);
518-
} else {
519-
// validate if it's a numeric value
520-
try {
521-
Integer.parseInt(uniqueId);
522-
uniqueIdValidityStatus = 0;
523-
} catch (NumberFormatException ex) {
524-
uniqueIdValidityStatus = 2;
525-
mHandler.post(mUniqueId);
526-
}
527-
mHandler.post(mUniqueId);
528-
}
529-
}
530-
};
531-
t.start();
532-
}
533-
534497
/**
535498
* A convenient method to return boolean values to a more meaningful format
536499
*

smssync/src/main/java/org/addhen/smssync/fragments/SyncUrlFragment.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ private void editSyncScheme() {
336336
editScheme.keySentTimeStamp
337337
.setText(scheme.getKey(SyncScheme.SyncDataKey.SENT_TIMESTAMP));
338338
editScheme.keySentTo.setText(scheme.getKey(SyncScheme.SyncDataKey.SENT_TO));
339+
editScheme.keyDeviceID.setText(scheme.getKey(SyncScheme.SyncDataKey.DEVICE_ID));
339340

340341
editScheme.methods.setSelection(scheme.getMethod().ordinal());
341342
editScheme.dataFormats.setSelection(scheme.getDataFormat().ordinal());
@@ -387,9 +388,7 @@ public void loadSyncUrlInBackground() {
387388
}
388389

389390
public void loadByStatus() {
390-
LoadingTask loadingStatusTask = new LoadingTask(getActivity());
391-
loadingStatusTask.loadSyncUrlByStatus = true;
392-
loadingStatusTask.execute((String) null);
391+
syncUrl = model.loadByStatus(1);
393392
}
394393

395394
/*

smssync/src/main/java/org/addhen/smssync/messages/ProcessMessage.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ public boolean saveMessage(Message message) {
7171
public boolean syncReceivedSms(Message message, SyncUrl syncUrl) {
7272
Logger.log(TAG, "syncReceivedSms(): Post received SMS to configured URL:" +
7373
message.toString() + " SyncUrlFragment: " + syncUrl.toString());
74+
Prefs.loadPreferences(context);
7475

7576
MessageSyncHttpClient client = new MessageSyncHttpClient(
76-
context, syncUrl, message, Util.getPhoneNumber(context)
77+
context, syncUrl, message, Util.getPhoneNumber(context), Prefs.uniqueId
7778
);
7879
final boolean posted = client.postSmsToWebService();
7980

@@ -224,6 +225,7 @@ public void performTask(SyncUrl syncUrl) {
224225

225226
if (payloadObject != null) {
226227
String task = payloadObject.getString("task");
228+
Logger.log(TAG, "Task "+task);
227229
boolean secretOk = TextUtils.isEmpty(urlSecret) ||
228230
urlSecret.equals(payloadObject.getString("secret"));
229231
if (secretOk && task.equals("send")) {
@@ -232,8 +234,12 @@ public void performTask(SyncUrl syncUrl) {
232234

233235
for (int index = 0; index < jsonArray.length(); ++index) {
234236
jsonObject = jsonArray.getJSONObject(index);
237+
238+
// Make sure message UUID has been set before attempting to get.
239+
// This should work with pre 2.5 releases
240+
String uuid = jsonObject.has("uuid") ? jsonObject.getString("uuid") : "";
235241
processSms.sendSms(jsonObject.getString("to"),
236-
jsonObject.getString("message"), jsonObject.getString("uuid"));
242+
jsonObject.getString("message"), uuid);
237243

238244
Util.logActivities(context,
239245
context.getString(R.string.processed_task,
@@ -263,7 +269,7 @@ public void performTask(SyncUrl syncUrl) {
263269
}
264270

265271
/**
266-
* Processes the incoming SMS to figure out how to exactly to route the message. If it fails to
272+
* Processes the incoming SMS to figure out how to exactly route the message. If it fails to
267273
* be synced online, cache it and queue it up for the scheduler to process it.
268274
*
269275
* @param message The sms to be routed

smssync/src/main/java/org/addhen/smssync/messages/ProcessSms.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,13 @@ public void sendSms(String sendTo, String msg, String uuid) {
367367
SmsManager sms = SmsManager.getDefault();
368368
ArrayList<String> parts = sms.divideMessage(msg);
369369
String validUUID;
370+
370371
if (null == uuid || "".equals(uuid)) {
371372
validUUID = getUuid();
372373
} else {
373374
validUUID = uuid;
374375
}
376+
375377
final Long timeMills = System.currentTimeMillis();
376378
Message message = new Message();
377379
message.setBody(msg);
@@ -380,15 +382,19 @@ public void sendSms(String sendTo, String msg, String uuid) {
380382
message.setUuid(validUUID);
381383

382384
for (int i = 0; i < parts.size(); i++) {
385+
383386
Intent sentMessageIntent = new Intent(ServicesConstants.SENT);
384387
sentMessageIntent.putExtra(ServicesConstants.SENT_SMS_BUNDLE, message);
388+
385389
PendingIntent sentIntent = PendingIntent.getBroadcast(context,
386390
(int) System.currentTimeMillis(), sentMessageIntent, PendingIntent.FLAG_UPDATE_CURRENT);
387391

388392
Intent delivered = new Intent(ServicesConstants.DELIVERED);
389-
delivered.putExtra(ServicesConstants.DELIVERED_SMS_BUNDLE, message);
393+
delivered.putExtra(ServicesConstants.DELIVERED_SMS_BUNDLE, message);
394+
390395
PendingIntent deliveryIntent = PendingIntent.getBroadcast(context,
391396
(int) System.currentTimeMillis(), delivered, PendingIntent.FLAG_UPDATE_CURRENT);
397+
392398
sentIntents.add(sentIntent);
393399

394400
deliveryIntents.add(deliveryIntent);
@@ -399,7 +405,6 @@ public void sendSms(String sendTo, String msg, String uuid) {
399405
* sms.sendMultipartTextMessage(sendTo, null, parts, sentIntents,
400406
* deliveryIntents);
401407
*/
402-
403408
sms.sendMultipartTextMessage(sendTo, null, parts, sentIntents,
404409
deliveryIntents);
405410

smssync/src/main/java/org/addhen/smssync/models/Message.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,19 @@ public void setDeliveryResultMessage(String mDeliveryResultMessage) {
191191
this.mDeliveryResultMessage = mDeliveryResultMessage;
192192
}
193193

194+
@Override
195+
public String toString() {
196+
return "Message{" +
197+
"body='" + body + '\'' +
198+
", from='" + from + '\'' +
199+
", timestamp='" + timestamp + '\'' +
200+
", uuid='" + uuid + '\'' +
201+
", mMessageType=" + mMessageType +
202+
", mSentResultCode=" + mSentResultCode +
203+
", mSentResultMessage='" + mSentResultMessage + '\'' +
204+
", mDeliveryResultCode=" + mDeliveryResultCode +
205+
", mDeliveryResultMessage='" + mDeliveryResultMessage + '\'' +
206+
", mMessageList=" + mMessageList +
207+
'}';
208+
}
194209
}

0 commit comments

Comments
 (0)