Пример #1
0
  private void enableAll() {
    hostText.setEnabled(true);

    if (!isPACCheck.isChecked()) {
      portText.setEnabled(true);
      proxyTypeList.setEnabled(true);
    }

    bypassAddrs.setEnabled(true);

    if (isAuthCheck.isChecked()) {
      userText.setEnabled(true);
      passwordText.setEnabled(true);
      isNTLMCheck.setEnabled(true);
      if (isNTLMCheck.isChecked()) domainText.setEnabled(true);
    }
    if ("https".equals(proxyTypeList.getValue())) {
      certificateText.setEnabled(true);
    }
    if (!isAutoSetProxyCheck.isChecked()) {
      proxyedApps.setEnabled(true);
      isBypassAppsCheck.setEnabled(true);
    }
    if (isAutoConnectCheck.isChecked()) ssidList.setEnabled(true);

    isDNSProxyCheck.setEnabled(true);
    profileList.setEnabled(true);
    isAutoSetProxyCheck.setEnabled(true);
    isAuthCheck.setEnabled(true);
    isAutoConnectCheck.setEnabled(true);
    isPACCheck.setEnabled(true);
  }
Пример #2
0
  /** @param resource if null, updates all resources */
  @Override
  public void updatePreferences(Preference preference, Object value) {
    Resources r = getResources();

    if (r.getString(R.string.p_rmd_quietStart).equals(preference.getKey())) {
      int index =
          AndroidUtilities.indexOf(
              r.getStringArray(R.array.EPr_quiet_hours_start_values), (String) value);
      Preference endPreference = findPreference(getString(R.string.p_rmd_quietEnd));
      if (index <= 0) {
        preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_desc_none));
        endPreference.setEnabled(false);
      } else {
        String setting = r.getStringArray(R.array.EPr_quiet_hours_start)[index];
        preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_start_desc, setting));
        endPreference.setEnabled(true);
      }
    } else if (r.getString(R.string.p_rmd_quietEnd).equals(preference.getKey())) {
      int index =
          AndroidUtilities.indexOf(
              r.getStringArray(R.array.EPr_quiet_hours_end_values), (String) value);
      int quietHoursStart = Preferences.getIntegerFromString(R.string.p_rmd_quietStart, -1);
      if (index == -1 || quietHoursStart == -1)
        preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_desc_none));
      else {
        String setting = r.getStringArray(R.array.EPr_quiet_hours_end)[index];
        preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_end_desc, setting));
      }
    } else if (r.getString(R.string.p_rmd_time).equals(preference.getKey())) {
      int index =
          AndroidUtilities.indexOf(r.getStringArray(R.array.EPr_rmd_time_values), (String) value);
      String setting = r.getStringArray(R.array.EPr_rmd_time)[index];
      preference.setSummary(r.getString(R.string.rmd_EPr_rmd_time_desc, setting));
    } else if (r.getString(R.string.p_rmd_ringtone).equals(preference.getKey())) {
      if (value == null
          || "content://settings/system/notification_sound".equals(value)) // $NON-NLS-1$
      preference.setSummary(r.getString(R.string.rmd_EPr_ringtone_desc_default));
      else if ("".equals(value)) // $NON-NLS-1$
      preference.setSummary(r.getString(R.string.rmd_EPr_ringtone_desc_silent));
      else preference.setSummary(r.getString(R.string.rmd_EPr_ringtone_desc_custom));
    } else if (r.getString(R.string.p_rmd_persistent).equals(preference.getKey())) {
      if ((Boolean) value)
        preference.setSummary(r.getString(R.string.rmd_EPr_persistent_desc_true));
      else preference.setSummary(r.getString(R.string.rmd_EPr_persistent_desc_false));
    } else if (r.getString(R.string.p_rmd_maxvolume).equals(preference.getKey())) {
      if ((Boolean) value)
        preference.setSummary(r.getString(R.string.rmd_EPr_multiple_maxvolume_desc_true));
      else preference.setSummary(r.getString(R.string.rmd_EPr_multiple_maxvolume_desc_false));
    } else if (r.getString(R.string.p_rmd_vibrate).equals(preference.getKey())) {
      if ((Boolean) value) preference.setSummary(r.getString(R.string.rmd_EPr_vibrate_desc_true));
      else preference.setSummary(r.getString(R.string.rmd_EPr_vibrate_desc_false));
    } else if (r.getString(R.string.p_rmd_nagging).equals(preference.getKey())) {
      if ((Boolean) value) preference.setSummary(r.getString(R.string.rmd_EPr_nagging_desc_true));
      else preference.setSummary(r.getString(R.string.rmd_EPr_nagging_desc_false));
    } else if (r.getString(R.string.p_rmd_snooze_dialog).equals(preference.getKey())) {
      if (value == null || ((Boolean) value) == true)
        preference.setSummary(r.getString(R.string.rmd_EPr_snooze_dialog_desc_true));
      else preference.setSummary(r.getString(R.string.rmd_EPr_snooze_dialog_desc_false));
    }
  }
  private void updateSummaries() {
    int t = PREFS_DEFAULT_LOCATION_TIMEOUT;
    try {
      t =
          Integer.parseInt(
              prefs.getString(PREFS_KEY_LOCATION_TIMEOUT, "" + PREFS_DEFAULT_LOCATION_TIMEOUT));
      if (t < 1) {
        t = PREFS_DEFAULT_LOCATION_TIMEOUT;
        final SharedPreferences.Editor edit = prefs.edit();
        edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
        edit.commit();
      }
    } catch (final Exception e) {
      t = PREFS_DEFAULT_LOCATION_TIMEOUT;
      final SharedPreferences.Editor edit = prefs.edit();
      edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
      edit.commit();
    }
    final EditTextPreference timeout =
        (EditTextPreference) prefFrag.findPreference(PREFS_KEY_LOCATION_TIMEOUT);
    String summary = getResources().getString(R.string.pref_geolocation_timeout_summary);
    summary += "\nTimeout: '" + t + "'";
    timeout.setSummary(summary);

    final Preference povider = prefFrag.findPreference(PREFS_KEY_OPENCELLID_PROVIDER);
    final Preference gps = prefFrag.findPreference(PREFS_KEY_GPS);
    final boolean en = prefs.getBoolean(PREFS_KEY_LOCATE, PREFS_DEFAULT_LOCATE);
    povider.setEnabled(en);
    timeout.setEnabled(en);
    gps.setEnabled(en);
  }
Пример #4
0
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    SharedPreferences sharedPreferences = getSharedPreferences(Main.PREFS, Activity.MODE_PRIVATE);
    Editor edit = sharedPreferences.edit();

    if (preference.getKey().equals(PREF_NOTIFY)) {
      vibratePref.setEnabled((Boolean) newValue);
      ledPref.setEnabled((Boolean) newValue);
      delayPref.setEnabled((Boolean) newValue);
    }
    if (preference.getKey().equals(PREF_DELAY)) {
      String value = (String) newValue;
      if (value != null && value.length() == 0) return false;
      edit.putInt(PREF_DELAY, Integer.parseInt(value));

      // Update alarms
      Intent intent = new Intent(FavoritesBroadcast.ACTION_FAVORITES_UPDATE);
      intent.putExtra(FavoritesBroadcast.EXTRA_TYPE, FavoritesBroadcast.EXTRA_TYPE_RESCHEDULE);
      sendBroadcast(intent);
    }
    if (preference.getKey().equals(PREF_UPCOMING)
        || preference.getKey().equals(PREF_NOTIFY)
        || preference.getKey().equals(PREF_VIBRATE)
        || preference.getKey().equals(PREF_LED)) {
      edit.putBoolean(preference.getKey(), (Boolean) newValue);
    }
    edit.commit();
    return true;
  }
 private void setTTSVisiblity() {
   boolean tts = mSharedPref.getBoolean(getString(R.string.pref_tts_enabled), false);
   Preference pref = findPreference(getString(R.string.pref_tts_value));
   if (pref != null) pref.setEnabled(tts);
   pref = findPreference(getString(R.string.pref_tts_bt_only));
   if (pref != null) pref.setEnabled(tts);
 }
Пример #6
0
 private void setPrefs() {
   if (mPush.isChecked()) {
     mYear.setEnabled(true);
     mYear.setSelectable(true);
   } else {
     mYear.setEnabled(false);
     mYear.setSelectable(false);
   }
 }
 private void updateTrustedPeer(@Nonnull final String trustedPeer) {
   if (trustedPeer.isEmpty()) {
     trustedPeerPreference.setSummary(R.string.preferences_trusted_peer_summary);
     trustedPeerOnlyPreference.setEnabled(false);
   } else {
     trustedPeerPreference.setSummary(trustedPeer);
     trustedPeerOnlyPreference.setEnabled(true);
   }
 }
Пример #8
0
 public void setMVNOPreferenceState(Preference preference) {
   if ("mvno_type".equals(preference.getKey())) {
     preference.setEnabled(false);
     Log.d(TAG, "disable MVNO type preference");
   } else if ("mvno_match_data".equals(preference.getKey())) {
     preference.setEnabled(false);
     Log.d(TAG, "disable MVNO match data preference");
   } else {
     Log.d(TAG, "nothing to do at present");
   }
 }
Пример #9
0
  private static Preference createSelectedLocationPreference(
      final PreferenceActivity context, String name, String value) {
    Preference pref = new Preference(context);
    pref.setKey(name);
    pref.setTitle(name);
    pref.setDefaultValue(value);
    pref.setEnabled(true);
    pref.setSummary(value);
    pref.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            // Displays the list of configured frontend locations.
            // Fires the locationChanged event when the user selects a
            // location even if the user selects the same location already
            // selected.
            SelectLocation(
                context,
                new LocationChangedEventListener() {
                  public void LocationChanged() {
                    // reset preference list with updated selection
                    setupPreferences(context);
                  }
                });
            return true;
          }
        });
    return pref;
  }
 private void setPrefsEnabledState(boolean enabled) {
   for (int i = 0; i < mAllPrefs.size(); i++) {
     Preference pref = mAllPrefs.get(i);
     pref.setEnabled(enabled && !mDisabledPrefs.contains(pref));
   }
   updateAllOptions();
 }
  /** Updates the UI based on the recording state. */
  private void updateUi() {
    boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
    backupPreference.setEnabled(!isRecording);
    backupPreference.setSummary(
        isRecording ? R.string.settings_not_while_recording : R.string.settings_backup_now_summary);

    restoreNowPreference.setEnabled(!isRecording);
    restoreNowPreference.setSummary(
        isRecording
            ? R.string.settings_not_while_recording
            : R.string.settings_backup_restore_summary);

    resetPreference.setEnabled(!isRecording);
    resetPreference.setSummary(
        isRecording ? R.string.settings_not_while_recording : R.string.settings_reset_summary);
  }
  private void updateUI() {
    Log.i(TAG, "mSimTracker is " + mSimTracker);
    if (mSimTracker.getInsertedSim().length == 0) {
      mPreference.setOnPreferenceClickListener(mNoSimListener);
      mPreference.setSummary(R.string.status_pending);
    } else {
      ControlData controlData = null;
      try {
        controlData = ControlData.buildControlData(mAgent.readControlData());
      } catch (RemoteException e) {
        e.printStackTrace();
      }

      if (controlData == null) {
        mPreference.setEnabled(false);
        return;
      }
      if (controlData.isEnabled()) {
        mPreference.setSummary(R.string.status_enabled);
        mPreference.setOnPreferenceClickListener(mEnabledListener);
      } else if (controlData.isProvisioned()) {
        mPreference.setSummary(R.string.status_provisioned);
        mPreference.setOnPreferenceClickListener(mProvisionedListener);
      } else {
        mPreference.setSummary(R.string.status_unprovisioned);
        mPreference.setOnPreferenceClickListener(mNotProvisionedListener);
      }
    }
  }
Пример #13
0
 @Override
 public boolean onPreferenceChange(Preference pref, Object newValue) {
   if (KEY_AUTO_SILENCE.equals(pref.getKey())) {
     final ListPreference autoSilencePref = (ListPreference) pref;
     String delay = (String) newValue;
     updateAutoSnoozeSummary(autoSilencePref, delay);
   } else if (KEY_CLOCK_STYLE.equals(pref.getKey())) {
     final ListPreference clockStylePref = (ListPreference) pref;
     final int idx = clockStylePref.findIndexOfValue((String) newValue);
     clockStylePref.setSummary(clockStylePref.getEntries()[idx]);
   } else if (KEY_HOME_TZ.equals(pref.getKey())) {
     final ListPreference homeTimezonePref = (ListPreference) pref;
     final int idx = homeTimezonePref.findIndexOfValue((String) newValue);
     homeTimezonePref.setSummary(homeTimezonePref.getEntries()[idx]);
     notifyHomeTimeZoneChanged();
   } else if (KEY_AUTO_HOME_CLOCK.equals(pref.getKey())) {
     final boolean autoHomeClockEnabled = ((CheckBoxPreference) pref).isChecked();
     final Preference homeTimeZonePref = findPreference(KEY_HOME_TZ);
     homeTimeZonePref.setEnabled(!autoHomeClockEnabled);
     notifyHomeTimeZoneChanged();
   } else if (KEY_VOLUME_BUTTONS.equals(pref.getKey())) {
     final ListPreference volumeButtonsPref = (ListPreference) pref;
     final int index = volumeButtonsPref.findIndexOfValue((String) newValue);
     volumeButtonsPref.setSummary(volumeButtonsPref.getEntries()[index]);
   } else if (KEY_WEEK_START.equals(pref.getKey())) {
     final ListPreference weekStartPref = (ListPreference) findPreference(KEY_WEEK_START);
     final int idx = weekStartPref.findIndexOfValue((String) newValue);
     weekStartPref.setSummary(weekStartPref.getEntries()[idx]);
   }
   // Set result so DeskClock knows to refresh itself
   getActivity().setResult(RESULT_OK);
   return true;
 }
 private void setSelectedNetworksEnabled(boolean b) {
   if (selectedNetworks != null) {
     for (Preference p : selectedNetworks) {
       p.setEnabled(b);
     }
   }
 }
  @Override
  protected void onResume() {
    super.onResume();
    // TODO Auto-generated method stub
    if (!PreyStatus.getInstance().isPreyConfigurationActivityResume()) {
      Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      intent.putExtra("EXIT", true);
      try {
        startActivity(intent);
      } catch (Exception e) {
      }
      finish();
    }
    try {
      if (PreyEmail.getEmail(getApplicationContext()) != null) {
        PreferenceCategory mCategory = (PreferenceCategory) findPreference("PREFS_CAT_PREFS");
        Preference p2 = findPreference(PreyConfig.PREFS_SCHEDULED);
        mCategory.removePreference(p2);
      }
    } catch (Exception e) {
    }

    PreyConfig preyConfig = PreyConfig.getPreyConfig(getApplicationContext());
    Preference p = findPreference("PREFS_ADMIN_DEVICE");
    if (preyConfig.isFroyoOrAbove()) {

      if (FroyoSupport.getInstance(getApplicationContext()).isAdminActive()) {
        p.setTitle(R.string.preferences_admin_enabled_title);
        p.setSummary(R.string.preferences_admin_enabled_summary);
      } else {
        p.setTitle(R.string.preferences_admin_disabled_title);
        p.setSummary(R.string.preferences_admin_disabled_summary);
      }
    } else p.setEnabled(false);

    p = findPreference("PREFS_ABOUT");
    p.setSummary("Version " + preyConfig.getPreyVersion() + " - Prey Inc.");

    Preference pGo = findPreference("PREFS_GOTO_WEB_CONTROL_PANEL");
    pGo.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl();
            PreyLogger.d("url control:" + url);
            Intent internetIntent = new Intent(Intent.ACTION_VIEW);
            internetIntent.setData(Uri.parse(url));
            try {
              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
              startActivity(intent);
            } catch (Exception e) {
            }
            return false;
          }
        });
  }
 protected void setCheckboxesEnabled(boolean enabled) {
   bookmarksPreference.setEnabled(enabled);
   historyPreference.setEnabled(enabled);
   tabsPreference.setEnabled(enabled);
   passwordsPreference.setEnabled(enabled);
   // Since we can't sync, we can't update our remote client record.
   deviceNamePreference.setEnabled(enabled);
   syncNowPreference.setEnabled(enabled);
 }
 private void updateBugreportOptions() {
   if ("user".equals(Build.TYPE)) {
     final ContentResolver resolver = getActivity().getContentResolver();
     final boolean adbEnabled =
         Settings.Global.getInt(resolver, Settings.Global.ADB_ENABLED, 0) != 0;
     if (adbEnabled) {
       mBugreport.setEnabled(true);
       mBugreportInPower.setEnabled(true);
     } else {
       mBugreport.setEnabled(false);
       mBugreportInPower.setEnabled(false);
       mBugreportInPower.setChecked(false);
       Settings.Secure.putInt(resolver, Settings.Secure.BUGREPORT_IN_POWER_MENU, 0);
     }
   } else {
     mBugreportInPower.setEnabled(true);
   }
 }
Пример #18
0
 private void setAppDirSummary() {
   File appDir = Utils.requireAppDir();
   Preference pref = findPreference(MyApplication.PrefKey.APP_DIR.getKey());
   if (appDir == null) {
     pref.setSummary(R.string.external_storage_unavailable);
     pref.setEnabled(false);
   } else {
     pref.setSummary(appDir.getPath());
   }
 }
 private boolean checkSDCard() {
   if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
     return true;
   } else {
     Toast.makeText(GenerateInfo.this, getString(R.string.sdcard_inexist), Toast.LENGTH_LONG)
         .show();
     toSdcardPref.setEnabled(false);
     return false;
   }
 }
Пример #20
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   addPreferencesFromResource(R.xml.preferences);
   File speech = new File(Config.SPEECH_PATH.concat("/A"));
   if (speech.exists() == false) {
     Preference pSpeech = findPreference("auto_speech");
     pSpeech.setEnabled(false);
   }
 }
 protected void updateSyncNowPreference() {
   final boolean currentlySyncing = fxAccount.isCurrentlySyncing();
   syncNowPreference.setEnabled(!currentlySyncing);
   if (currentlySyncing) {
     syncNowPreference.setTitle(R.string.fxaccount_status_syncing);
   } else {
     syncNowPreference.setTitle(R.string.fxaccount_status_sync_now);
   }
   scheduleAndUpdateLastSyncedTime();
 }
Пример #22
0
 private void onVoiceReminderStatusChanged(final Preference preference, boolean newValue) {
   try {
     VoiceOutputService.getVoiceOutputInstance();
     if (newValue) VoiceOutputService.getVoiceOutputInstance().checkIsTTSInstalled();
   } catch (VerifyError e) {
     // doesn't work :(
     preference.setEnabled(false);
     Preferences.setBoolean(preference.getKey(), false);
   }
 }
Пример #23
0
  private void disableAll() {
    hostText.setEnabled(false);
    portText.setEnabled(false);
    userText.setEnabled(false);
    passwordText.setEnabled(false);
    domainText.setEnabled(false);
    ssidList.setEnabled(false);
    proxyTypeList.setEnabled(false);
    proxyedApps.setEnabled(false);
    profileList.setEnabled(false);
    bypassAddrs.setEnabled(false);

    isAuthCheck.setEnabled(false);
    isNTLMCheck.setEnabled(false);
    isDNSProxyCheck.setEnabled(false);
    isAutoSetProxyCheck.setEnabled(false);
    isAutoConnectCheck.setEnabled(false);
    isPACCheck.setEnabled(false);
    isBypassAppsCheck.setEnabled(false);
  }
Пример #24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    // Check if there is a Bluetooth device. If not, disable option for Receiver settings
    Preference pr = findPreference("readersettings");
    BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
    if (bta == null) {
      pr.setEnabled(false);
      pr.setSummary("No Bluetooth Device Found");
    } else {
      pr.setEnabled(true);
      pr.setSummary("");
    }

    // Display the current values
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
      initSummary(getPreferenceScreen().getPreference(i));
    }
  }
Пример #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    settings = new Settings(this);
    String registrationId = settings.getRegistrationIdentifier();

    preferenceAlert1 = this.findPreference(getString(R.string.ringtonePref1));
    preferenceAlert2 = this.findPreference(getString(R.string.ringtonePref2));
    preferenceAlert3 = this.findPreference(getString(R.string.ringtonePref3));
    preferenceAlert4 = this.findPreference(getString(R.string.ringtonePref4));
    preferenceAlert5 = this.findPreference(getString(R.string.ringtonePref5));
    preferenceManualDeviceIdentifier = this.findPreference(getString(R.string.manualDeviceIdPref));

    preferenceManualDeviceIdentifier.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            Boolean result = false;
            String deviceId = newValue.toString().toLowerCase();

            if (deviceId.equals("") || deviceId.matches("[[a-z]\\d]{12}")) {
              result = true;
            } else {
              Toast.makeText(
                      preference.getContext(),
                      getString(R.string.manual_device_id_error),
                      Toast.LENGTH_LONG)
                  .show();
            }

            return result;
          }
        });

    String deviceIdentifier = settings.getDeviceIdentifier();

    if (deviceIdentifier.equals("")) {
      deviceIdentifier = settings.scrambleIDS();
      Toast.makeText(this, getString(R.string.generated_id) + deviceIdentifier, Toast.LENGTH_SHORT)
          .show();
    }

    Preference deviceIDPref = this.findPreference(getString(R.string.deviceIdPref));
    deviceIDPref.setTitle(deviceIdentifier);

    if (!registrationId.equals("")) {
      // Already registered: disable manual setting of Device Identifier

      preferenceManualDeviceIdentifier.setSummary("Unregister first");
      preferenceManualDeviceIdentifier.setEnabled(false);
    }
  }
Пример #26
0
  private void handleDockChange(Intent intent) {
    if (mDockAudioSettings != null) {
      int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);

      boolean isBluetooth = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) != null;

      mDockIntent = intent;

      if (dockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
        // remove undocked dialog if currently showing.
        try {
          removeDialog(DIALOG_NOT_DOCKED);
        } catch (IllegalArgumentException iae) {
          // Maybe it was already dismissed
        }

        if (isBluetooth) {
          mDockAudioSettings.setEnabled(true);
        } else {
          if (dockState == Intent.EXTRA_DOCK_STATE_LE_DESK) {
            ContentResolver resolver = getContentResolver();
            mDockAudioSettings.setEnabled(true);
            if (Settings.Global.getInt(resolver, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, -1)
                == -1) {
              Settings.Global.putInt(resolver, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0);
            }
            mDockAudioMediaEnabled =
                (CheckBoxPreference) findPreference(KEY_DOCK_AUDIO_MEDIA_ENABLED);
            mDockAudioMediaEnabled.setPersistent(false);
            mDockAudioMediaEnabled.setChecked(
                Settings.Global.getInt(resolver, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0) != 0);
          } else {
            mDockAudioSettings.setEnabled(false);
          }
        }
      } else {
        mDockAudioSettings.setEnabled(false);
      }
    }
  }
Пример #27
0
 @Override
 public void onStart() {
   super.onStart();
   PreferenceScreen screen = getPreferenceScreen();
   int count = screen.getPreferenceCount();
   for (int i = 0; i < count; i++) {
     Preference pre = screen.getPreference(i);
     if (null != pre) {
       Intent intent = pre.getIntent();
       pre.setEnabled(isActivityAvailable(intent));
     }
   }
 }
Пример #28
0
  private static Preference createLocationPreference(
      final Activity context, String key, String name, String value) {
    Preference pref = new Preference(context);
    pref.setKey(key);
    pref.setTitle(name);
    pref.setDefaultValue(value);
    pref.setEnabled(true);
    pref.setSummary(value);
    pref.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {
            // Open location edit dialog with a location loaded
            FrontendLocation location = new FrontendLocation();

            location.ID = Integer.parseInt(preference.getKey());

            MythMoteDbManager dbAdapter = new MythMoteDbManager(context);
            dbAdapter.open();
            Cursor cursor = dbAdapter.fetchFrontendLocation(location.ID);

            if (cursor != null && cursor.getCount() > 0) {
              // get column indexes
              sIdIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_ROWID);
              sAddressIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_ADDRESS);
              sNameIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_NAME);
              sPortIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_PORT);
              sMacIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_MAC);
              sWifiOnlyIndex = cursor.getColumnIndex(MythMoteDbHelper.KEY_WIFIONLY);

              // get data
              location.Name = cursor.getString(sNameIndex);
              location.Address = cursor.getString(sAddressIndex);
              location.Port = cursor.getInt(sPortIndex);
              location.MAC = cursor.getString(sMacIndex);
              location.WifiOnly = cursor.getInt(sWifiOnlyIndex);

              // show location editor
              showLocationEditDialog(context, location);

              // close cursor
              cursor.close();
            }

            // close db adapter
            dbAdapter.close();
            return false;
          }
        });
    return pref;
  }
Пример #29
0
 public static Preference Preference(
     Context paramContext,
     PreferenceCategory paramPreferenceCategory,
     String paramString1,
     String paramString2,
     boolean paramBoolean,
     Preference.OnPreferenceClickListener paramOnPreferenceClickListener) {
   Preference localPreference = new Preference(paramContext);
   localPreference.setTitle(paramString1);
   localPreference.setSummary(paramString2);
   localPreference.setEnabled(paramBoolean);
   if (paramOnPreferenceClickListener != null)
     localPreference.setOnPreferenceClickListener(paramOnPreferenceClickListener);
   paramPreferenceCategory.addPreference(localPreference);
   return localPreference;
 }
Пример #30
0
  @Override
  public void updatePreferences(final Preference preference, Object value) {
    final Resources r = getResources();

    if (r.getString(R.string.p_showNotes).equals(preference.getKey())) {
      if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_showNotes_desc_disabled);
      else preference.setSummary(R.string.EPr_showNotes_desc_enabled);
      if ((Boolean) value != Preferences.getBoolean(preference.getKey(), false)) {
        taskService.clearDetails(Criterion.all);
        Flags.set(Flags.REFRESH);
      }
    } else if (r.getString(R.string.p_transparent).equals(preference.getKey())) {
      if (AndroidUtilities.getSdkVersion() < 5) {
        preference.setEnabled(false);
        preference.setSummary(R.string.EPr_transparent_desc_unsupported);
      } else if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_transparent_desc_disabled);
      else preference.setSummary(R.string.EPr_transparent_desc_enabled);
    }

    // statistics service
    else if (r.getString(R.string.p_statistics).equals(preference.getKey())) {
      if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_statistics_desc_disabled);
      else preference.setSummary(R.string.EPr_statistics_desc_enabled);
    }

    // voice input and output
    if (!addOnService.hasPowerPack()) return;

    if (r.getString(R.string.p_voiceInputEnabled).equals(preference.getKey())) {
      if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_voiceInputEnabled_desc_disabled);
      else preference.setSummary(R.string.EPr_voiceInputEnabled_desc_enabled);
      onVoiceInputStatusChanged(preference, (Boolean) value);
    } else if (r.getString(R.string.p_voiceRemindersEnabled).equals(preference.getKey())) {
      if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_voiceRemindersEnabled_desc_disabled);
      else preference.setSummary(R.string.EPr_voiceRemindersEnabled_desc_enabled);
      onVoiceReminderStatusChanged(preference, (Boolean) value);
    } else if (r.getString(R.string.p_voiceInputCreatesTask).equals(preference.getKey())) {
      if (value != null && !(Boolean) value)
        preference.setSummary(R.string.EPr_voiceInputCreatesTask_desc_disabled);
      else preference.setSummary(R.string.EPr_voiceInputCreatesTask_desc_enabled);
    }
  }