Fixed bug in dark mode where search suggestions wouldn't show up. Sped up app startup by using singleton in BookmarkManager.

This commit is contained in:
Anthony Restaino 2015-04-17 08:46:16 -04:00
parent 8c29cb4450
commit 4822996da1
8 changed files with 406 additions and 32 deletions

View File

@ -22,8 +22,16 @@ public class AdBlock {
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
private boolean mBlockAds; private boolean mBlockAds;
private static final Locale mLocale = Locale.getDefault(); private static final Locale mLocale = Locale.getDefault();
private static AdBlock mInstance;
public AdBlock(Context context) { public static AdBlock getInstance(Context context) {
if (mInstance == null) {
mInstance = new AdBlock(context);
}
return mInstance;
}
private AdBlock(Context context) {
if (mBlockedDomainsList.isEmpty()) { if (mBlockedDomainsList.isEmpty()) {
loadBlockedDomainsList(context); loadBlockedDomainsList(context);
} }

View File

@ -45,7 +45,7 @@ public class BookmarkActivity extends ThemableSettingsActivity implements OnClic
TextView importBookmarks = (TextView) findViewById(R.id.isImportBrowserAvailable); TextView importBookmarks = (TextView) findViewById(R.id.isImportBrowserAvailable);
mBookmarkManager = new BookmarkManager(this); mBookmarkManager = BookmarkManager.getInstance(getApplicationContext());
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);

View File

@ -34,8 +34,16 @@ public class BookmarkManager {
private static final String FILE_BOOKMARKS = "bookmarks.dat"; private static final String FILE_BOOKMARKS = "bookmarks.dat";
private static SortedMap<String, Integer> mBookmarkMap = new TreeMap<String, Integer>( private static SortedMap<String, Integer> mBookmarkMap = new TreeMap<String, Integer>(
String.CASE_INSENSITIVE_ORDER); String.CASE_INSENSITIVE_ORDER);
private static BookmarkManager mInstance;
public BookmarkManager(Context context) { public static BookmarkManager getInstance(Context context) {
if (mInstance == null) {
mInstance = new BookmarkManager(context);
}
return mInstance;
}
private BookmarkManager(Context context) {
mContext = context; mContext = context;
mBookmarkMap = getBookmarkUrls(); mBookmarkMap = getBookmarkUrls();
} }

View File

@ -18,7 +18,6 @@ import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix; import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
@ -139,13 +138,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} else { } else {
mWebViews = new ArrayList<LightningView>(); mWebViews = new ArrayList<LightningView>();
} }
mBookmarkManager = new BookmarkManager(this);
if (!mPreferences.getBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, false)) {
List<HistoryItem> old = Utils.getOldBookmarks(this);
mBookmarkManager.addBookmarkList(old);
mPreferences.edit().putBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, true)
.apply();
}
mActivity = this; mActivity = this;
mClickHandler = new ClickHandler(this); mClickHandler = new ClickHandler(this);
mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame);
@ -193,13 +186,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener());
mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener());
mBookmarkList = mBookmarkManager.getBookmarks(true);
mBookmarkAdapter = new BookmarkViewAdapter(this, R.layout.bookmark_list_item, mBookmarkList);
mDrawerListRight.setAdapter(mBookmarkAdapter);
mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener()); mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener());
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener()); mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
mHistoryDatabase = HistoryDatabase.getInstance(this); mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext());
// set display options of the ActionBar // set display options of the ActionBar
mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayShowTitleEnabled(false);
@ -262,6 +252,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override @Override
public void run() { public void run() {
mBookmarkManager = BookmarkManager.getInstance(mActivity.getApplicationContext());
mBookmarkList = mBookmarkManager.getBookmarks(true);
mBookmarkAdapter = new BookmarkViewAdapter(mActivity, R.layout.bookmark_list_item,
mBookmarkList);
mDrawerListRight.setAdapter(mBookmarkAdapter);
initializeSearchSuggestions(mSearch); initializeSearchSuggestions(mSearch);
} }
@ -611,6 +606,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
int count = 0; int count = 0;
for (int n = 0; n < array.length; n++) { for (int n = 0; n < array.length; n++) {
if (array[n].length() > 0) { if (array[n].length() > 0) {
if (url != null && url.compareTo(array[n]) == 0) {
url = null;
}
newTab(array[n], true); newTab(array[n], true);
count++; count++;
} }
@ -1365,7 +1363,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mCurrentView.resumeTimers(); mCurrentView.resumeTimers();
mCurrentView.onResume(); mCurrentView.onResume();
mHistoryDatabase = HistoryDatabase.getInstance(this); mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext());
mBookmarkList = mBookmarkManager.getBookmarks(true); mBookmarkList = mBookmarkManager.getBookmarks(true);
notifyBookmarkDataSetChanged(); notifyBookmarkDataSetChanged();
} }
@ -1509,14 +1507,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
ImageView exit; ImageView exit;
} }
} }
private class CloseTabListener implements OnClickListener{ private class CloseTabListener implements OnClickListener {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
deleteTab((int) v.getTag()); deleteTab((int) v.getTag());
} }
} }
private void changeToolbarBackground(Bitmap favicon) { private void changeToolbarBackground(Bitmap favicon) {
@ -1592,10 +1590,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> { public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
Context context; Context context;
int layoutResourceId;
List<HistoryItem> data = null; List<HistoryItem> data = null;
int layoutResourceId;
public BookmarkViewAdapter(Context context, int layoutResourceId, List<HistoryItem> data) { public BookmarkViewAdapter(Context context, int layoutResourceId, List<HistoryItem> data) {
super(context, layoutResourceId, data); super(context, layoutResourceId, data);
@ -1889,7 +1885,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}); });
getUrl.setSelectAllOnFocus(true); getUrl.setSelectAllOnFocus(true);
mSearchAdapter = new SearchAdapter(mContext, isIncognito() || mDarkTheme); mSearchAdapter = new SearchAdapter(mContext, mDarkTheme, isIncognito());
getUrl.setAdapter(mSearchAdapter); getUrl.setAdapter(mSearchAdapter);
} }

View File

@ -53,7 +53,7 @@ public class HistoryPage {
} }
private static List<HistoryItem> getWebHistory(Context context) { private static List<HistoryItem> getWebHistory(Context context) {
HistoryDatabase databaseHandler = HistoryDatabase.getInstance(context); HistoryDatabase databaseHandler = HistoryDatabase.getInstance(context.getApplicationContext());
return databaseHandler.getLastHundredItems(); return databaseHandler.getLastHundredItems();
} }
} }

View File

@ -86,7 +86,7 @@ public class LightningView {
mActivity = activity; mActivity = activity;
mWebView = new WebView(activity); mWebView = new WebView(activity);
mTitle = new Title(activity, darkTheme); mTitle = new Title(activity, darkTheme);
mAdBlock = new AdBlock(activity); mAdBlock = AdBlock.getInstance(activity.getApplicationContext());
if (darkTheme) { if (darkTheme) {
mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(), mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(),

View File

@ -0,0 +1,360 @@
package acr.browser.lightning;
import android.content.SharedPreferences;
import android.os.Environment;
public class Preferences {
private static Preferences mInstance;
private static SharedPreferences mPrefs;
private static final String PREFERENCES = "settings";
private Preferences(){
mPrefs = BrowserApp.getAppContext().getSharedPreferences(PREFERENCES, 0);
}
public static Preferences getInstance(){
if(mInstance == null){
mInstance = new Preferences();
}
return mInstance;
}
public int getFlashSupport(){
return mPrefs.getInt(Name.ADOBE_FLASH_SUPPORT, 0);
}
public void setFlashSupport(int n){
mPrefs.edit().putInt(Name.ADOBE_FLASH_SUPPORT, n).apply();
}
public boolean getAdBlockEnabled(){
return mPrefs.getBoolean(Name.BLOCK_ADS, false);
}
public void setAdBlockEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.BLOCK_ADS, enable).apply();
}
public boolean getBlockImagesEnabled(){
return mPrefs.getBoolean(Name.BLOCK_IMAGES, false);
}
public void setBlockImagesEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.BLOCK_IMAGES, enable).apply();
}
public boolean getClearCacheExit(){
return mPrefs.getBoolean(Name.CLEAR_CACHE_EXIT, false);
}
public void setClearCacheExit(boolean enable){
mPrefs.edit().putBoolean(Name.CLEAR_CACHE_EXIT, enable).apply();
}
public boolean getCookiesEnabled(){
return mPrefs.getBoolean(Name.COOKIES, true);
}
public void setCookiesEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.COOKIES, enable).apply();
}
public String getDownloadDirectory(){
return mPrefs.getString(Name.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS);
}
public void setDownloadDirectory(String directory){
mPrefs.edit().putString(Name.DOWNLOAD_DIRECTORY, directory).apply();
}
public boolean getFullScreenEnabled(){
return mPrefs.getBoolean(Name.FULL_SCREEN, false);
}
public void setFullScreenEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.FULL_SCREEN, enable).apply();
}
public boolean getHideStatusBarEnabled(){
return mPrefs.getBoolean(Name.HIDE_STATUS_BAR, false);
}
public void setHideStatusBarEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.HIDE_STATUS_BAR, enable).apply();
}
public String getHomepage(){
return mPrefs.getString(Name.HOMEPAGE, Constants.HOMEPAGE);
}
public void setHomepage(String homepage){
mPrefs.edit().putString(Name.HOMEPAGE, homepage).apply();
}
public boolean getIncognitoCookiesEnabled(){
return mPrefs.getBoolean(Name.INCOGNITO_COOKIES, false);
}
public void setIncognitoCookiesEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.INCOGNITO_COOKIES, enable).apply();
}
public boolean getJavaScriptEnabled(){
return mPrefs.getBoolean(PreferenceConstants.JAVASCRIPT, true);
}
public void setJavaScriptEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.JAVASCRIPT, enable).apply();
}
public boolean getLocationEnabled(){
return mPrefs.getBoolean(Name.LOCATION, false);
}
public void setLocationEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.LOCATION, enable).apply();
}
public boolean getOverviewModeEnabled(){
return mPrefs.getBoolean(Name.OVERVIEW_MODE, true);
}
public void setOverviewModeEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.OVERVIEW_MODE, enable).apply();
}
public boolean getPopupsEnabled(){
return mPrefs.getBoolean(Name.POPUPS, true);
}
public void setPopupsEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.POPUPS, enable).apply();
}
public boolean getRestoreLostTabsEnabled(){
return mPrefs.getBoolean(Name.RESTORE_LOST_TABS, true);
}
public void setRestoreLostTabsEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.RESTORE_LOST_TABS, enable).apply();
}
public boolean getSavePasswordsEnabled(){
return mPrefs.getBoolean(Name.SAVE_PASSWORDS, true);
}
public void setSavePasswordsEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.SAVE_PASSWORDS, enable).apply();
}
public int getSearchChoice(){
return mPrefs.getInt(Name.SEARCH, 1);
}
public void setSearchChoice(int choice){
mPrefs.edit().putInt(Name.SEARCH, choice).apply();
}
public String getSearchUrl(){
return mPrefs.getString(Name.SEARCH_URL, Constants.GOOGLE_SEARCH);
}
public void setSearchUrl(String url){
mPrefs.edit().putString(Name.SEARCH_URL, url).apply();
}
public boolean getSystemBrowserPresent(){
return mPrefs.getBoolean(Name.SYSTEM_BROWSER_PRESENT, false);
}
public void setSystemBrowserPresent(boolean available){
mPrefs.edit().putBoolean(Name.SYSTEM_BROWSER_PRESENT, available).apply();
}
public boolean getTextReflowEnabled(){
return mPrefs.getBoolean(Name.TEXT_REFLOW, false);
}
public void setTextReflowEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.TEXT_REFLOW, enable).apply();
}
public int getTextSize(){
return mPrefs.getInt(Name.TEXT_SIZE, 3);
}
public void setTextSize(int size){
mPrefs.edit().putInt(Name.TEXT_SIZE, size).apply();
}
public String getMemoryUrl(){
return mPrefs.getString(Name.URL_MEMORY, "");
}
public void setMemoryUrl(String url){
mPrefs.edit().putString(Name.URL_MEMORY, url).apply();
}
public boolean getUseWideViewportEnabled(){
return mPrefs.getBoolean(Name.USE_WIDE_VIEWPORT, true);
}
public void setUseWideViewportEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.USE_WIDE_VIEWPORT, enable).apply();
}
public int getUserAgentChoice(){
return mPrefs.getInt(Name.USER_AGENT, 1);
}
public void setUserAgentChoice(int choice){
mPrefs.edit().putInt(Name.USER_AGENT, choice).apply();
}
public String getUserAgentString(String def){
return mPrefs.getString(Name.USER_AGENT_STRING, def);
}
public void setUserAgentString(String agent){
mPrefs.edit().putString(Name.USER_AGENT_STRING, agent).apply();
}
public boolean getGoogleSearchSuggestionsEnabled(){
return mPrefs.getBoolean(Name.GOOGLE_SEARCH_SUGGESTIONS, true);
}
public void setGoogleSearchSuggestionsEnabled(boolean enabled){
mPrefs.edit().putBoolean(Name.GOOGLE_SEARCH_SUGGESTIONS, enabled).apply();
}
public boolean getClearHistoryExitEnabled(){
return mPrefs.getBoolean(Name.CLEAR_HISTORY_EXIT, false);
}
public void setClearHistoryExitEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.CLEAR_HISTORY_EXIT, enable).apply();
}
public boolean getClearCookiesExitEnabled(){
return mPrefs.getBoolean(Name.CLEAR_COOKIES_EXIT, false);
}
public void setClearCookiesExitEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.CLEAR_COOKIES_EXIT, enable).apply();
}
public String getSavedUrl(){
return mPrefs.getString(Name.SAVE_URL, null);
}
public void setSavedUrl(String url){
mPrefs.edit().putString(Name.SAVE_URL, url).apply();
}
public int getRenderingMode(){
return mPrefs.getInt(Name.RENDERING_MODE, 0);
}
public void setRenderingMode(int mode){
mPrefs.edit().putInt(Name.RENDERING_MODE, mode).apply();
}
public boolean getSyncHistoryEnabled(){
return mPrefs.getBoolean(Name.SYNC_HISTORY, true);
}
public void setSyncHistoryEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.SYNC_HISTORY, enable).apply();
}
public boolean getBlockThirdPartyCookiesEnabled(){
return mPrefs.getBoolean(Name.BLOCK_THIRD_PARTY, false);
}
public void setBlockThirdPartyCookiesEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.BLOCK_THIRD_PARTY, enable).apply();
}
public boolean getColorModeEnabled(){
return mPrefs.getBoolean(Name.ENABLE_COLOR_MODE, true);
}
public void setColorModeEnabled(boolean enable){
mPrefs.edit().putBoolean(Name.ENABLE_COLOR_MODE, enable).apply();
}
public int getUrlBoxContentChoice(){
return mPrefs.getInt(Name.URL_BOX_CONTENTS, 0);
}
public void setUrlBoxContentChoice(int choice){
mPrefs.edit().putInt(Name.URL_BOX_CONTENTS, choice).apply();
}
public boolean getUseProxy(){
return mPrefs.getBoolean(Name.USE_PROXY, false);
}
public void setUseProxy(boolean enable){
mPrefs.edit().putBoolean(Name.USE_PROXY, enable).apply();
}
public String getProxyHost(){
return mPrefs.getString(Name.USE_PROXY_HOST, "localhost");
}
public int getProxyPort(){
return mPrefs.getInt(Name.USE_PROXY_PORT, 8118);
}
public boolean getCheckedForTor(){
return mPrefs.getBoolean(Name.INITIAL_CHECK_FOR_TOR, false);
}
public void setCheckedForTor(boolean check){
mPrefs.edit().putBoolean(Name.INITIAL_CHECK_FOR_TOR, check).apply();
}
private class Name {
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
public static final String BLOCK_ADS = "AdBlock";
public static final String BLOCK_IMAGES = "blockimages";
public static final String CLEAR_CACHE_EXIT = "cache";
public static final String COOKIES = "cookies";
public static final String DOWNLOAD_DIRECTORY = "download";
public static final String FULL_SCREEN = "fullscreen";
public static final String HIDE_STATUS_BAR = "hidestatus";
public static final String HOMEPAGE = "home";
public static final String INCOGNITO_COOKIES = "incognitocookies";
public static final String JAVASCRIPT = "java";
public static final String LOCATION = "location";
public static final String OVERVIEW_MODE = "overviewmode";
public static final String POPUPS = "newwindows";
public static final String RESTORE_LOST_TABS = "restoreclosed";
public static final String SAVE_PASSWORDS = "passwords";
public static final String SEARCH = "search";
public static final String SEARCH_URL = "searchurl";
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
public static final String TEXT_REFLOW = "textreflow";
public static final String TEXT_SIZE = "textsize";
public static final String URL_MEMORY = "memory";
public static final String USE_WIDE_VIEWPORT = "wideviewport";
public static final String USER_AGENT = "agentchoose";
public static final String USER_AGENT_STRING = "userAgentString";
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
public static final String SAVE_URL = "saveUrl";
public static final String RENDERING_MODE = "renderMode";
public static final String SYNC_HISTORY = "syncHistory";
public static final String BLOCK_THIRD_PARTY = "thirdParty";
public static final String ENABLE_COLOR_MODE = "colorMode";
public static final String URL_BOX_CONTENTS = "urlContent";
public static final String USE_PROXY = "useProxy";
public static final String USE_PROXY_HOST = "useProxyHost";
public static final String USE_PROXY_PORT = "useProxyPort";
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
}
}

View File

@ -50,6 +50,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private boolean mUseGoogle = true; private boolean mUseGoogle = true;
private boolean mIsExecuting = false; private boolean mIsExecuting = false;
private boolean mDarkTheme; private boolean mDarkTheme;
private boolean mIncognito;
private BookmarkManager mBookmarkManager; private BookmarkManager mBookmarkManager;
private static final String ENCODING = "ISO-8859-1"; private static final String ENCODING = "ISO-8859-1";
private static final long INTERVAL_DAY = 86400000; private static final long INTERVAL_DAY = 86400000;
@ -58,20 +59,21 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private Theme mTheme; private Theme mTheme;
private SearchFilter mFilter; private SearchFilter mFilter;
public SearchAdapter(Context context, boolean dark) { public SearchAdapter(Context context, boolean dark, boolean incognito) {
mDatabaseHandler = HistoryDatabase.getInstance(context); mDatabaseHandler = HistoryDatabase.getInstance(context.getApplicationContext());
mTheme = context.getTheme(); mTheme = context.getTheme();
mFilteredList = new ArrayList<HistoryItem>(); mFilteredList = new ArrayList<HistoryItem>();
mHistory = new ArrayList<HistoryItem>(); mHistory = new ArrayList<HistoryItem>();
mBookmarks = new ArrayList<HistoryItem>(); mBookmarks = new ArrayList<HistoryItem>();
mSuggestions = new ArrayList<HistoryItem>(); mSuggestions = new ArrayList<HistoryItem>();
mBookmarkManager = new BookmarkManager(context); mBookmarkManager = BookmarkManager.getInstance(context.getApplicationContext());
mAllBookmarks = mBookmarkManager.getBookmarks(true); mAllBookmarks = mBookmarkManager.getBookmarks(true);
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mContext = context; mContext = context;
mSearchSubtitle = mContext.getString(R.string.suggestion); mSearchSubtitle = mContext.getString(R.string.suggestion);
mDarkTheme = dark; mDarkTheme = dark || incognito;
mIncognito = incognito;
Thread delete = new Thread(new Runnable() { Thread delete = new Thread(new Runnable() {
@Override @Override
@ -227,7 +229,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
return results; return results;
} }
String query = constraint.toString().toLowerCase(Locale.getDefault()); String query = constraint.toString().toLowerCase(Locale.getDefault());
if (mUseGoogle && !mDarkTheme && !mIsExecuting) { if (mUseGoogle && !mIncognito && !mIsExecuting) {
new RetrieveSearchSuggestions().execute(query); new RetrieveSearchSuggestions().execute(query);
} }
@ -248,7 +250,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
} }
if (mDatabaseHandler == null) { if (mDatabaseHandler == null) {
mDatabaseHandler = HistoryDatabase.getInstance(mContext); mDatabaseHandler = HistoryDatabase.getInstance(mContext.getApplicationContext());
} }
mHistory = mDatabaseHandler.findItemsContaining(constraint.toString()); mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
@ -405,7 +407,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
int maxBookmarks = (suggestionsSize + historySize < 3) ? (5 - suggestionsSize - historySize) int maxBookmarks = (suggestionsSize + historySize < 3) ? (5 - suggestionsSize - historySize)
: 2; : 2;
if (!mUseGoogle || mDarkTheme) { if (!mUseGoogle || mIncognito) {
maxHistory++; maxHistory++;
maxBookmarks++; maxBookmarks++;
} }