Android Open Source - xposed-keyboard-tweaks Cached Black List






From Project

Back to project page xposed-keyboard-tweaks.

License

The source code is released under:

Apache License

If you think the Android project xposed-keyboard-tweaks 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 ca.spacek.gkdd;
/*w  ww.jav  a 2  s  .c o m*/
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

import android.database.Cursor;
import android.util.Log;

import ca.spacek.gkdd.blacklist.gk.ContextManager;
import ca.spacek.gkdd.contentprovider.DictionaryWordContentProvider;
import ca.spacek.gkdd.data.DictionaryWordTable;

public class CachedBlackList implements BlackList {
  private final ContextManager contextManager;
  private Set<String> words = new TreeSet<String>(CASE_INSENSITVE);
  private boolean dirty = true;

  public CachedBlackList(ContextManager contextManager) {
    this.contextManager = contextManager;
  }

  @Override
  public boolean contains(String word) {
    if (dirty) {
            Log.d("blacklist", "Was dirty, refreshing");
            refresh();
    }

        Log.d("blacklist", "Checking if blacklist contains " + word);
    return words.contains(word);
  }

  private void refresh() {
    dirty = false;
    words.clear();

        if (!contextManager.get().isPresent()) {
            return;
        }

        Cursor cursor = contextManager.get().get().getContentResolver().query(
        DictionaryWordContentProvider.CONTENT_URI,
        new String[] { DictionaryWordTable.COLUMN_ID, DictionaryWordTable.COLUMN_WORD }, null, null, null);

    if (cursor == null || !cursor.moveToFirst()) {
      return;
    }

    do {
      String word = cursor.getString(1);
      Log.d("blacklist", "Adding word: " + word);
      words.add(word);
    } while (cursor.moveToNext());

        Log.i("blacklist", "Using blacklist of " + words.size() + " words");
  }

  private static Comparator<String> CASE_INSENSITVE = new Comparator<String>() {
    @Override
    public int compare(String lhs, String rhs) {
      return lhs.compareToIgnoreCase(rhs);
    }
  };

  public void flagDirty() {
    dirty = true;
  }
}




Java Source Code List

ca.spacek.gkdd.BlackList.java
ca.spacek.gkdd.CachedBlackListDictionaryWordContentObserver.java
ca.spacek.gkdd.CachedBlackList.java
ca.spacek.gkdd.DictionaryWordsListActivity.java
ca.spacek.gkdd.Initialize.java
ca.spacek.gkdd.Injector.java
ca.spacek.gkdd.blacklist.AddToBlackListHook.java
ca.spacek.gkdd.blacklist.ContextChangeHook.java
ca.spacek.gkdd.blacklist.GetSuggestedWordsHook.java
ca.spacek.gkdd.blacklist.ReflectionException.java
ca.spacek.gkdd.blacklist.SuggestionBlackLister.java
ca.spacek.gkdd.blacklist.gk.ContextManager.java
ca.spacek.gkdd.blacklist.gk.CurrentGoogleKeyboardInjector.java
ca.spacek.gkdd.blacklist.gk.LongPressReplacementMethod.java
ca.spacek.gkdd.blacklist.gk.OnSuggestedWordCallbackHandler.java
ca.spacek.gkdd.blacklist.gk.OnSuggestedWordCallbackProxyFactory.java
ca.spacek.gkdd.blacklist.gk.PackageReflection.java
ca.spacek.gkdd.blacklist.gk.SuggestedWordInfoTransform.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileAddToBlackListHook.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileContextChangeHook.java
ca.spacek.gkdd.blacklist.gk.hook.ProfileGetSuggestedWordsHook.java
ca.spacek.gkdd.contentprovider.DictionaryWordContentProvider.java
ca.spacek.gkdd.data.DictionaryWordDatabaseHelper.java
ca.spacek.gkdd.data.DictionaryWordTable.java