Пример #1
0
 private void setProtectionDependentsState() {
   boolean isProtected = MyApplication.PrefKey.PERFORM_PROTECTION.getBoolean(false);
   findPreference(MyApplication.PrefKey.SECURITY_QUESTION.getKey())
       .setEnabled(MyApplication.getInstance().isContribEnabled() && isProtected);
   findPreference(MyApplication.PrefKey.PROTECTION_DELAY_SECONDS.getKey()).setEnabled(isProtected);
   findPreference(MyApplication.PrefKey.PROTECTION_ENABLE_ACCOUNT_WIDGET.getKey())
       .setEnabled(isProtected);
   findPreference(MyApplication.PrefKey.PROTECTION_ENABLE_TEMPLATE_WIDGET.getKey())
       .setEnabled(isProtected);
   findPreference(MyApplication.PrefKey.PROTECTION_ENABLE_DATA_ENTRY_FROM_WIDGET.getKey())
       .setEnabled(isProtected);
 }
Пример #2
0
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals(MyApplication.PrefKey.PERFORM_PROTECTION.getKey())) {
     setProtectionDependentsState();
     AbstractWidget.updateWidgets(this, AccountWidget.class);
     AbstractWidget.updateWidgets(this, TemplateWidget.class);
   } else if (key.equals(MyApplication.PrefKey.UI_FONTSIZE.getKey())
       || key.equals(MyApplication.PrefKey.UI_LANGUAGE.getKey())
       || key.equals(MyApplication.PrefKey.UI_THEME_KEY.getKey())) {
     restart();
   } else if (key.equals(MyApplication.PrefKey.PROTECTION_ENABLE_ACCOUNT_WIDGET.getKey())) {
     Log.d("DEBUG", "shared preference changed: Account Widget");
     AbstractWidget.updateWidgets(this, AccountWidget.class);
   } else if (key.equals(MyApplication.PrefKey.PROTECTION_ENABLE_TEMPLATE_WIDGET.getKey())) {
     Log.d("DEBUG", "shared preference changed: Template Widget");
     AbstractWidget.updateWidgets(this, TemplateWidget.class);
   }
 }
Пример #3
0
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    setTheme(MyApplication.getThemeId(Build.VERSION.SDK_INT < 11));
    super.onCreate(savedInstanceState);
    setTitle(Utils.concatResStrings(this, R.string.app_name, R.string.menu_settings));
    addPreferencesFromResource(R.layout.preferences);
    Preference pref = findPreference(MyApplication.PrefKey.SHARE_TARGET.getKey());
    pref.setSummary(
        getString(R.string.pref_share_target_summary)
            + ":\n"
            + "ftp: \"ftp://*****:*****@my.example.org:port/my/directory/\"\n"
            + "mailto: \"mailto:[email protected]\"");
    pref.setOnPreferenceChangeListener(this);
    configureContribPrefs();
    findPreference(MyApplication.PrefKey.SEND_FEEDBACK.getKey()).setOnPreferenceClickListener(this);
    findPreference(MyApplication.PrefKey.MORE_INFO_DIALOG.getKey())
        .setOnPreferenceClickListener(this);

    pref = findPreference(MyApplication.PrefKey.RESTORE.getKey());
    pref.setTitle(getString(R.string.pref_restore_title) + " (ZIP)");
    pref.setOnPreferenceClickListener(this);

    pref = findPreference(MyApplication.PrefKey.RESTORE_LEGACY.getKey());
    pref.setTitle(
        getString(R.string.pref_restore_title)
            + " ("
            + getString(R.string.pref_restore_legacy_data)
            + ")");
    pref.setOnPreferenceClickListener(this);

    findPreference(MyApplication.PrefKey.RATE.getKey()).setOnPreferenceClickListener(this);

    findPreference(MyApplication.PrefKey.ENTER_LICENCE.getKey())
        .setOnPreferenceChangeListener(this);
    setProtectionDependentsState();

    findPreference(MyApplication.PrefKey.PERFORM_PROTECTION.getKey())
        .setOnPreferenceChangeListener(this);

    findPreference(MyApplication.PrefKey.PROTECTION_ENABLE_ACCOUNT_WIDGET.getKey())
        .setOnPreferenceChangeListener(this);

    findPreference(MyApplication.PrefKey.PROTECTION_ENABLE_TEMPLATE_WIDGET.getKey())
        .setOnPreferenceChangeListener(this);

    findPreference(MyApplication.PrefKey.APP_DIR.getKey()).setOnPreferenceClickListener(this);
    setAppDirSummary();
    if (savedInstanceState == null
        && TextUtils.equals(
            getIntent().getStringExtra(KEY_OPEN_PREF_KEY),
            MyApplication.PrefKey.PLANNER_CALENDAR_ID.getKey())) {
      ((CalendarListPreference) findPreference(MyApplication.PrefKey.PLANNER_CALENDAR_ID.getKey()))
          .show();
    }

    findPreference(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSACTION.getKey())
        .setOnPreferenceClickListener(this);
    findPreference(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSFER.getKey())
        .setOnPreferenceClickListener(this);
    findPreference(MyApplication.PrefKey.SHORTCUT_CREATE_SPLIT.getKey())
        .setOnPreferenceClickListener(this);
    findPreference(MyApplication.PrefKey.SECURITY_QUESTION.getKey())
        .setSummary(
            Utils.concatResStrings(
                this, R.string.pref_security_question_summary, R.string.contrib_key_requires));
    findPreference(MyApplication.PrefKey.SHORTCUT_CREATE_SPLIT.getKey())
        .setSummary(
            Utils.concatResStrings(
                this, R.string.pref_shortcut_summary, R.string.contrib_key_requires));
  }