Android Open Source - iSiteProyect Preferences Activity






From Project

Back to project page iSiteProyect.

License

The source code is released under:

Copyright (C) 2013 Plasty Grove <plasty.grove@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Softwar...

If you think the Android project iSiteProyect listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Released under MIT License http://opensource.org/licenses/MIT
 * Copyright (c) 2013 Plasty Grove/*from  w w  w .j  a va2s .c om*/
 * Refer to file LICENSE or URL above for full text 
 */

package com.iSiteProyect;

import java.util.Map;

import com.iSiteProyect.R;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
  @SuppressWarnings("deprecation")//ver
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityHelper.initialize(this);
    addPreferencesFromResource(R.xml.preferences); // Using this for compatibility with Android 2.2 devices
  }

  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    @SuppressWarnings("deprecation")//ver
    Preference pref = findPreference(key);

    if (pref instanceof ListPreference) {
      ListPreference listPref = (ListPreference) pref;
      pref.setSummary(listPref.getEntry());
      ActivityHelper.initialize(this);
    }

    if (pref instanceof EditTextPreference) {
      EditTextPreference editPref = (EditTextPreference) pref;
      pref.setSummary(editPref.getText());
    }
  }

  @Override
  protected void onPause() {

    PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
    super.onPause();
  }

  @Override
  protected void onResume() {
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
    Map<String, ?> keys = PreferenceManager.getDefaultSharedPreferences(this).getAll();

    for (Map.Entry<String, ?> entry : keys.entrySet()) {
      // Log.d("map values", entry.getKey() + ": " + entry.getValue().toString());
      Preference pref = findPreference(entry.getKey());
      if (pref != null) {
        pref.setSummary(entry.getValue().toString());
      }
    }

    super.onResume();
  }

}




Java Source Code List

com.iSiteProyect.ActivityHelper.java
com.iSiteProyect.FileArrayAdapter.java
com.iSiteProyect.FileChooser.java
com.iSiteProyect.Homescreen.java
com.iSiteProyect.Item.java
com.iSiteProyect.MainActivity.java
com.iSiteProyect.MyApplication.java
com.iSiteProyect.PreferencesActivity.java
com.iSiteProyect.Servicios.MiServicio.java
com.iSiteProyect.ll_Apuntamiento.java
com.iSiteProyect.ll_Inicio_Login.java