|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.unikassel.android.sdcframework.preferences.ApplicationPreferenceManagerImpl
public final class ApplicationPreferenceManagerImpl
The application preference manager for the SDC framework is providing a
uniform access to preferences or current configuration values.
Provided features are:
Nested Class Summary | |
---|---|
class |
ApplicationPreferenceManagerImpl.DeviceConfigurationChangeEventSource
Observable event source implementation for sensor device configuration change events |
class |
ApplicationPreferenceManagerImpl.LogLevelConfigurationChangeEventSource
Observable event source implementation for log level change events |
class |
ApplicationPreferenceManagerImpl.ServiceConfigurationChangeEventSource
Observable event source implementation for service configuration change events |
class |
ApplicationPreferenceManagerImpl.TimeProviderConfigurationChangeEventSource
Observable event source implementation for time provider change events |
Field Summary | |
---|---|
private DevicePreferencesCollection |
devicePreferences
The device preferences |
private SharedPreferences.OnSharedPreferenceChangeListener |
listener
the shared preferences listener |
private SinglePreference<LogLevelConfiguration> |
logLevelPreference
The log level preferences |
private Map<Class<? extends ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>>,ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>> |
mapChangeEventSource
Map to hold the supported change event sources mapped to events class name |
private Map<String,SensorDevicePreferences> |
mapKeyToDevicePreferences
preference key to device preferences mapping |
private ServicePreferences |
servicePreferences
The service preferences |
private TimeProviderPreference |
timeProviderPreference
The time provider preferences |
private UUIDPreference |
uuidPreference
The UUID preferences |
Constructor Summary | |
---|---|
ApplicationPreferenceManagerImpl()
Constructor |
Method Summary | |
---|---|
SensorDeviceConfiguration |
getDeviceConfiguration(SensorDeviceIdentifier deviceIdentifier,
Context applicationContext)
Access to device configurations created from current device preferences |
private DevicePreferencesCollection |
getDevicePreferences()
Getter for the device preferences |
private ApplicationPreferenceManagerImpl.DeviceConfigurationChangeEventSource |
getDeviceUpdateSource()
Getter for the device update source |
LogLevelConfiguration |
getLogLevelConfiguration(Context applicationContext)
Access to log level configuration created from current log level preferences |
SinglePreference<LogLevelConfiguration> |
getLogLevelPreference()
Getter for log level preferences |
private ObservableEventSource<LogLevelConfigurationChangeEvent> |
getLogUpdateSource()
Getter for the log update source |
private Map<String,SensorDevicePreferences> |
getMapKeyToDevicePreferences()
Getter for the key to device preferences map |
Collection<ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>> |
getObservableEventSources()
Method to get a collection of the internal observable event sources for test purpose |
SensorDevicePreferences |
getPreferencesForDevice(SensorDeviceIdentifier deviceIdentifier)
Getter for specific device preferences |
ServiceConfiguration |
getServiceConfiguration(Context applicationContext)
Access to service configuration created from current service preferences |
ServicePreferences |
getServicePreferences()
Getter for the service preferences |
private ObservableEventSource<ServiceConfigurationChangeEvent> |
getServiceUpdateSource()
Getter for the service update source |
SharedPreferences |
getSharedPreferences(Context applicationContext)
Does return the shared preferences for the application context |
TimeProviderConfiguration |
getTimeProviderConfiguration(Context applicationContext)
Access to the time provider configuration created from current time provider preferences |
TimeProviderPreference |
getTimeProviderPreference()
Getter for time provider preferences |
private ObservableEventSource<TimeProviderConfigurationChangeEvent> |
getTimeProviderUpdateSource()
Getter for the time provider update source |
String |
getUUIDConfiguration(Context applicationContext)
Access to the UUID configuration created from the current UUID preferences |
UUIDPreference |
getUUIDPreference()
Getter for UUID preferences |
private void |
handlePreferenceUpdate(SharedPreferences sharedPreferences,
String key)
Handler for preference changes |
void |
onDestroy()
Internal destroy method to clean up references |
private void |
registerDevicePreferences(SensorDevicePreferences preferences)
Does register device preferences for the key to device preference mapping |
void |
registerEventObserver(EventObserver<? extends ConfigurationChangeEvent<? extends Configuration>> observer)
Does register an observer |
void |
removeAllObservers()
Does remove all registered observers |
void |
resetToDefaults(Context applicationContext)
Does reset the local stored changes for all preferences. |
void |
startListening(Context applicationContext)
Does start the listening for application preferences changes |
void |
stopListening(Context applicationContext)
Does stop the listening for application preferences changes |
void |
unregisterEventObserver(EventObserver<? extends ConfigurationChangeEvent<? extends Configuration>> observer)
Does delete a registered observer |
void |
updateLogLevelConfiguration(Context applicationContext,
LogLevel logLevel)
Method to update the store log level preference |
void |
updatePreferenceState(Context applicationContext,
SinglePreference<Boolean> preference,
boolean state)
Method to change the state for a given boolean preference |
protected void |
updateSchedule(Context applicationContext,
WeeklySchedule schedule)
Internal update method for the weekly schedule |
void |
updateUUIDConfiguration(Context applicationContext,
String sUuid)
Method to update the stored device UUID. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final Map<Class<? extends ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>>,ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>> mapChangeEventSource
private final DevicePreferencesCollection devicePreferences
private final SinglePreference<LogLevelConfiguration> logLevelPreference
private final UUIDPreference uuidPreference
private final TimeProviderPreference timeProviderPreference
private final ServicePreferences servicePreferences
private final SharedPreferences.OnSharedPreferenceChangeListener listener
private final Map<String,SensorDevicePreferences> mapKeyToDevicePreferences
Constructor Detail |
---|
public ApplicationPreferenceManagerImpl()
Method Detail |
---|
private final ApplicationPreferenceManagerImpl.DeviceConfigurationChangeEventSource getDeviceUpdateSource()
private final ObservableEventSource<LogLevelConfigurationChangeEvent> getLogUpdateSource()
private final ObservableEventSource<TimeProviderConfigurationChangeEvent> getTimeProviderUpdateSource()
private final ObservableEventSource<ServiceConfigurationChangeEvent> getServiceUpdateSource()
public final Collection<ObservableEventSource<? extends ConfigurationChangeEvent<? extends Configuration>>> getObservableEventSources()
private final DevicePreferencesCollection getDevicePreferences()
private final Map<String,SensorDevicePreferences> getMapKeyToDevicePreferences()
private final void handlePreferenceUpdate(SharedPreferences sharedPreferences, String key)
sharedPreferences
- the shared preferenceskey
- the preference key identifierprivate final void registerDevicePreferences(SensorDevicePreferences preferences)
preferences
- the device preferences to registerpublic final SensorDevicePreferences getPreferencesForDevice(SensorDeviceIdentifier deviceIdentifier)
ApplicationPreferenceManager
getPreferencesForDevice
in interface ApplicationPreferenceManager
deviceIdentifier
- the device identifier
public final SinglePreference<LogLevelConfiguration> getLogLevelPreference()
ApplicationPreferenceManager
getLogLevelPreference
in interface ApplicationPreferenceManager
public final TimeProviderPreference getTimeProviderPreference()
ApplicationPreferenceManager
getTimeProviderPreference
in interface ApplicationPreferenceManager
public final ServicePreferences getServicePreferences()
ApplicationPreferenceManager
getServicePreferences
in interface ApplicationPreferenceManager
public UUIDPreference getUUIDPreference()
ApplicationPreferenceManager
getUUIDPreference
in interface ApplicationPreferenceManager
public final SensorDeviceConfiguration getDeviceConfiguration(SensorDeviceIdentifier deviceIdentifier, Context applicationContext)
ApplicationPreferenceManager
getDeviceConfiguration
in interface ApplicationPreferenceManager
deviceIdentifier
- the device identifierapplicationContext
- the application context
public final LogLevelConfiguration getLogLevelConfiguration(Context applicationContext)
ApplicationPreferenceManager
getLogLevelConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application context
public void updateLogLevelConfiguration(Context applicationContext, LogLevel logLevel)
ApplicationPreferenceManager
updateLogLevelConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application contextlogLevel
- the logLevel to update topublic final TimeProviderConfiguration getTimeProviderConfiguration(Context applicationContext)
ApplicationPreferenceManager
getTimeProviderConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application context
public final ServiceConfiguration getServiceConfiguration(Context applicationContext)
ApplicationPreferenceManager
getServiceConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application context
public String getUUIDConfiguration(Context applicationContext)
ApplicationPreferenceManager
getUUIDConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application context
public void updateUUIDConfiguration(Context applicationContext, String sUuid)
ApplicationPreferenceManager
updateUUIDConfiguration
in interface ApplicationPreferenceManager
applicationContext
- the application contextsUuid
- the new UUID to store in preferencespublic final void startListening(Context applicationContext)
ApplicationPreferenceManager
startListening
in interface ApplicationPreferenceManager
applicationContext
- the application contextpublic final void stopListening(Context applicationContext)
ApplicationPreferenceManager
stopListening
in interface ApplicationPreferenceManager
applicationContext
- the application contextpublic final SharedPreferences getSharedPreferences(Context applicationContext)
ApplicationPreferenceManager
getSharedPreferences
in interface ApplicationPreferenceManager
applicationContext
- the application context
public final void unregisterEventObserver(EventObserver<? extends ConfigurationChangeEvent<? extends Configuration>> observer)
ObserverRegistration
unregisterEventObserver
in interface ObserverRegistration<ConfigurationChangeEvent<? extends Configuration>>
observer
- the observer to deletepublic final void registerEventObserver(EventObserver<? extends ConfigurationChangeEvent<? extends Configuration>> observer)
ObserverRegistration
registerEventObserver
in interface ObserverRegistration<ConfigurationChangeEvent<? extends Configuration>>
observer
- the observer to addpublic final void onDestroy()
ApplicationPreferenceManager
onDestroy
in interface ApplicationPreferenceManager
public void removeAllObservers()
ObserverRegistration
removeAllObservers
in interface ObserverRegistration<ConfigurationChangeEvent<? extends Configuration>>
public void resetToDefaults(Context applicationContext)
ApplicationPreferenceManager
resetToDefaults
in interface ApplicationPreferenceManager
applicationContext
- the application contextprotected final void updateSchedule(Context applicationContext, WeeklySchedule schedule)
applicationContext
- the application contextschedule
- the schedulepublic final void updatePreferenceState(Context applicationContext, SinglePreference<Boolean> preference, boolean state)
ApplicationPreferenceManager
updatePreferenceState
in interface ApplicationPreferenceManager
applicationContext
- the application contextpreference
- the preference to changestate
- the state to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |