Skip to content
This repository was archived by the owner on Mar 27, 2020. It is now read-only.

Commit 82f4d2a

Browse files
committed
Fixed blank message issue and fixed tests
1 parent 3079a33 commit 82f4d2a

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/main/java/com/apb/beacon/model/SMSSettings.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ public SMSSettings(List<String> phoneNumbers, String message) {
2929
this.message = message;
3030
}
3131

32-
public static void save(Context context, SMSSettings smsSettings) {
32+
public static void saveContacts(Context context, SMSSettings smsSettings) {
3333
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
3434
SharedPreferences.Editor editor = settings.edit();
3535
int i = 0;
3636
for (String phoneNumber : smsSettings.phoneNumbers) {
3737
String validPhoneDigit = phoneNumber.replaceAll("[- ]", "");
3838
editor.putString(PHONE_NUMBER + i++, validPhoneDigit);
3939
}
40-
editor.putString(SMS_MESSAGE, smsSettings.message);
4140
editor.commit();
4241
}
4342

src/main/java/com/apb/beacon/sms/SetupContactsFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void onClick(View v) {
8383
Log.e(">>>>", "action button pressed");
8484
SMSSettings newSMSSettings = getSMSSettingsFromView();
8585

86-
SMSSettings.save(activity, newSMSSettings);
86+
SMSSettings.saveContacts(activity, newSMSSettings);
8787
displaySettings(newSMSSettings);
8888

8989
String pageId = currentPage.getAction().get(0).getLink();

src/test/java/com/apb/beacon/alert/PanicMessageTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public void setUp() {
5555
finerLocation = LocationTestUtil.location(LocationManager.NETWORK_PROVIDER, finerLatitude, finerLongitude, currentTimeMillis(), 10.0f);
5656

5757
SMSSettings smsSettings = new SMSSettings(asList(mobile1, mobile2, mobile3), message);
58-
SMSSettings.save(context, smsSettings);
58+
SMSSettings.saveContacts(context, smsSettings);
59+
SMSSettings.saveMessage(context, message);
5960
}
6061

6162
@Test

src/test/java/com/apb/beacon/location/LocationUpdateReceiverTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ public void shouldReturnLocationWhichHasAlmostSameAccuracyAndRelativelyNew() {
9898
public void shouldReturnLocationFromSameProviderAndNotSignificantlyAccurateButRelativelyNew() {
9999
Location oldLocation = location(NETWORK_PROVIDER, 12.0, 20.0, currentTimeMillis(), LESS_ACCURATE);
100100
Location lessAccurateButNewLocation = location(NETWORK_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(10), VERY_LESS_ACCURATE);
101-
Location diffProviderLocation = location(GPS_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(20), VERY_LESS_ACCURATE + 10.0f);
101+
Location diffMoreAccurateProviderLocation = location(GPS_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(20), VERY_LESS_ACCURATE + 10.0f);
102102
Location significantlyLessAccurateLocation = location(NETWORK_PROVIDER, 13.0, 20.0, offsetCurrentTimeBy(10), SIGNIFICANTLY_LESS_ACCURATE);
103103

104104
locationUpdateReceiver.onReceive(context, getIntent(oldLocation));
105105
locationUpdateReceiver.onReceive(context, getIntent(lessAccurateButNewLocation));
106-
locationUpdateReceiver.onReceive(context, getIntent(diffProviderLocation));
106+
locationUpdateReceiver.onReceive(context, getIntent(diffMoreAccurateProviderLocation));
107107
locationUpdateReceiver.onReceive(context, getIntent(significantlyLessAccurateLocation));
108108

109-
assertLocation(lessAccurateButNewLocation);
109+
assertLocation(diffMoreAccurateProviderLocation);
110110
}
111111

112112
private Intent getIntent(Location location) {

src/test/java/com/apb/beacon/model/SMSSettingsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public void shouldSaveAndRetrieveSMSSettings() throws Exception {
3030

3131
SMSSettings smsSettings = new SMSSettings(expectedPhoneNumbers, expectedMessage);
3232

33-
SMSSettings.save(context, smsSettings);
33+
SMSSettings.saveContacts(context, smsSettings);
34+
SMSSettings.saveMessage(context, expectedMessage);
3435
SMSSettings retrievedSMSSettings = SMSSettings.retrieve(context);
3536

3637
assertEquals(expectedMessage, retrievedSMSSettings.message());

0 commit comments

Comments
 (0)