anthony restaino
8 years ago
16 changed files with 305 additions and 135 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
package acr.browser.lightning.search; |
||||
|
||||
import android.support.annotation.NonNull; |
||||
|
||||
import javax.inject.Inject; |
||||
|
||||
import acr.browser.lightning.app.BrowserApp; |
||||
import acr.browser.lightning.preference.PreferenceManager; |
||||
import acr.browser.lightning.search.engine.AskSearch; |
||||
import acr.browser.lightning.search.engine.BaiduSearch; |
||||
import acr.browser.lightning.search.engine.BaseSearchEngine; |
||||
import acr.browser.lightning.search.engine.BingSearch; |
||||
import acr.browser.lightning.search.engine.CustomSearch; |
||||
import acr.browser.lightning.search.engine.DuckLiteSearch; |
||||
import acr.browser.lightning.search.engine.DuckSearch; |
||||
import acr.browser.lightning.search.engine.GoogleSearch; |
||||
import acr.browser.lightning.search.engine.StartPageMobileSearch; |
||||
import acr.browser.lightning.search.engine.StartPageSearch; |
||||
import acr.browser.lightning.search.engine.YahooSearch; |
||||
import acr.browser.lightning.search.engine.YandexSearch; |
||||
|
||||
/** |
||||
* The model that provides the search engine based |
||||
* on the user's preference. |
||||
*/ |
||||
public class SearchEngineProvider { |
||||
|
||||
@Inject PreferenceManager mPreferenceManager; |
||||
|
||||
@Inject |
||||
public SearchEngineProvider() { |
||||
BrowserApp.getAppComponent().inject(this); |
||||
} |
||||
|
||||
@NonNull |
||||
public BaseSearchEngine getCurrentSearchEngine() { |
||||
switch (mPreferenceManager.getSearchChoice()) { |
||||
case 0: |
||||
return new CustomSearch(mPreferenceManager.getSearchUrl()); |
||||
case 1: |
||||
default: |
||||
return new GoogleSearch(); |
||||
case 2: |
||||
return new AskSearch(); |
||||
case 3: |
||||
return new BingSearch(); |
||||
case 4: |
||||
return new YahooSearch(); |
||||
case 5: |
||||
return new StartPageSearch(); |
||||
case 6: |
||||
return new StartPageMobileSearch(); |
||||
case 7: |
||||
return new DuckSearch(); |
||||
case 8: |
||||
return new DuckLiteSearch(); |
||||
case 9: |
||||
return new BaiduSearch(); |
||||
case 10: |
||||
return new YandexSearch(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Ask search engine. |
||||
*/ |
||||
public class AskSearch extends BaseSearchEngine { |
||||
|
||||
public AskSearch() { |
||||
super("file:///android_asset/ask.png", Constants.ASK_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Baidu search engine. |
||||
* <p> |
||||
* See http://www.baidu.com/img/bdlogo.gif for the icon.
|
||||
*/ |
||||
public class BaiduSearch extends BaseSearchEngine { |
||||
|
||||
public BaiduSearch() { |
||||
super("file:///android_asset/baidu.png", Constants.BAIDU_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import android.support.annotation.NonNull; |
||||
|
||||
import acr.browser.lightning.utils.Preconditions; |
||||
|
||||
/** |
||||
* A class representative of a search engine. |
||||
*/ |
||||
public class BaseSearchEngine { |
||||
|
||||
@NonNull private final String mIconUrl; |
||||
@NonNull private final String mQueryUrl; |
||||
|
||||
public BaseSearchEngine(@NonNull String iconUrl, @NonNull String queryUrl) { |
||||
Preconditions.checkNonNull(iconUrl); |
||||
Preconditions.checkNonNull(queryUrl); |
||||
|
||||
mIconUrl = iconUrl; |
||||
mQueryUrl = queryUrl; |
||||
} |
||||
|
||||
@NonNull |
||||
public final String getIconUrl() { |
||||
return mIconUrl; |
||||
} |
||||
|
||||
@NonNull |
||||
public final String getQueryUrl() { |
||||
return mQueryUrl; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Bing search engine. |
||||
* <p> |
||||
* See http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png
|
||||
* for the icon. |
||||
*/ |
||||
public class BingSearch extends BaseSearchEngine { |
||||
|
||||
public BingSearch() { |
||||
super("file:///android_asset/bing.png", Constants.BING_SEARCH); |
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import android.support.annotation.NonNull; |
||||
|
||||
/** |
||||
* A custom search engine. |
||||
*/ |
||||
public class CustomSearch extends BaseSearchEngine { |
||||
|
||||
public CustomSearch(@NonNull String queryUrl) { |
||||
super("file:///android_asset/lightning.png", queryUrl); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The DuckDuckGo Lite search engine. |
||||
* <p> |
||||
* See https://duckduckgo.com/assets/logo_homepage.normal.v101.png for the icon.
|
||||
*/ |
||||
public class DuckLiteSearch extends BaseSearchEngine { |
||||
|
||||
public DuckLiteSearch() { |
||||
super("file:///android_asset/duckduckgo.png", Constants.DUCK_LITE_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The DuckDuckGo search engine. |
||||
* <p> |
||||
* See https://duckduckgo.com/assets/logo_homepage.normal.v101.png for the icon.
|
||||
*/ |
||||
public class DuckSearch extends BaseSearchEngine { |
||||
|
||||
public DuckSearch() { |
||||
super("file:///android_asset/duckduckgo.png", Constants.DUCK_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Google search engine. |
||||
* <p> |
||||
* See https://www.google.com/images/srpr/logo11w.png for the icon.
|
||||
*/ |
||||
public class GoogleSearch extends BaseSearchEngine { |
||||
|
||||
public GoogleSearch() { |
||||
super("file:///android_asset/google.png", Constants.GOOGLE_SEARCH); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The StartPage mobile search engine. |
||||
*/ |
||||
public class StartPageMobileSearch extends BaseSearchEngine { |
||||
|
||||
public StartPageMobileSearch() { |
||||
super("file:///android_asset/startpage.png", Constants.STARTPAGE_MOBILE_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The StartPage search engine. |
||||
*/ |
||||
public class StartPageSearch extends BaseSearchEngine { |
||||
|
||||
public StartPageSearch() { |
||||
super("file:///android_asset/startpage.png", Constants.STARTPAGE_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Yahoo search engine. |
||||
* <p> |
||||
* See http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png
|
||||
* for the icon. |
||||
*/ |
||||
public class YahooSearch extends BaseSearchEngine { |
||||
|
||||
public YahooSearch() { |
||||
super("file:///android_asset/yahoo.png", Constants.YAHOO_SEARCH); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package acr.browser.lightning.search.engine; |
||||
|
||||
import acr.browser.lightning.constant.Constants; |
||||
|
||||
/** |
||||
* The Yandex search engine. |
||||
* <p> |
||||
* See http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png
|
||||
* for the icon. |
||||
*/ |
||||
public class YandexSearch extends BaseSearchEngine { |
||||
|
||||
public YandexSearch() { |
||||
super("file:///android_asset/yandex.png", Constants.YANDEX_SEARCH); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue