org.android.activityminer.logic.configuration
Class GlobalSharedPreferenceObserver

Package class diagram package GlobalSharedPreferenceObserver
java.lang.Object
  extended by org.android.activityminer.logic.util.AbstractActivatableComponentImpl
      extended by org.android.activityminer.logic.configuration.GlobalSharedPreferenceObserver
All Implemented Interfaces:
SharedPreferenceChangeObserver, ActivatableComponent

public final class GlobalSharedPreferenceObserver
extends AbstractActivatableComponentImpl
implements SharedPreferenceChangeObserver

Global singleton instance of a central shared preference observer which is notifying registered shared preference observers about changes.


Field Summary
private  Context context
          The application context.
private  Configuration currentConfig
          The actual configuration.
private static GlobalSharedPreferenceObserver instance
          The global singleton instance
private  SparseArray<String> mapKeyToViolationMessage
          The mapping of preference keys to the related limit violation message.
private  ConcurrentLinkedQueue<SharedPreferenceChangeNotificationReceiver> observers
          The observer collection
private  SharedPreferences preferences
          A reference to the shared preferences.
private  SharedPreferences.OnSharedPreferenceChangeListener prefListener
          The listener for shared preferences changes.
 
Constructor Summary
private GlobalSharedPreferenceObserver(Context applicationContext)
          Constructor
 
Method Summary
 boolean addToSelectedFeatures(FeatureTypes[] featureTypes)
          Method to update the selected features by adding additional ones
private  double getBeta(SharedPreferences sharedPreferences)
          Does read the current beta value from the shared preferences.
private  double getBWCutOffFrequency(SharedPreferences sharedPreferences)
          Does read the current Butterworth cut-off frequency value from the shared preferences.
private  int getBWFilterOrder(SharedPreferences sharedPreferences)
          Does read the current Butterworth filter order value from the shared preferences.
 Configuration getConfiguration()
          Does create a configuration from the current shared preference values.
protected  long getCountDownTime(SharedPreferences sharedPreferences)
          Does read the current count-down time from the shared preferences.
private  int getEvaluationAccuracyThreshold(SharedPreferences sharedPreferences)
          Does read the accuracy threshold for evaluation from the shared preferences.
private  FilterTypes getFilterType(SharedPreferences sharedPreferences)
          Does read the filter type from the shared preferences.
private  double getGravitationCutOffFrequency(SharedPreferences sharedPreferences)
          Does read the current gravitation filter cut-off frequency value from the shared preferences.
static GlobalSharedPreferenceObserver getInstance(Context applicationContext)
          Getter for the global instance
protected  boolean getLocationDataUsageFlag(SharedPreferences sharedPreferences)
          Does read the location data usage flag from the shared preferences.
private  int getMaximumRecordingTime(SharedPreferences sharedPreferences)
          Does read the current maximum recording time from the shared preferences.
protected  long getMaximumSampleRate(SharedPreferences sharedPreferences)
          Does read the maximum sample rate from the shared preferences.
private  double getMinCutOffFrequency(SharedPreferences sharedPreferences)
          Does read the current minimum cut-off frequency value from the shared preferences.
private  int getOverlapSize(SharedPreferences sharedPreferences)
          Does read the current cutOut overlap size from the shared preferences.
private  boolean getOwnAccImplUsageFlag(SharedPreferences sharedPreferences)
          Does read the flag for usage of internal linear accelerometer implementation from the shared preferences.
private  int getParameterKForKNN(SharedPreferences sharedPreferences)
          Does read the parameter k for the nearest neighbor classifier from the shared preferences.
protected  boolean getParameterNormalizeForKNN(SharedPreferences sharedPreferences)
          Does read the KNN parameter for normalization from the shared preferences.
protected  int getParamterKForCrossValidation(SharedPreferences sharedPreferences)
          Does read the parameter k for cross validation from the shared preferences.
private  double getPreferenceValue(SharedPreferences sharedPreferences, int keyId, double defaultValue)
          Getter for double preference values
private  int getPreferenceValue(SharedPreferences sharedPreferences, int keyId, int defaultValue)
          Getter for integer preference values
private  long getPreferenceValue(SharedPreferences sharedPreferences, int keyId, long defaultValue)
          Getter for long preference values
protected  long getRecordingTime(SharedPreferences sharedPreferences)
          Does read the current recording time from the shared preferences.
protected  long getSampleRate(SharedPreferences sharedPreferences)
          Does read the current sample rate from the shared preferences.
private  Long[] getSelectedClasses(SharedPreferences sharedPreferences)
          Does read the selected classes from the shared preferences.
protected  ClassifierTypes getSelectedClassifierType(SharedPreferences sharedPreferences)
          Does read the classifier type from the shared preferences.
private  boolean getSelectionState(FeatureTypes featureType, SharedPreferences sharedPreferences)
          Does read the selection state for the feature type from the shared preferences.
protected  String getUUID(SharedPreferences sharedPreferences)
          Does read the UUID from the shared preferences.
private  long getWindowSize(SharedPreferences sharedPreferences)
          Does read the current cut-out size from the shared preferences.
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void onBetaPreferenceChange(double beta)
          The handler for beta value preference changes.
 void onBWCutOffPreferenceChanged(double cutOff)
          The handler for Butterworth filter cut-off frequency preference changes.
 void onBWFilterOrderPreferenceChanged(int order)
          The handler for Butterworth filter order changes.
 void onClassSelectionChange(Long[] selectedClasses)
          The handler for changes of the class selection.
 void onCountDownTimeChange(long countDownTime)
          The handler for count-down time parameter changes.
 void onCrossValidationParameterKChange(int parameterK)
          The handler for changes of the parameter k for cross validation.
 void onDefaultRecordingTimeChange(long defaultRecordingTime)
          The handler for default recording time parameter changes.
 void onEvaluationAccuracyThresholdChanged(int threshold)
          The handler for changes of the parameter k for cross validation.
 void onFeatureSelection(FeatureTypes featureType, boolean isSelected)
          The handler for feature selection state changes.
 void onGravitationCutOffPreferenceChanged(double cutOff)
          The handler for gravitation filter cut-off frequency preference changes.
 void onKNNClassifierParameterKChange(int parameterK)
          The handler for changes of the parameter k for the nearest neighbor classifier (knn).
 void onKNNClassifierParameterNormalizeChange(boolean normalize)
          The handler for changes of the parameter normalize for the nearest neighbor classifier (knn).
 void onLimitViolation(String message, String key)
          Does notify for a limit violation by a user preference change.
 void onLocationDataUsageFlagChange(boolean newUsage)
          The handler for changes of location data usage flag
 void onMaximumRecordingTimeChange(int maximumRecordingTime)
          The handler for maximum recording time parameter changes.
 void onMaximumSampleRateChange(long maxSampleRate)
          The handler for maximum sample rate changes.
 void onMinCutOffPreferenceChanged(double minCutOff)
          The handler for minimum cut-off frequency preference changes.
 void onOverlapSizeChange(int overlapSize)
          The handler for cutOut overlap size parameter changes.
 void onOwnLinAccImplementationUsageFlagChange(boolean newUsage)
          The handler for changes of the internal linear acceleration implementation usage flag.
 void onSampleRateChange(long sampleRate)
          The handler for sample rate changes.
 void onSelectedAccFilterChanged(FilterTypes filterType)
          The handler for filter type changes.
 void onSelectedClassifierChange(ClassifierTypes classifierType)
          The handler for changes of the selected classifier.
 void onWindowSizeChange(long windowSize)
          The handler for cutOut size parameter changes.
private  Configuration readCurrentConfig()
           
 void register(SharedPreferenceChangeNotificationReceiver observer)
          Method to register for shared preference change notifications.
private  void resetPreferenceValue(int keyConstant, double value)
          Does reset a stored shared double preference value and notifies for limit violation.
private  void resetPreferenceValue(int keyConstant, int value)
          Does reset a stored shared integer preference value and notifies for limit violation.
private  void resetPreferenceValue(int keyConstant, long value)
          Does reset a stored shared long preference value and notifies for limit violation.
private  void resetPreferenceValue(int keyConstant, String value)
          Does reset a stored shared string preference value and notifies for limit violation.
 void unregister(SharedPreferenceChangeNotificationReceiver observer)
          Method to unregister for shared preference change notifications.
 void updateCurrentConfig(Configuration config)
           
 void updatePreferenceValue(int keyConstant, boolean value)
          Does reset a stored shared boolean preference value and notifies for limit violation.
protected  void updateSelectedFeatures(boolean useLocationFeatures)
          Method to update selected features according to the location feature usage flag
 boolean updateSelectedFeatures(FeatureTypes[] featureTypes)
          Method to update the selected features
private  void writeBeta(SharedPreferences sharedPreferences, double beta)
          Does write the current beta value to the shared preferences.
private  void writeBWCutOffFrequency(SharedPreferences sharedPreferences, double cutOffFrequency)
          Does write the Butterworth cut-off frequency value to the shared preferences.
private  void writeBWFilterOrder(SharedPreferences sharedPreferences, int order)
          Does write the new Butterworth filter order value to the shared preferences.
private  void writeCountDownTime(SharedPreferences sharedPreferences, long countDownTime)
          Does write the current count-down time to the shared preferences.
private  void writeEvaluationAccuracyThreshold(SharedPreferences sharedPreferences, int evalAccuracyThreshold)
          Does write the accuracy threshold for evaluation to the shared preferences.
private  void writeFilterType(SharedPreferences sharedPreferences, FilterTypes filterType)
          Does write the filter type to the shared preferences.
private  void writeGravitationCutOffFrequency(SharedPreferences sharedPreferences, double cutOffFrequency)
          Does write the gravitation filter cut-off frequency value to the shared preferences.
private  void writeLocationDataUsageFlag(SharedPreferences sharedPreferences, boolean isUseLocationData)
          Does write the location data usage flag to the shared preferences.
private  void writeMaximumRecordingTime(SharedPreferences sharedPreferences, int maximumRecordingTime)
          Does write the maximum recording time to the shared preferences.
private  void writeMinCutOffFrequency(SharedPreferences sharedPreferences, double minCutOffFrequency)
          Does write the current minimum cut-off frequency value to the shared preferences.
private  void writeOverlapSize(SharedPreferences sharedPreferences, int windowOverlap)
          Does write the current cutOut overlap size to the shared preferences.
private  void writeOwnAccImplUsageFlag(SharedPreferences sharedPreferences, boolean useOwnLinAcc)
          Does write the usage flag for the internal linear accelerometer implementation to the shared preferences.
private  void writeParameterKForKNN(SharedPreferences sharedPreferences, int parameterKForKNN)
          Does write the parameter k for the nearest neighbor classifier to the shared preferences.
private  void writeParameterNormalizeForKNN(SharedPreferences sharedPreferences, boolean parameterNormalizeForKNN)
          Does write the KNN parameter for normalization to the shared preferences.
private  void writeParamterKForCrossValidation(SharedPreferences sharedPreferences, int crossValidationK)
          Does write the parameter k for cross validation to the shared preferences.
 void writePreferenceValue(SharedPreferences sharedPreferences, int keyId, boolean value)
          Setter for boolean preference values
private  void writePreferenceValue(SharedPreferences sharedPreferences, int keyId, double value)
          Setter for double preference values
private  void writePreferenceValue(SharedPreferences sharedPreferences, int keyId, int value)
          Getter for integer preference values
private  void writePreferenceValue(SharedPreferences sharedPreferences, int keyId, long value)
          Setter for long preference values
private  void writePreferenceValue(SharedPreferences sharedPreferences, int keyId, String sValue)
          Setter for string preference values
private  void writeRecordingTime(SharedPreferences sharedPreferences, long recordingTime)
          Does write the current recording time to the shared preferences.
private  void writeSampleRate(SharedPreferences sharedPreferences, long sampleRate)
          Does write the current sample rate to the shared preferences.
private  void writeSelectedClasses(SharedPreferences sharedPreferences, Set<Long> selectedClasses)
          Does write the selected classes to the shared preferences.
protected  void writeSelectedClassifierType(SharedPreferences sharedPreferences, ClassifierTypes type)
          Does write the classifier type to the shared preferences.
private  void writeUUID(SharedPreferences sharedPreferences, String uuid)
          Does write the UUID to the shared preferences.
private  void writeWindowSize(SharedPreferences sharedPreferences, long windowSize)
          Does write the current cut-out size to the shared preferences.
 
Methods inherited from class org.android.activityminer.logic.util.AbstractActivatableComponentImpl
isActive, setActivationState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

observers

private final ConcurrentLinkedQueue<SharedPreferenceChangeNotificationReceiver> observers
The observer collection


prefListener

private final SharedPreferences.OnSharedPreferenceChangeListener prefListener
The listener for shared preferences changes.


context

private final Context context
The application context.


currentConfig

private Configuration currentConfig
The actual configuration.


preferences

private final SharedPreferences preferences
A reference to the shared preferences.


instance

private static GlobalSharedPreferenceObserver instance
The global singleton instance


mapKeyToViolationMessage

private final SparseArray<String> mapKeyToViolationMessage
The mapping of preference keys to the related limit violation message.

Constructor Detail

GlobalSharedPreferenceObserver

private GlobalSharedPreferenceObserver(Context applicationContext)
Constructor

Parameters:
applicationContext - the application context
Method Detail

getInstance

public static final GlobalSharedPreferenceObserver getInstance(Context applicationContext)
Getter for the global instance

Parameters:
applicationContext - the application context
Returns:
the global instance

readCurrentConfig

private final Configuration readCurrentConfig()
Returns:
the current configuration created from shared preferences

updateCurrentConfig

public final void updateCurrentConfig(Configuration config)
Parameters:
config - the new configuration

getPreferenceValue

private final int getPreferenceValue(SharedPreferences sharedPreferences,
                                     int keyId,
                                     int defaultValue)
Getter for integer preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
defaultValue - the default value
Returns:
the preference value for the given key

getPreferenceValue

private final long getPreferenceValue(SharedPreferences sharedPreferences,
                                      int keyId,
                                      long defaultValue)
Getter for long preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
defaultValue - the default value
Returns:
the preference value for the given key

getPreferenceValue

private final double getPreferenceValue(SharedPreferences sharedPreferences,
                                        int keyId,
                                        double defaultValue)
Getter for double preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
defaultValue - the default value
Returns:
the preference value for the given key

writePreferenceValue

private final void writePreferenceValue(SharedPreferences sharedPreferences,
                                        int keyId,
                                        int value)
Getter for integer preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
value - the value

writePreferenceValue

private final void writePreferenceValue(SharedPreferences sharedPreferences,
                                        int keyId,
                                        long value)
Setter for long preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
value - the value

writePreferenceValue

private final void writePreferenceValue(SharedPreferences sharedPreferences,
                                        int keyId,
                                        double value)
Setter for double preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
value - the value

writePreferenceValue

public final void writePreferenceValue(SharedPreferences sharedPreferences,
                                       int keyId,
                                       boolean value)
Setter for boolean preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
value - the value

writePreferenceValue

private final void writePreferenceValue(SharedPreferences sharedPreferences,
                                        int keyId,
                                        String sValue)
Setter for string preference values

Parameters:
sharedPreferences - the shared preference instance to use
keyId - the key identifier
sValue - the value

getSelectedClasses

private Long[] getSelectedClasses(SharedPreferences sharedPreferences)
Does read the selected classes from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
an array with the selected classes

writeSelectedClasses

private void writeSelectedClasses(SharedPreferences sharedPreferences,
                                  Set<Long> selectedClasses)
Does write the selected classes to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
selectedClasses - the selected classes to write to preferrences

getFilterType

private final FilterTypes getFilterType(SharedPreferences sharedPreferences)
Does read the filter type from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the filter type

writeFilterType

private final void writeFilterType(SharedPreferences sharedPreferences,
                                   FilterTypes filterType)
Does write the filter type to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
filterType - the filter type

getGravitationCutOffFrequency

private final double getGravitationCutOffFrequency(SharedPreferences sharedPreferences)
Does read the current gravitation filter cut-off frequency value from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the current gravitation filter cut-off frequency value

writeGravitationCutOffFrequency

private final void writeGravitationCutOffFrequency(SharedPreferences sharedPreferences,
                                                   double cutOffFrequency)
Does write the gravitation filter cut-off frequency value to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
cutOffFrequency - the new gravitation filter cut-off frequency value

getBWCutOffFrequency

private final double getBWCutOffFrequency(SharedPreferences sharedPreferences)
Does read the current Butterworth cut-off frequency value from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the current Butterworth cut-off frequency value

writeBWCutOffFrequency

private final void writeBWCutOffFrequency(SharedPreferences sharedPreferences,
                                          double cutOffFrequency)
Does write the Butterworth cut-off frequency value to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
cutOffFrequency - the new Butterworth cut-off frequency value

getBWFilterOrder

private final int getBWFilterOrder(SharedPreferences sharedPreferences)
Does read the current Butterworth filter order value from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the current Butterworth filter order value

writeBWFilterOrder

private final void writeBWFilterOrder(SharedPreferences sharedPreferences,
                                      int order)
Does write the new Butterworth filter order value to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
order - the new Butterworth filter order

getMinCutOffFrequency

private final double getMinCutOffFrequency(SharedPreferences sharedPreferences)
Does read the current minimum cut-off frequency value from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the current minimum cut-off frequency value

writeMinCutOffFrequency

private final void writeMinCutOffFrequency(SharedPreferences sharedPreferences,
                                           double minCutOffFrequency)
Does write the current minimum cut-off frequency value to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
minCutOffFrequency - the current minimum cut-off frequency value

getBeta

private final double getBeta(SharedPreferences sharedPreferences)
Does read the current beta value from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the current beta value

writeBeta

private final void writeBeta(SharedPreferences sharedPreferences,
                             double beta)
Does write the current beta value to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
beta - the current beta value

getSelectionState

private final boolean getSelectionState(FeatureTypes featureType,
                                        SharedPreferences sharedPreferences)
Does read the selection state for the feature type from the shared preferences.

Parameters:
featureType - the feature type
sharedPreferences - the shared preference instance
Returns:
the selection state of the feature

getCountDownTime

protected long getCountDownTime(SharedPreferences sharedPreferences)
Does read the current count-down time from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the count-down time

writeCountDownTime

private void writeCountDownTime(SharedPreferences sharedPreferences,
                                long countDownTime)
Does write the current count-down time to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
countDownTime - the count-down time

getRecordingTime

protected long getRecordingTime(SharedPreferences sharedPreferences)
Does read the current recording time from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the recording time

getMaximumRecordingTime

private final int getMaximumRecordingTime(SharedPreferences sharedPreferences)
Does read the current maximum recording time from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the maximum recording time

writeRecordingTime

private final void writeRecordingTime(SharedPreferences sharedPreferences,
                                      long recordingTime)
Does write the current recording time to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
recordingTime - the recording time

writeMaximumRecordingTime

private final void writeMaximumRecordingTime(SharedPreferences sharedPreferences,
                                             int maximumRecordingTime)
Does write the maximum recording time to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
maximumRecordingTime - the maximum recording time

getSampleRate

protected final long getSampleRate(SharedPreferences sharedPreferences)
Does read the current sample rate from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the sample rate in milliseconds between samples

writeSampleRate

private final void writeSampleRate(SharedPreferences sharedPreferences,
                                   long sampleRate)
Does write the current sample rate to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
sampleRate - the sample rate in milliseconds between samples

getMaximumSampleRate

protected final long getMaximumSampleRate(SharedPreferences sharedPreferences)
Does read the maximum sample rate from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the maximum sample rate in milliseconds between samples

getParamterKForCrossValidation

protected final int getParamterKForCrossValidation(SharedPreferences sharedPreferences)
Does read the parameter k for cross validation from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the parameter k for cross validation

writeParamterKForCrossValidation

private final void writeParamterKForCrossValidation(SharedPreferences sharedPreferences,
                                                    int crossValidationK)
Does write the parameter k for cross validation to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
crossValidationK - the parameter k for cross validation

getEvaluationAccuracyThreshold

private int getEvaluationAccuracyThreshold(SharedPreferences sharedPreferences)
Does read the accuracy threshold for evaluation from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the accuracy threshold for evaluation

writeEvaluationAccuracyThreshold

private final void writeEvaluationAccuracyThreshold(SharedPreferences sharedPreferences,
                                                    int evalAccuracyThreshold)
Does write the accuracy threshold for evaluation to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
evalAccuracyThreshold - sharedPreferences

getParameterKForKNN

private final int getParameterKForKNN(SharedPreferences sharedPreferences)
Does read the parameter k for the nearest neighbor classifier from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the parameter k for knn

writeParameterKForKNN

private final void writeParameterKForKNN(SharedPreferences sharedPreferences,
                                         int parameterKForKNN)
Does write the parameter k for the nearest neighbor classifier to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
parameterKForKNN - the parameter k for KNN

getLocationDataUsageFlag

protected final boolean getLocationDataUsageFlag(SharedPreferences sharedPreferences)
Does read the location data usage flag from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the location data usage flag

getOwnAccImplUsageFlag

private boolean getOwnAccImplUsageFlag(SharedPreferences sharedPreferences)
Does read the flag for usage of internal linear accelerometer implementation from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the internal linear accelerometer implementation usage flag size

getUUID

protected final String getUUID(SharedPreferences sharedPreferences)
Does read the UUID from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the UUID

writeUUID

private final void writeUUID(SharedPreferences sharedPreferences,
                             String uuid)
Does write the UUID to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
uuid - the uuid

writeLocationDataUsageFlag

private final void writeLocationDataUsageFlag(SharedPreferences sharedPreferences,
                                              boolean isUseLocationData)
Does write the location data usage flag to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
isUseLocationData - the location data usage flag

writeOwnAccImplUsageFlag

private void writeOwnAccImplUsageFlag(SharedPreferences sharedPreferences,
                                      boolean useOwnLinAcc)
Does write the usage flag for the internal linear accelerometer implementation to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
useOwnLinAcc - the internal linear accelerometer implementation usage flag

getParameterNormalizeForKNN

protected final boolean getParameterNormalizeForKNN(SharedPreferences sharedPreferences)
Does read the KNN parameter for normalization from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the KNN parameter for normalization

writeParameterNormalizeForKNN

private final void writeParameterNormalizeForKNN(SharedPreferences sharedPreferences,
                                                 boolean parameterNormalizeForKNN)
Does write the KNN parameter for normalization to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
parameterNormalizeForKNN - the KNN parameter for normalization

getOverlapSize

private final int getOverlapSize(SharedPreferences sharedPreferences)
Does read the current cutOut overlap size from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the overlap size

writeOverlapSize

private final void writeOverlapSize(SharedPreferences sharedPreferences,
                                    int windowOverlap)
Does write the current cutOut overlap size to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
windowOverlap - the overlap size

getWindowSize

private final long getWindowSize(SharedPreferences sharedPreferences)
Does read the current cut-out size from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the cutOut size

writeWindowSize

private final void writeWindowSize(SharedPreferences sharedPreferences,
                                   long windowSize)
Does write the current cut-out size to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
windowSize - the cutOut size

getSelectedClassifierType

protected final ClassifierTypes getSelectedClassifierType(SharedPreferences sharedPreferences)
Does read the classifier type from the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
Returns:
the classifier type

writeSelectedClassifierType

protected final void writeSelectedClassifierType(SharedPreferences sharedPreferences,
                                                 ClassifierTypes type)
Does write the classifier type to the shared preferences.

Parameters:
sharedPreferences - the shared preference instance
type - the classifier type

getConfiguration

public final Configuration getConfiguration()
Does create a configuration from the current shared preference values.

Returns:
a configuration build from shared preferences

register

public final void register(SharedPreferenceChangeNotificationReceiver observer)
Method to register for shared preference change notifications.

Parameters:
observer - the observer to register

unregister

public final void unregister(SharedPreferenceChangeNotificationReceiver observer)
Method to unregister for shared preference change notifications.

Parameters:
observer - the observer to register

onActivationStateChange

protected final void onActivationStateChange(boolean active)
Description copied from class: AbstractActivatableComponentImpl
Handler for activation state changes

Specified by:
onActivationStateChange in class AbstractActivatableComponentImpl
Parameters:
active - the new activation state

resetPreferenceValue

private final void resetPreferenceValue(int keyConstant,
                                        String value)
Does reset a stored shared string preference value and notifies for limit violation.

Parameters:
value - the string value
keyConstant - the key constant

resetPreferenceValue

private final void resetPreferenceValue(int keyConstant,
                                        int value)
Does reset a stored shared integer preference value and notifies for limit violation.

Parameters:
value - the integer value
keyConstant - the key constant

resetPreferenceValue

private final void resetPreferenceValue(int keyConstant,
                                        long value)
Does reset a stored shared long preference value and notifies for limit violation.

Parameters:
value - the double value
keyConstant - the key constant

resetPreferenceValue

private final void resetPreferenceValue(int keyConstant,
                                        double value)
Does reset a stored shared double preference value and notifies for limit violation.

Parameters:
value - the double value
keyConstant - the key constant

updatePreferenceValue

public final void updatePreferenceValue(int keyConstant,
                                        boolean value)
Does reset a stored shared boolean preference value and notifies for limit violation.

Parameters:
value - the boolean value
keyConstant - the key constant

onSelectedAccFilterChanged

public final void onSelectedAccFilterChanged(FilterTypes filterType)
Description copied from interface: SharedPreferenceChangeObserver
The handler for filter type changes.

Specified by:
onSelectedAccFilterChanged in interface SharedPreferenceChangeObserver
Parameters:
filterType - the filterType

onGravitationCutOffPreferenceChanged

public void onGravitationCutOffPreferenceChanged(double cutOff)
Description copied from interface: SharedPreferenceChangeObserver
The handler for gravitation filter cut-off frequency preference changes.

Specified by:
onGravitationCutOffPreferenceChanged in interface SharedPreferenceChangeObserver
Parameters:
cutOff - the new cut-off frequency value

onBWCutOffPreferenceChanged

public void onBWCutOffPreferenceChanged(double cutOff)
Description copied from interface: SharedPreferenceChangeObserver
The handler for Butterworth filter cut-off frequency preference changes.

Specified by:
onBWCutOffPreferenceChanged in interface SharedPreferenceChangeObserver
Parameters:
cutOff - the new cut-off frequency value

onBWFilterOrderPreferenceChanged

public void onBWFilterOrderPreferenceChanged(int order)
Description copied from interface: SharedPreferenceChangeObserver
The handler for Butterworth filter order changes.

Specified by:
onBWFilterOrderPreferenceChanged in interface SharedPreferenceChangeObserver
Parameters:
order - the new filter order

onMinCutOffPreferenceChanged

public final void onMinCutOffPreferenceChanged(double minCutOff)
Description copied from interface: SharedPreferenceChangeObserver
The handler for minimum cut-off frequency preference changes.

Specified by:
onMinCutOffPreferenceChanged in interface SharedPreferenceChangeObserver
Parameters:
minCutOff - the new minimum cut-off frequency value

onBetaPreferenceChange

public final void onBetaPreferenceChange(double beta)
Description copied from interface: SharedPreferenceChangeObserver
The handler for beta value preference changes.

Specified by:
onBetaPreferenceChange in interface SharedPreferenceChangeObserver
Parameters:
beta - the new beta value

onFeatureSelection

public final void onFeatureSelection(FeatureTypes featureType,
                                     boolean isSelected)
Description copied from interface: SharedPreferenceChangeObserver
The handler for feature selection state changes.

Specified by:
onFeatureSelection in interface SharedPreferenceChangeObserver
Parameters:
featureType - the feature type identifier
isSelected - the selection state

onClassSelectionChange

public final void onClassSelectionChange(Long[] selectedClasses)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the class selection.

Specified by:
onClassSelectionChange in interface SharedPreferenceChangeObserver
Parameters:
selectedClasses - the actual class selection

onOverlapSizeChange

public final void onOverlapSizeChange(int overlapSize)
Description copied from interface: SharedPreferenceChangeObserver
The handler for cutOut overlap size parameter changes.

Specified by:
onOverlapSizeChange in interface SharedPreferenceChangeObserver
Parameters:
overlapSize - the new overlap size

onWindowSizeChange

public final void onWindowSizeChange(long windowSize)
Description copied from interface: SharedPreferenceChangeObserver
The handler for cutOut size parameter changes.

Specified by:
onWindowSizeChange in interface SharedPreferenceChangeObserver
Parameters:
windowSize - the new cutOut size

onCountDownTimeChange

public final void onCountDownTimeChange(long countDownTime)
Description copied from interface: SharedPreferenceChangeObserver
The handler for count-down time parameter changes.

Specified by:
onCountDownTimeChange in interface SharedPreferenceChangeObserver
Parameters:
countDownTime - the new count-down time size

onDefaultRecordingTimeChange

public final void onDefaultRecordingTimeChange(long defaultRecordingTime)
Description copied from interface: SharedPreferenceChangeObserver
The handler for default recording time parameter changes.

Specified by:
onDefaultRecordingTimeChange in interface SharedPreferenceChangeObserver
Parameters:
defaultRecordingTime - the new default recording time in seconds

onMaximumRecordingTimeChange

public void onMaximumRecordingTimeChange(int maximumRecordingTime)
Description copied from interface: SharedPreferenceChangeObserver
The handler for maximum recording time parameter changes.

Specified by:
onMaximumRecordingTimeChange in interface SharedPreferenceChangeObserver
Parameters:
maximumRecordingTime - the new default maximum time in seconds

onSampleRateChange

public final void onSampleRateChange(long sampleRate)
Description copied from interface: SharedPreferenceChangeObserver
The handler for sample rate changes.

Specified by:
onSampleRateChange in interface SharedPreferenceChangeObserver
Parameters:
sampleRate - the new sample rate as the milliseconds between two samples

onMaximumSampleRateChange

public final void onMaximumSampleRateChange(long maxSampleRate)
Description copied from interface: SharedPreferenceChangeObserver
The handler for maximum sample rate changes.

Specified by:
onMaximumSampleRateChange in interface SharedPreferenceChangeObserver
Parameters:
maxSampleRate - the new maximum sample rate as the milliseconds between two samples

onCrossValidationParameterKChange

public final void onCrossValidationParameterKChange(int parameterK)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the parameter k for cross validation.

Specified by:
onCrossValidationParameterKChange in interface SharedPreferenceChangeObserver
Parameters:
parameterK - the new parameter k for cross validation

onEvaluationAccuracyThresholdChanged

public void onEvaluationAccuracyThresholdChanged(int threshold)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the parameter k for cross validation.

Specified by:
onEvaluationAccuracyThresholdChanged in interface SharedPreferenceChangeObserver
Parameters:
threshold - the accuracy threshold for evaluation

onKNNClassifierParameterKChange

public final void onKNNClassifierParameterKChange(int parameterK)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the parameter k for the nearest neighbor classifier (knn).

Specified by:
onKNNClassifierParameterKChange in interface SharedPreferenceChangeObserver
Parameters:
parameterK - the new parameter value

onKNNClassifierParameterNormalizeChange

public void onKNNClassifierParameterNormalizeChange(boolean normalize)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the parameter normalize for the nearest neighbor classifier (knn).

Specified by:
onKNNClassifierParameterNormalizeChange in interface SharedPreferenceChangeObserver
Parameters:
normalize - the new normalize flag value

onLocationDataUsageFlagChange

public final void onLocationDataUsageFlagChange(boolean newUsage)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of location data usage flag

Specified by:
onLocationDataUsageFlagChange in interface SharedPreferenceChangeObserver
Parameters:
newUsage - the new location data usage flag

onOwnLinAccImplementationUsageFlagChange

public final void onOwnLinAccImplementationUsageFlagChange(boolean newUsage)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the internal linear acceleration implementation usage flag.

Specified by:
onOwnLinAccImplementationUsageFlagChange in interface SharedPreferenceChangeObserver
Parameters:
newUsage - the internal linear acceleration implementation usage flag

updateSelectedFeatures

protected final void updateSelectedFeatures(boolean useLocationFeatures)
Method to update selected features according to the location feature usage flag

Parameters:
useLocationFeatures - flag if location features are available

addToSelectedFeatures

public final boolean addToSelectedFeatures(FeatureTypes[] featureTypes)
Method to update the selected features by adding additional ones

Parameters:
featureTypes - the feature types to add to selection
Returns:
true if successful, false otherwise

updateSelectedFeatures

public final boolean updateSelectedFeatures(FeatureTypes[] featureTypes)
Method to update the selected features

Parameters:
featureTypes - the feature types to set as selection
Returns:
true if successful, false otherwise

onSelectedClassifierChange

public final void onSelectedClassifierChange(ClassifierTypes classifierType)
Description copied from interface: SharedPreferenceChangeObserver
The handler for changes of the selected classifier.

Specified by:
onSelectedClassifierChange in interface SharedPreferenceChangeObserver
Parameters:
classifierType - the type of the new selected classifier

onLimitViolation

public final void onLimitViolation(String message,
                                   String key)
Description copied from interface: SharedPreferenceChangeObserver
Does notify for a limit violation by a user preference change.

Specified by:
onLimitViolation in interface SharedPreferenceChangeObserver
Parameters:
message - the violation message
key - the shared preference key, which value have been reset due to limit violation