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

Commit

Permalink
#178 few more constant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niccs committed Mar 2, 2016
1 parent d6ae3a2 commit 02f46f7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 60 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/org/iilab/pb/HomeActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.iilab.pb;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;

Expand Down Expand Up @@ -61,7 +61,7 @@
import static org.iilab.pb.common.ApplicationSettings.setSelectedLanguage;


public class HomeActivity extends Activity {
public class HomeActivity extends AppCompatActivity {

ProgressDialog pDialog;

Expand Down Expand Up @@ -186,6 +186,8 @@ private void startNextActivity() {
if ((supportedLangs == null) || !(supportedLangs.contains(selectedLang))) {
setSelectedLanguage(this, DEFAULT_LANGUAGE_ENG);
}
//TODO remove after testing
// wizardState=WIZARD_FLAG_HOME_READY;
if (wizardState != WIZARD_FLAG_HOME_READY) {
Log.d(TAG, "First run TRUE, running WizardActivity with pageId = " + pageId);
Intent i = new Intent(HomeActivity.this, WizardActivity.class);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/org/iilab/pb/common/AppConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public class AppConstants {
public static final int VIBRATION_PAUSE_LONG = 400;
public static final int VIBRATION_PAUSE_VERY_LONG = 1000;

public static final String ALARM_5_CLICKS = "5";


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.util.Log;

Expand All @@ -18,6 +17,7 @@
import org.iilab.pb.WizardActivity;
import org.iilab.pb.trigger.HardwareTriggerService;

import static org.iilab.pb.common.AppConstants.ALARM_5_CLICKS;
import static org.iilab.pb.common.AppConstants.ALARM_SENDING_CONFIRMATION_PATTERN_LONG;
import static org.iilab.pb.common.AppConstants.ALARM_SENDING_CONFIRMATION_PATTERN_NONE;
import static org.iilab.pb.common.AppConstants.PAGE_ADVANCED_SETTINGS;
Expand All @@ -33,12 +33,8 @@
import static org.iilab.pb.common.ApplicationSettings.setInitialClicksForAlertTrigger;

public class AdvancedSettingsFragment extends PreferenceFragmentCompat {


private static final String TAG = AdvancedSettingsFragment.class.getName();



public static AdvancedSettingsFragment newInstance(String pageId, int parentActivity) {
AdvancedSettingsFragment f = new AdvancedSettingsFragment();
Bundle args = new Bundle();
Expand All @@ -48,17 +44,14 @@ public static AdvancedSettingsFragment newInstance(String pageId, int parentActi
return (f);
}


@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);


final CheckBoxPreference default7RepeatedPress = (CheckBoxPreference) findPreference(getString(R.string.default7RepeatedPressKey));
final CheckBoxPreference extraConfirmationClick = (CheckBoxPreference) findPreference(getString(R.string.extraConfirmationPressKey));
final CheckBoxPreference customPreference = (CheckBoxPreference) findPreference(getString(R.string.customKey));
final Preference customSettings = (Preference) findPreference(getString(R.string.customSettingsKey));
final CheckBoxPreference customPreference = (CheckBoxPreference) findPreference(getString(R.string.customKey));
final Preference customSettings = (Preference) findPreference(getString(R.string.customSettingsKey));
if (getCustomSettings(getActivity())) {
default7RepeatedPress.setChecked(false);
extraConfirmationClick.setChecked(false);
Expand Down Expand Up @@ -89,11 +82,10 @@ public boolean onPreferenceClick(Preference preference) {
});

Preference powerButtonAlarmTrigger = (Preference) findPreference(getString(R.string.configurePowerButtonTriggerKey));

powerButtonAlarmTrigger.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside on preference change of power redoTrainingBtton trigger setting");
Log.d(TAG, "Inside on preference change of power redoTrainingButton trigger setting");

if (selectedValue.equals(getString(R.string.activate_power_button_trigger))) {
getActivity().startService(new Intent(getActivity(), HardwareTriggerService.class));
Expand All @@ -113,7 +105,7 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
alertConfirmationSettings.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside of feedback for alarm activation settings");
Log.d(TAG, "Inside of Alarm confirmation settings");

if (selectedValue.equals(getString(R.string.confirmationSequenceDefault))) {
// disable Confirmation Wait Time/ Confirmation Wait Vibration
Expand All @@ -134,7 +126,7 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
default7RepeatedPress.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside on preference change of main trigger setting " + selectedValue.getClass());
Log.d(TAG, "Inside on preference change of default 7 repeated press checkbox " + selectedValue.getClass());

if ((Boolean) selectedValue) {
extraConfirmationClick.setChecked(false);
Expand All @@ -149,16 +141,15 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
extraConfirmationClick.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside on preference change of main trigger setting " + selectedValue.getClass());
Log.d(TAG, "Inside on preference change of 5 presses and a confirmation click " + selectedValue.getClass());

if ((Boolean) selectedValue) {
default7RepeatedPress.setChecked(false);
customPreference.setChecked(false);
customSettings.setEnabled(false);
// make the press 5
setInitialClicksForAlertTrigger(getActivity(), "5");
setInitialClicksForAlertTrigger(getActivity(), ALARM_5_CLICKS);
setConfirmationFeedbackVibrationPattern(getActivity(), ALARM_SENDING_CONFIRMATION_PATTERN_LONG);

Log.d(TAG, "Default 5 presses to trigger alarm with confirmation click");
}
return true;
Expand All @@ -168,33 +159,20 @@ public boolean onPreferenceChange(Preference preference, Object selectedValue) {
customPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object selectedValue) {
Log.d(TAG, "Inside on preference change of main trigger setting " + selectedValue.getClass());
Log.d(TAG, "Inside on preference change of custom checkbox selection " + selectedValue.getClass());

if ((Boolean) selectedValue) {
default7RepeatedPress.setChecked(false);
extraConfirmationClick.setChecked(false);
customSettings.setEnabled(true);
setConfirmationFeedbackVibrationPattern(getActivity(), ALARM_SENDING_CONFIRMATION_PATTERN_NONE);
// enableAdvancedSettings(false);
// enableRedoTraining(true);
Log.d(TAG, "Default 7 presses to trigger alarm without confirmation click");
Log.d(TAG, "Custom setting are enabled and confirmation click defaults to false");
}
return true;
}
});
}

private void enableAdvancedSettings(boolean flag) {
PreferenceCategory prefCatTriggerPatternSettings = (PreferenceCategory) findPreference(getString(R.string.triggerPatternSettingsKey));
// 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);
// prefCatTriggerVibrationSettings.setEnabled(flag);
prefCatRedoTraining.setEnabled(flag);
prefCatPowerButtonTriggerSettings.setEnabled(flag);
}

private void enableConfirmationFeedback(boolean flag) {
Preference confirmationWaitTime = (Preference) findPreference(getString(R.string.confirmationWaitTimeKey));
confirmationWaitTime.setEnabled(flag);
Expand Down Expand Up @@ -234,21 +212,5 @@ private void displayNotification() {
// pass the Notification object to the system
myNotificationManager.notify(notifyID, mBuilder.build());
}
//
// @Override
// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
// String key) {
// Log.d(TAG, "callback called");
// if (key.equals(R.string.default7RepeatedPressKey)) {
// Log.d(TAG, "callback called");
//
// Preference connectionPref = findPreference("customSettings");
// // Set summary to be the user-description for the selected value
// connectionPref.setSummary(sharedPreferences.getString(key, "trying to change this runtime"));
// connectionPref.setDefaultValue(false);
// }
// }


}

5 changes: 2 additions & 3 deletions app/src/main/java/org/iilab/pb/receiver/UpdateReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import org.iilab.pb.CalculatorActivity;
import org.iilab.pb.R;

import static org.iilab.pb.common.AppConstants.APP_RELEASE_VERSION_1_5;
import static org.iilab.pb.common.ApplicationSettings.getLastUpdatedVersion;
import static org.iilab.pb.common.AppUtil.playTrainingForRelease1_5;

public class UpdateReceiver extends BroadcastReceiver
{
Expand All @@ -36,7 +35,7 @@ public void onReceive(Context context, Intent intent)
public static void onUpdate(Context context)
{
Log.d(TAG, "PB app updated");
if (getLastUpdatedVersion(context) == APP_RELEASE_VERSION_1_5)
if (playTrainingForRelease1_5(context))
displayNotification(context);
}

Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@
<string name="redoTrainingKey">redoTraining</string>

<string name="triggerSettingsHeaderTitle">Alarm Trigger Settings</string>
<!--<string name="triggerSettingsTitle">Trigger Settings</string>-->
<!--<string name="triggerSettingsSummary">Alarm Trigger Settings</string>-->
<!--<string name="triggerSettingsKey">triggerSettings</string>-->

<string name="default7RepeatedPressTitle">(Default) 7 repeated presses</string>
<string name="default7RepeatedPressKey">default7Press</string>
<string name="extraConfirmationPressTitle">5 presses plus confirmation </string>
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@
<string name="redoTrainingKey">redoTraining</string>

<string name="triggerSettingsHeaderTitle">Alarm Trigger Settings</string>
<!--<string name="triggerSettingsTitle">Trigger Settings</string>-->
<!--<string name="triggerSettingsSummary">Alarm Trigger Settings</string>-->
<!--<string name="triggerSettingsKey">triggerSettings</string>-->

<string name="default7RepeatedPressTitle">(Default) 7 repeated presses</string>
<string name="extraConfirmationPressTitle">5 presses plus confirmation </string>
Expand Down

0 comments on commit 02f46f7

Please sign in to comment.