com.android.sdklib.internal.repository.updater
Class SettingsController

java.lang.Object
  extended by com.android.sdklib.internal.repository.updater.SettingsController

public class SettingsController
extends java.lang.Object

Controller class to get settings values. Settings are kept in-memory. Users of this class must first load the settings before changing them and save them when modified.

Settings are enumerated by constants in ISettingsPage.


Nested Class Summary
static interface SettingsController.OnChangedListener
           
static class SettingsController.Settings
           
 
Constructor Summary
  SettingsController(com.android.utils.ILogger sdkLog)
          Constructs a new default SettingsController.
protected SettingsController(com.android.utils.ILogger sdkLog, SettingsController.Settings settings)
          Specialized constructor that wraps an existing SettingsController.Settings instance.
 
Method Summary
 void applySettings()
          Applies the current settings.
 SettingsController.Settings getSettings()
           
 void loadSettings()
          Load settings from the settings file.
 void registerOnChangedListener(SettingsController.OnChangedListener listener)
           
 void saveSettings()
          Saves settings to the settings file.
 void setMonitorDensity(int density)
          Sets the value of the ISettingsPage.KEY_MONITOR_DENSITY setting.
 void setSettingsPage(ISettingsPage settingsPage)
          Associate the given ISettingsPage with this SettingsController.
 void setShowUpdateOnly(boolean enabled)
          Sets the value of the ISettingsPage.KEY_SHOW_UPDATE_ONLY setting.
 void unregisterOnChangedListener(SettingsController.OnChangedListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettingsController

public SettingsController(@NonNull
                          com.android.utils.ILogger sdkLog)
Constructs a new default SettingsController.

Parameters:
sdkLog - A non-null logger to use.

SettingsController

protected SettingsController(@NonNull
                             com.android.utils.ILogger sdkLog,
                             @NonNull
                             SettingsController.Settings settings)
Specialized constructor that wraps an existing SettingsController.Settings instance. This is mostly used in unit-tests to override settings that are being used. Normal usage should NOT need to call this constructor.

Parameters:
sdkLog - A non-null logger to use.
settings - A non-null SettingsController.Settings to use as-is. It is not duplicated.
Method Detail

getSettings

public SettingsController.Settings getSettings()

registerOnChangedListener

public void registerOnChangedListener(SettingsController.OnChangedListener listener)

unregisterOnChangedListener

public void unregisterOnChangedListener(SettingsController.OnChangedListener listener)

setShowUpdateOnly

public void setShowUpdateOnly(boolean enabled)
Sets the value of the ISettingsPage.KEY_SHOW_UPDATE_ONLY setting.

Parameters:
enabled - True if only compatible non-obsolete update items should be shown.
See Also:
ISettingsPage.KEY_SHOW_UPDATE_ONLY

setMonitorDensity

public void setMonitorDensity(int density)
Sets the value of the ISettingsPage.KEY_MONITOR_DENSITY setting.

Parameters:
density - the density of the monitor
See Also:
ISettingsPage.KEY_MONITOR_DENSITY

setSettingsPage

public void setSettingsPage(ISettingsPage settingsPage)
Associate the given ISettingsPage with this SettingsController.

This loads the current properties into the setting page UI. It then associates the SettingsChanged callback with this controller.

If the setting page given is null, it will be unlinked from controller.

Parameters:
settingsPage - An ISettingsPage to associate with the controller.

loadSettings

public void loadSettings()
Load settings from the settings file.


saveSettings

public void saveSettings()
Saves settings to the settings file.


applySettings

public void applySettings()
Applies the current settings.