Ejemplo n.º 1
0
        public void onClick(DialogInterface dialog, int whichItem) {
          int set = updateSleepPolicy();
          boolean message = settings.getBoolean(PREF_MESSAGE, DEFAULT_MESSAGE);

          try {
            copyFile(
                new File(profilePath + profileFiles[whichItem]),
                new File(sharedPrefsPath + sharedPrefsFile + ".xml"));
          } catch (Exception e) {
            Toast.makeText(
                    context, getString(R.string.settings_profile_import_error), Toast.LENGTH_SHORT)
                .show();
            return;
          }

          settings.unregisterOnSharedPreferenceChangeListener(context);
          setDefaultValues();

          // Restart the engine
          Receiver.engine(context).halt();
          Receiver.engine(context).StartEngine();

          reload();
          settings.registerOnSharedPreferenceChangeListener(context);
          updateSummaries();
          if (set != updateSleepPolicy()) updateSleep();
          if (message) {
            Editor edit = settings.edit();
            edit.putBoolean(PREF_MESSAGE, true);
            edit.commit();
          }
        }
Ejemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Receiver.mContext == null) Receiver.mContext = this;
    addPreferencesFromResource(R.xml.preferences);
    setDefaultValues();
    Codecs.check();
  }