예제 #1
0
 /**
  * Set whether necessary system version information retrieved and cached properly
  *
  * @param value true if information retrieved and saved, false othwerwise
  */
 public static void setSystemVersionInformationCached(boolean value) {
   getSystemVersionPreferences()
       .edit()
       .putBoolean(
           CommonUtils.getStringResource(R.string.setting_system_version_info_updated), value)
       .commit();
 }
예제 #2
0
 /**
  * Set the uploading limit resets on date
  *
  * @param date
  */
 public static void setUploadLimitResetsOnDate(Date date) {
   getLimitsSharedPreferences()
       .edit()
       .putLong(
           CommonUtils.getStringResource(R.string.setting_upload_limit_reset_date),
           date == null ? 0l : date.getTime())
       .commit();
 }
예제 #3
0
 /**
  * Store the access permissions to preferences cache
  *
  * @param permissions
  */
 public static void setAccessPermissions(AccessPermissions permissions) {
   getLimitsSharedPreferences()
       .edit()
       .putString(
           CommonUtils.getStringResource(R.string.setting_account_access_permissions),
           permissions == null ? null : permissions.toJsonString())
       .commit();
 }
예제 #4
0
 /**
  * Set currently supported api version
  *
  * @param apiVersion
  */
 public static void setApiVersion(ApiVersion apiVersion) {
   getSystemVersionPreferences()
       .edit()
       .putString(
           CommonUtils.getStringResource(R.string.setting_system_version_api_version),
           apiVersion.getName())
       .commit();
 }
예제 #5
0
 /**
  * Get the uploading limit resets on date
  *
  * @return
  */
 public static Date getUploadLimitResetsOnDate() {
   long value =
       getLimitsSharedPreferences()
           .getLong(CommonUtils.getStringResource(R.string.setting_upload_limit_reset_date), 0);
   if (value == 0) {
     return null;
   } else {
     return new Date(value);
   }
 }
예제 #6
0
 /**
  * Get currently supported api version information
  *
  * @return
  */
 public static ApiVersion getCurrentApiVersion() {
   String apiVersion =
       getSystemVersionPreferences()
           .getString(
               CommonUtils.getStringResource(R.string.setting_system_version_api_version), null);
   if (apiVersion == null) {
     return ApiVersion.V1;
   } else {
     return ApiVersion.getApiVersionByName(apiVersion);
   }
 }
예제 #7
0
 /**
  * Get the cached access permissions information
  *
  * @return
  * @throws JSONException
  */
 public static AccessPermissions getAccessPermissions() throws JSONException {
   String jsonString =
       getLimitsSharedPreferences()
           .getString(
               CommonUtils.getStringResource(R.string.setting_account_access_permissions), "");
   AccessPermissions result = null;
   if (!TextUtils.isEmpty(jsonString)) {
     result = AccessPermissions.fromJson(new JSONObject(jsonString));
   }
   return result;
 }
 /**
  * @param message the sharing message
  * @param photo the photo to share
  * @param thumbSize the thumb image size
  * @param appendToken whether to append share token to the photo url
  * @throws FileNotFoundException
  * @throws MalformedURLException
  * @throws IOException
  */
 public static void sharePhoto(
     String message, Photo photo, ReturnSizes thumbSize, boolean appendToken)
     throws FileNotFoundException, MalformedURLException, IOException {
   Facebook facebook = FacebookProvider.getFacebook();
   Bundle bparams = new Bundle();
   bparams.putString("message", message);
   bparams.putString("name", photo.getTitle());
   bparams.putString("caption", photo.getTitle());
   bparams.putString(
       "description", CommonUtils.getStringResource(R.string.share_facebook_default_description));
   bparams.putString("picture", photo.getUrl(thumbSize.toString()));
   bparams.putString("link", PhotoUtils.getShareUrl(photo, appendToken));
   TrackerUtils.trackSocial("facebook", "feed", message + " | " + photo.getUrl(Photo.URL));
   facebook.request("feed", bparams, "POST");
 }
예제 #9
0
  public static void logout(Context context) {
    getDefaultSharedPreferences(context)
        .edit()
        .putBoolean(context.getString(R.string.setting_account_loggedin_key), false)
        .remove(CommonUtils.getStringResource(R.string.setting_intro_skip))
        .commit();
    getDefaultSharedPreferences(context)
        .edit()
        .putString(
            context.getString(R.string.setting_account_server_key),
            context.getString(R.string.setting_account_server_default))
        .commit();

    getSharedPreferences("oauth").edit().clear().commit();
    getLimitsSharedPreferences().edit().clear().commit();
    getSystemVersionPreferences().edit().clear().commit();
    getVerifiedPaymentsPreferences().edit().clear().commit();
    getDefaultSharedPreferences(context)
        .edit()
        .remove(context.getString(R.string.setting_account_server_key))
        .commit();
  }
예제 #10
0
 /**
  * Check whether currently logged in user account type (pro or free)
  *
  * @return
  */
 public static boolean isProUser() {
   return getLimitsSharedPreferences()
       .getBoolean(CommonUtils.getStringResource(R.string.setting_account_type), false);
 }
예제 #11
0
 /**
  * Check whether necessary system version information already retrieved and stored in the cache
  *
  * @return
  */
 public static boolean isSystemVersionInformationCached() {
   return getSystemVersionPreferences()
       .getBoolean(
           CommonUtils.getStringResource(R.string.setting_system_version_info_updated), false);
 }
예제 #12
0
 /**
  * Check whether currently used server is hosted or self-hosted
  *
  * @return true if server is hosted, otherwise return false
  */
 public static boolean isHosted() {
   return getSystemVersionPreferences()
       .getBoolean(CommonUtils.getStringResource(R.string.setting_system_version_hosted), false);
 }
예제 #13
0
 /**
  * Set the skip intro flag
  *
  * @param skipIntro
  */
 public static void setSkipIntro(boolean skipIntro) {
   getDefaultSharedPreferences()
       .edit()
       .putBoolean(CommonUtils.getStringResource(R.string.setting_intro_skip), skipIntro)
       .commit();
 }
예제 #14
0
 /**
  * Set the remaining uploading limit
  *
  * @param limit
  */
 public static void setRemainingUploadingLimit(int limit) {
   getLimitsSharedPreferences()
       .edit()
       .putInt(CommonUtils.getStringResource(R.string.setting_remaining_upload_limit), limit)
       .commit();
 }
예제 #15
0
 /**
  * Get the remaining uploading limit
  *
  * @return
  */
 public static int getRemainingUploadingLimit() {
   return getLimitsSharedPreferences()
       .getInt(
           CommonUtils.getStringResource(R.string.setting_remaining_upload_limit),
           Integer.MAX_VALUE);
 }
예제 #16
0
 /**
  * Get current account access type
  *
  * @return
  */
 public static String getAccountAccessType() {
   return getLimitsSharedPreferences()
       .getString(
           CommonUtils.getStringResource(R.string.setting_account_access_type),
           Credentials.OWNER_TYPE);
 }
예제 #17
0
 /**
  * Set currently loggged in user account access type. Either owner, admin or group
  *
  * @param accessType
  */
 public static void setAccountAccessType(String accessType) {
   getLimitsSharedPreferences()
       .edit()
       .putString(CommonUtils.getStringResource(R.string.setting_account_access_type), accessType)
       .commit();
 }
예제 #18
0
 /**
  * Set currently logged in user account type
  *
  * @param value true if user is a pro, false if user uses free account type
  */
 public static void setProUser(boolean value) {
   getLimitsSharedPreferences()
       .edit()
       .putBoolean(CommonUtils.getStringResource(R.string.setting_account_type), value)
       .commit();
 }
예제 #19
0
 /**
  * Whether the intro should be skipped
  *
  * @return
  */
 public static boolean isSkipIntro() {
   return getDefaultSharedPreferences()
       .getBoolean(CommonUtils.getStringResource(R.string.setting_intro_skip), false);
 }
 @Override
 protected void onSuccessPostExecute() {
   loggedInAsText.setText(
       CommonUtils.getStringResource(R.string.share_facebook_logged_in_as, name));
 }