Exemplo n.º 1
0
  @Override
  @SuppressWarnings("ResourceType")
  protected void setUp() throws Exception {
    super.setUp();

    preferences = mock(SharedPreferences.class);
    when(preferences.getBoolean(eq(KEY_PREF_SERVICE_ENABLED), anyBoolean())).thenReturn(true);
    when(preferences.getBoolean(eq(KEY_PREF_SERVICE_ENABLED), anyBoolean())).thenReturn(true);
    when(preferences.getString(eq(KEY_PREF_SENDER_ACCOUNT), anyString()))
        .thenReturn("*****@*****.**");
    when(preferences.getString(eq(KEY_PREF_SENDER_PASSWORD), anyString())).thenReturn("password");
    when(preferences.getString(eq(KEY_PREF_RECIPIENTS_ADDRESS), anyString()))
        .thenReturn("*****@*****.**");
    when(preferences.getString(eq(KEY_PREF_EMAIL_HOST), anyString())).thenReturn("smtp.mail.com");
    when(preferences.getString(eq(KEY_PREF_EMAIL_PORT), anyString())).thenReturn("111");
    when(preferences.getStringSet(eq(KEY_PREF_EMAIL_TRIGGERS), anySetOf(String.class)))
        .thenReturn(DEFAULT_TRIGGERS);
    when(preferences.getStringSet(eq(KEY_PREF_EMAIL_CONTENT), anySetOf(String.class)))
        .thenReturn(DEFAULT_CONTENT);

    networkInfo = mock(NetworkInfo.class);
    when(networkInfo.isConnected()).thenReturn(true);

    ConnectivityManager connectivityManager = mock(ConnectivityManager.class);
    when(connectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo);

    context = mock(Context.class);
    when(context.getSystemService(eq(Context.CONNECTIVITY_SERVICE)))
        .thenReturn(connectivityManager);
    when(context.getContentResolver()).thenReturn(getContext().getContentResolver());
    when(context.getResources()).thenReturn(getContext().getResources());
    when(context.getSharedPreferences(anyString(), anyInt())).thenReturn(preferences);

    database = new Database(getContext(), "test.sqlite"); /* not mock context */
    database.destroy();

    cryptor = mock(Cryptor.class);

    when(cryptor.decrypt(anyString()))
        .then(
            new Answer<String>() {

              @Override
              public String answer(InvocationOnMock invocation) throws Throwable {
                return "decrypted " + invocation.getArguments()[0];
              }
            });

    transport = mock(MailTransport.class);
    notifications = mock(Notifications.class);
  }
  public void restorePreferences() {
    // Restore last tab
    SharedPreferences settings = getPreferences(MODE_PRIVATE);
    curTab = settings.getInt("lastTab", 0);

    // Restore last expanded buildings (by tab)
    nearbyExpandedBldgs =
        settings.getStringSet("lastNearbyExpandedBuildings", new HashSet<String>());
    allExpandedBldgs = settings.getStringSet("lastAllExpandedBuildings", new HashSet<String>());

    // Restore position in each tab
    sm.setCurPos(settings.getInt("curPosIndex", 0), settings.getInt("curPosTop", 0));
    sm.setNearbyPos(settings.getInt("nearPosIndex", 0), settings.getInt("nearPosTop", 0));
    sm.setAllPos(settings.getInt("allPosIndex", 0), settings.getInt("allPosTop", 0));
  }
Exemplo n.º 3
0
  private void startSearch() {
    if (searchRunning != 0) {
      Toast.makeText(getActivity(), "Suche läuft bereits.", Toast.LENGTH_SHORT).show();
      return;
    }
    getActivity().setProgressBarIndeterminateVisibility(true);
    searchString =
        ((TextView) rootView.findViewById(R.id.autoCompleteTextView1)).getText().toString();
    String url =
        "http://" + conf.getString("HOST", "") + ":" + String.valueOf(conf.getString("PORT", "80"));

    Bundle args = new Bundle();
    args.putString("url", url);
    if (vollSuche) {
      for (String rai : conf.getStringSet("rai_list", new HashSet<String>())) {
        searchRunning++;
        adapter.changeCursor(null);
        args.putString("search", rai);
        getLoaderManager().restartLoader(Katalog.LOCATION, args, this);
      }
    } else {
      args.putString("search", searchString);
      // new FetchLocation(getActivity(), new FetchLocationListener()).execute(args);
      searchRunning++;
      // 1. Hier geht's los!!
      getLoaderManager().restartLoader(Katalog.LOCATION, args, this);
    }
  }
 public static void removeFromInstallQueue(
     Context context, ArrayList<String> packageNames, UserHandleCompat user) {
   if (packageNames.isEmpty()) {
     return;
   }
   String spKey = LauncherAppState.getSharedPreferencesKey();
   SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
   synchronized (sLock) {
     Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
     if (DBG) {
       Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames);
     }
     if (strings != null) {
       Set<String> newStrings = new HashSet<String>(strings);
       Iterator<String> newStringsIter = newStrings.iterator();
       while (newStringsIter.hasNext()) {
         String encoded = newStringsIter.next();
         PendingInstallShortcutInfo info = decode(encoded, context);
         if (info == null
             || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) {
           newStringsIter.remove();
         }
       }
       sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit();
     }
   }
 }
 @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();
   }
 }
Exemplo n.º 6
0
 /**
  * Returns the set of long codes of the keys assigned to a preference.
  *
  * @param context The context to use for a PreferenceManager
  * @param key The preference key
  * @return The {@code Set<Long>} of the keys assigned to the preference
  */
 public static Set<Long> getKeyCodesForPreference(Context context, String key) {
   final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
   Set<Long> result = new HashSet<>();
   try {
     Set<String> longPrefStringSet = prefs.getStringSet(key, Collections.EMPTY_SET);
     for (String longPrefString : longPrefStringSet) {
       result.add(Long.valueOf(longPrefString));
     }
   } catch (ClassCastException e) {
     /*
      * Key maps to preference that is not a set. Fall back on legacy behavior before we
      * supported multiple keys
      */
     long keyCode = prefs.getLong(key, KeyComboPreference.INVALID_EXTENDED_KEY_CODE);
     if (keyCode != INVALID_EXTENDED_KEY_CODE) {
       result.add(keyCode);
     }
   } catch (NumberFormatException e) {
     /*
      * One of the strings in the string set can't be converted to a Long. This should
      * not be possible unless the preferences are corrupted. Remove the preference and
      * return an empty set.
      */
     prefs.edit().remove(key).apply();
   }
   return result;
 }
 private void reloadSoundsToPlayList() {
   HashSet<String> defaultSounds = new HashSet<String>();
   defaultSounds.add("sound_start");
   defaultSounds.add("sound_error");
   defaultSounds.add("sound_end");
   mSoundsToPlayList = prefs.getStringSet(Common.PREF_SOUNDS_TO_PLAY, defaultSounds);
 }
Exemplo n.º 8
0
 @Nullable
 @Override
 public Set<String> getStringSet(String key, Set<String> defValues) {
   SharedPreferences sp =
       context.getSharedPreferences(SharedPreferencesName, Context.MODE_PRIVATE);
   return sp.getStringSet(key, defValues);
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
  public static boolean existInFavorites(Context context, MovieEntity entity) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    Set<String> movieFavoritesList = sp.getStringSet(ConstantValues.PREF_MOVIE_FAVORITES, null);

    if (movieFavoritesList != null && movieFavoritesList.contains(String.valueOf(entity.getId())))
      return true;
    return false;
  }
 @SuppressLint("NewApi")
 @Override
 public Set<String> getStringSet(String key, Set<String> defValue) {
   if (VERSION.SDK_INT >= 11) {
     return prefs.getStringSet(key, defValue);
   } else {
     return getSet(key, defValue, String.class);
   }
 }
  public void saveLeaguer(String spName, String key, String leaguer) {
    SharedPreferences sp = getApplicationContext().getSharedPreferences(spName, MODE_PRIVATE);

    Set<String> teamLeaguer = sp.getStringSet(key, new LinkedHashSet<String>());
    Editor edit = sp.edit();
    teamLeaguer.add(leaguer);
    edit.putStringSet(key, teamLeaguer);
    edit.commit();
  }
Exemplo n.º 13
0
  public boolean isFavorite(Context context) {

    SharedPreferences settings = context.getSharedPreferences("CSPPrefsFile", 0);
    List<String> favs = new ArrayList<String>(settings.getStringSet("Favorites", null));
    if (favs == null) {
      return false;
    }
    return favs.contains(String.valueOf(this.unitID));
  }
Exemplo n.º 14
0
  public static void removeFromFavorites(Context context, MovieEntity entity) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    Set<String> movieFavoritesList = sp.getStringSet(ConstantValues.PREF_MOVIE_FAVORITES, null);

    if (movieFavoritesList == null) movieFavoritesList = new TreeSet<String>();

    movieFavoritesList.remove(String.valueOf(entity.getId()));
    sp.edit().putStringSet(ConstantValues.PREF_MOVIE_FAVORITES, movieFavoritesList).apply();
  }
Exemplo n.º 15
0
  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;
  }
Exemplo n.º 16
0
  private ArrayList<String> getArray() {
    SharedPreferences sp = this.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE);

    // NOTE: if shared preference is null, the method return empty Hashset and not null
    Set<String> set = sp.getStringSet("list", new LinkedHashSet<String>());

    // Toast.makeText(this, "print linkedhashset " + set.toString(), Toast.LENGTH_LONG).show();

    return new ArrayList<String>(set);
  }
Exemplo n.º 17
0
 public ListPreferenceCustom(Context context, AttributeSet attrs, int array, String stringSetKey) {
   super(context, attrs);
   String defaultItemsArray[] = context.getResources().getStringArray(array);
   SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
   Set<String> itemsSet =
       sharedPreferences.getStringSet(stringSetKey, Globals.arrayToSet(defaultItemsArray));
   String items[] = Globals.setToArray(itemsSet);
   this.setEntries(items);
   this.setEntryValues(items);
 }
Exemplo n.º 18
0
 public static void dumpTimersFromSharedPrefs(SharedPreferences prefs) {
   Object[] timerStrings = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>()).toArray();
   Log.v(TAG, "--------------------- timers list in shared prefs");
   if (timerStrings.length > 0) {
     for (int i = 0; i < timerStrings.length; i++) {
       int id = Integer.parseInt((String) timerStrings[i]);
       Log.v(TAG, "---------------------timer  " + (i + 1) + ": id - " + id);
     }
   }
 }
Exemplo n.º 19
0
 protected String[] getCalendarIds() {
   Set<String> calendarPreference =
       sharedPref.getStringSet(
           SettingsFragment.PREFERENCE_KEY_RELEVANT_CALENDARS, new HashSet<String>(0));
   if (calendarPreference == null) {
     return new String[0];
   } else {
     return calendarPreference.toArray(new String[calendarPreference.size()]);
   }
 }
  /** Initiate ViewPager and PagerAdapter */
  public void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getFragmentManager());

    Bundle bundle = new Bundle();
    bundle.putString(MIME_TYPE, Audio.Playlists.CONTENT_TYPE);
    bundle.putLong(BaseColumns._ID, PLAYLIST_RECENTLY_ADDED);

    // Get tab visibility preferences
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Set<String> defaults =
        new HashSet<String>(Arrays.asList(getResources().getStringArray(R.array.tab_titles)));
    Set<String> tabs_set = sp.getStringSet(TABS_ENABLED, defaults);
    // if its empty fill reset it to full defaults
    // stops app from crashing when no tabs are shown
    // TODO:rewrite activity to not crash when no tabs are chosen to show
    if (tabs_set.size() == 0) {
      tabs_set = defaults;
    }

    // Only show tabs that were set in preferences
    // Recently added tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_recent)))
      mPagerAdapter.addFragment(new RecentlyAddedFragment(bundle));
    // Artists
    if (tabs_set.contains(getResources().getString(R.string.tab_artists)))
      mPagerAdapter.addFragment(new ArtistsFragment());
    // Albums
    if (tabs_set.contains(getResources().getString(R.string.tab_albums)))
      mPagerAdapter.addFragment(new AlbumsFragment());
    // // Tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_songs)))
      mPagerAdapter.addFragment(new TracksFragment());
    // // Playlists
    if (tabs_set.contains(getResources().getString(R.string.tab_playlists)))
      mPagerAdapter.addFragment(new PlaylistsFragment());
    // // Genres
    if (tabs_set.contains(getResources().getString(R.string.tab_genres)))
      mPagerAdapter.addFragment(new GenresFragment());

    // Initiate ViewPager
    ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    // mViewPager.setCurrentItem(0);

    // Tabs
    initScrollableTabs(mViewPager);

    // Theme chooser
    ThemeUtils.initThemeChooser(this, mViewPager, "viewpager", THEME_ITEM_BACKGROUND);
    ThemeUtils.setMarginDrawable(this, mViewPager, "viewpager_margin");
  }
  /**
   * If the LocalWorkspace has saved preferences, this method loads them.
   *
   * <p>Returns true if preferences exist, false otherwise
   */
  protected boolean loadPreferences() {
    SharedPreferences settings = GlobalContext.getGC().getPreferences(0);

    // Settigns exist for this LocalWorkspace
    if (settings.getBoolean(genPrefKey(LocalWorkspace.HAS_PREFS_KEY), false)) {

      setVisibility(settings.getBoolean(genPrefKey(LocalWorkspace.IS_PUBLIC_KEY), isPublic()));

      int storedMaxSize = settings.getInt(genPrefKey(LocalWorkspace.SIZE_KEY), getMaxSpace());
      if (storedMaxSize < getUsedSpace()) {
        try {
          setMaxSpace(getUsedSpace());
          Log.w(
              Constants.LOG_TAG,
              String.format(
                  "LocalWorkspace.loadPreferences, name: %s, "
                      + "Invalid stored MaxSize: %d. \n"
                      + "Files must have been altered externally. New maxSize : %d.",
                  getName(), storedMaxSize, getUsedSpace()));
        } catch (InvalidMaxSpace e) {
          Log.e(
              Constants.LOG_TAG,
              "LocalWorkspace.loadPreferences, setMaxSpace(getMaxSpace()); throwed InvalidMaxSpace");
          System.exit(-1);
        }
      }

      tags = new ArrayList<>(settings.getStringSet(genPrefKey(LocalWorkspace.TAGS_KEY), null));
      userACL =
          new ArrayList<>(settings.getStringSet(genPrefKey(LocalWorkspace.USERACL_KEY), null));

      Log.i(
          Constants.LOG_TAG,
          String.format("LocalWorkspace.loadPreferences, name: %s, sucess", getName()));
      return true;
    }

    Log.i(
        Constants.LOG_TAG,
        String.format("LocalWorkspace.loadPreferences, name: %s, failure", getName()));
    return false;
  }
Exemplo n.º 22
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();
 }
Exemplo n.º 23
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();
 }
Exemplo n.º 24
0
 private void loadAvailableStylesPref() {
   if (currentSlobUri == null) {
     Log.w(TAG, "Can't load article view available styles pref - slob uri is null");
     return;
   }
   SharedPreferences prefs = prefs();
   Log.d(TAG, "Available styles before pref load: " + styleTitles.size());
   styleTitles =
       new TreeSet(
           prefs.getStringSet(PREF_STYLE_AVAILABLE + currentSlobUri, Collections.EMPTY_SET));
   Log.d(TAG, "Loaded available styles: " + styleTitles.size());
 }
Exemplo n.º 25
0
 public static void getTimersFromSharedPrefs(
     SharedPreferences prefs, ArrayList<TimerObj> timers, int match) {
   Object[] timerStrings = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>()).toArray();
   if (timerStrings.length > 0) {
     for (int i = 0; i < timerStrings.length; i++) {
       TimerObj t = new TimerObj();
       t.mTimerId = Integer.parseInt((String) timerStrings[i]);
       t.readFromSharedPref(prefs);
       if (t.mState == match) {
         timers.add(t);
       }
     }
   }
 }
Exemplo n.º 26
0
 /** Listens for a change in the preferences */
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   System.out.println("GUEEEEE ON SHARED PREFERENCE CHANGED");
   if (key.equals(KEY_PREF_SYNC_CONN)) {
     System.out.println("key multilist changed");
     MultiSelectListPreference connectionPref = (MultiSelectListPreference) findPreference(key);
     // Get the new values
     Set<String> set = sharedPreferences.getStringSet(key, null);
     // Set the new values on the list
     MainActivity.websNames = set.toArray(new String[0]);
     // Set the values on the list shown
     connectionPref.setValues(set);
   }
 }
Exemplo n.º 27
0
  private static void clearAllSnoozePreferences(
      final Context context, final SharedPreferences prefs) {
    NotificationManager nm =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final Set<String> snoozedIds = prefs.getStringSet(PREF_SNOOZE_IDS, new HashSet<String>());
    final SharedPreferences.Editor ed = prefs.edit();
    for (String snoozeId : snoozedIds) {
      nm.cancel(Integer.parseInt(snoozeId));
      ed.remove(getAlarmPrefSnoozeTimeKey(snoozeId));
    }

    ed.remove(PREF_SNOOZE_IDS);
    ed.apply();
  }
  @Override
  public void onSharedPreferenceChanged(
      final SharedPreferences sharedPreferences, final String key) {
    if (key.equals("pref_force_desktop")) {
      mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false);
      mNavigationHelper.onPrefChanged();
    } else if (key.equals("pref_user_location_mode")) {
      final int mode = Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0"));
      if (mUserLocation.setLocationMode(mode)) mReloadNeeded = true;
      return;
    } else if (key.equals("pref_persistent_zoom")) {
      mPersistentZoom = mSharedPrefs.getBoolean("pref_persistent_zoom", false);
      return;
    } else if (key.equals("pref_fullscreen")) {
      mIitcWebView.updateFullscreenStatus();
      mNavigationHelper.onPrefChanged();
      return;
    } else if (key.equals("pref_android_menu")) {
      final String[] menuDefaults =
          getResources().getStringArray(R.array.pref_android_menu_default);
      mAdvancedMenu =
          mSharedPrefs.getStringSet(
              "pref_android_menu", new HashSet<String>(Arrays.asList(menuDefaults)));
      mNavigationHelper.setDebugMode(mAdvancedMenu.contains(R.string.menu_debug));
      invalidateOptionsMenu();
      // no reload needed
      return;
    } else if (key.equals("pref_fake_user_agent")) {
      mIitcWebView.setUserAgent();
    } else if (key.equals("pref_last_plugin_update")) {
      final Long forceUpdate = sharedPreferences.getLong("pref_last_plugin_update", 0);
      if (forceUpdate == 0) mFileManager.updatePlugins(true);
      return;
    } else if (key.equals("pref_update_plugins_interval")) {
      final int interval =
          Integer.parseInt(mSharedPrefs.getString("pref_update_plugins_interval", "7"));
      mFileManager.setUpdateInterval(interval);
      return;
    } else if (key.equals("pref_press_twice_to_exit")
        || key.equals("pref_share_selected_tab")
        || key.equals("pref_messages")
        || key.equals("pref_secure_updates")
        || key.equals("pref_external_storage")) {
      // no reload needed
      return;
    }

    mReloadNeeded = true;
  }
Exemplo n.º 29
0
 public static ArrayList<TodoElement> getAllItems(final Context context) {
   final SharedPreferences preferences = context.getSharedPreferences(PREFS_NAME, 0);
   final Set<String> ids = preferences.getStringSet(ITEMS_KEY, new HashSet<String>());
   final ArrayList<TodoElement> items = new ArrayList<TodoElement>();
   final HashSet<String> confirmedIds = new HashSet<String>();
   for (final String id : ids) {
     final TodoElement item = getItem(context, UUID.fromString(id));
     if (item != null) {
       items.add(item);
       confirmedIds.add(id);
     }
   }
   preferences.edit().putStringSet(ITEMS_KEY, confirmedIds).commit();
   return items;
 }
Exemplo n.º 30
0
 public boolean isBlackListed() {
     String txt = mText;
     Set<String> blacklist = mSharedPref.getStringSet(_(R.string.pref_blacklist), null);
     if (blacklist != null) {
         for (String entry : blacklist) {
             entry = entry.replace(".", "\\.").replace("*", ".*");
             Pattern pat = Pattern.compile(entry, Pattern.DOTALL);
             if (pat.matcher(txt).matches()) {
                 Log.d(TAG, txt + " matches " + entry);
                 return true;
             }
         }
     }
     Set<String> appblacklist = mSharedPref.getStringSet(_(R.string.pref_blocked_applist), null);
     if (appblacklist != null) {
         for (String entry : appblacklist) {
             if (entry.equals(mPkg)) {
                 return true;
             }
         }
     }
     
     return false;
 }