diff --git a/app/src/main/java/org/iilab/pb/fragment/AdvancedSettingsFragment.java b/app/src/main/java/org/iilab/pb/fragment/AdvancedSettingsFragment.java index b781a6bb..d4bdbb49 100644 --- a/app/src/main/java/org/iilab/pb/fragment/AdvancedSettingsFragment.java +++ b/app/src/main/java/org/iilab/pb/fragment/AdvancedSettingsFragment.java @@ -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); @@ -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() { @@ -105,7 +124,7 @@ 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; } @@ -113,7 +132,7 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) { } 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); @@ -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 diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 7c798817..de830282 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -82,23 +82,29 @@ Trigger Pattern Settings triggerPatternSettings - Initial Presses + Number of Presses 7 Number of presses needed to trigger the alarm initialClicks - Initial Times + Time to complete the presses 6 Time to complete the number of initial presses. Decreasing this number might create problems with detecting multiple presses with certain devices. initialTime + Feedback on Alarm Activation + feedbackAlarmActivation + Confirmation Settings + 1 + Time to wait until the confirmation press + confirmationWaitTime + + Confirmation Wait Time 2 Time to wait until the confirmation press confirmationWaitTime - Vibration Settings - vibrationSettings Confirmation Wait Vibration 1 Vibration pattern during the wait time until the confirmation press @@ -109,14 +115,16 @@ Vibration pattern to inform that the alarm has been activated alertSendingConfirmationVibration - Alarm NOT Confirmed + Feedback on NON Confirmation Alarm + feedbackAlarmActivation + Feedback on NON Confirmation Alarm 1 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. alertNotConfirmed - Redo training + Configuration Training redoTrainingKey - Test Alarm + Test your new configuration Offering the user to redo the training exercise redoTraining diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 5fcae5f1..c0f59261 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -38,6 +38,15 @@ 7 8 + + (Default) Inactive + Active + + + + 1 + 2 + 1 sec 2 sec diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 258e4d9e..59409171 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -83,23 +83,28 @@ Trigger Pattern Settings triggerPatternSettings - Initial Presses + Number of Presses 7 Number of presses needed to trigger the alarm initialClicks - Initial Times + Time to complete the presses 6 Time to complete the number of initial presses. Decreasing this number might create problems with detecting multiple presses with certain devices. initialTime + Feedback on Alarm Activation + feedbackAlarmActivation + Confirmation Settings + 1 + Time to wait until the confirmation press + confirmationWaitTime + Confirmation Wait Time 2 Time to wait until the confirmation press confirmationWaitTime - Vibration Settings - vibrationSettings Confirmation Wait Vibration 1 Vibration pattern during the wait time until the confirmation press @@ -110,14 +115,16 @@ Vibration pattern to inform that the alarm has been activated alertSendingConfirmationVibration - Alarm NOT Confirmed + Feedback on NON Confirmation Alarm + feedbackAlarmActivation + Feedback on NON Confirmation Alarm 1 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. alertNotConfirmed - Redo training + Configuration Training redoTrainingKey - Test Alarm + Test your new configuration Offering the user to redo the training exercise redoTraining diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index d7a8c61a..6434d8bc 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -25,6 +25,17 @@ android:key="@string/initialTimeKey" android:summary="@string/initialTimeSummary" android:title="@string/initialTimeTitle" /> + + + + - - + +