@Override
  protected View onCreateDialogView() {
    Resources res = getContext().getResources();
    final Context context = getContext();
    final View root =
        new DialogBuilder(context)
            .setIcon(mIcon)
            .setTitle(mTitle)
            .setContentView(R.layout.preference_dialog_timeout)
            .createView();

    Config config = Config.getInstance();

    mProgresses = new int[1];
    mGroups = new Group[mProgresses.length];
    mGroups[0] =
        new Group(
            (SeekBar) root.findViewById(R.id.normal_timeout_seekbar),
            (TextView) root.findViewById(R.id.normal_timeout_value),
            config.getOption(Config.KEY_NOTIFY_DECAY_TIME));

    final int max = res.getInteger(R.integer.config_timeout_maxDurationMillis) / MULTIPLIER;
    mMin = res.getInteger(R.integer.config_timeout_minDurationMillis) / MULTIPLIER;
    mSoftStoredLabels = new SoftReference[max + 1];

    for (Group group : mGroups) {
      int progress = (int) group.option.read(config);
      group.seekBar.setOnSeekBarChangeListener(this);
      group.seekBar.setMax(max);
      group.seekBar.setProgress(progress / MULTIPLIER);
    }

    return root;
  }
  public Enabler(Context context, Switch switch_, String key) {
    mContext = context;

    mKey = key;
    mConfig = Config.getInstance();
    mOption = mConfig.getHashMap().get(mKey);

    mSwitch = switch_;
  }
  private void onEnabledInternal(Context context) {
    if (mConfig != null) {
      return; // already initialized
    }

    mConfig = Config.getInstance();
    mConfig.registerListener(this);

    if (DEBUG) Log.d(TAG, "Toggle widget enabled");
  }
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    if (!positiveResult) {
      return;
    }

    // Save changes to config.
    Config config = Config.getInstance();
    for (Group group : mGroups) {
      int value = group.seekBar.getProgress() * MULTIPLIER;
      group.option.write(config, getContext(), value, null);
    }
  }
 @Override
 public Config getConfig() {
   return Config.getInstance();
 }