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

Commit

Permalink
#178 modifying settings and adding logs
Browse files Browse the repository at this point in the history
  • Loading branch information
niccs committed Feb 2, 2016
1 parent f0bafb6 commit e111af6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
8 changes: 3 additions & 5 deletions app/src/main/java/org/iilab/pb/alert/PanicAlert.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@
import static org.iilab.pb.common.Intents.locationPendingIntent;

public class PanicAlert {

private static final String TAG = PanicAlert.class.getName();
private LocationManager locationManager;
private Context context;
private AlarmManager alarmManager1, alarmManager2;

// TODO --for testing vibrations
public int VIBRATION_DURATION_SHORT ;
public int VIBRATION_PAUSE_SHORT ;
public int VIBRATION_DURATION_LONG ;
public int VIBRATION_PAUSE_LONG ;

public PanicAlert(Context context) {
this.context = context;
Expand Down Expand Up @@ -83,8 +79,10 @@ public void deActivate() {
}

private void sendFirstAlert() {
Log.d(TAG, "inside of sendFirstAlert");
CurrentLocationProvider currentLocationProvider = getCurrentLocationProvider();
Location loc = getLocation(currentLocationProvider);
Log.d(TAG, "Identified location is "+loc);
if (loc != null) {
ApplicationSettings.setFirstMsgWithLocationTriggered(context, true);
} else {
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/org/iilab/pb/alert/SMSAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
import org.iilab.pb.common.ApplicationSettings;

public class SMSAdapter {
private static final String LOG_TAG = SMSAdapter.class.getName();
private static final String TAG = SMSAdapter.class.getName();

public void sendSMS(Context context, String phoneNumber, String message) {
// Log.e("20140411", "sending fake SMS -> " + message);
if(!ApplicationSettings.isFirstMsgSent(context)){
ApplicationSettings.setFirstMsgSent(context, true);
}
SmsManager smsManager = getSmsManager();
Log.d(TAG, "Sms manager is : " + getSmsManager());
try {
smsManager.sendTextMessage(phoneNumber, null, message, null, null);
Log.i(LOG_TAG, "Sms sent: " + message);
Log.d(TAG, "Sms sent: " + message);
} catch (Exception exception) {
Log.e(LOG_TAG, "Sending SMS failed " + exception.getMessage());
exception.printStackTrace();
Log.e(TAG, "Sending SMS failed " + exception.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public static boolean isHardwareTriggerServiceEnabled(Context context) {
}


public static void setInitialClicksForAlertTrigger(Context context, String initialPresses) {
saveString(context,context.getString(R.string.initialPressesKey),initialPresses);
}
public static String getInitialClicksForAlertTrigger(Context context) {
return sharedPreferences(context).getString(context.getString(R.string.initialPressesKey), context.getString(R.string.initialPressesDefault));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import static org.iilab.pb.common.AppConstants.PAGE_SETTINGS;
import static org.iilab.pb.common.AppConstants.PAGE_SETUP_ALARM_RETRAINING;
import static org.iilab.pb.common.AppConstants.PARENT_ACTIVITY;
import static org.iilab.pb.common.ApplicationSettings.getInitialClicksForAlertTrigger;
import static org.iilab.pb.common.ApplicationSettings.getTriggerSettings;
import static org.iilab.pb.common.ApplicationSettings.isConfirmationFeedback;
import static org.iilab.pb.common.ApplicationSettings.setConfirmationFeedback;
import static org.iilab.pb.common.ApplicationSettings.setConfirmationFeedbackVibrationPattern;
import static org.iilab.pb.common.ApplicationSettings.setInitialClicksForAlertTrigger;

public class AdvancedSettingsFragment extends PreferenceFragmentCompat {

Expand Down Expand Up @@ -127,10 +129,12 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
enableRedoTraining(true);
Log.d(TAG, "Extra confirmation click required to trigger alarm");
} else if (selectedValue.equals(getString(R.string.extraConfirmationPressValue))) {
//make the press 5
setInitialClicksForAlertTrigger(getActivity(),"5");
setConfirmationFeedbackVibrationPattern(getActivity(), ALARM_SENDING_CONFIRMATION_PATTERN_LONG);
enableAdvancedSettings(false);
enableRedoTraining(true);
Log.d(TAG, "Extra confirmation click required to trigger alarm");
Log.d(TAG, "Extra confirmation click required to trigger alarm "+getInitialClicksForAlertTrigger(getActivity()));
} else if (selectedValue.equals(getString(R.string.custom_modeValue))) {
enableAdvancedSettings(true);
// enable all the advanced settings
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<string name="triggerSettingsKey">triggerSettings</string>

<string name="default7RepeatedPress">(Default) 7 repeated presses</string>
<string name="extraConfirmationPress">Extra confirmation press </string>
<string name="extraConfirmationPress">5 presses plus confirmation </string>
<string name="custom_mode">Custom</string>
<string name="default7RepeatedPressValue">1</string>
<string name="extraConfirmationPressValue">2</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<string name="triggerSettingsKey">triggerSettings</string>

<string name="default7RepeatedPress">(Default) 7 repeated presses</string>
<string name="extraConfirmationPress">Extra confirmation press </string>
<string name="extraConfirmationPress">5 presses plus confirmation </string>
<string name="custom_mode">Custom</string>
<string name="default7RepeatedPressValue">1</string>
<string name="extraConfirmationPressValue">2</string>
Expand Down

0 comments on commit e111af6

Please sign in to comment.