Before Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 18 KiB |
@ -1,95 +0,0 @@ |
|||||||
package acr.browser.lightning.di; |
|
||||||
|
|
||||||
import javax.inject.Singleton; |
|
||||||
|
|
||||||
import acr.browser.lightning.browser.activity.BrowserActivity; |
|
||||||
import acr.browser.lightning.reading.activity.ReadingActivity; |
|
||||||
import acr.browser.lightning.browser.TabsManager; |
|
||||||
import acr.browser.lightning.browser.activity.ThemableBrowserActivity; |
|
||||||
import acr.browser.lightning.settings.activity.ThemableSettingsActivity; |
|
||||||
import acr.browser.lightning.BrowserApp; |
|
||||||
import acr.browser.lightning.browser.BrowserPresenter; |
|
||||||
import acr.browser.lightning.browser.SearchBoxModel; |
|
||||||
import acr.browser.lightning.constant.BookmarkPage; |
|
||||||
import acr.browser.lightning.constant.DownloadsPage; |
|
||||||
import acr.browser.lightning.constant.HistoryPage; |
|
||||||
import acr.browser.lightning.constant.StartPage; |
|
||||||
import acr.browser.lightning.dialog.LightningDialogBuilder; |
|
||||||
import acr.browser.lightning.download.DownloadHandler; |
|
||||||
import acr.browser.lightning.download.LightningDownloadListener; |
|
||||||
import acr.browser.lightning.settings.fragment.BookmarkSettingsFragment; |
|
||||||
import acr.browser.lightning.browser.fragment.BookmarksFragment; |
|
||||||
import acr.browser.lightning.settings.fragment.DebugSettingsFragment; |
|
||||||
import acr.browser.lightning.settings.fragment.GeneralSettingsFragment; |
|
||||||
import acr.browser.lightning.settings.fragment.LightningPreferenceFragment; |
|
||||||
import acr.browser.lightning.settings.fragment.PrivacySettingsFragment; |
|
||||||
import acr.browser.lightning.browser.fragment.TabsFragment; |
|
||||||
import acr.browser.lightning.search.SearchEngineProvider; |
|
||||||
import acr.browser.lightning.search.SuggestionsAdapter; |
|
||||||
import acr.browser.lightning.utils.ProxyUtils; |
|
||||||
import acr.browser.lightning.view.LightningChromeClient; |
|
||||||
import acr.browser.lightning.view.LightningView; |
|
||||||
import acr.browser.lightning.view.LightningWebClient; |
|
||||||
import dagger.Component; |
|
||||||
|
|
||||||
@Singleton |
|
||||||
@Component(modules = {AppModule.class}) |
|
||||||
public interface AppComponent { |
|
||||||
|
|
||||||
void inject(BrowserActivity activity); |
|
||||||
|
|
||||||
void inject(BookmarksFragment fragment); |
|
||||||
|
|
||||||
void inject(BookmarkSettingsFragment fragment); |
|
||||||
|
|
||||||
void inject(LightningDialogBuilder builder); |
|
||||||
|
|
||||||
void inject(TabsFragment fragment); |
|
||||||
|
|
||||||
void inject(LightningView lightningView); |
|
||||||
|
|
||||||
void inject(ThemableBrowserActivity activity); |
|
||||||
|
|
||||||
void inject(LightningPreferenceFragment fragment); |
|
||||||
|
|
||||||
void inject(BrowserApp app); |
|
||||||
|
|
||||||
void inject(ProxyUtils proxyUtils); |
|
||||||
|
|
||||||
void inject(ReadingActivity activity); |
|
||||||
|
|
||||||
void inject(LightningWebClient webClient); |
|
||||||
|
|
||||||
void inject(ThemableSettingsActivity activity); |
|
||||||
|
|
||||||
void inject(LightningDownloadListener listener); |
|
||||||
|
|
||||||
void inject(PrivacySettingsFragment fragment); |
|
||||||
|
|
||||||
void inject(StartPage startPage); |
|
||||||
|
|
||||||
void inject(HistoryPage historyPage); |
|
||||||
|
|
||||||
void inject(BookmarkPage bookmarkPage); |
|
||||||
|
|
||||||
void inject(DownloadsPage downloadsPage); |
|
||||||
|
|
||||||
void inject(BrowserPresenter presenter); |
|
||||||
|
|
||||||
void inject(TabsManager manager); |
|
||||||
|
|
||||||
void inject(DebugSettingsFragment fragment); |
|
||||||
|
|
||||||
void inject(SuggestionsAdapter suggestionsAdapter); |
|
||||||
|
|
||||||
void inject(LightningChromeClient chromeClient); |
|
||||||
|
|
||||||
void inject(DownloadHandler downloadHandler); |
|
||||||
|
|
||||||
void inject(SearchBoxModel searchBoxModel); |
|
||||||
|
|
||||||
void inject(SearchEngineProvider searchEngineProvider); |
|
||||||
|
|
||||||
void inject(GeneralSettingsFragment generalSettingsFragment); |
|
||||||
|
|
||||||
} |
|
@ -1,112 +0,0 @@ |
|||||||
package acr.browser.lightning.search; |
|
||||||
|
|
||||||
import android.support.annotation.NonNull; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
import javax.inject.Inject; |
|
||||||
|
|
||||||
import acr.browser.lightning.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(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public int mapSearchEngineToPreferenceIndex(@NonNull BaseSearchEngine searchEngine) { |
|
||||||
if (searchEngine instanceof CustomSearch) { |
|
||||||
return 0; |
|
||||||
} else if (searchEngine instanceof GoogleSearch) { |
|
||||||
return 1; |
|
||||||
} else if (searchEngine instanceof AskSearch) { |
|
||||||
return 2; |
|
||||||
} else if (searchEngine instanceof BingSearch) { |
|
||||||
return 3; |
|
||||||
} else if (searchEngine instanceof YahooSearch) { |
|
||||||
return 4; |
|
||||||
} else if (searchEngine instanceof StartPageSearch) { |
|
||||||
return 5; |
|
||||||
} else if (searchEngine instanceof StartPageMobileSearch) { |
|
||||||
return 6; |
|
||||||
} else if (searchEngine instanceof DuckSearch) { |
|
||||||
return 7; |
|
||||||
} else if (searchEngine instanceof DuckLiteSearch) { |
|
||||||
return 8; |
|
||||||
} else if (searchEngine instanceof BaiduSearch) { |
|
||||||
return 9; |
|
||||||
} else if (searchEngine instanceof YandexSearch) { |
|
||||||
return 10; |
|
||||||
} else { |
|
||||||
throw new UnsupportedOperationException("Unknown search engine provided: " + searchEngine.getClass()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@NonNull |
|
||||||
public List<BaseSearchEngine> getAllSearchEngines() { |
|
||||||
return new ArrayList<BaseSearchEngine>(11) {{ |
|
||||||
add(new CustomSearch(mPreferenceManager.getSearchUrl())); |
|
||||||
add(new GoogleSearch()); |
|
||||||
add(new AskSearch()); |
|
||||||
add(new BingSearch()); |
|
||||||
add(new YahooSearch()); |
|
||||||
add(new StartPageSearch()); |
|
||||||
add(new StartPageMobileSearch()); |
|
||||||
add(new DuckSearch()); |
|
||||||
add(new DuckLiteSearch()); |
|
||||||
add(new BaiduSearch()); |
|
||||||
add(new YandexSearch()); |
|
||||||
}}; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,13 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Ask search engine. |
|
||||||
*/ |
|
||||||
class AskSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/ask.png", |
|
||||||
Constants.ASK_SEARCH, |
|
||||||
R.string.search_engine_ask |
|
||||||
) |
|
@ -1,15 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Baidu search engine. |
|
||||||
* |
|
||||||
* See http://www.baidu.com/img/bdlogo.gif for the icon. |
|
||||||
*/ |
|
||||||
class BaiduSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/baidu.png", |
|
||||||
Constants.BAIDU_SEARCH, |
|
||||||
R.string.search_engine_baidu |
|
||||||
) |
|
@ -1,16 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Bing search engine. |
|
||||||
* |
|
||||||
* 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. |
|
||||||
*/ |
|
||||||
class BingSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/bing.png", |
|
||||||
Constants.BING_SEARCH, |
|
||||||
R.string.search_engine_bing |
|
||||||
) |
|
@ -1,15 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Google search engine. |
|
||||||
* |
|
||||||
* See https://www.google.com/images/srpr/logo11w.png for the icon. |
|
||||||
*/ |
|
||||||
class GoogleSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/google.png", |
|
||||||
Constants.GOOGLE_SEARCH, |
|
||||||
R.string.search_engine_google |
|
||||||
) |
|
@ -1,13 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The StartPage mobile search engine. |
|
||||||
*/ |
|
||||||
class StartPageMobileSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/startpage.png", |
|
||||||
Constants.STARTPAGE_MOBILE_SEARCH, |
|
||||||
R.string.search_engine_startpage_mobile |
|
||||||
) |
|
@ -1,13 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The StartPage search engine. |
|
||||||
*/ |
|
||||||
class StartPageSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/startpage.png", |
|
||||||
Constants.STARTPAGE_SEARCH, |
|
||||||
R.string.search_engine_startpage |
|
||||||
) |
|
@ -1,16 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Yahoo search engine. |
|
||||||
* |
|
||||||
* See http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png |
|
||||||
* for the icon. |
|
||||||
*/ |
|
||||||
class YahooSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/yahoo.png", |
|
||||||
Constants.YAHOO_SEARCH, |
|
||||||
R.string.search_engine_yahoo |
|
||||||
) |
|
@ -1,16 +0,0 @@ |
|||||||
package acr.browser.lightning.search.engine |
|
||||||
|
|
||||||
import acr.browser.lightning.R |
|
||||||
import acr.browser.lightning.constant.Constants |
|
||||||
|
|
||||||
/** |
|
||||||
* The Yandex search engine. |
|
||||||
* |
|
||||||
* See http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png |
|
||||||
* for the icon. |
|
||||||
*/ |
|
||||||
class YandexSearch : BaseSearchEngine( |
|
||||||
"file:///android_asset/yandex.png", |
|
||||||
Constants.YANDEX_SEARCH, |
|
||||||
R.string.search_engine_yandex |
|
||||||
) |
|
@ -1,68 +0,0 @@ |
|||||||
package acr.browser.lightning.search.suggestions; |
|
||||||
|
|
||||||
import android.app.Application; |
|
||||||
import android.support.annotation.NonNull; |
|
||||||
import android.support.annotation.Nullable; |
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser; |
|
||||||
import org.xmlpull.v1.XmlPullParserException; |
|
||||||
import org.xmlpull.v1.XmlPullParserFactory; |
|
||||||
|
|
||||||
import java.io.BufferedInputStream; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
import acr.browser.lightning.R; |
|
||||||
import acr.browser.lightning.database.HistoryItem; |
|
||||||
|
|
||||||
/** |
|
||||||
* Search suggestions provider for Google search engine. |
|
||||||
*/ |
|
||||||
public class GoogleSuggestionsModel extends BaseSuggestionsModel { |
|
||||||
|
|
||||||
@NonNull private static final String ENCODING = "UTF-8"; |
|
||||||
@Nullable private static XmlPullParser sXpp; |
|
||||||
@NonNull private final String mSearchSubtitle; |
|
||||||
|
|
||||||
public GoogleSuggestionsModel(@NonNull Application application) { |
|
||||||
super(application, ENCODING); |
|
||||||
mSearchSubtitle = application.getString(R.string.suggestion); |
|
||||||
} |
|
||||||
|
|
||||||
@NonNull |
|
||||||
protected String createQueryUrl(@NonNull String query, @NonNull String language) { |
|
||||||
return "https://suggestqueries.google.com/complete/search?output=toolbar&hl=" |
|
||||||
+ language + "&q=" + query; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception { |
|
||||||
BufferedInputStream bufferedInput = new BufferedInputStream(inputStream); |
|
||||||
XmlPullParser parser = getParser(); |
|
||||||
parser.setInput(bufferedInput, ENCODING); |
|
||||||
int eventType = parser.getEventType(); |
|
||||||
int counter = 0; |
|
||||||
while (eventType != XmlPullParser.END_DOCUMENT) { |
|
||||||
if (eventType == XmlPullParser.START_TAG && "suggestion".equals(parser.getName())) { |
|
||||||
String suggestion = parser.getAttributeValue(null, "data"); |
|
||||||
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', |
|
||||||
suggestion, R.drawable.ic_search)); |
|
||||||
counter++; |
|
||||||
if (counter >= MAX_RESULTS) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
eventType = parser.next(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@NonNull |
|
||||||
private static synchronized XmlPullParser getParser() throws XmlPullParserException { |
|
||||||
if (sXpp == null) { |
|
||||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); |
|
||||||
factory.setNamespaceAware(true); |
|
||||||
sXpp = factory.newPullParser(); |
|
||||||
} |
|
||||||
return sXpp; |
|
||||||
} |
|
||||||
} |
|
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.animation; |
package org.purplei2p.lightning.animation; |
||||||
|
|
||||||
import android.support.annotation.DrawableRes; |
import android.support.annotation.DrawableRes; |
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
@ -1,8 +1,8 @@ |
|||||||
package acr.browser.lightning.browser; |
package org.purplei2p.lightning.browser; |
||||||
|
|
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
|
|
||||||
import acr.browser.lightning.database.HistoryItem; |
import org.purplei2p.lightning.database.HistoryItem; |
||||||
|
|
||||||
public interface BookmarksView { |
public interface BookmarksView { |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.browser; |
package org.purplei2p.lightning.browser; |
||||||
|
|
||||||
import android.content.DialogInterface; |
import android.content.DialogInterface; |
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.browser; |
package org.purplei2p.lightning.browser; |
||||||
|
|
||||||
public interface TabsView { |
public interface TabsView { |
||||||
|
|
@ -1,8 +1,8 @@ |
|||||||
package acr.browser.lightning.browser.bookmark; |
package org.purplei2p.lightning.browser.bookmark; |
||||||
|
|
||||||
import android.support.annotation.Nullable; |
import android.support.annotation.Nullable; |
||||||
|
|
||||||
import acr.browser.lightning.browser.BookmarksView; |
import org.purplei2p.lightning.browser.BookmarksView; |
||||||
|
|
||||||
/** |
/** |
||||||
* The UI model representing the current folder shown |
* The UI model representing the current folder shown |
@ -1,13 +1,13 @@ |
|||||||
/* |
/* |
||||||
* Copyright 2014 A.C.R. Development |
* Copyright 2014 A.C.R. Development |
||||||
*/ |
*/ |
||||||
package acr.browser.lightning.database; |
package org.purplei2p.lightning.database; |
||||||
|
|
||||||
import android.graphics.Bitmap; |
import android.graphics.Bitmap; |
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
import android.support.annotation.Nullable; |
import android.support.annotation.Nullable; |
||||||
|
|
||||||
import acr.browser.lightning.utils.Preconditions; |
import org.purplei2p.lightning.utils.Preconditions; |
||||||
|
|
||||||
public class HistoryItem implements Comparable<HistoryItem> { |
public class HistoryItem implements Comparable<HistoryItem> { |
||||||
|
|
@ -1,12 +1,12 @@ |
|||||||
/* |
/* |
||||||
* Copyright 2014 A.C.R. Development |
* Copyright 2014 A.C.R. Development |
||||||
*/ |
*/ |
||||||
package acr.browser.lightning.database.downloads; |
package org.purplei2p.lightning.database.downloads; |
||||||
|
|
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
import android.support.annotation.Nullable; |
import android.support.annotation.Nullable; |
||||||
|
|
||||||
import acr.browser.lightning.utils.Preconditions; |
import org.purplei2p.lightning.utils.Preconditions; |
||||||
|
|
||||||
public class DownloadItem implements Comparable<DownloadItem> { |
public class DownloadItem implements Comparable<DownloadItem> { |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.database.downloads; |
package org.purplei2p.lightning.database.downloads; |
||||||
|
|
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
import android.support.annotation.WorkerThread; |
import android.support.annotation.WorkerThread; |
@ -0,0 +1,95 @@ |
|||||||
|
package org.purplei2p.lightning.di; |
||||||
|
|
||||||
|
import javax.inject.Singleton; |
||||||
|
|
||||||
|
import org.purplei2p.lightning.browser.activity.BrowserActivity; |
||||||
|
import org.purplei2p.lightning.reading.activity.ReadingActivity; |
||||||
|
import org.purplei2p.lightning.browser.TabsManager; |
||||||
|
import org.purplei2p.lightning.browser.activity.ThemableBrowserActivity; |
||||||
|
import org.purplei2p.lightning.settings.activity.ThemableSettingsActivity; |
||||||
|
import org.purplei2p.lightning.BrowserApp; |
||||||
|
import org.purplei2p.lightning.browser.BrowserPresenter; |
||||||
|
import org.purplei2p.lightning.browser.SearchBoxModel; |
||||||
|
import org.purplei2p.lightning.constant.BookmarkPage; |
||||||
|
import org.purplei2p.lightning.constant.DownloadsPage; |
||||||
|
import org.purplei2p.lightning.constant.HistoryPage; |
||||||
|
import org.purplei2p.lightning.constant.StartPage; |
||||||
|
import org.purplei2p.lightning.dialog.LightningDialogBuilder; |
||||||
|
import org.purplei2p.lightning.download.DownloadHandler; |
||||||
|
import org.purplei2p.lightning.download.LightningDownloadListener; |
||||||
|
import org.purplei2p.lightning.settings.fragment.BookmarkSettingsFragment; |
||||||
|
import org.purplei2p.lightning.browser.fragment.BookmarksFragment; |
||||||
|
import org.purplei2p.lightning.settings.fragment.DebugSettingsFragment; |
||||||
|
import org.purplei2p.lightning.settings.fragment.GeneralSettingsFragment; |
||||||
|
import org.purplei2p.lightning.settings.fragment.LightningPreferenceFragment; |
||||||
|
import org.purplei2p.lightning.settings.fragment.PrivacySettingsFragment; |
||||||
|
import org.purplei2p.lightning.browser.fragment.TabsFragment; |
||||||
|
import org.purplei2p.lightning.search.SearchEngineProvider; |
||||||
|
import org.purplei2p.lightning.search.SuggestionsAdapter; |
||||||
|
import org.purplei2p.lightning.utils.ProxyUtils; |
||||||
|
import org.purplei2p.lightning.view.LightningChromeClient; |
||||||
|
import org.purplei2p.lightning.view.LightningView; |
||||||
|
import org.purplei2p.lightning.view.LightningWebClient; |
||||||
|
import dagger.Component; |
||||||
|
|
||||||
|
@Singleton |
||||||
|
@Component(modules = {AppModule.class}) |
||||||
|
public interface AppComponent { |
||||||
|
|
||||||
|
void inject(BrowserActivity activity); |
||||||
|
|
||||||
|
void inject(BookmarksFragment fragment); |
||||||
|
|
||||||
|
void inject(BookmarkSettingsFragment fragment); |
||||||
|
|
||||||
|
void inject(LightningDialogBuilder builder); |
||||||
|
|
||||||
|
void inject(TabsFragment fragment); |
||||||
|
|
||||||
|
void inject(LightningView lightningView); |
||||||
|
|
||||||
|
void inject(ThemableBrowserActivity activity); |
||||||
|
|
||||||
|
void inject(LightningPreferenceFragment fragment); |
||||||
|
|
||||||
|
void inject(BrowserApp app); |
||||||
|
|
||||||
|
void inject(ProxyUtils proxyUtils); |
||||||
|
|
||||||
|
void inject(ReadingActivity activity); |
||||||
|
|
||||||
|
void inject(LightningWebClient webClient); |
||||||
|
|
||||||
|
void inject(ThemableSettingsActivity activity); |
||||||
|
|
||||||
|
void inject(LightningDownloadListener listener); |
||||||
|
|
||||||
|
void inject(PrivacySettingsFragment fragment); |
||||||
|
|
||||||
|
void inject(StartPage startPage); |
||||||
|
|
||||||
|
void inject(HistoryPage historyPage); |
||||||
|
|
||||||
|
void inject(BookmarkPage bookmarkPage); |
||||||
|
|
||||||
|
void inject(DownloadsPage downloadsPage); |
||||||
|
|
||||||
|
void inject(BrowserPresenter presenter); |
||||||
|
|
||||||
|
void inject(TabsManager manager); |
||||||
|
|
||||||
|
void inject(DebugSettingsFragment fragment); |
||||||
|
|
||||||
|
void inject(SuggestionsAdapter suggestionsAdapter); |
||||||
|
|
||||||
|
void inject(LightningChromeClient chromeClient); |
||||||
|
|
||||||
|
void inject(DownloadHandler downloadHandler); |
||||||
|
|
||||||
|
void inject(SearchBoxModel searchBoxModel); |
||||||
|
|
||||||
|
void inject(SearchEngineProvider searchEngineProvider); |
||||||
|
|
||||||
|
void inject(GeneralSettingsFragment generalSettingsFragment); |
||||||
|
|
||||||
|
} |
@ -1,7 +1,7 @@ |
|||||||
/* |
/* |
||||||
* Copyright 2014 A.C.R. Development |
* Copyright 2014 A.C.R. Development |
||||||
*/ |
*/ |
||||||
package acr.browser.lightning.download; |
package org.purplei2p.lightning.download; |
||||||
|
|
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
import android.support.annotation.Nullable; |
import android.support.annotation.Nullable; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.favicon; |
package org.purplei2p.lightning.favicon; |
||||||
|
|
||||||
import android.net.Uri; |
import android.net.Uri; |
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.interpolator; |
package org.purplei2p.lightning.interpolator; |
||||||
|
|
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
import android.support.v4.view.animation.PathInterpolatorCompat; |
import android.support.v4.view.animation.PathInterpolatorCompat; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.reading; |
package org.purplei2p.lightning.reading; |
||||||
|
|
||||||
import java.util.ArrayList; |
import java.util.ArrayList; |
||||||
import java.util.Arrays; |
import java.util.Arrays; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.reading; |
package org.purplei2p.lightning.reading; |
||||||
|
|
||||||
import org.jsoup.nodes.Element; |
import org.jsoup.nodes.Element; |
||||||
|
|
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.reading; |
package org.purplei2p.lightning.reading; |
||||||
|
|
||||||
import org.jsoup.Jsoup; |
import org.jsoup.Jsoup; |
||||||
import org.jsoup.nodes.Element; |
import org.jsoup.nodes.Element; |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.receiver; |
package org.purplei2p.lightning.receiver; |
||||||
|
|
||||||
import android.content.BroadcastReceiver; |
import android.content.BroadcastReceiver; |
||||||
import android.content.Context; |
import android.content.Context; |
@ -0,0 +1,70 @@ |
|||||||
|
package org.purplei2p.lightning.search; |
||||||
|
|
||||||
|
import android.support.annotation.NonNull; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import javax.inject.Inject; |
||||||
|
|
||||||
|
import org.purplei2p.lightning.BrowserApp; |
||||||
|
import org.purplei2p.lightning.preference.PreferenceManager; |
||||||
|
import org.purplei2p.lightning.search.engine.BaseSearchEngine; |
||||||
|
import org.purplei2p.lightning.search.engine.CustomSearch; |
||||||
|
import org.purplei2p.lightning.search.engine.DuckLiteSearch; |
||||||
|
import org.purplei2p.lightning.search.engine.DuckSearch; |
||||||
|
import org.purplei2p.lightning.search.engine.LegworkSearch; |
||||||
|
|
||||||
|
/** |
||||||
|
* 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 LegworkSearch(); |
||||||
|
case 2: |
||||||
|
return new DuckSearch(); |
||||||
|
case 3: |
||||||
|
return new DuckLiteSearch(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int mapSearchEngineToPreferenceIndex(@NonNull BaseSearchEngine searchEngine) { |
||||||
|
if (searchEngine instanceof CustomSearch) { |
||||||
|
return 0; |
||||||
|
} else if (searchEngine instanceof LegworkSearch) { |
||||||
|
return 1; |
||||||
|
} else if (searchEngine instanceof DuckSearch) { |
||||||
|
return 2; |
||||||
|
} else if (searchEngine instanceof DuckLiteSearch) { |
||||||
|
return 3; |
||||||
|
} else { |
||||||
|
throw new UnsupportedOperationException("Unknown search engine provided: " + searchEngine.getClass()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@NonNull |
||||||
|
public List<BaseSearchEngine> getAllSearchEngines() { |
||||||
|
return new ArrayList<BaseSearchEngine>(4) {{ |
||||||
|
add(new CustomSearch(mPreferenceManager.getSearchUrl())); |
||||||
|
add(new LegworkSearch()); |
||||||
|
add(new DuckSearch()); |
||||||
|
add(new DuckLiteSearch()); |
||||||
|
}}; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,4 +1,4 @@ |
|||||||
package acr.browser.lightning.search.engine |
package org.purplei2p.lightning.search.engine |
||||||
|
|
||||||
import android.support.annotation.StringRes |
import android.support.annotation.StringRes |
||||||
|
|
@ -1,6 +1,6 @@ |
|||||||
package acr.browser.lightning.search.engine |
package org.purplei2p.lightning.search.engine |
||||||
|
|
||||||
import acr.browser.lightning.R |
import org.purplei2p.lightning.R |
||||||
|
|
||||||
/** |
/** |
||||||
* A custom search engine. |
* A custom search engine. |
@ -1,7 +1,7 @@ |
|||||||
package acr.browser.lightning.search.engine |
package org.purplei2p.lightning.search.engine |
||||||
|
|
||||||
import acr.browser.lightning.R |
import org.purplei2p.lightning.R |
||||||
import acr.browser.lightning.constant.Constants |
import org.purplei2p.lightning.constant.Constants |
||||||
|
|
||||||
/** |
/** |
||||||
* The DuckDuckGo Lite search engine. |
* The DuckDuckGo Lite search engine. |
@ -1,7 +1,7 @@ |
|||||||
package acr.browser.lightning.search.engine |
package org.purplei2p.lightning.search.engine |
||||||
|
|
||||||
import acr.browser.lightning.R |
import org.purplei2p.lightning.R |
||||||
import acr.browser.lightning.constant.Constants |
import org.purplei2p.lightning.constant.Constants |
||||||
|
|
||||||
/** |
/** |
||||||
* The DuckDuckGo search engine. |
* The DuckDuckGo search engine. |
@ -0,0 +1,15 @@ |
|||||||
|
package org.purplei2p.lightning.search.engine |
||||||
|
|
||||||
|
import org.purplei2p.lightning.R |
||||||
|
import org.purplei2p.lightning.constant.Constants |
||||||
|
|
||||||
|
/** |
||||||
|
* The Legwork.I2P search engine. |
||||||
|
* |
||||||
|
* See http://legwork.i2p/env/grafics/LegworkLogo_200.png for the icon. |
||||||
|
*/ |
||||||
|
class LegworkSearch : BaseSearchEngine( |
||||||
|
"file:///android_asset/legwork.png", |
||||||
|
Constants.LEGWORK_SEARCH, |
||||||
|
R.string.search_engine_legwork |
||||||
|
) |
@ -1,53 +1,52 @@ |
|||||||
package acr.browser.lightning.search.suggestions; |
package org.purplei2p.lightning.search.suggestions; |
||||||
|
|
||||||
import android.app.Application; |
import android.app.Application; |
||||||
import android.support.annotation.NonNull; |
import android.support.annotation.NonNull; |
||||||
|
|
||||||
import org.json.JSONArray; |
import org.json.JSONArray; |
||||||
|
import org.json.JSONObject; |
||||||
|
|
||||||
import java.io.InputStream; |
import java.io.InputStream; |
||||||
import java.util.List; |
import java.util.List; |
||||||
|
|
||||||
import acr.browser.lightning.R; |
import org.purplei2p.lightning.R; |
||||||
import acr.browser.lightning.database.HistoryItem; |
import org.purplei2p.lightning.database.HistoryItem; |
||||||
import acr.browser.lightning.utils.FileUtils; |
import org.purplei2p.lightning.utils.FileUtils; |
||||||
|
|
||||||
/** |
/** |
||||||
* The search suggestions provider for the Baidu search engine. |
* The search suggestions provider for the DuckDuckGo search engine. |
||||||
*/ |
*/ |
||||||
public class BaiduSuggestionsModel extends BaseSuggestionsModel { |
public final class LegworkSuggestionsModel extends BaseSuggestionsModel { |
||||||
|
|
||||||
@NonNull private static final String ENCODING = "UTF-8"; |
@NonNull private static final String ENCODING = "UTF-8"; |
||||||
@NonNull private final String mSearchSubtitle; |
@NonNull private final String mSearchSubtitle; |
||||||
|
|
||||||
public BaiduSuggestionsModel(@NonNull Application application) { |
public LegworkSuggestionsModel(@NonNull Application application) { |
||||||
super(application, ENCODING); |
super(application, ENCODING); |
||||||
mSearchSubtitle = application.getString(R.string.suggestion); |
mSearchSubtitle = application.getString(R.string.suggestion); |
||||||
} |
} |
||||||
|
|
||||||
@NonNull |
@NonNull |
||||||
|
@Override |
||||||
protected String createQueryUrl(@NonNull String query, @NonNull String language) { |
protected String createQueryUrl(@NonNull String query, @NonNull String language) { |
||||||
// see http://unionsug.baidu.com/su?wd=encodeURIComponent(U)
|
return "http://legwork.i2p/suggest.json?query=" + query; |
||||||
// see http://suggestion.baidu.com/s?wd=encodeURIComponent(U)&action=opensearch
|
|
||||||
return "http://suggestion.baidu.com/s?wd=" + query + "&action=opensearch"; |
|
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception { |
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception { |
||||||
String content = FileUtils.readStringFromStream(inputStream, "GBK"); |
String content = FileUtils.readStringFromStream(inputStream, ENCODING); |
||||||
JSONArray respArray = new JSONArray(content); |
JSONArray jsonArray = new JSONArray(content); |
||||||
JSONArray jsonArray = respArray.getJSONArray(1); |
|
||||||
|
|
||||||
int counter = 0; |
int counter = 0; |
||||||
for (int n = 0, size = jsonArray.length(); n < size; n++) { |
for (int n = 0, size = jsonArray.length(); n < size; n++) { |
||||||
String suggestion = jsonArray.getString(n); |
JSONObject object = jsonArray.getJSONObject(n); |
||||||
|
String suggestion = object.getString("phrase"); |
||||||
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', |
results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"', |
||||||
suggestion, R.drawable.ic_search)); |
suggestion, R.drawable.ic_search)); |
||||||
counter++; |
counter++; |
||||||
|
|
||||||
if (counter >= MAX_RESULTS) { |
if (counter >= MAX_RESULTS) { |
||||||
break; |
break; |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -1,12 +1,12 @@ |
|||||||
package acr.browser.lightning.settings.fragment; |
package org.purplei2p.lightning.settings.fragment; |
||||||
|
|
||||||
import android.os.Bundle; |
import android.os.Bundle; |
||||||
import android.preference.PreferenceFragment; |
import android.preference.PreferenceFragment; |
||||||
|
|
||||||
import javax.inject.Inject; |
import javax.inject.Inject; |
||||||
|
|
||||||
import acr.browser.lightning.BrowserApp; |
import org.purplei2p.lightning.BrowserApp; |
||||||
import acr.browser.lightning.preference.PreferenceManager; |
import org.purplei2p.lightning.preference.PreferenceManager; |
||||||
|
|
||||||
/** |
/** |
||||||
* Simplify {@link PreferenceManager} inject in all the PreferenceFragments |
* Simplify {@link PreferenceManager} inject in all the PreferenceFragments |