예제 #1
0
  protected void buildLists() {
    ListPreference deckConfPref = (ListPreference) findPreference("deckConf");
    ArrayList<JSONObject> confs = mCol.getDecks().allConf();
    Collections.sort(confs, new JSONNameComparator());
    String[] confValues = new String[confs.size()];
    String[] confLabels = new String[confs.size()];
    try {
      for (int i = 0; i < confs.size(); i++) {
        JSONObject o = confs.get(i);
        confValues[i] = o.getString("id");
        confLabels[i] = o.getString("name");
      }
    } catch (JSONException e) {
      throw new RuntimeException(e);
    }
    deckConfPref.setEntries(confLabels);
    deckConfPref.setEntryValues(confValues);
    deckConfPref.setValue(mPref.getString("deckConf", "0"));

    ListPreference newOrderPref = (ListPreference) findPreference("newOrder");
    newOrderPref.setEntries(R.array.new_order_labels);
    newOrderPref.setEntryValues(R.array.new_order_values);
    newOrderPref.setValue(mPref.getString("newOrder", "0"));

    ListPreference leechActPref = (ListPreference) findPreference("lapLeechAct");
    leechActPref.setEntries(R.array.leech_action_labels);
    leechActPref.setEntryValues(R.array.leech_action_values);
    leechActPref.setValue(mPref.getString("lapLeechAct", "0"));
  }
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      // Load the preferences from an XML resource
      addPreferencesFromResource(R.xml.prefs_statusbar_toggles);

      mEnabledToggles = findPreference(PREF_ENABLE_TOGGLES);

      mBrightnessLocation = (ListPreference) findPreference(PREF_BRIGHTNESS_LOC);
      mBrightnessLocation.setOnPreferenceChangeListener(this);
      mBrightnessLocation.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(),
                  Settings.System.STATUSBAR_TOGGLES_BRIGHTNESS_LOC,
                  1)));

      mToggleStyle = (ListPreference) findPreference(PREF_TOGGLES_STYLE);
      mToggleStyle.setOnPreferenceChangeListener(this);
      mToggleStyle.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(), Settings.System.STATUSBAR_TOGGLES_STYLE, 3)));

      mAlternateButtonLayout = (CheckBoxPreference) findPreference(PREF_ALT_BUTTON_LAYOUT);
      mAlternateButtonLayout.setChecked(
          Settings.System.getInt(
                  getContentResolver(), Settings.System.STATUSBAR_TOGGLES_USE_BUTTONS, 0)
              == 1);
    }
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
      preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

      super.onCreate(savedInstanceState);
      preferences.registerOnSharedPreferenceChangeListener(this);
      addPreferencesFromResource(R.xml.performance);

      final int frequencies[] = getFrequencies();
      final String freqList[] = getMHz(frequencies);
      final String freqValues[] = getValues(frequencies);
      final String maxFreq = (Helpers.getFile(MAX_FREQ).trim());
      final String minFreq = (Helpers.getFile(MIN_FREQ).trim());
      final String maxInMhz = (Integer.toString((Integer.parseInt(maxFreq) / 1000)) + " MHz");
      final String minInMhz = (Integer.toString((Integer.parseInt(minFreq) / 1000)) + " MHz");
      final String govs[] = getAllGovs();
      final String currentGov = (Helpers.getFile(CUR_GOV).trim());

      mMaxCpu = (ListPreference) findPreference(KEY_MAX_CPU);
      mMaxCpu.setEntries(freqList);
      mMaxCpu.setEntryValues(freqValues);
      mMaxCpu.setValue(maxFreq);
      mMaxCpu.setSummary(getString(R.string.ps_set_max, maxInMhz));

      mMinCpu = (ListPreference) findPreference(KEY_MIN_CPU);
      mMinCpu.setEntries(freqList);
      mMinCpu.setEntryValues(freqValues);
      mMinCpu.setValue(minFreq);
      mMinCpu.setSummary(getString(R.string.ps_set_min, minInMhz));

      mSetGov = (ListPreference) findPreference(KEY_GOV);
      mSetGov.setEntries(govs);
      mSetGov.setEntryValues(govs);
      mSetGov.setValue(currentGov);
      mSetGov.setSummary(getString(R.string.ps_set_gov, currentGov));

      final int minFree = getMinFreeValue();
      final String values[] = getResources().getStringArray(R.array.minfree_values);
      String closestValue = preferences.getString(KEY_MINFREE, values[0]);

      if (minFree < 37) closestValue = values[0];
      else if (minFree < 62) closestValue = values[1];
      else if (minFree < 77) closestValue = values[2];
      else if (minFree < 90) closestValue = values[3];
      else closestValue = values[4];

      mFreeMem = (ListPreference) findPreference(KEY_MINFREE);
      mFreeMem.setValue(closestValue);
      mFreeMem.setSummary(getString(R.string.ps_free_memory, minFree + "mb"));

      PreferenceScreen ps = (PreferenceScreen) findPreference("volt_control");
      if (!new File(VoltageControl.MV_TABLE0).exists()) {
        ((PreferenceCategory) getPreferenceScreen().findPreference("cpu")).removePreference(ps);
      }

      doneLoading = true;
    }
예제 #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mGovernorFormat = getString(R.string.cpu_governors_summary);
    mMinFrequencyFormat = getString(R.string.cpu_min_freq_summary);
    mMaxFrequencyFormat = getString(R.string.cpu_max_freq_summary);

    String[] availableGovernors = readOneLine(GOVERNORS_LIST_FILE).split(" ");
    String[] availableFrequencies = new String[0];
    String availableFrequenciesLine = readOneLine(FREQ_LIST_FILE);
    if (availableFrequenciesLine != null)
      availableFrequencies = availableFrequenciesLine.split(" ");
    String[] frequencies;
    String temp;

    frequencies = new String[availableFrequencies.length];
    for (int i = 0; i < frequencies.length; i++) {
      frequencies[i] = toMHz(availableFrequencies[i]);
    }

    setTitle(R.string.cpu_title);
    addPreferencesFromResource(R.xml.cpu_settings);

    PreferenceScreen PrefScreen = getPreferenceScreen();

    temp = readOneLine(GOVERNOR);

    mGovernorPref = (ListPreference) PrefScreen.findPreference(GOV_PREF);
    mGovernorPref.setEntryValues(availableGovernors);
    mGovernorPref.setEntries(availableGovernors);
    mGovernorPref.setValue(temp);
    mGovernorPref.setSummary(String.format(mGovernorFormat, temp));
    mGovernorPref.setOnPreferenceChangeListener(this);

    temp = readOneLine(FREQ_MIN_FILE);

    mMinFrequencyPref = (ListPreference) PrefScreen.findPreference(MIN_FREQ_PREF);
    mMinFrequencyPref.setEntryValues(availableFrequencies);
    mMinFrequencyPref.setEntries(frequencies);
    mMinFrequencyPref.setValue(temp);
    mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp)));
    mMinFrequencyPref.setOnPreferenceChangeListener(this);

    temp = readOneLine(FREQ_MAX_FILE);

    mMaxFrequencyPref = (ListPreference) PrefScreen.findPreference(MAX_FREQ_PREF);
    mMaxFrequencyPref.setEntryValues(availableFrequencies);
    mMaxFrequencyPref.setEntries(frequencies);
    mMaxFrequencyPref.setValue(temp);
    mMaxFrequencyPref.setSummary(String.format(mMaxFrequencyFormat, toMHz(temp)));
    mMaxFrequencyPref.setOnPreferenceChangeListener(this);
  }
예제 #5
0
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (mCameraChange == preference) {
     String prefsValueCameraChange = (String) newValue;
     mCameraChange.setValue(prefsValueCameraChange);
     int mode = Integer.parseInt(prefsValueCameraChange);
     switch (mode) {
       case 0:
         preference.setSummary(R.string.Hongmi_camera);
         RootCmd.RunRootCmd("busybox mount -o remount,rw /system");
         RootCmd.RunRootCmd("mv /system/app/CP_camera.apk /system/app/CP_camera.bak");
         RootCmd.RunRootCmd("mv /system/app/Hongmi_camera.bak /system/app/Hongmi_camera.apk");
         break;
       case 1:
         preference.setSummary(R.string.CP_camera);
         RootCmd.RunRootCmd("busybox mount -o remount,rw /system");
         RootCmd.RunRootCmd("mv /system/app/Hongmi_camera.apk /system/app/Hongmi_camera.bak");
         RootCmd.RunRootCmd("mv /system/app/CP_camera.bak /system/app/CP_camera.apk");
         break;
       default:
         break;
     }
   }
   if (mSwitchVold == preference) {
     String prefsValueSwitchVold = (String) newValue;
     mSwitchVold.setValue(prefsValueSwitchVold);
     int mode = Integer.parseInt(prefsValueSwitchVold);
     switch (mode) {
       case 0:
         preference.setSummary(R.string.External_sdcard);
         RootCmd.RunRootCmd("busybox mount -o remount,rw /system");
         RootCmd.RunRootCmd("busybox cp /system/bin/stocksettings/external_vold /system/bin/vold");
         RootCmd.RunRootCmd(
             "busybox cp /system/bin/stocksettings/external_sdcard /system/bin/sdcard");
         RootCmd.RunRootCmd("busybox chmod 0755 /system/bin/vold");
         RootCmd.RunRootCmd("busybox chmod 0755 /system/bin/sdcard");
         RootCmd.RunRootCmd("reboot");
         break;
       case 1:
         preference.setSummary(R.string.Internal_sdcard);
         RootCmd.RunRootCmd("busybox mount -o remount,rw /system");
         RootCmd.RunRootCmd("busybox cp /system/bin/stocksettings/internal_vold /system/bin/vold");
         RootCmd.RunRootCmd(
             "busybox cp /system/bin/stocksettings/internal_sdcard /system/bin/sdcard");
         RootCmd.RunRootCmd("busybox chmod 0755 /system/bin/vold");
         RootCmd.RunRootCmd("busybox chmod 0755 /system/bin/sdcard");
         RootCmd.RunRootCmd("reboot");
         break;
       default:
         break;
     }
   }
   return true;
 }
  private void initPreferences() {
    CheckBoxPreference notifyOpenNetworks =
        (CheckBoxPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
    notifyOpenNetworks.setChecked(
        Secure.getInt(getContentResolver(), Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0)
            == 1);
    notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());

    CheckBoxPreference watchdogEnabled =
        (CheckBoxPreference) findPreference(KEY_ENABLE_WIFI_WATCHDOG);
    if (watchdogEnabled != null) {
      watchdogEnabled.setChecked(
          Secure.getInt(getContentResolver(), Secure.WIFI_WATCHDOG_ON, 1) == 1);

      // TODO: Bring this back after changing watchdog behavior
      getPreferenceScreen().removePreference(watchdogEnabled);
    }

    ListPreference frequencyPref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);

    if (mWifiManager.isDualBandSupported()) {
      frequencyPref.setOnPreferenceChangeListener(this);
      int value = mWifiManager.getFrequencyBand();
      if (value != -1) {
        frequencyPref.setValue(String.valueOf(value));
      } else {
        Log.e(TAG, "Failed to fetch frequency band");
      }
    } else {
      if (frequencyPref != null) {
        // null if it has already been removed before resume
        getPreferenceScreen().removePreference(frequencyPref);
      }
    }

    ListPreference sleepPolicyPref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
    if (sleepPolicyPref != null) {
      if (Utils.isWifiOnly(getActivity())) {
        sleepPolicyPref.setEntries(R.array.wifi_sleep_policy_entries_wifi_only);
      }
      sleepPolicyPref.setOnPreferenceChangeListener(this);
      int value =
          Settings.System.getInt(
              getContentResolver(),
              Settings.System.WIFI_SLEEP_POLICY,
              Settings.System.WIFI_SLEEP_POLICY_NEVER);
      String stringValue = String.valueOf(value);
      sleepPolicyPref.setValue(stringValue);
      updateSleepPolicySummary(sleepPolicyPref, stringValue);
    }
  }
예제 #7
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.option);

    geted = PreferenceManager.getDefaultSharedPreferences(this).edit();
    geted.putBoolean("AI", false);
    geted.putString("name", Nom);
    geted.putString("surname", Prénom);
    geted.putString("nickname", Pseudonyme);

    geted.putString("IPadress", IPAdress);
    if (externe) {
      geted.putBoolean("externe", true);
      geted.putString("IPadress_ext", IPadress_ext);
      geted.putString("SSID", SSID);
    } else {
      geted.putBoolean("externe", false);
    }
    geted.putBoolean("shake", ShakeService);
    geted.putBoolean("event", EventService);
    geted.putBoolean("tts_pref", TTS);
    geted.putBoolean("update", Update_Com);
    geted.commit();

    ListPreference lp = (ListPreference) findPreference("sexe");
    lp.setEntries(Values);
    lp.setEntryValues(Values);
    if (Sexe < 3) lp.setValue(Values[Sexe]);

    finish();
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    if (getActivity() == null) return;

    mRingMode.setValue(getPhoneRingModeSettingValue());
    mRingMode.setSummary(mRingMode.getEntry());
    updateQuietHoursSummary();
  }
  /**
   * Invoked on each preference click in this hierarchy, overrides PreferenceActivity's
   * implementation. Used to make sure we track the preference click events.
   */
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    /** TODO: Refactor and get rid of the if's using subclasses */
    if (mGsmUmtsOptions != null && mGsmUmtsOptions.preferenceTreeClick(preference) == true) {
      return true;
    } else if (mCdmaOptions != null && mCdmaOptions.preferenceTreeClick(preference) == true) {
      if (Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {

        mClickedPreference = preference;

        // In ECM mode launch ECM app dialog
        startActivityForResult(
            new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
            REQUEST_CODE_EXIT_ECM);
      }
      return true;
    } else if (preference == mButtonPreferredNetworkMode) {
      // displays the value taken from the Settings.System
      int settingsNetworkMode = getPreferredNetworkMode();
      mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
      return true;
    } else {
      // if the button is anything but the simple toggle preference,
      // we'll need to disable all preferences to reject all click
      // events until the sub-activity's UI comes up.
      preferenceScreen.setEnabled(false);
      // Let the intents be launched by the Preference manager
      return false;
    }
  }
 private void disableUnusableTimeouts(ListPreference screenTimeoutPreference) {
   final DevicePolicyManager dpm =
       (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
   final long maxTimeout = dpm != null ? dpm.getMaximumTimeToLock(null) : 0;
   if (maxTimeout == 0) {
     return; // policy not enforced
   }
   final CharSequence[] entries = screenTimeoutPreference.getEntries();
   final CharSequence[] values = screenTimeoutPreference.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.parseLong(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     screenTimeoutPreference.setEntries(
         revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     screenTimeoutPreference.setEntryValues(
         revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.parseInt(screenTimeoutPreference.getValue());
     if (userPreference <= maxTimeout) {
       screenTimeoutPreference.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   screenTimeoutPreference.setEnabled(revisedEntries.size() > 0);
 }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.recents_panel_settings);

    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    PackageManager pm = getPackageManager();

    mRecentsClearAll = (SwitchPreference) prefSet.findPreference(SHOW_CLEAR_ALL_RECENTS);
    mRecentsClearAll.setChecked(
        Settings.System.getIntForUser(
                resolver, Settings.System.SHOW_CLEAR_ALL_RECENTS, 1, UserHandle.USER_CURRENT)
            == 1);
    mRecentsClearAll.setOnPreferenceChangeListener(this);

    mRecentsClearAllLocation = (ListPreference) prefSet.findPreference(RECENTS_CLEAR_ALL_LOCATION);
    int location =
        Settings.System.getIntForUser(
            resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 3, UserHandle.USER_CURRENT);
    mRecentsClearAllLocation.setValue(String.valueOf(location));
    mRecentsClearAllLocation.setOnPreferenceChangeListener(this);
    updateRecentsLocation(location);

    mOmniSwitch = (Preference) prefSet.findPreference(KEY_OMNISWITCH);
    if (!Helpers.isPackageInstalled(OMNISWITCH_PACKAGE_NAME, pm)) {
      prefSet.removePreference(mOmniSwitch);
    }
  }
 private void disableUnusableTimeouts(long maxTimeout) {
   final CharSequence[] entries = mLockAfter.getEntries();
   final CharSequence[] values = mLockAfter.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.valueOf(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     mLockAfter.setEntries(revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     mLockAfter.setEntryValues(revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.valueOf(mLockAfter.getValue());
     if (userPreference <= maxTimeout) {
       mLockAfter.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   mLockAfter.setEnabled(revisedEntries.size() > 0);
 }
  /**
   * Implemented to support onPreferenceChangeListener to look for preference changes specifically
   * on CLIR.
   *
   * @param preference is the preference to be changed, should be mButtonCLIR.
   * @param objValue should be the value of the selection, NOT its localized display value.
   */
  public boolean onPreferenceChange(Preference preference, Object objValue) {
    if (preference == mButtonPreferredNetworkMode) {
      // NOTE onPreferenceChange seems to be called even if there is no change
      // Check if the button value is changed from the System.Setting
      mButtonPreferredNetworkMode.setValue((String) objValue);
      int buttonNetworkMode;
      buttonNetworkMode = Integer.valueOf((String) objValue).intValue();
      int settingsNetworkMode = getPreferredNetworkMode();
      if (buttonNetworkMode != settingsNetworkMode) {
        int modemNetworkMode = buttonNetworkMode;
        // if new mode is invalid set mode to default preferred
        if ((modemNetworkMode < Phone.NT_MODE_WCDMA_PREF)
            || (modemNetworkMode > Phone.NT_MODE_LTE_ONLY)) {
          modemNetworkMode = Phone.PREFERRED_NT_MODE;
        }

        // If button has no valid selection && setting is LTE ONLY
        // mode, let the setting stay in LTE ONLY mode. UI is not
        // supported but LTE ONLY mode could be used in testing.
        if ((modemNetworkMode == Phone.PREFERRED_NT_MODE)
            && (settingsNetworkMode == Phone.NT_MODE_LTE_ONLY)) {
          return true;
        }

        UpdatePreferredNetworkModeSummary(buttonNetworkMode);
        setPreferredNetworkMode(buttonNetworkMode);
        // Set the modem network mode
        mPhone.setPreferredNetworkType(
            modemNetworkMode, mHandler.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
      }
    }

    // always let the preference setting proceed.
    return true;
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    final int ringerMode = mAudioManager.getRingerMode();

    // NB: in the UI we now simply call this "silent mode". A separate
    // setting controls whether we're in RINGER_MODE_SILENT or
    // RINGER_MODE_VIBRATE.
    final boolean silentOrVibrateMode = ringerMode != AudioManager.RINGER_MODE_NORMAL;

    if (silentOrVibrateMode != mSilent.isChecked() || force) {
      mSilent.setChecked(silentOrVibrateMode);
    }

    String phoneVibrateSetting = getPhoneVibrateSettingValue();

    if (!phoneVibrateSetting.equals(mVibrate.getValue()) || force) {
      mVibrate.setValue(phoneVibrateSetting);
    }
    mVibrate.setSummary(mVibrate.getEntry());

    int silentModeStreams =
        Settings.System.getInt(
            getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
    boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0;
    mSilent.setSummary(
        isAlarmInclSilentMode
            ? R.string.silent_mode_incl_alarm_summary
            : R.string.silent_mode_summary);
  }
예제 #15
0
  @Override
  public void onResume() {
    String temp;

    super.onResume();

    temp = readOneLine(FREQ_MAX_FILE);
    mMaxFrequencyPref.setValue(temp);
    mMaxFrequencyPref.setSummary(String.format(mMaxFrequencyFormat, toMHz(temp)));

    temp = readOneLine(FREQ_MIN_FILE);
    mMinFrequencyPref.setValue(temp);
    mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp)));

    temp = readOneLine(GOVERNOR);
    mGovernorPref.setSummary(String.format(mGovernorFormat, temp));
  }
 private void updateInputMethodSelectorSummary(int value) {
   String[] inputMethodSelectorTitles =
       getResources().getStringArray(R.array.input_method_selector_titles);
   if (inputMethodSelectorTitles.length > value) {
     mShowInputMethodSelectorPref.setSummary(inputMethodSelectorTitles[value]);
     mShowInputMethodSelectorPref.setValue(String.valueOf(value));
   }
 }
 public void updateRotationTimeout(int timeout) {
   if (timeout == 0) {
     timeout = KEYBOARD_ROTATION_TIMEOUT_DEFAULT;
   }
   mKeyboardRotationTimeout.setValue(Integer.toString(timeout));
   mKeyboardRotationTimeout.setSummary(
       getString(R.string.keyboard_rotation_timeout_summary, mKeyboardRotationTimeout.getEntry()));
 }
예제 #18
0
 /** Handles time zone preference changes */
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   String tz;
   final Activity activity = getActivity();
   if (preference == mUseHomeTZ) {
     if ((Boolean) newValue) {
       tz = mTimeZoneId;
     } else {
       tz = CalendarCache.TIMEZONE_TYPE_AUTO;
     }
     Utils.setTimeZone(activity, tz);
     return true;
   } else if (preference == mHideDeclined) {
     mHideDeclined.setChecked((Boolean) newValue);
     Intent intent = new Intent(Utils.getWidgetScheduledUpdateAction(activity));
     intent.setDataAndType(CalendarContract.CONTENT_URI, Utils.APPWIDGET_DATA_TYPE);
     activity.sendBroadcast(intent);
     return true;
   } else if (preference == mWeekStart) {
     mWeekStart.setValue((String) newValue);
     mWeekStart.setSummary(mWeekStart.getEntry());
   } else if (preference == mDefaultReminder) {
     mDefaultReminder.setValue((String) newValue);
     mDefaultReminder.setSummary(mDefaultReminder.getEntry());
   } else if (preference == mSnoozeDelay) {
     mSnoozeDelay.setValue((String) newValue);
     mSnoozeDelay.setSummary(mSnoozeDelay.getEntry());
   } else if (preference == mRingtone) {
     if (newValue instanceof String) {
       Utils.setRingTonePreference(activity, (String) newValue);
       String ringtone = getRingtoneTitleFromUri(activity, (String) newValue);
       mRingtone.setSummary(ringtone == null ? "" : ringtone);
     }
     return true;
   } else if (preference == mVibrate) {
     mVibrate.setChecked((Boolean) newValue);
     return true;
   } else if (preference == mDefaultStart) {
     int i = mDefaultStart.findIndexOfValue((String) newValue);
     mDefaultStart.setSummary(mDefaultStart.getEntries()[i]);
     return true;
   } else {
     return true;
   }
   return false;
 }
예제 #19
0
  @Override
  public void onResume() {
    String temp;

    super.onResume();
    temp = getCurMode();
    mA2sdPref.setValue(temp);
    mA2sdPref.setSummary(String.format(mModeFormat, temp));
  }
예제 #20
0
 @Override
 public void setValue(String value) {
   String oldValue = getValue();
   super.setValue(value);
   if (!value.equals(oldValue)) {
     updateState(value);
     notifyDependencyChange(shouldDisableDependents());
   }
 }
예제 #21
0
  @Override
  public void fillLayout(final SipProfile account) {
    super.fillLayout(account);

    accountUsername.setTitle(R.string.w_advanced_caller_id);
    accountUsername.setDialogTitle(R.string.w_advanced_caller_id_desc);

    boolean recycle = true;
    providerListPref = (ListPreference) findPreference(PROVIDER_LIST_KEY);
    if (providerListPref == null) {
      Log.d(THIS_FILE, "Create new list pref");
      providerListPref = new ListPreference(parent);
      providerListPref.setKey(PROVIDER_LIST_KEY);
      recycle = false;
    } else {
      Log.d(THIS_FILE, "Recycle existing list pref");
    }

    CharSequence[] v = new CharSequence[providers.size()];
    int i = 0;
    for (String pv : providers.keySet()) {
      v[i] = pv;
      i++;
    }

    providerListPref.setEntries(v);
    providerListPref.setEntryValues(v);
    providerListPref.setKey(PROVIDER);
    providerListPref.setDialogTitle("Provider");
    providerListPref.setTitle("Provider");
    providerListPref.setSummary("Betamax clone provider");
    providerListPref.setDefaultValue("12VoIP");

    if (!recycle) {
      addPreference(providerListPref);
    }
    hidePreference(null, SERVER);

    String domain = account.getDefaultDomain();
    if (domain != null) {
      for (Entry<String, String[]> entry : providers.entrySet()) {
        String[] val = entry.getValue();
        if (val[0].equalsIgnoreCase(domain)) {
          Log.d(THIS_FILE, "Set provider list pref value to " + entry.getKey());
          providerListPref.setValue(entry.getKey());
          break;
        }
      }
    }
    Log.d(THIS_FILE, providerListPref.getValue());

    // Get wizard specific row
    customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
    customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);

    updateAccountInfos(account);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.general_system_property_pref);

    mSetting = new SystemPropertySetting(this);

    boolean value;

    value = mSetting.getCameraSound();
    mCameraSound = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CAMERA_SOUND);
    mCameraSound.setChecked(value);
    mCameraSound.setOnPreferenceChangeListener(this);

    String lcdDensity = mSetting.getLcdDensity();
    mLcdDensity = (SeekBarPreference) findPreference(SystemPropertySetting.KEY_LCD_DENSITY);
    mLcdDensity.setValue(300, 120, Integer.valueOf(lcdDensity));
    mLcdDensity.setSummary(Misc.getCurrentValueText(this, lcdDensity));
    mLcdDensity.setOnPreferenceDoneListener(this);

    value = mSetting.getCrtEffect();
    mCrtEffect = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CRT_EFFECT);
    mCrtEffect.setChecked(value);
    mCrtEffect.setOnPreferenceChangeListener(this);

    value = mSetting.getLogger();
    mLogger = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_LOGGER);
    mLogger.setChecked(value);
    mLogger.setOnPreferenceChangeListener(this);

    value = mSetting.getCifs();
    mCifs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_CIFS);
    mCifs.setChecked(value);
    mCifs.setOnPreferenceChangeListener(this);

    value = mSetting.getNtfs();
    mNtfs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_NTFS);
    mNtfs.setChecked(value);
    mNtfs.setOnPreferenceChangeListener(this);

    value = mSetting.getJ4fs();
    mJ4fs = (CheckBoxPreference) findPreference(SystemPropertySetting.KEY_J4FS);
    mJ4fs.setChecked(value);
    mJ4fs.setOnPreferenceChangeListener(this);

    String strValue = mSetting.getUsbConfig();
    mUsbConfig = (ListPreference) findPreference(SystemPropertySetting.KEY_USB_CONFIG);
    mUsbConfig.setValue(strValue);
    mUsbConfig.setSummary(
        Misc.getCurrentValueText(
            this,
            Misc.getEntryFromEntryValue(
                mUsbConfig.getEntries(), mUsbConfig.getEntryValues(), strValue)));
    mUsbConfig.setOnPreferenceChangeListener(this);
  }
 @Override
 public void setValue(String value) {
   super.setValue(value);
   CharSequence entry = getEntry();
   if (entry != null) {
     setSummary(entry.toString());
   } else {
     setSummary(value);
   }
 }
예제 #24
0
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    if (getActivity() == null) return;

    final int vibrateMode = mAudioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);

    mVibrateOnRing.setChecked(vibrateMode == AudioManager.VIBRATE_SETTING_ON);
    mSilentMode.setValue(getPhoneSilentModeSettingValue());

    mSilentMode.setSummary(mSilentMode.getEntry());
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.gesture_anywhere);

    mEnabledPref = (SwitchPreference) findPreference(KEY_ENABLED);
    mEnabledPref.setChecked(
        (Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, 0)
            == 1));
    mEnabledPref.setOnPreferenceChangeListener(this);

    mGestureAnywhereFloatingWindow = (SwitchPreference) findPreference(GESTURE_ANYWHERE_FLOATING);
    mGestureAnywhereFloatingWindow.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_FLOATING, 0)
            == 1);
    mGestureAnywhereFloatingWindow.setOnPreferenceChangeListener(this);

    PreferenceScreen prefSet = getPreferenceScreen();
    mPositionPref = (ListPreference) prefSet.findPreference(KEY_POSITION);
    mPositionPref.setOnPreferenceChangeListener(this);
    int position =
        Settings.System.getInt(
            getContentResolver(), Settings.System.GESTURE_ANYWHERE_POSITION, Gravity.LEFT);
    mPositionPref.setValue(String.valueOf(position));
    updatePositionSummary(position);

    mTriggerWidthPref = (SeekBarPreferenceCham) findPreference(KEY_TRIGGER_WIDTH);
    mTriggerWidthPref.setValue(
        Settings.System.getInt(
            getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, 10));
    mTriggerWidthPref.setOnPreferenceChangeListener(this);

    mTriggerTopPref = (SeekBarPreferenceCham) findPreference(KEY_TRIGGER_TOP);
    mTriggerTopPref.setValue(
        Settings.System.getInt(
            getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, 0));
    mTriggerTopPref.setOnPreferenceChangeListener(this);

    mTriggerBottomPref = (SeekBarPreferenceCham) findPreference(KEY_TRIGGER_BOTTOM);
    mTriggerBottomPref.setValue(
        Settings.System.getInt(
            getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, 100));
    mTriggerBottomPref.setOnPreferenceChangeListener(this);

    Preference pref = findPreference(KEY_GESTURES);
    pref.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            startActivity(new Intent(getActivity(), GestureAnywhereBuilderActivity.class));
            return true;
          }
        });
  }
예제 #26
0
  public boolean onPreferenceChange(Preference p, Object newValue) {
    ListPreference l = (ListPreference) p;
    value = (String) newValue;

    updateFlags(value);

    l.setValue(value);
    l.setSummary(l.getEntry());

    return true;
  }
  private void loadSetPreferences() {
    String defaultBTRFIDDevice =
        SharedPreferenceManager.getSharedPreference(
            this,
            SharedPreferenceManager.SP_DEFAULT_BT_RFID_DEVICE_ADDRESS,
            BluetoothHandler.DEFAULT_BT_MAC_ADDRESS);
    String btRFIDDefaultDevName = null;

    btRFIDDefaultDevLP.setValue(defaultBTRFIDDevice);

    if (!defaultBTRFIDDevice.equals(BluetoothHandler.DEFAULT_BT_MAC_ADDRESS)) {
      if (pairedBTDeviceAddresses != null && pairedBTDeviceNames != null) {
        for (int i = 0; i < pairedBTDeviceAddresses.size(); i++) {
          if (pairedBTDeviceAddresses.get(i).equals(defaultBTRFIDDevice)) {
            btRFIDDefaultDevName = pairedBTDeviceNames.get(i).toString();
          }
        }

        if (btRFIDDefaultDevName
            == null) { // means that the default rfid device is no longer paired with this device.
          // set the default device to no device
          defaultBTRFIDDevice = BluetoothHandler.DEFAULT_BT_MAC_ADDRESS;
          SharedPreferenceManager.setSharedPreference(
              this,
              SharedPreferenceManager.SP_DEFAULT_BT_RFID_DEVICE_ADDRESS,
              BluetoothHandler.DEFAULT_BT_MAC_ADDRESS);

          Log.w(
              TAG,
              "The saved default bluetooth RFID device is no longer paired with this device. Setting the default bluetooth RFID device to nothing");
        }
      }
    }

    btRFIDDefaultDevLP.setValue(defaultBTRFIDDevice);
    if (btRFIDDefaultDevName != null) {
      btRFIDDefaultDevLP.setSummary(btRFIDDefaultDevName);
    } else {
      btRFIDDefaultDevLP.setSummary(getString(R.string.pref_bt_rfid_default_dev_summary));
    }
  }
  protected void onCreate(Bundle savedInstanceState, int titleRes, int layout, int preferencesXml) {
    super.onCreate(savedInstanceState);

    packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME);

    // get package title
    try {
      ApplicationInfo ai = getPackageManager().getApplicationInfo(packageName, 0);
      String appName = getPackageManager().getApplicationLabel(ai).toString();
      if (appName == null) appName = packageName;
      setTitle(appName + " - " + getString(titleRes));
    } catch (PackageManager.NameNotFoundException e) {
      setTitle(packageName + " - " + getString(titleRes));
    }

    LayoutInflater inflater = getLayoutInflater();
    View v = inflater.inflate(layout, null);
    setContentView(v);

    addPreferencesFromResource(preferencesXml);
    PreferenceScreen prefScreen = getPreferenceScreen();
    SharedPreferences sharedPrefs =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
      PreferenceGroup prefGroup = (PreferenceGroup) prefScreen.getPreference(i);

      for (int j = 0; j < prefGroup.getPreferenceCount(); j++) {
        Preference pref = prefGroup.getPreference(j);
        String key = packageName + "." + pref.getKey();

        if (pref instanceof ListPreference) {
          ListPreference listPref = ((ListPreference) pref);
          String globalValue = listPref.getValue();
          String currValue = sharedPrefs.getString(key, globalValue);

          listPref.setKey(key);
          listPref.setValue(currValue);
        } else if (pref instanceof CheckBoxPreference) {
          CheckBoxPreference checkPref = (CheckBoxPreference) pref;
          boolean globalValue = checkPref.isChecked();
          boolean currValue = sharedPrefs.getBoolean(key, globalValue);
          checkPref.setKey(key);
          checkPref.setChecked(currValue);
        }
      }
    }

    // apply card layout
    CardPreferenceFragment.applyLayoutToPreferences(prefScreen);

    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.input_methods_settings);

    mDisableFullscreenKeyboard =
        (CheckBoxPreference) findPreference(PREF_DISABLE_FULLSCREEN_KEYBOARD);
    mDisableFullscreenKeyboard.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.DISABLE_FULLSCREEN_KEYBOARD, 0)
            == 1);
    mDisableFullscreenKeyboard.setOnPreferenceChangeListener(this);

    // Enable or disable mStatusBarImeSwitcher based on boolean value: config_show_cmIMESwitcher
    final Preference keyImeSwitcherPref = findPreference(KEY_IME_SWITCHER);
    if (keyImeSwitcherPref != null) {
      if (!getResources().getBoolean(com.android.internal.R.bool.config_show_IMESwitcher)) {
        getPreferenceScreen().removePreference(keyImeSwitcherPref);
      } else {
        mStatusBarImeSwitcher = (CheckBoxPreference) keyImeSwitcherPref;
        mStatusBarImeSwitcher.setOnPreferenceChangeListener(this);
      }
    }

    mVolumeKeyCursorControl = (ListPreference) findPreference(VOLUME_KEY_CURSOR_CONTROL);
    if (mVolumeKeyCursorControl != null) {
      mVolumeKeyCursorControl.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getContentResolver(), Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0)));
      mVolumeKeyCursorControl.setSummary(mVolumeKeyCursorControl.getEntry());
      mVolumeKeyCursorControl.setOnPreferenceChangeListener(this);
    }

    mKeyboardRotationToggle = (CheckBoxPreference) findPreference(KEYBOARD_ROTATION_TOGGLE);
    mKeyboardRotationToggle.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.KEYBOARD_ROTATION_TIMEOUT, 0)
            > 0);
    mKeyboardRotationToggle.setOnPreferenceChangeListener(this);

    mKeyboardRotationTimeout = (ListPreference) findPreference(KEYBOARD_ROTATION_TIMEOUT);
    mKeyboardRotationTimeout.setOnPreferenceChangeListener(this);
    updateRotationTimeout(
        Settings.System.getInt(
            getContentResolver(),
            Settings.System.KEYBOARD_ROTATION_TIMEOUT,
            KEYBOARD_ROTATION_TIMEOUT_DEFAULT));

    mShowEnterKey = (CheckBoxPreference) findPreference(SHOW_ENTER_KEY);
    mShowEnterKey.setChecked(
        Settings.System.getInt(getContentResolver(), Settings.System.FORMAL_TEXT_INPUT, 0) == 1);
    mShowEnterKey.setOnPreferenceChangeListener(this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SettingsActivityComponent cmp = DaggerService.getDaggerComponent(getActivity());
    cmp.inject(this);

    mSettings.setCached(true);

    addPreferencesFromResource(R.xml.prefs_service);

    runWhen = (ListPreference) findPreference(ServiceSettings.RUN_WHEN);
    runWhen.setPersistent(false);
    runWhen.setValue(mSettings.runWhen());
    runWhen.setOnPreferenceChangeListener(this);

    onlyOnWifi = (CheckBoxPreference) findPreference(ServiceSettings.ONLY_WIFI);
    onlyOnWifi.setPersistent(false);
    onlyOnWifi.setChecked(mSettings.onlyOnWifi());
    onlyOnWifi.setOnPreferenceChangeListener(this);

    wifiNetwork = (MultiSelectListPreference) findPreference(ServiceSettings.WIFI_NETWORKS);
    wifiNetwork.setPersistent(false);
    String[] ssids = getWifiNetworks();
    wifiNetwork.setEntries(ssids);
    wifiNetwork.setEntryValues(ssids);
    wifiNetwork.setValues(mSettings.allowedWifiNetworks());
    wifiNetwork.setOnPreferenceChangeListener(this);

    onlyCharging = (CheckBoxPreference) findPreference(ServiceSettings.ONLY_CHARGING);
    onlyCharging.setPersistent(false);
    onlyCharging.setChecked(mSettings.onlyWhenCharging());
    onlyCharging.setOnPreferenceChangeListener(this);

    catBetween = (PreferenceCategory) findPreference("cat_between");
    hideShowRunWhenCategories(mSettings.runWhen());

    scheduleStart = (TimePreference) findPreference(ServiceSettings.RANGE_START);
    scheduleStart.setPersistent(false);
    scheduleStart.setValue(mSettings.getScheduledStartTime());
    scheduleStart.setOnPreferenceChangeListener(this);

    scheduleEnd = (TimePreference) findPreference(ServiceSettings.RANGE_END);
    scheduleEnd.setPersistent(false);
    scheduleEnd.setValue(mSettings.getScheduledEndTime());
    scheduleEnd.setOnPreferenceChangeListener(this);

    exportConfig = findPreference("export");
    exportConfig.setOnPreferenceClickListener(this);
    importConfig = findPreference("import");
    importConfig.setOnPreferenceClickListener(this);
  }