Android Open Source - android-clock-livewallpaper Settings Activity






From Project

Back to project page android-clock-livewallpaper.

License

The source code is released under:

MIT License

If you think the Android project android-clock-livewallpaper 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

package com.ssaurel.clocklw;
//from   www  .j av a2 s.  co m
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.widget.Toast;

/**
 * Settings activity
 * 
 * @author sylsau - sylvain.saurel@gmail.com - http://www.ssaurel.com
 *
 */
public class SettingsActivity extends PreferenceActivity {

  /** Key for display hand sec. */
  public static final String DISPLAY_HAND_SEC_KEY = "displayHandSec";
  private Preference displayHandSecPref;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);
    displayHandSecPref = findPreference(DISPLAY_HAND_SEC_KEY);
    displayHandSecPref.setOnPreferenceChangeListener(prefChangeListener);
  }

  private OnPreferenceChangeListener prefChangeListener = new OnPreferenceChangeListener() {

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {

      if (DISPLAY_HAND_SEC_KEY.equals(preference.getKey())) {
        boolean value = (Boolean) newValue;
        Toast.makeText(getApplicationContext(),
            R.string.display_hand_sec_txt + " "
                + (value ? R.string.enabled : R.string.disabled),
            Toast.LENGTH_SHORT).show();
        return true;
      }

      return false;
    }
  };
}




Java Source Code List

com.ssaurel.clocklw.AnalogClock.java
com.ssaurel.clocklw.ClockWallpaperService.java
com.ssaurel.clocklw.MainActivity.java
com.ssaurel.clocklw.SettingsActivity.java