Android Open Source - android.bigredsnapshot Prefs Manager






From Project

Back to project page android.bigredsnapshot.

License

The source code is released under:

MIT License

If you think the Android project android.bigredsnapshot 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 io.evercam.bigredsnapshot.helper;
/*  w ww . java 2 s . c  om*/
import io.evercam.EvercamException;
import io.evercam.User;
import android.content.SharedPreferences;

public class PrefsManager
{
  public final static String KEY_USER_NAME = "userName";
  public final static String KEY_PASSWORD = "passWord";
  public final static String KEY_EMAIL = "email";
  public final static String KEY_FORENAME = "forename";
  public final static String KEY_LASTNAME = "lastname";
  public final static String KEY_COUNTRY = "country";
  public final static String KEY_USER_API_KEY = "userApiKey";
  public final static String KEY_USER_API_ID = "userApiId";

  private PrefsManager()
  {
  }

  public static String getUsername(SharedPreferences sharedPrefs)
  {
    return sharedPrefs.getString(KEY_USER_NAME, null);
  }

  public static String getPassword(SharedPreferences sharedPrefs)
  {
    return sharedPrefs.getString(KEY_PASSWORD, null);
  }

  public static void saveEvercamCredential(SharedPreferences sharedPrefs, User user,
      String password) throws EvercamException
  {
    SharedPreferences.Editor editor = sharedPrefs.edit();
    editor.putString(KEY_USER_NAME, user.getId());
    editor.putString(KEY_PASSWORD, password);
    editor.putString(KEY_COUNTRY, user.getCountry());
    editor.putString(KEY_EMAIL, user.getEmail());
    editor.putString(KEY_FORENAME, user.getFirstName());
    editor.putString(KEY_LASTNAME, user.getLastName());
    editor.commit();
  }

  public static void saveEvercamUserKeyPair(SharedPreferences sharedPrefs, String apiKey,
      String apiId)
  {
    SharedPreferences.Editor editor = sharedPrefs.edit();
    editor.putString(KEY_USER_API_KEY, apiKey);
    editor.putString(KEY_USER_API_ID, apiId);
    editor.commit();
  }

  public static String getUserApiKey(SharedPreferences sharedPrefs)
  {
    return sharedPrefs.getString(KEY_USER_API_KEY, null);
  }

  public static String getUserApiId(SharedPreferences sharedPrefs)
  {
    return sharedPrefs.getString(KEY_USER_API_ID, null);
  }

  public static void clearEvercamCredential(SharedPreferences sharedPrefs)
  {
    SharedPreferences.Editor editor = sharedPrefs.edit();
    editor.putString(KEY_USER_NAME, null);
    editor.putString(KEY_PASSWORD, null);
    editor.putString(KEY_COUNTRY, null);
    editor.putString(KEY_EMAIL, null);
    editor.putString(KEY_FORENAME, null);
    editor.putString(KEY_LASTNAME, null);
    editor.commit();
  }
}




Java Source Code List

io.evercam.bigredsnapshot.BigButtonActivity.java
io.evercam.bigredsnapshot.BigRedSnapshot.java
io.evercam.bigredsnapshot.ChooseCameraActivity.java
io.evercam.bigredsnapshot.LoginActivity.java
io.evercam.bigredsnapshot.SignUpActivity.java
io.evercam.bigredsnapshot.SlideActivity.java
io.evercam.bigredsnapshot.SnapshotRequest.java
io.evercam.bigredsnapshot.UrlStatus.java
io.evercam.bigredsnapshot.account.AccountUtils.java
io.evercam.bigredsnapshot.account.ProfileQuery.java
io.evercam.bigredsnapshot.account.UserProfile.java
io.evercam.bigredsnapshot.helper.CustomedDialog.java
io.evercam.bigredsnapshot.helper.PrefsManager.java
io.evercam.bigredsnapshot.helper.PropertyReader.java
io.evercam.bigredsnapshot.tasks.CaptureSnapshotTask.java
io.evercam.bigredsnapshot.tasks.CheckInternetTask.java