Android Open Source - SipgateInfo Setup Activity






From Project

Back to project page SipgateInfo.

License

The source code is released under:

GNU General Public License

If you think the Android project SipgateInfo 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 net.skweez.sipgate.activity;
// w w w .j  a  va 2s.  c om
import net.skweez.sipgate.R;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.util.Log;

public class SetupActivity extends PreferenceActivity implements
    OnSharedPreferenceChangeListener {

  private static final String TAG = SetupActivity.class.getName();

  private EditTextPreference userNamePreference;

  private String KEY_USERNAME;

  private String KEY_VERSION;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    KEY_USERNAME = getString(R.string.prefs_username_key);
    KEY_VERSION = getString(R.string.prefs_version_key);

    setContentView(R.layout.setup);
    addPreferencesFromResource(R.xml.preferences);
    userNamePreference = (EditTextPreference) getPreferenceScreen()
        .findPreference(KEY_USERNAME);

    loadVersionInformation();
  }

  /**
   * Gets the version number from the package manager and sets it as the
   * summary of the version preference.
   */
  private void loadVersionInformation() {
    PackageManager pm = getPackageManager();
    PackageInfo info = null;
    try {
      info = pm.getPackageInfo("net.skweez.sipgate", 0);
    } catch (NameNotFoundException e) {
      Log.e(TAG, "Cannot find package info.");
    }
    Preference version = findPreference(KEY_VERSION);
    version.setSummary(info.versionName);
  }

  /** {@inheritDoc} */
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
      String key) {
    if (key.equals(KEY_USERNAME)) {
      userNamePreference.setSummary(sharedPreferences.getString(
          KEY_USERNAME, getString(R.string.prefs_username_summary)));
    }
  }

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

    userNamePreference.setSummary(getPreferenceScreen()
        .getSharedPreferences().getString(KEY_USERNAME,
            getString(R.string.prefs_username_summary)));

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

  @Override
  protected void onPause() {
    super.onPause();
    getPreferenceScreen().getSharedPreferences()
        .unregisterOnSharedPreferenceChangeListener(this);
  }
}




Java Source Code List

net.skweez.sipgate.CallUtils.java
net.skweez.sipgate.PreferencesAuthenticator.java
net.skweez.sipgate.SipgateApplication.java
net.skweez.sipgate.activity.AccountInfoAdapter.java
net.skweez.sipgate.activity.CallListAdapter.java
net.skweez.sipgate.activity.MainActivity.java
net.skweez.sipgate.activity.SetupActivity.java
net.skweez.sipgate.api.AuthenticationException.java
net.skweez.sipgate.api.Call.java
net.skweez.sipgate.api.ECallStatus.java
net.skweez.sipgate.api.ISipgateAPI.java
net.skweez.sipgate.api.Price.java
net.skweez.sipgate.api.SipgateException.java
net.skweez.sipgate.api.UserName.java
net.skweez.sipgate.api.UserUri.java
net.skweez.sipgate.api.xmlrpc.SipgateUriHelper.java
net.skweez.sipgate.api.xmlrpc.SipgateXmlRpcImpl.java
net.skweez.sipgate.db.DataSource.java
net.skweez.sipgate.db.DatabaseHelper.java
net.skweez.sipgate.model.AccountInfo.java
net.skweez.sipgate.service.QueryResultReceiver.java
net.skweez.sipgate.service.QueryService.java