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

Commit

Permalink
#178 advanced settings changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niccs committed Feb 1, 2016
1 parent de6fc46 commit 4232339
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
enableAdvancedSettings(false);
}

Preference button = (Preference) findPreference(getString(R.string.redoTrainingKey));
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
Preference redoTrainingButton = (Preference) findPreference(getString(R.string.redoTrainingKey));
redoTrainingButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Log.d(TAG, "Testing redo training button");
Log.d(TAG, "Testing redo training redoTrainingBtton");
// During redo exercise of alarm trigger, stop the send alert hardware service.
getActivity().stopService(new Intent(getActivity(), HardwareTriggerService.class));
Intent i = new Intent(getActivity(), WizardActivity.class);
Expand All @@ -71,20 +71,39 @@ public boolean onPreferenceClick(Preference preference) {
powerButtonAlarmTrigger.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside on preference change of power button trigger setting");
Log.d(TAG, "Inside on preference change of power redoTrainingBtton trigger setting");

if (selectedValue.equals(getString(R.string.activate_power_button_trigger))) {
getActivity().startService(new Intent(getActivity(), HardwareTriggerService.class));
Log.d(TAG, "Power button alarm trigger is enabled");
Log.d(TAG, "Power redoTrainingBtton alarm trigger is enabled");
} else {
getActivity().stopService(new Intent(getActivity(), HardwareTriggerService.class));
displayNotification();
Log.d(TAG, "Power button alarm trigger is disabled");
Log.d(TAG, "Power redoTrainingBtton alarm trigger is disabled");
}
return true;
}
});

Preference alertConfirmationSettings = (Preference) findPreference(getString(R.string.feedbackAlarmActivationKey));

alertConfirmationSettings.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside of feedback for alarm activation settings");

if (selectedValue.equals(getString(R.string.confirmationSettingsDefault))) {
// disable Confirmation Wait Time/ Confirmation Wait Vibration
enableConfirmationFeedback(false);
Log.d(TAG, "default confirmation press deactivated");
} else {
// enable Confirmation Wait Time/ Confirmation Wait Vibration
enableConfirmationFeedback(true);
Log.d(TAG, "Confirmation press enabled");
}
return true;
}
});
Preference triggerSettingsPef = (Preference) findPreference(getString(R.string.triggerSettingsKey));

triggerSettingsPef.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
Expand All @@ -105,15 +124,15 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
} else if (selectedValue.equals(getString(R.string.custom_modeValue))) {
enableAdvancedSettings(true);
// enable all the advanced settings
Log.d(TAG, "Power button alarm trigger is disabled");
Log.d(TAG, "Power redoTrainingButton alarm trigger is disabled");
}
return true;
}
});
}
private void enableAdvancedSettings(boolean flag){
PreferenceCategory prefCatTriggerPatternSettings = (PreferenceCategory) findPreference(getString(R.string.triggerPatternSettingsKey));
PreferenceCategory prefCatTriggerVibrationSettings = (PreferenceCategory) findPreference(getString(R.string.VibrationSettingsKey));
PreferenceCategory prefCatTriggerVibrationSettings = (PreferenceCategory) findPreference(getString(R.string.feedbackAlarmActivationKey));
PreferenceCategory prefCatRedoTraining = (PreferenceCategory) findPreference(getString(R.string.redoTrainingPrefCatKey));
PreferenceCategory prefCatPowerButtonTriggerSettings = (PreferenceCategory) findPreference(getString(R.string.configurePowerButtonPrefCatKey));
prefCatTriggerPatternSettings.setEnabled(flag);
Expand All @@ -122,9 +141,16 @@ private void enableAdvancedSettings(boolean flag){
prefCatPowerButtonTriggerSettings.setEnabled(flag);
}
private void enableRedoTraining(boolean flag){
PreferenceCategory prefCatRedoTraining = (PreferenceCategory) findPreference(getString(R.string.redoTrainingPrefCatKey));
Preference prefCatRedoTraining = (Preference) findPreference(getString(R.string.redoTrainingPrefCatKey));
prefCatRedoTraining.setEnabled(flag);
}
private void enableConfirmationFeedback(boolean flag){
PreferenceCategory confirmationWaitTime = (PreferenceCategory) findPreference(getString(R.string.confirmationWaitTimeKey));
confirmationWaitTime.setEnabled(flag);
PreferenceCategory confirmationWaitVibration = (PreferenceCategory) findPreference(getString(R.string.hapticFeedbackVibrationPatternKey));
confirmationWaitVibration.setEnabled(flag);

}

private void displayNotification() {
// Invoking the default notification service
Expand Down
22 changes: 15 additions & 7 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,29 @@

<string name="triggerPatternSettingsTitle">Trigger Pattern Settings</string>
<string name="triggerPatternSettingsKey">triggerPatternSettings</string>
<string name="initialPressesTitle">Initial Presses</string>
<string name="initialPressesTitle">Number of Presses</string>
<string name="initialPressesDefault">7</string>
<string name="initialPressesSummary">Number of presses needed to trigger the alarm</string>
<string name="initialPressesKey">initialClicks</string>

<string name="initialTimeTitle">Initial Times</string>
<string name="initialTimeTitle">Time to complete the presses</string>
<string name="initialTimeDefault">6</string>
<string name="initialTimeSummary">Time to complete the number of initial presses. Decreasing this number might create problems with detecting multiple presses with certain devices.</string>
<string name="initialTimeKey">initialTime</string>

<string name="feedbackAlarmActivationTitle">Feedback on Alarm Activation</string>
<string name="feedbackAlarmActivationKey">feedbackAlarmActivation</string>
<string name="confirmationSettingsTitle">Confirmation Settings</string>
<string name="confirmationSettingsDefault">1</string>
<string name="confirmationSettingsSummary">Time to wait until the confirmation press</string>
<string name="confirmationSettingsKey">confirmationWaitTime</string>


<string name="confirmationWaitTimeTitle">Confirmation Wait Time</string>
<string name="confirmationWaitTimeDefault">2</string>
<string name="confirmationWaitTimeSummary">Time to wait until the confirmation press</string>
<string name="confirmationWaitTimeKey">confirmationWaitTime</string>

<string name="VibrationSettingsTitle">Vibration Settings</string>
<string name="VibrationSettingsKey">vibrationSettings</string>
<string name="hapticFeedbackVibrationPatternTitle">Confirmation Wait Vibration </string>
<string name="hapticFeedbackDefaultPattern">1 </string>
<string name="hapticFeedbackVibrationPatternSummary">Vibration pattern during the wait time until the confirmation press</string>
Expand All @@ -109,14 +115,16 @@
<string name="alertSendingConfirmationVibrationSummary">Vibration pattern to inform that the alarm has been activated</string>
<string name="alertSendingConfirmationVibrationKey">alertSendingConfirmationVibration</string>

<string name="alertNotConfirmedTitle">Alarm NOT Confirmed </string>
<string name="feedbackAlarmNonConfirmationTitle">Feedback on NON Confirmation Alarm</string>
<string name="feedbackAlarmNonConfirmationKey">feedbackAlarmActivation</string>
<string name="alertNotConfirmedTitle">Feedback on NON Confirmation Alarm </string>
<string name="alertNotConfirmedDefault">1</string>
<string name="alertNotConfirmedSummary">Vibration pattern to inform that the alarm has NOT been activated. This will happen if you make the correct number of initial presses but do NOT confirm.</string>
<string name="alertNotConfirmedKey">alertNotConfirmed</string>

<string name="redoTrainingTitle">Redo training</string>
<string name="redoTrainingTitle">Configuration Training</string>
<string name="redoTrainingPrefCatKey">redoTrainingKey</string>
<string name="testAlarmTitle">Test Alarm </string>
<string name="testAlarmTitle">Test your new configuration</string>
<string name="redoTrainingSummary">Offering the user to redo the training exercise</string>
<string name="redoTrainingKey">redoTraining</string>

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
<item>7</item>
<item>8</item>
</string-array>
<string-array name="confirmationSettingsArray">
<item>(Default) Inactive</item>
<item>Active</item>
</string-array>

<string-array name="confirmationSettingsValues">
<item>1</item>
<item>2</item>
</string-array>
<string-array name="confirmationWaitArray">
<item>1 sec</item>
<item>2 sec</item>
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,28 @@

<string name="triggerPatternSettingsTitle">Trigger Pattern Settings</string>
<string name="triggerPatternSettingsKey">triggerPatternSettings</string>
<string name="initialPressesTitle">Initial Presses</string>
<string name="initialPressesTitle">Number of Presses</string>
<string name="initialPressesDefault">7</string>
<string name="initialPressesSummary">Number of presses needed to trigger the alarm</string>
<string name="initialPressesKey">initialClicks</string>

<string name="initialTimeTitle">Initial Times</string>
<string name="initialTimeTitle">Time to complete the presses</string>
<string name="initialTimeDefault">6</string>
<string name="initialTimeSummary">Time to complete the number of initial presses. Decreasing this number might create problems with detecting multiple presses with certain devices.</string>
<string name="initialTimeKey">initialTime</string>

<string name="feedbackAlarmActivationTitle">Feedback on Alarm Activation</string>
<string name="feedbackAlarmActivationKey">feedbackAlarmActivation</string>
<string name="confirmationSettingsTitle">Confirmation Settings</string>
<string name="confirmationSettingsDefault">1</string>
<string name="confirmationSettingsSummary">Time to wait until the confirmation press</string>
<string name="confirmationSettingsKey">confirmationWaitTime</string>

<string name="confirmationWaitTimeTitle">Confirmation Wait Time</string>
<string name="confirmationWaitTimeDefault">2</string>
<string name="confirmationWaitTimeSummary">Time to wait until the confirmation press</string>
<string name="confirmationWaitTimeKey">confirmationWaitTime</string>

<string name="VibrationSettingsTitle">Vibration Settings</string>
<string name="VibrationSettingsKey">vibrationSettings</string>
<string name="hapticFeedbackVibrationPatternTitle">Confirmation Wait Vibration </string>
<string name="hapticFeedbackDefaultPattern">1 </string>
<string name="hapticFeedbackVibrationPatternSummary">Vibration pattern during the wait time until the confirmation press</string>
Expand All @@ -110,14 +115,16 @@
<string name="alertSendingConfirmationVibrationSummary">Vibration pattern to inform that the alarm has been activated</string>
<string name="alertSendingConfirmationVibrationKey">alertSendingConfirmationVibration</string>

<string name="alertNotConfirmedTitle">Alarm NOT Confirmed </string>
<string name="feedbackAlarmNonConfirmationTitle">Feedback on NON Confirmation Alarm</string>
<string name="feedbackAlarmNonConfirmationKey">feedbackAlarmActivation</string>
<string name="alertNotConfirmedTitle">Feedback on NON Confirmation Alarm</string>
<string name="alertNotConfirmedDefault">1</string>
<string name="alertNotConfirmedSummary">Vibration pattern to inform that the alarm has NOT been activated. This will happen if you make the correct number of initial presses but do NOT confirm.</string>
<string name="alertNotConfirmedKey">alertNotConfirmed</string>

<string name="redoTrainingTitle">Redo training</string>
<string name="redoTrainingTitle">Configuration Training</string>
<string name="redoTrainingPrefCatKey">redoTrainingKey</string>
<string name="testAlarmTitle">Test Alarm </string>
<string name="testAlarmTitle">Test your new configuration </string>
<string name="redoTrainingSummary">Offering the user to redo the training exercise</string>
<string name="redoTrainingKey">redoTraining</string>

Expand Down
17 changes: 14 additions & 3 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@
android:key="@string/initialTimeKey"
android:summary="@string/initialTimeSummary"
android:title="@string/initialTimeTitle" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/feedbackAlarmActivationTitle"
android:key = "@string/feedbackAlarmActivationKey">
<ListPreference
android:defaultValue="@string/confirmationSettingsDefault"
android:entries="@array/confirmationSettingsArray"
android:entryValues="@array/confirmationSettingsValues"
android:key="@string/confirmationSettingsKey"
android:summary="@string/confirmationSettingsSummary"
android:title="@string/confirmationSettingsTitle" />

<ListPreference
android:defaultValue="@string/confirmationWaitTimeDefault"
android:entries="@array/confirmationWaitArray"
android:entryValues="@array/confirmationWaitValues"
android:key="@string/confirmationWaitTimeKey"
android:summary="@string/confirmationWaitTimeSummary"
android:title="@string/confirmationWaitTimeTitle" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/VibrationSettingsTitle"
android:key = "@string/VibrationSettingsKey">
<ListPreference
android:defaultValue="@string/hapticFeedbackDefaultPattern"
android:entries="@array/hapticFeedbackPatternArray"
Expand All @@ -49,6 +57,9 @@
android:key="@string/alertSendingConfirmationVibrationKey"
android:summary="@string/alertSendingConfirmationVibrationSummary"
android:title="@string/alertSendingConfirmationVibrationTitle" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/feedbackAlarmNonConfirmationTitle"
android:key = "@string/feedbackAlarmNonConfirmationTitleKey">
<ListPreference
android:defaultValue="@string/alertNotConfirmedDefault"
android:entries="@array/alertNotConfirmedArray"
Expand Down

0 comments on commit 4232339

Please sign in to comment.