Android Open Source - BlueMouse Preferences






From Project

Back to project page BlueMouse.

License

The source code is released under:

GNU General Public License

If you think the Android project BlueMouse 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.oldsch00l.BlueMouse;
//from w ww  . j a  v  a 2s . co m
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.PreferenceActivity;

public class Preferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
  public static final String KEY_UPDATE_INTERVAL = "update_interval";

  private EditTextPreference mEditPrefUpdateInterval;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference);

    mEditPrefUpdateInterval = (EditTextPreference)getPreferenceScreen().findPreference(KEY_UPDATE_INTERVAL);
  }

//  private String getStringResourceByName(String aString)
//  {
//    String packageName = "com.oldsch00l.BlueMouse";
//    int resId = getResources().getIdentifier(aString, "string", packageName);
//    return getString(resId);
//  }

  @Override
  protected void onPause() {
    super.onPause();

    getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
  }

  @Override
  protected void onResume() {
    super.onResume();

    SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
    mEditPrefUpdateInterval.setSummary(sp.getString(KEY_UPDATE_INTERVAL, "2000") + " ms");

    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }

  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
      String key) {
    if(key.equals(KEY_UPDATE_INTERVAL)) {
      mEditPrefUpdateInterval.setSummary(sharedPreferences.getString(KEY_UPDATE_INTERVAL, "2000") + " ms");
    }
  }
}




Java Source Code List

com.oldsch00l.BlueMouse.BlueMouseService.java
com.oldsch00l.BlueMouse.BlueMouse.java
com.oldsch00l.BlueMouse.NMEAHelper.java
com.oldsch00l.BlueMouse.Preferences.java