Exemplo n.º 1
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));
    }
  }
Exemplo n.º 2
0
 private void handleActivityNotFound(String fileType) {
   if (fileType.startsWith(FileMetadata.FILE_TYPE_AUDIO)) {
     searchMarket(
         "com.clov4r.android.nil",
         R.string.search_market_audio_title,
         R.string.search_market_audio); // $NON-NLS-1$
   } else if (fileType.equals(FileMetadata.FILE_TYPE_PDF)) {
     searchMarket(
         "com.adobe.reader",
         R.string.search_market_pdf_title,
         R.string.search_market_pdf); // $NON-NLS-1$
   } else if (AndroidUtilities.indexOf(FileMetadata.MS_FILETYPES, fileType) >= 0) {
     searchMarket(
         "com.dataviz.docstogo",
         R.string.search_market_ms_title,
         R.string.search_market_ms); // $NON-NLS-1$
   } else {
     DialogUtilities.okDialog(
         activity,
         activity.getString(R.string.file_type_unhandled_title),
         0,
         activity.getString(R.string.file_type_unhandled),
         null);
   }
 }
Exemplo n.º 3
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_fullTaskTitle).equals(preference.getKey())) {
      if (value != null && (Boolean) value)
        preference.setSummary(R.string.EPr_fullTask_desc_enabled);
      else preference.setSummary(R.string.EPr_fullTask_desc_disabled);
    } else if (r.getString(R.string.p_theme).equals(preference.getKey())) {
      if (AndroidUtilities.getSdkVersion() < 5) {
        preference.setEnabled(false);
        preference.setSummary(R.string.EPr_theme_desc_unsupported);
      } else {
        int index = 0;
        if (value instanceof String && !TextUtils.isEmpty((String) value))
          index =
              AndroidUtilities.indexOf(
                  r.getStringArray(R.array.EPr_theme_settings), (String) value);
        if (index < 0) index = 0;
        preference.setSummary(
            getString(R.string.EPr_theme_desc, r.getStringArray(R.array.EPr_themes)[index]));
      }
    } else if (r.getString(R.string.p_theme_widget).equals(preference.getKey())) {
      if (AndroidUtilities.getSdkVersion() < 5) {
        preference.setEnabled(false);
        preference.setSummary(R.string.EPr_theme_desc_unsupported);
      } else {
        int index = 0;
        if (value instanceof String && !TextUtils.isEmpty((String) value))
          index =
              AndroidUtilities.indexOf(
                  r.getStringArray(R.array.EPr_theme_widget_settings), (String) value);
        if (index < 0) index = 0;
        preference.setSummary(
            getString(R.string.EPr_theme_desc, r.getStringArray(R.array.EPr_themes_widget)[index]));
      }
    }

    // pp preferences
    else if (booleanPreference(
        preference,
        value,
        R.string.p_statistics,
        R.string.EPr_statistics_desc_disabled,
        R.string.EPr_statistics_desc_enabled)) ;
    else if (booleanPreference(
        preference,
        value,
        R.string.p_autoIdea,
        R.string.EPr_ideaAuto_desc_disabled,
        R.string.EPr_ideaAuto_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);
    }
  }
Exemplo n.º 4
0
  private void launchTaskList() {
    Intent intent = getIntent();

    Bundle extras = intent.getExtras();

    Intent taskListIntent = new Intent(this, TaskListActivity.class);
    taskListIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

    if (extras != null && extras.containsKey(TOKEN_CUSTOM_CLASS)) {
      taskListIntent.putExtras(intent.getExtras());
    }

    if (extras != null && extras.containsKey(TOKEN_FILTER_SQL)) {
      // launched from desktop shortcut, must create a fake filter
      String title = extras.getString(TOKEN_FILTER_TITLE);
      String sql = extras.getString(TOKEN_FILTER_SQL);
      sql = sql.replace("tasks.userId=0", "1"); // TODO: replace dirty hack for missing column
      ContentValues values = new ContentValues();
      for (String key : extras.keySet()) {
        if (!key.startsWith(TOKEN_FILTER_VALUES_ITEM)) {
          continue;
        }

        Object value = extras.get(key);
        key = key.substring(TOKEN_FILTER_VALUES_ITEM.length());

        // assume one of the big 4...
        if (value instanceof String) {
          values.put(key, (String) value);
        } else if (value instanceof Integer) {
          values.put(key, (Integer) value);
        } else if (value instanceof Double) {
          values.put(key, (Double) value);
        } else if (value instanceof Long) {
          values.put(key, (Long) value);
        } else {
          throw new IllegalStateException(
              "Unsupported bundle type " + value.getClass()); // $NON-NLS-1$
        }
      }

      Filter filter;
      if (extras.containsKey(TOKEN_CUSTOM_CLASS)) {
        filter = new FilterWithCustomIntent(title, sql, values);
        Bundle customExtras = new Bundle();
        Set<String> keys = extras.keySet();
        for (String key : keys) {
          if (AndroidUtilities.indexOf(CUSTOM_EXTRAS, key) < 0) {
            AndroidUtilities.putInto(customExtras, key, extras.get(key));
          }
        }

        ((FilterWithCustomIntent) filter).customExtras = customExtras; // Something
        ((FilterWithCustomIntent) filter).customTaskList =
            ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS));
      } else {
        filter = new Filter(title, sql, values);
      }
      taskListIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
    }

    startActivity(taskListIntent);
    finish();
  }