From 4822996da1ed2ee0975ca0c55fc857b450ebde71 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Fri, 17 Apr 2015 08:46:16 -0400 Subject: [PATCH] Fixed bug in dark mode where search suggestions wouldn't show up. Sped up app startup by using singleton in BookmarkManager. --- src/acr/browser/lightning/AdBlock.java | 10 +- .../browser/lightning/BookmarkActivity.java | 2 +- .../browser/lightning/BookmarkManager.java | 10 +- .../browser/lightning/BrowserActivity.java | 36 +- src/acr/browser/lightning/HistoryPage.java | 2 +- src/acr/browser/lightning/LightningView.java | 2 +- src/acr/browser/lightning/Preferences.java | 360 ++++++++++++++++++ src/acr/browser/lightning/SearchAdapter.java | 16 +- 8 files changed, 406 insertions(+), 32 deletions(-) create mode 100644 src/acr/browser/lightning/Preferences.java diff --git a/src/acr/browser/lightning/AdBlock.java b/src/acr/browser/lightning/AdBlock.java index c0fe833..2417b1e 100644 --- a/src/acr/browser/lightning/AdBlock.java +++ b/src/acr/browser/lightning/AdBlock.java @@ -22,8 +22,16 @@ public class AdBlock { private SharedPreferences mPreferences; private boolean mBlockAds; 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()) { loadBlockedDomainsList(context); } diff --git a/src/acr/browser/lightning/BookmarkActivity.java b/src/acr/browser/lightning/BookmarkActivity.java index 339daa9..8e71004 100644 --- a/src/acr/browser/lightning/BookmarkActivity.java +++ b/src/acr/browser/lightning/BookmarkActivity.java @@ -45,7 +45,7 @@ public class BookmarkActivity extends ThemableSettingsActivity implements OnClic TextView importBookmarks = (TextView) findViewById(R.id.isImportBrowserAvailable); - mBookmarkManager = new BookmarkManager(this); + mBookmarkManager = BookmarkManager.getInstance(getApplicationContext()); mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); diff --git a/src/acr/browser/lightning/BookmarkManager.java b/src/acr/browser/lightning/BookmarkManager.java index 6bba8dc..af1cfb9 100644 --- a/src/acr/browser/lightning/BookmarkManager.java +++ b/src/acr/browser/lightning/BookmarkManager.java @@ -34,8 +34,16 @@ public class BookmarkManager { private static final String FILE_BOOKMARKS = "bookmarks.dat"; private static SortedMap mBookmarkMap = new TreeMap( 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; mBookmarkMap = getBookmarkUrls(); } diff --git a/src/acr/browser/lightning/BrowserActivity.java b/src/acr/browser/lightning/BrowserActivity.java index f23bb95..6050073 100644 --- a/src/acr/browser/lightning/BrowserActivity.java +++ b/src/acr/browser/lightning/BrowserActivity.java @@ -18,7 +18,6 @@ import android.database.sqlite.SQLiteException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; @@ -139,13 +138,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll } else { mWebViews = new ArrayList(); } - mBookmarkManager = new BookmarkManager(this); - if (!mPreferences.getBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, false)) { - List old = Utils.getOldBookmarks(this); - mBookmarkManager.addBookmarkList(old); - mPreferences.edit().putBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, true) - .apply(); - } + mActivity = this; mClickHandler = new ClickHandler(this); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); @@ -193,13 +186,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); 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.setOnItemLongClickListener(new BookmarkItemLongClickListener()); - mHistoryDatabase = HistoryDatabase.getInstance(this); + mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext()); // set display options of the ActionBar mActionBar.setDisplayShowTitleEnabled(false); @@ -262,6 +252,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @Override 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); } @@ -611,6 +606,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll int count = 0; for (int n = 0; n < array.length; n++) { if (array[n].length() > 0) { + if (url != null && url.compareTo(array[n]) == 0) { + url = null; + } newTab(array[n], true); count++; } @@ -1365,7 +1363,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll mCurrentView.resumeTimers(); mCurrentView.onResume(); - mHistoryDatabase = HistoryDatabase.getInstance(this); + mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext()); mBookmarkList = mBookmarkManager.getBookmarks(true); notifyBookmarkDataSetChanged(); } @@ -1509,14 +1507,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll ImageView exit; } } - - private class CloseTabListener implements OnClickListener{ + + private class CloseTabListener implements OnClickListener { @Override public void onClick(View v) { deleteTab((int) v.getTag()); } - + } private void changeToolbarBackground(Bitmap favicon) { @@ -1592,10 +1590,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll public class BookmarkViewAdapter extends ArrayAdapter { Context context; - - int layoutResourceId; - List data = null; + int layoutResourceId; public BookmarkViewAdapter(Context context, int layoutResourceId, List data) { super(context, layoutResourceId, data); @@ -1889,7 +1885,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll }); getUrl.setSelectAllOnFocus(true); - mSearchAdapter = new SearchAdapter(mContext, isIncognito() || mDarkTheme); + mSearchAdapter = new SearchAdapter(mContext, mDarkTheme, isIncognito()); getUrl.setAdapter(mSearchAdapter); } diff --git a/src/acr/browser/lightning/HistoryPage.java b/src/acr/browser/lightning/HistoryPage.java index e5d82ab..a087e52 100644 --- a/src/acr/browser/lightning/HistoryPage.java +++ b/src/acr/browser/lightning/HistoryPage.java @@ -53,7 +53,7 @@ public class HistoryPage { } private static List getWebHistory(Context context) { - HistoryDatabase databaseHandler = HistoryDatabase.getInstance(context); + HistoryDatabase databaseHandler = HistoryDatabase.getInstance(context.getApplicationContext()); return databaseHandler.getLastHundredItems(); } } diff --git a/src/acr/browser/lightning/LightningView.java b/src/acr/browser/lightning/LightningView.java index d6f254d..9d56c8e 100644 --- a/src/acr/browser/lightning/LightningView.java +++ b/src/acr/browser/lightning/LightningView.java @@ -86,7 +86,7 @@ public class LightningView { mActivity = activity; mWebView = new WebView(activity); mTitle = new Title(activity, darkTheme); - mAdBlock = new AdBlock(activity); + mAdBlock = AdBlock.getInstance(activity.getApplicationContext()); if (darkTheme) { mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(), diff --git a/src/acr/browser/lightning/Preferences.java b/src/acr/browser/lightning/Preferences.java new file mode 100644 index 0000000..e47330c --- /dev/null +++ b/src/acr/browser/lightning/Preferences.java @@ -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"; + } +} diff --git a/src/acr/browser/lightning/SearchAdapter.java b/src/acr/browser/lightning/SearchAdapter.java index b7b32dc..72f341a 100644 --- a/src/acr/browser/lightning/SearchAdapter.java +++ b/src/acr/browser/lightning/SearchAdapter.java @@ -50,6 +50,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { private boolean mUseGoogle = true; private boolean mIsExecuting = false; private boolean mDarkTheme; + private boolean mIncognito; private BookmarkManager mBookmarkManager; private static final String ENCODING = "ISO-8859-1"; private static final long INTERVAL_DAY = 86400000; @@ -58,20 +59,21 @@ public class SearchAdapter extends BaseAdapter implements Filterable { private Theme mTheme; private SearchFilter mFilter; - public SearchAdapter(Context context, boolean dark) { - mDatabaseHandler = HistoryDatabase.getInstance(context); + public SearchAdapter(Context context, boolean dark, boolean incognito) { + mDatabaseHandler = HistoryDatabase.getInstance(context.getApplicationContext()); mTheme = context.getTheme(); mFilteredList = new ArrayList(); mHistory = new ArrayList(); mBookmarks = new ArrayList(); mSuggestions = new ArrayList(); - mBookmarkManager = new BookmarkManager(context); + mBookmarkManager = BookmarkManager.getInstance(context.getApplicationContext()); mAllBookmarks = mBookmarkManager.getBookmarks(true); mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); mContext = context; mSearchSubtitle = mContext.getString(R.string.suggestion); - mDarkTheme = dark; + mDarkTheme = dark || incognito; + mIncognito = incognito; Thread delete = new Thread(new Runnable() { @Override @@ -227,7 +229,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { return results; } String query = constraint.toString().toLowerCase(Locale.getDefault()); - if (mUseGoogle && !mDarkTheme && !mIsExecuting) { + if (mUseGoogle && !mIncognito && !mIsExecuting) { new RetrieveSearchSuggestions().execute(query); } @@ -248,7 +250,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { } if (mDatabaseHandler == null) { - mDatabaseHandler = HistoryDatabase.getInstance(mContext); + mDatabaseHandler = HistoryDatabase.getInstance(mContext.getApplicationContext()); } mHistory = mDatabaseHandler.findItemsContaining(constraint.toString()); @@ -405,7 +407,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { int maxBookmarks = (suggestionsSize + historySize < 3) ? (5 - suggestionsSize - historySize) : 2; - if (!mUseGoogle || mDarkTheme) { + if (!mUseGoogle || mIncognito) { maxHistory++; maxBookmarks++; }