// Save preferences: scroll position, selected tab, expanded buildings
  @Override
  public void onPause() {
    super.onPause();

    SharedPreferences settings = getPreferences(MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();

    // Save last tab
    editor.putInt("lastTab", curTab);

    // Save current expanded buildings to be retrieved later
    editor.putStringSet("lastNearbyExpandedBuildings", nearbyExpandedBldgs);
    editor.putStringSet("lastAllExpandedBuildings", allExpandedBldgs);

    // Save list position (index & top) in each tab
    int curPos[] = sm.getCurPos();
    int nearPos[] = sm.getNearPos();
    int allPos[] = sm.getAllPos();

    editor.putInt("curPosIndex", curPos[0]);
    editor.putInt("nearPosIndex", nearPos[0]);
    editor.putInt("allPosIndex", allPos[0]);
    editor.putInt("curPosTop", curPos[1]);
    editor.putInt("nearPosTop", nearPos[1]);
    editor.putInt("allPosTop", allPos[1]);

    // Note: Only those buildings still nearby should become expanded
    // Since the fragments all call getBuildings before re-populating.
    // So only those still in the getBuildings list will be able to be
    // re-expanded!

    editor.commit();
  }
  /** Saves the users settings persistently. */
  protected void savePreferences() {
    SharedPreferences settings = GlobalContext.getGC().getPreferences(0);
    SharedPreferences.Editor editor = settings.edit();

    editor.putBoolean(genPrefKey(LocalWorkspace.HAS_PREFS_KEY), true);

    editor.putBoolean(genPrefKey(LocalWorkspace.IS_PUBLIC_KEY), isPublic());
    editor.putStringSet(genPrefKey(LocalWorkspace.TAGS_KEY), new HashSet<>(getTags()));
    editor.putStringSet(genPrefKey(LocalWorkspace.USERACL_KEY), new HashSet<>(getUserACL()));
    editor.putInt(genPrefKey(LocalWorkspace.SIZE_KEY), getMaxSpace());

    editor.apply();

    Log.i(Constants.LOG_TAG, String.format("LocalWorkspace.savePreferences, name: %s", getName()));
  }
 @SuppressWarnings("unchecked")
 public void onClick_blockHost(View view) {
   Set<String> defaultSet = new HashSet<>();
   SharedPreferences blocked_hosts =
       Dynamo_Interface.application_context.getSharedPreferences(
           "blocked_hosts", Context.MODE_PRIVATE);
   ArrayList<String> host_list = new ArrayList<>(blocked_hosts.getStringSet("hosts", defaultSet));
   if (!host_list.contains(viewing_post.getHost())) {
     host_list.add(viewing_post.getHost());
     Set updated_List = new HashSet(host_list);
     SharedPreferences.Editor editor = blocked_hosts.edit();
     editor.putStringSet("hosts", updated_List);
     editor.commit();
     new AlertDialog.Builder(view_post_screen.this)
         .setTitle("Host Block")
         .setMessage(
             viewing_post.getHost()
                 + " is now blocked.  Check the ban list screen to undo this action")
         .setPositiveButton(
             "OK",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                 startActivity(new Intent(view_post_screen.this, view_post_list_screen.class));
               }
             })
         .show();
   } else {
     new AlertDialog.Builder(view_post_screen.this)
         .setTitle("Already Blocked")
         .setMessage("That host has already been blocked.")
         .setPositiveButton("OK", null)
         .show();
   }
 }
 public void deleteFromSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   String key = PREF_TIMER_ID + Integer.toString(mTimerId);
   String id = Integer.toString(mTimerId);
   editor.remove(key);
   key = PREF_START_TIME + id;
   editor.remove(key);
   key = PREF_TIME_LEFT + id;
   editor.remove(key);
   key = PREF_ORIGINAL_TIME + id;
   editor.remove(key);
   key = PREF_SETUP_TIME + id;
   editor.remove(key);
   key = PREF_STATE + id;
   editor.remove(key);
   Set<String> timersList = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>());
   timersList.remove(id);
   editor.putStringSet(PREF_TIMERS_LIST, timersList);
   key = PREF_LABEL + id;
   editor.remove(key);
   key = PREF_DELETE_AFTER_USE + id;
   editor.remove(key);
   editor.commit();
   // dumpTimersFromSharedPrefs(prefs);
 }
  public void checkBookmark(SurahName surahName) {
    if (GLOBAL.bookmarkedStore != null) {
      Set<String> bookmarkSet = null;

      bookmarkSet = GLOBAL.bookmarkedStore.getStringSet("bookmarkSet", null);
      if (bookmarkSet != null) {
        if (bookmarkSet.contains(surahName.getSurahNo())) {
          imgBookMark.setImageDrawable(context.getResources().getDrawable(R.drawable.bookmark_50));
        } else {
          imgBookMark.setImageDrawable(
              context.getResources().getDrawable(R.drawable.bookmark_empty_50));
        }
      } else {

        SharedPreferences.Editor editor = GLOBAL.bookmarkedStore.edit();
        bookmarkSet = new HashSet<>();
        editor.putStringSet("bookmarkSet", bookmarkSet);
        editor.commit();
        checkBookmark(surahName);
      }

    } else {
      GLOBAL.bookmarkedStore =
          context.getSharedPreferences("bookmarkedStore", Context.MODE_PRIVATE);
      checkBookmark(surahName);
    }
  }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 private static void putStringSet(
     SharedPreferences.Editor editor, String key, Iterator<String> remainingArgs) {
   HashSet<String> set = new HashSet<String>();
   while (remainingArgs.hasNext()) {
     set.add(remainingArgs.next());
   }
   editor.putStringSet(key, set);
 }
 private void saveAvailableStylesPref(Set<String> styleTitles) {
   SharedPreferences prefs = prefs();
   SharedPreferences.Editor editor = prefs.edit();
   editor.putStringSet(PREF_STYLE_AVAILABLE + currentSlobUri, styleTitles);
   boolean success = editor.commit();
   if (!success) {
     Log.w(TAG, "Failed to save article view available styles pref");
   }
 }
  public boolean getFollowers(Twitter twitter) {
    boolean newActivity = false;

    try {
      List<User> followers =
          twitter.getFollowersList(
              useSecondAccount
                  ? AppSettings.getInstance(context).secondScreenName
                  : AppSettings.getInstance(context).myScreenName,
              -1,
              200);
      User me = twitter.verifyCredentials();

      int oldFollowerCount = sharedPrefs.getInt("activity_follower_count_" + currentAccount, 0);
      Set<String> latestFollowers =
          sharedPrefs.getStringSet(
              "activity_latest_followers_" + currentAccount, new HashSet<String>());

      Log.v(TAG, "followers set size: " + latestFollowers.size());
      Log.v(TAG, "old follower count: " + oldFollowerCount);
      Log.v(TAG, "current follower count: " + me.getFollowersCount());

      List<User> newFollowers = new ArrayList<User>();
      if (latestFollowers.size() != 0) {
        for (int i = 0; i < followers.size(); i++) {
          if (!latestFollowers.contains(followers.get(i).getScreenName())) {
            Log.v(TAG, "inserting @" + followers.get(i).getScreenName() + " as new follower");
            newFollowers.add(followers.get(i));
            newActivity = true;
          } else {
            break;
          }
        }
      }

      insertFollowers(newFollowers);

      latestFollowers.clear();
      for (int i = 0; i < 50; i++) {
        if (i < followers.size()) {
          latestFollowers.add(followers.get(i).getScreenName());
        } else {
          break;
        }
      }

      SharedPreferences.Editor e = sharedPrefs.edit();
      e.putStringSet("activity_latest_followers_" + currentAccount, latestFollowers);
      e.putInt("activity_follower_count_" + currentAccount, me.getFollowersCount());
      e.commit();
    } catch (TwitterException e) {
      e.printStackTrace();
    }

    return newActivity;
  }
Example #9
0
  private boolean saveArray() {
    SharedPreferences sp = this.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE);
    SharedPreferences.Editor mEdit1 = sp.edit();
    LinkedHashSet<String> set = new LinkedHashSet<String>();
    set.addAll(newcost);

    mEdit1.putStringSet("list", set);
    // Toast.makeText(this, set.toString(), Toast.LENGTH_LONG).show();
    return mEdit1.commit();
  }
  @Override
  public SharedPreferences.Editor putStringSet(String key, Set<String> values) {

    SharedPreferences sharedPreferences =
        context.getSharedPreferences(SharedPreferencesName, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putStringSet(key, values);
    editor.commit();
    return editor;
  }
 @Override
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public SharedPreferences.Editor putStringSet(String key, Set<String> values) {
   final Set<String> encryptedValues = new HashSet<String>(values.size());
   for (String value : values) {
     encryptedValues.add(SecurePreferencesOld.encrypt(value));
   }
   mEditor.putStringSet(SecurePreferencesOld.encrypt(key), encryptedValues);
   return this;
 }
 @Override
 @SuppressLint("NewApi")
 public Editor putStringSet(String key, Set<String> value) {
   if (VERSION.SDK_INT >= 11) {
     editor.putStringSet(key, value);
   } else {
     editor.putString(key, setToString(value));
   }
   return this;
 }
Example #13
0
 public void delete(Context context) {
   SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
   SharedPreferences.Editor editor = sharedPreferences.edit();
   Set<String> idSet = sharedPreferences.getStringSet(REBOOT_IDS, new HashSet<String>());
   idSet.remove(Integer.toString(mId));
   editor.putStringSet(REBOOT_IDS, idSet);
   editor.remove(Integer.toString(mId) + REBOOT_TIME_HOUR);
   editor.remove(Integer.toString(mId) + REBOOT_TIME_MINUTE);
   editor.remove(Integer.toString(mId) + REBOOT_ACTIVE);
   editor.commit();
 }
Example #14
0
 /** TODO: Move this code to RebootManager */
 public void saveToPreferences(Context context) {
   SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
   SharedPreferences.Editor editor = sharedPreferences.edit();
   Set<String> idSet = sharedPreferences.getStringSet(REBOOT_IDS, new HashSet<String>());
   idSet.add(Integer.toString(mId));
   editor.putStringSet(REBOOT_IDS, idSet);
   editor.putInt(Integer.toString(mId) + REBOOT_TIME_HOUR, mRebootHour);
   editor.putInt(Integer.toString(mId) + REBOOT_TIME_MINUTE, mRebootMinute);
   editor.putBoolean(Integer.toString(mId) + REBOOT_ACTIVE, isActive);
   editor.commit();
 }
Example #15
0
  protected void onPause() {
    Log.e("SDL", "onPause()");
    super.onPause();

    editor = settings.edit();
    editor.putString("connectionUrl", edtIpAddress.getText().toString());

    editor.putStringSet("connectionHistory", edtIpAddressHistory);
    editor.commit();

    if (player != null) player.onPause();
  }
 private void createTestUsers() {
   Application application = getActivity().getApplication();
   SharedPreferences.Editor editor =
       application
           .getSharedPreferences(PreferenceAdapter.PREFERENCES_FILE_COMMON, MODE_PRIVATE)
           .edit();
   Set<String> profiles = new LinkedHashSet<String>();
   profiles.add("Default User");
   profiles.add("John Doe");
   profiles.add("Jayne Doe");
   editor.putStringSet(getString(R.string.profile_entries), profiles);
   editor.commit();
 }
Example #17
0
 public void writeToSharedPref(SharedPreferences prefs) {
   final SharedPreferences.Editor editor = prefs.edit();
   final String id = Integer.toString(mTimerId);
   editor.putInt(PREF_TIMER_ID + id, mTimerId);
   editor.putLong(PREF_START_TIME + id, mStartTime);
   editor.putLong(PREF_TIME_LEFT + id, mTimeLeft);
   editor.putLong(PREF_ORIGINAL_TIME + id, mOriginalLength);
   editor.putLong(PREF_SETUP_TIME + id, mSetupLength);
   editor.putInt(PREF_STATE + id, mState);
   final Set<String> timersList = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>());
   timersList.add(id);
   editor.putStringSet(PREF_TIMERS_LIST, timersList);
   editor.putString(PREF_LABEL + id, mLabel);
   editor.putBoolean(PREF_DELETE_AFTER_USE + id, mDeleteAfterUse);
   editor.apply();
 }
 /**
  * writeActionState - write out some state to a preference file
  *
  * @param action - integer
  * @return N/A
  */
 protected void writeActionState(int action, String[] cps) {
   try {
     SharedPreferences prefs =
         getApplicationContext().getSharedPreferences(CPMAINT_STATE_PREFERENCE, MODE_PRIVATE);
     SharedPreferences.Editor editPrefs = prefs.edit();
     editPrefs.putInt(CURRENT_TASK, action);
     if (cps != null) {
       // Save the list of ContentProvider authority strings to the shared pref
       Set<String> mySet = new HashSet<String>(Arrays.asList(cps));
       editPrefs.putStringSet(CP_LIST, mySet);
     }
     editPrefs.commit();
   } catch (Exception e) {
     LogUtils.e(LogUtils.TAG, "Unable to save CP Maint action: %s", e.getMessage());
   }
 }
Example #19
0
  // Helper to remove the snooze preference. Do not use clear because that
  // will erase the clock preferences. Also clear the snooze notification in
  // the window shade.
  private static void clearSnoozePreference(
      final Context context, final SharedPreferences prefs, final int id) {
    final String alarmStr = Integer.toString(id);
    final Set<String> snoozedIds = prefs.getStringSet(PREF_SNOOZE_IDS, new HashSet<String>());
    if (snoozedIds.contains(alarmStr)) {
      NotificationManager nm =
          (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      nm.cancel(id);
    }

    final SharedPreferences.Editor ed = prefs.edit();
    snoozedIds.remove(alarmStr);
    ed.putStringSet(PREF_SNOOZE_IDS, snoozedIds);
    ed.remove(getAlarmPrefSnoozeTimeKey(alarmStr));
    ed.apply();
  }
Example #20
0
 static void saveSnoozeAlert(final Context context, final int id, final long time) {
   SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);
   if (id == INVALID_ALARM_ID) {
     if (!android.util.KpFeatures.DESKCLOCK_SNZOOZE) {
       clearAllSnoozePreferences(context, prefs);
     }
   } else {
     final Set<String> snoozedIds = prefs.getStringSet(PREF_SNOOZE_IDS, new HashSet<String>());
     snoozedIds.add(Integer.toString(id));
     final SharedPreferences.Editor ed = prefs.edit();
     ed.putStringSet(PREF_SNOOZE_IDS, snoozedIds);
     ed.putLong(getAlarmPrefSnoozeTimeKey(id), time);
     ed.apply();
   }
   // Set the next alert after updating the snooze.
   setNextAlert(context);
 }
  @Override
  public void onClick(View v) {
    boolean isAlreadyFavorite = isMovieFavorite();

    int labelId = -1;
    int backgroundColorId = -1;
    int textColorId = -1;

    Set<String> favoriteMovieIdsSet = null;

    if (mPrefs.contains(FAVORITE_MOVIE_IDS_SET_KEY)) {
      favoriteMovieIdsSet = mPrefs.getStringSet(FAVORITE_MOVIE_IDS_SET_KEY, null);
    }

    if (favoriteMovieIdsSet == null) {
      favoriteMovieIdsSet = new LinkedHashSet<>();
    }

    if (isAlreadyFavorite) {
      favoriteMovieIdsSet.remove(Integer.toString(movieId));
      labelId = R.string.label_movie_marked_not_favorite;
      backgroundColorId = R.color.favorite_not_selected;
      textColorId = R.color.text_favorite_not_selected;

    } else {
      favoriteMovieIdsSet.add(Integer.toString(movieId));
      final SharedPreferences.Editor prefsEdit = mPrefs.edit();
      prefsEdit.putStringSet(FAVORITE_MOVIE_IDS_SET_KEY, favoriteMovieIdsSet);
      prefsEdit.commit();

      labelId = R.string.label_movie_marked_favorite;
      backgroundColorId = R.color.favorite_selected;
      textColorId = R.color.text_favorite_selected;
    }

    if (mFavoriteToast != null) {
      mFavoriteToast.cancel();
    }

    mFavoriteToast = Toast.makeText(mContext, getString(labelId), Toast.LENGTH_SHORT);

    mFavoriteToast.show();
    mFavoriteButton.setBackgroundColor(getResources().getColor(backgroundColorId));
    mFavoriteButton.setTextColor(getResources().getColor(textColorId));
  }
Example #22
0
 @Override
 protected void onDialogClosed(boolean positiveResult) {
   super.onDialogClosed(positiveResult);
   if (positiveResult) {
     Set<String> longPrefStringSet = new HashSet<>(mKeyCombos.size());
     for (Long keyCombo : mKeyCombos) {
       longPrefStringSet.add(keyCombo.toString());
     }
     SharedPreferences sharedPreferences = getSharedPreferences();
     SharedPreferences.Editor editor = sharedPreferences.edit();
     String key = getKey();
     editor.putStringSet(key, longPrefStringSet);
     editor.apply();
     callChangeListener(longPrefStringSet);
     notifyChanged();
   } else {
     mKeyCombos = getKeyCodesForPreference(getContext(), getKey());
   }
 }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public static void putStringSet(
      SharedPreferences preferences, final String key, final Set<String> set) {
    final SharedPreferences.Editor editor = preferences.edit();
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
      editor.putStringSet(key, set);
    } else {
      // removes old occurrences of key
      for (String k : preferences.getAll().keySet()) {
        if (k.startsWith(key)) {
          editor.remove(k);
        }
      }

      int i = 0;
      for (String value : set) {
        editor.putString(key + i++, value);
      }
    }
    editor.commit();
  }
Example #24
0
 public void writeToSharedPref(SharedPreferences prefs) {
   SharedPreferences.Editor editor = prefs.edit();
   String key = PREF_TIMER_ID + Integer.toString(mTimerId);
   String id = Integer.toString(mTimerId);
   editor.putInt(key, mTimerId);
   key = PREF_START_TIME + id;
   editor.putLong(key, mStartTime);
   key = PREF_TIME_LEFT + id;
   editor.putLong(key, mTimeLeft);
   key = PREF_ORIGINAL_TIME + id;
   editor.putLong(key, mOriginalLength);
   key = PREF_SETUP_TIME + id;
   editor.putLong(key, mSetupLength);
   key = PREF_STATE + id;
   editor.putInt(key, mState);
   Set<String> timersList = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>());
   timersList.add(id);
   editor.putStringSet(PREF_TIMERS_LIST, timersList);
   key = PREF_LABEL + id;
   editor.putString(key, mLabel);
   editor.apply();
 }
    @Override
    protected void onPostExecute(List<RssItem> result) {
      // once the load has finished
      // load.dismiss();

      Set<String> set;
      SharedPreferences.Editor prefEditor;

      // Get a ListView from main view
      ListView itcItems = (ListView) findViewById(R.id.list);

      // Retrieve shared preferences
      SharedPreferences sharedPref = getSharedPreferences(PREFS_NAME, 0);

      // A variable in order to check if this activity has launched for first time
      Boolean FirstTimeLaunched = sharedPref.getBoolean("FirstTimeLaunched", true);

      // if is first time activity running, create a Set to keep which news has user already clicked
      if (FirstTimeLaunched) {
        set = new HashSet<String>();
        prefEditor = sharedPref.edit();
        prefEditor.putBoolean("FirstTimeLaunched", false);
        prefEditor.putStringSet(CLICKED_TITLES, set);
        prefEditor.commit();
      } else { // else retrieve the Set from shared preferences
        set = sharedPref.getStringSet(CLICKED_TITLES, null);
      }
      // Create a list adapter
      MyAdapter adapter = new MyAdapter(local, android.R.layout.simple_list_item_1, result, set);

      // Set list adapter for the ListView
      itcItems.setAdapter(adapter);

      // Set list view item click listener
      itcItems.setOnItemClickListener(new ListListener(result, local));
    }
Example #26
0
 public boolean putStringSet(String key, List<String> values) {
   SharedPreferences.Editor editor = mPref.edit();
   editor.putStringSet(key, new HashSet<>(values));
   return editor.commit();
 }
Example #27
0
    @Override
    protected void onPostExecute(String result) {
      if (action.equals("login")) {
        if (statusCode == 201) {
          try {
            Toast.makeText(getActivity(), "Login Successful", Toast.LENGTH_SHORT).show();
            JSONArray creditcards;
            JSONObject jsonObject = new JSONObject(result);
            creditcards = jsonObject.getJSONArray("creditcards");
            Set<String> creditCardSet = new HashSet<>();
            for (int i = 0; i < creditcards.length(); i++) {
              JSONObject cc = creditcards.getJSONObject(i);
              String ccnumber = cc.getString("credit_card_number");
              String mm = cc.getString("mm");
              String yy = cc.getString("yy");
              String cvv = cc.getString("cvv");
              String newCC = ccnumber + ":" + mm + ":" + yy + ":" + cvv;
              creditCardSet.add(newCC);
            }

            SharedPreferences sp =
                getActivity().getSharedPreferences("Session", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();

            editor.putStringSet("credit cards", creditCardSet);

            JSONObject userdata = jsonObject.getJSONObject("userdata");
            String email = userdata.getString("email");
            String name = userdata.getString("name");
            String lastname = userdata.getString("last_name");
            String phone = userdata.getString("phone");
            editor.putString("email", email);
            editor.putString("name", name);
            editor.putString("last name", lastname);
            editor.putString("phone", phone);

            String home = userdata.getString("home");
            if (!home.equals("")) {
              String homelat = userdata.getString("home_lat");
              String homelong = userdata.getString("home_long");

              editor.putString("home", home);
              editor.putString("homelat", homelat);
              editor.putString("homelong", homelong);
            }

            String work = userdata.getString("work");
            if (!work.equals("")) {
              String worklat = userdata.getString("work_lat");
              String worklong = userdata.getString("work_long");

              editor.putString("work", work);
              editor.putString("worklat", worklat);
              editor.putString("worklong", worklong);
            }

            editor.commit();

            startActivity(new Intent(getActivity(), MainActivity.class));
            getActivity().finish();
          } catch (JSONException e) {
            e.printStackTrace();
          }
        } else if (statusCode == 401) {
          password.setError("Incorrect Password");
        } else if (statusCode == 402) {
          email.setError("This email is not registered");
        }
      }
    }
 public void setPreferenceValueSet(String key, Set<String> values) {
   editor.putStringSet(key, values);
   editor.commit();
 }
  public static void checkUpdate(final Context context) {
    final SharedPreferences sharedPrefs =
        context.getSharedPreferences(
            "com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);

    if (sharedPrefs.getBoolean("3.1.5", true)) {
      sharedPrefs.edit().putBoolean("3.1.5", false).commit();

      // want to make sure if tweetmarker was on, it remains on.
      if (sharedPrefs.getBoolean("tweetmarker", false)) {
        sharedPrefs.edit().putString("tweetmarker_options", "1").commit();
        AppSettings.invalidate();
      }
    }

    if (sharedPrefs.getBoolean("4.0.0", true)) {
      SharedPreferences.Editor e = sharedPrefs.edit();
      e.putBoolean("4.0.0", false);

      // show them all for now
      Set<String> set = new HashSet<String>();
      set.add("0"); // activity
      set.add("1"); // timeline
      set.add("2"); // mentions
      set.add("3"); // dm's
      set.add("4"); // discover
      set.add("5"); // lists
      set.add("6"); // favorite users
      set.add("7"); // retweets
      set.add("8"); // favorite Tweets
      set.add("9"); // saved searches

      e.putStringSet("drawer_elements_shown_1", set);
      e.putStringSet("drawer_elements_shown_2", set);

      // reset their pages to just home,
      String pageIdentifier = "account_" + 1 + "_page_";
      e.putInt(pageIdentifier + 1, AppSettings.PAGE_TYPE_ACTIVITY);
      e.putInt(pageIdentifier + 2, AppSettings.PAGE_TYPE_HOME);
      e.putInt(pageIdentifier + 3, AppSettings.PAGE_TYPE_MENTIONS);
      e.putInt(pageIdentifier + 4, AppSettings.PAGE_TYPE_DMS);

      pageIdentifier = "account_" + 2 + "_page_";
      e.putInt(pageIdentifier + 1, AppSettings.PAGE_TYPE_ACTIVITY);
      e.putInt(pageIdentifier + 2, AppSettings.PAGE_TYPE_HOME);
      e.putInt(pageIdentifier + 3, AppSettings.PAGE_TYPE_MENTIONS);
      e.putInt(pageIdentifier + 4, AppSettings.PAGE_TYPE_DMS);

      e.putInt("default_timeline_page_" + 1, 1);
      e.putInt("default_timeline_page_" + 2, 1);

      e.commit();
    }

    if (!sharedPrefs.getBoolean("displayed_upgrade_message", false)
        && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      sharedPrefs.edit().putBoolean("displayed_upgrade_message", true).commit();

      new AlertDialog.Builder(context)
          .setTitle("Love Talon?")
          .setMessage(
              "Consider upgrading to the Material Design version of the app! All the latest design elements, in the same Twitter app you have come to enjoy every day.\n\n"
                  + "This 'classic' version of the app will continue to receive all the new features that are possible, just without the visual updates.")
          .setPositiveButton(
              "Upgrade",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  new WebIntentBuilder(context)
                      .setShouldForceExternal(true)
                      .setUrl(
                          "https://play.google.com/store/apps/details?id=com.klinker.android.twitter_l")
                      .build()
                      .start();
                }
              })
          .setNegativeButton(
              "Learn More",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  new WebIntentBuilder(context)
                      .setShouldForceExternal(true)
                      .setUrl("https://plus.google.com/+LukeKlinker/posts/KG4AcH3YA2U")
                      .build()
                      .start();
                }
              })
          .create()
          .show();
    }

    if (sharedPrefs.getBoolean("need_translation_update", true)) {
      sharedPrefs.edit().putBoolean("need_translation_update", false).commit();
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    User user = Utils.getTwitter(context).verifyCredentials();
                    sharedPrefs
                        .edit()
                        .putString("translate_url", Utils.getTranslateURL(user.getLang()))
                        .commit();
                  } catch (Exception e) {

                  }
                }
              })
          .start();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_display_story);

    // Get the message from the intent
    Intent intent = getIntent();
    String jsonStr = intent.getStringExtra(MainActivity.SERVER_STORY);

    // Obtain user story in json data

    String story;
    Integer score = 0, id = 0;
    try {
      // If the json string is empty show the error message
      if (jsonStr.equals("")) {
        story = getResources().getString(R.string.no_story_error);
      } else {
        // Get text, id, score and number of ratings from json
        JSONObject recvStory = new JSONObject(jsonStr);
        story = (String) recvStory.get("text");
        score = (Integer) recvStory.get("score");
        id = (Integer) recvStory.get("id");
        numRatings = (Integer) recvStory.get("nratings");

        // Save id of story for future use (rating)
        storyObj = new JSONObject();
        storyObj.put("id", id);

        // Set the number of ratings the user can give
        RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
        ratingBar.setNumStars(numRatings - 1);
      }
    } catch (JSONException e) {
      e.printStackTrace();
      story = getResources().getString(R.string.server_error);
    }

    // Save story as read if it was loaded
    if (storyObj != null) {

      // Load shared preferences to mark story as read
      SharedPreferences sharedPref =
          getSharedPreferences(getString(R.string.preference_file), Context.MODE_PRIVATE);

      // Get the set with ids of read stories
      Set<String> read_ids =
          sharedPref.getStringSet(getString(R.string.saved_ids), new HashSet<String>());

      // Append id if story read
      SharedPreferences.Editor editor = sharedPref.edit();
      read_ids.add(id.toString());
      editor.putStringSet(getString(R.string.saved_ids), read_ids);
      editor.commit();

      // Disable rating bar and send button if story not received
    } else {
      Button sendRate = (Button) findViewById(R.id.send_rate);
      sendRate.setEnabled(false);
      sendRate.setTextColor(getResources().getColor(R.color.disabled_button));

      RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
      ratingBar.setOnTouchListener(
          new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });
      ratingBar.setFocusable(false);
      ratingBar.setVisibility(View.GONE);
      TextView scoreView = (TextView) findViewById(R.id.story_score);
      scoreView.setVisibility(View.GONE);
    }

    // Set the text in the story_view to the other user story
    TextView storyView = (TextView) findViewById(R.id.story_view);
    storyView.setText(story);
    // Set the text in the score view to the story rating
    TextView scoreView = (TextView) findViewById(R.id.story_score);
    scoreView.setText(score.toString());
  }