Mirror AppComponent getters in BrowserApp so that classes are less reliant on AppComponent, refactored getAppContext to getContext
This commit is contained in:
parent
f00bb77851
commit
057b4296d7
@ -32,8 +32,8 @@ public class ProxyUtils {
|
|||||||
private final Bus mEventBus;
|
private final Bus mEventBus;
|
||||||
|
|
||||||
private ProxyUtils(Context context) {
|
private ProxyUtils(Context context) {
|
||||||
mPreferences = BrowserApp.getAppComponent().getPreferenceManager();
|
mPreferences = BrowserApp.getPreferenceManager();
|
||||||
mEventBus = BrowserApp.getAppComponent().getBus();
|
mEventBus = BrowserApp.getBus();
|
||||||
mI2PHelper = new I2PAndroidHelper(context.getApplicationContext());
|
mI2PHelper = new I2PAndroidHelper(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ public class ProxyUtils {
|
|||||||
private static ProxyUtils mInstance;
|
private static ProxyUtils mInstance;
|
||||||
|
|
||||||
private ProxyUtils(Context context) {
|
private ProxyUtils(Context context) {
|
||||||
mPreferences = BrowserApp.getAppComponent().getPreferenceManager();
|
mPreferences = BrowserApp.getPreferenceManager();
|
||||||
mI2PHelper = new I2PAndroidHelper(context.getApplicationContext());
|
mI2PHelper = new I2PAndroidHelper(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProxyUtils getInstance() {
|
public static ProxyUtils getInstance() {
|
||||||
if (mInstance == null) {
|
if (mInstance == null) {
|
||||||
mInstance = new ProxyUtils(BrowserApp.getAppContext());
|
mInstance = new ProxyUtils(BrowserApp.getContext());
|
||||||
}
|
}
|
||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
@ -147,11 +147,11 @@ public class ProxyUtils {
|
|||||||
public boolean isProxyReady() {
|
public boolean isProxyReady() {
|
||||||
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
|
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
|
||||||
if (!mI2PHelper.isI2PAndroidRunning()) {
|
if (!mI2PHelper.isI2PAndroidRunning()) {
|
||||||
BrowserApp.getAppComponent().getBus()
|
BrowserApp.getBus()
|
||||||
.post(new BrowserEvents.ShowSnackBarMessage(R.string.i2p_not_running));
|
.post(new BrowserEvents.ShowSnackBarMessage(R.string.i2p_not_running));
|
||||||
return false;
|
return false;
|
||||||
} else if (!mI2PHelper.areTunnelsActive()) {
|
} else if (!mI2PHelper.areTunnelsActive()) {
|
||||||
BrowserApp.getAppComponent().getBus()
|
BrowserApp.getBus()
|
||||||
.post(new BrowserEvents.ShowSnackBarMessage(R.string.i2p_tunnels_not_ready));
|
.post(new BrowserEvents.ShowSnackBarMessage(R.string.i2p_tunnels_not_ready));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ public class ProxyUtils {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Constants.PROXY_I2P:
|
case Constants.PROXY_I2P:
|
||||||
I2PAndroidHelper ih = new I2PAndroidHelper(BrowserApp.getAppContext());
|
I2PAndroidHelper ih = new I2PAndroidHelper(BrowserApp.getContext());
|
||||||
if (!ih.isI2PAndroidInstalled()) {
|
if (!ih.isI2PAndroidInstalled()) {
|
||||||
choice = Constants.NO_PROXY;
|
choice = Constants.NO_PROXY;
|
||||||
ih.promptToInstall(activity);
|
ih.promptToInstall(activity);
|
||||||
|
@ -1342,7 +1342,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
if (UrlUtils.isSpecialUrl(url)) {
|
if (UrlUtils.isSpecialUrl(url)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BrowserApp.getAppComponent().getHistoryDatabase().getIOThread().execute(new Runnable() {
|
BrowserApp.getHistoryDatabase().getIOThread().execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1406,7 +1406,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
*/
|
*/
|
||||||
private void openHistory() {
|
private void openHistory() {
|
||||||
// use a thread so that history retrieval doesn't block the UI
|
// use a thread so that history retrieval doesn't block the UI
|
||||||
BrowserApp.getAppComponent().getHistoryDatabase().getIOThread().execute(new Runnable() {
|
BrowserApp.getHistoryDatabase().getIOThread().execute(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -53,7 +53,7 @@ public class ReadingActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
|
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
|
||||||
mPreferences = BrowserApp.getAppComponent().getPreferenceManager();
|
mPreferences = BrowserApp.getPreferenceManager();
|
||||||
mInvert = mPreferences.getInvertColors();
|
mInvert = mPreferences.getInvertColors();
|
||||||
final int color;
|
final int color;
|
||||||
if (mInvert) {
|
if (mInvert) {
|
||||||
|
@ -13,7 +13,7 @@ public abstract class ThemableSettingsActivity extends AppCompatPreferenceActivi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mTheme = BrowserApp.getAppComponent().getPreferenceManager().getUseTheme();
|
mTheme = BrowserApp.getPreferenceManager().getUseTheme();
|
||||||
|
|
||||||
// set the theme
|
// set the theme
|
||||||
if (mTheme == 0) {
|
if (mTheme == 0) {
|
||||||
@ -32,7 +32,7 @@ public abstract class ThemableSettingsActivity extends AppCompatPreferenceActivi
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (BrowserApp.getAppComponent().getPreferenceManager().getUseTheme() != mTheme) {
|
if (BrowserApp.getPreferenceManager().getUseTheme() != mTheme) {
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,27 @@ import android.app.Application;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.squareup.leakcanary.LeakCanary;
|
import com.squareup.leakcanary.LeakCanary;
|
||||||
|
import com.squareup.otto.Bus;
|
||||||
|
|
||||||
|
import acr.browser.lightning.constant.BookmarkPage;
|
||||||
|
import acr.browser.lightning.database.HistoryDatabase;
|
||||||
|
import acr.browser.lightning.preference.PreferenceManager;
|
||||||
|
|
||||||
public class BrowserApp extends Application {
|
public class BrowserApp extends Application {
|
||||||
|
|
||||||
private static Context sContext;
|
private static BrowserApp sInstance;
|
||||||
private static AppComponent appComponent;
|
private static AppComponent appComponent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
sInstance = this;
|
||||||
LeakCanary.install(this);
|
LeakCanary.install(this);
|
||||||
buildDepencyGraph();
|
buildDepencyGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static BrowserApp getContext() {
|
||||||
protected void attachBaseContext(Context base) {
|
return sInstance;
|
||||||
super.attachBaseContext(base);
|
|
||||||
sContext = base;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Context getAppContext() {
|
|
||||||
return sContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AppComponent getAppComponent() {
|
public static AppComponent getAppComponent() {
|
||||||
@ -35,4 +35,20 @@ public class BrowserApp extends Application {
|
|||||||
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
|
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HistoryDatabase getHistoryDatabase() {
|
||||||
|
return appComponent.getHistoryDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PreferenceManager getPreferenceManager() {
|
||||||
|
return appComponent.getPreferenceManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bus getBus() {
|
||||||
|
return appComponent.getBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BookmarkPage getBookmarkPage() {
|
||||||
|
return appComponent.getBookmarkPage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import acr.browser.lightning.utils.Utils;
|
|||||||
public class ImageDownloadTask extends AsyncTask<Void, Void, Bitmap> {
|
public class ImageDownloadTask extends AsyncTask<Void, Void, Bitmap> {
|
||||||
|
|
||||||
private static final String TAG = ImageDownloadTask.class.getSimpleName();
|
private static final String TAG = ImageDownloadTask.class.getSimpleName();
|
||||||
private static final File mCacheDir = BrowserApp.getAppContext().getCacheDir();
|
private static final File mCacheDir = BrowserApp.getContext().getCacheDir();
|
||||||
private final WeakReference<ImageView> bmImage;
|
private final WeakReference<ImageView> bmImage;
|
||||||
private final HistoryItem mWeb;
|
private final HistoryItem mWeb;
|
||||||
private final String mUrl;
|
private final String mUrl;
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning.constant;
|
package acr.browser.lightning.constant;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -31,7 +29,7 @@ public final class BookmarkPage {
|
|||||||
"<meta content='text/html; charset=utf-8' http-equiv=Content-Type />\n" +
|
"<meta content='text/html; charset=utf-8' http-equiv=Content-Type />\n" +
|
||||||
"<meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>\n" +
|
"<meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>\n" +
|
||||||
"<title>" +
|
"<title>" +
|
||||||
BrowserApp.getAppContext().getString(R.string.action_bookmarks) +
|
BrowserApp.getContext().getString(R.string.action_bookmarks) +
|
||||||
"</title>\n" +
|
"</title>\n" +
|
||||||
"</head>\n" +
|
"</head>\n" +
|
||||||
"<style>body{background:#e1e1e1;max-width:100%;min-height:100%}#content{width:100%;max-width:800px;margin:0 auto;text-align:center}.box{vertical-align:middle;text-align:center;position:relative;display:inline-block;height:45px;width:150px;margin:10px;background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,0.25);font-family:Arial;color:#444;font-size:12px;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px}.box-content{height:25px;width:100%;vertical-align:middle;text-align:center;display:table-cell}p.ellipses{" +
|
"<style>body{background:#e1e1e1;max-width:100%;min-height:100%}#content{width:100%;max-width:800px;margin:0 auto;text-align:center}.box{vertical-align:middle;text-align:center;position:relative;display:inline-block;height:45px;width:150px;margin:10px;background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,0.25);font-family:Arial;color:#444;font-size:12px;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px}.box-content{height:25px;width:100%;vertical-align:middle;text-align:center;display:table-cell}p.ellipses{" +
|
||||||
@ -61,10 +59,10 @@ public final class BookmarkPage {
|
|||||||
private final File CACHE_DIR;
|
private final File CACHE_DIR;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BookmarkPage(Context context) {
|
public BookmarkPage() {
|
||||||
BrowserApp.getAppComponent().inject(this);
|
BrowserApp.getAppComponent().inject(this);
|
||||||
FILES_DIR = context.getFilesDir();
|
FILES_DIR = BrowserApp.getContext().getFilesDir();
|
||||||
CACHE_DIR = context.getCacheDir();
|
CACHE_DIR = BrowserApp.getContext().getCacheDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildBookmarkPage(final String folder) {
|
public void buildBookmarkPage(final String folder) {
|
||||||
|
@ -22,7 +22,7 @@ public class HistoryPage {
|
|||||||
public static final String FILENAME = "history.html";
|
public static final String FILENAME = "history.html";
|
||||||
|
|
||||||
private static final String HEADING = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"><title>"
|
private static final String HEADING = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"><title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.action_history)
|
+ BrowserApp.getContext().getString(R.string.action_history)
|
||||||
+ "</title></head><style>body { background: #e1e1e1;}.box { vertical-align:middle;position:relative; display: block; margin: 10px;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:5px; background-color:#fff;box-shadow: 0px 2px 3px rgba( 0, 0, 0, 0.25 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}.black {color: black;font-size: 15px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.font {color: gray;font-size: 10px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}</style><body><div id=\"content\">";
|
+ "</title></head><style>body { background: #e1e1e1;}.box { vertical-align:middle;position:relative; display: block; margin: 10px;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:5px; background-color:#fff;box-shadow: 0px 2px 3px rgba( 0, 0, 0, 0.25 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}.black {color: black;font-size: 15px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.font {color: gray;font-size: 10px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}</style><body><div id=\"content\">";
|
||||||
|
|
||||||
private static final String PART1 = "<div class=\"box\"><a href=\"";
|
private static final String PART1 = "<div class=\"box\"><a href=\"";
|
||||||
@ -37,7 +37,7 @@ public class HistoryPage {
|
|||||||
|
|
||||||
public static String getHistoryPage(Context context) {
|
public static String getHistoryPage(Context context) {
|
||||||
StringBuilder historyBuilder = new StringBuilder(HistoryPage.HEADING);
|
StringBuilder historyBuilder = new StringBuilder(HistoryPage.HEADING);
|
||||||
List<HistoryItem> historyList = getWebHistory(context);
|
List<HistoryItem> historyList = getWebHistory();
|
||||||
Iterator<HistoryItem> it = historyList.iterator();
|
Iterator<HistoryItem> it = historyList.iterator();
|
||||||
HistoryItem helper;
|
HistoryItem helper;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -65,8 +65,8 @@ public class HistoryPage {
|
|||||||
return Constants.FILE + historyWebPage;
|
return Constants.FILE + historyWebPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<HistoryItem> getWebHistory(Context context) {
|
private static List<HistoryItem> getWebHistory() {
|
||||||
HistoryDatabase databaseHandler = BrowserApp.getAppComponent().getHistoryDatabase();
|
HistoryDatabase databaseHandler = BrowserApp.getHistoryDatabase();
|
||||||
return databaseHandler.getLastHundredItems();
|
return databaseHandler.getLastHundredItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class StartPage {
|
|||||||
+ "<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />"
|
+ "<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />"
|
||||||
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">"
|
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">"
|
||||||
+ "<title>"
|
+ "<title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.home)
|
+ BrowserApp.getContext().getString(R.string.home)
|
||||||
+ "</title>"
|
+ "</title>"
|
||||||
+ "</head>"
|
+ "</head>"
|
||||||
+ "<style>body{background:#f2f2f2;text-align:center;margin:0px;}#search_input{height:35px; "
|
+ "<style>body{background:#f2f2f2;text-align:center;margin:0px;}#search_input{height:35px; "
|
||||||
@ -57,7 +57,7 @@ public class StartPage {
|
|||||||
StringBuilder homepageBuilder = new StringBuilder(StartPage.HEAD);
|
StringBuilder homepageBuilder = new StringBuilder(StartPage.HEAD);
|
||||||
String icon;
|
String icon;
|
||||||
String searchUrl;
|
String searchUrl;
|
||||||
final PreferenceManager preferenceManager = BrowserApp.getAppComponent().getPreferenceManager();
|
final PreferenceManager preferenceManager = BrowserApp.getPreferenceManager();
|
||||||
switch (preferenceManager.getSearchChoice()) {
|
switch (preferenceManager.getSearchChoice()) {
|
||||||
case 0:
|
case 0:
|
||||||
// CUSTOM SEARCH
|
// CUSTOM SEARCH
|
||||||
|
@ -186,7 +186,7 @@ public class DownloadHandler {
|
|||||||
// or, should it be set to one of several Environment.DIRECTORY* dirs
|
// or, should it be set to one of several Environment.DIRECTORY* dirs
|
||||||
// depending on mimetype?
|
// depending on mimetype?
|
||||||
|
|
||||||
String location = BrowserApp.getAppComponent().getPreferenceManager().getDownloadDirectory();
|
String location = BrowserApp.getPreferenceManager().getDownloadDirectory();
|
||||||
Uri downloadFolder;
|
Uri downloadFolder;
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
location = addNecessarySlashes(location);
|
location = addNecessarySlashes(location);
|
||||||
@ -194,7 +194,7 @@ public class DownloadHandler {
|
|||||||
} else {
|
} else {
|
||||||
location = addNecessarySlashes(DEFAULT_DOWNLOAD_PATH);
|
location = addNecessarySlashes(DEFAULT_DOWNLOAD_PATH);
|
||||||
downloadFolder = Uri.parse(location);
|
downloadFolder = Uri.parse(location);
|
||||||
BrowserApp.getAppComponent().getPreferenceManager().setDownloadDirectory(location);
|
BrowserApp.getPreferenceManager().setDownloadDirectory(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
File dir = new File(downloadFolder.getPath());
|
File dir = new File(downloadFolder.getPath());
|
||||||
|
@ -54,7 +54,7 @@ class FetchUrlMimeType extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
// User agent is likely to be null, though the AndroidHttpClient
|
// User agent is likely to be null, though the AndroidHttpClient
|
||||||
// seems ok with that.
|
// seems ok with that.
|
||||||
final Bus eventBus = BrowserApp.getAppComponent().getBus();
|
final Bus eventBus = BrowserApp.getBus();
|
||||||
String mimeType = null;
|
String mimeType = null;
|
||||||
String contentDisposition = null;
|
String contentDisposition = null;
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
|
@ -149,8 +149,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0, int arg1) {
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
BrowserApp.getAppComponent()
|
BrowserApp.getHistoryDatabase()
|
||||||
.getHistoryDatabase()
|
|
||||||
.getIOThread()
|
.getIOThread()
|
||||||
.execute(new Runnable() {
|
.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,7 +106,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteOldCacheFiles() {
|
private static void deleteOldCacheFiles() {
|
||||||
File dir = new File(BrowserApp.getAppContext().getCacheDir().toString());
|
File dir = new File(BrowserApp.getContext().getCacheDir().toString());
|
||||||
String[] fileList = dir.list(new NameFilter());
|
String[] fileList = dir.list(new NameFilter());
|
||||||
long earliestTimeAllowed = System.currentTimeMillis() - INTERVAL_DAY;
|
long earliestTimeAllowed = System.currentTimeMillis() - INTERVAL_DAY;
|
||||||
for (String fileName : fileList) {
|
for (String fileName : fileList) {
|
||||||
@ -373,11 +373,11 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
* @return the cache file containing the suggestions
|
* @return the cache file containing the suggestions
|
||||||
*/
|
*/
|
||||||
private static File downloadSuggestionsForQuery(String query, String language) {
|
private static File downloadSuggestionsForQuery(String query, String language) {
|
||||||
File cacheFile = new File(BrowserApp.getAppContext().getCacheDir(), query.hashCode() + CACHE_FILE_TYPE);
|
File cacheFile = new File(BrowserApp.getContext().getCacheDir(), query.hashCode() + CACHE_FILE_TYPE);
|
||||||
if (System.currentTimeMillis() - INTERVAL_DAY < cacheFile.lastModified()) {
|
if (System.currentTimeMillis() - INTERVAL_DAY < cacheFile.lastModified()) {
|
||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
if (!isNetworkConnected(BrowserApp.getAppContext())) {
|
if (!isNetworkConnected(BrowserApp.getContext())) {
|
||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
|
@ -44,11 +44,11 @@ public class AdBlock {
|
|||||||
if (mBlockedDomainsList.isEmpty() && Constants.FULL_VERSION) {
|
if (mBlockedDomainsList.isEmpty() && Constants.FULL_VERSION) {
|
||||||
loadHostsFile(context);
|
loadHostsFile(context);
|
||||||
}
|
}
|
||||||
mBlockAds = BrowserApp.getAppComponent().getPreferenceManager().getAdBlockEnabled();
|
mBlockAds = BrowserApp.getPreferenceManager().getAdBlockEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePreference() {
|
public void updatePreference() {
|
||||||
mBlockAds = BrowserApp.getAppComponent().getPreferenceManager().getAdBlockEnabled();
|
mBlockAds = BrowserApp.getPreferenceManager().getAdBlockEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlockedDomainsList(final Context context) {
|
private void loadBlockedDomainsList(final Context context) {
|
||||||
|
@ -34,7 +34,7 @@ public class WebUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clearHistory(@NonNull Context context) {
|
public static void clearHistory(@NonNull Context context) {
|
||||||
BrowserApp.getAppComponent().getHistoryDatabase().deleteHistory();
|
BrowserApp.getHistoryDatabase().deleteHistory();
|
||||||
WebViewDatabase m = WebViewDatabase.getInstance(context);
|
WebViewDatabase m = WebViewDatabase.getInstance(context);
|
||||||
m.clearFormData();
|
m.clearFormData();
|
||||||
m.clearHttpAuthUsernamePassword();
|
m.clearHttpAuthUsernamePassword();
|
||||||
|
@ -31,7 +31,7 @@ class IconCacheTask implements Runnable{
|
|||||||
Log.d(Constants.TAG, "Caching icon for " + uri.getHost());
|
Log.d(Constants.TAG, "Caching icon for " + uri.getHost());
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
File image = new File(BrowserApp.getAppContext().getCacheDir(), hash + ".png");
|
File image = new File(BrowserApp.getContext().getCacheDir(), hash + ".png");
|
||||||
fos = new FileOutputStream(image);
|
fos = new FileOutputStream(image);
|
||||||
icon.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
icon.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
||||||
fos.flush();
|
fos.flush();
|
||||||
|
@ -49,7 +49,7 @@ class LightningChromeClient extends WebChromeClient {
|
|||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mUIController = (UIController) activity;
|
mUIController = (UIController) activity;
|
||||||
mLightningView = lightningView;
|
mLightningView = lightningView;
|
||||||
eventBus = BrowserApp.getAppComponent().getBus();
|
eventBus = BrowserApp.getBus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,7 +84,7 @@ class LightningChromeClient extends WebChromeClient {
|
|||||||
Log.d(Constants.TAG, "Caching icon for " + uri.getHost());
|
Log.d(Constants.TAG, "Caching icon for " + uri.getHost());
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
try {
|
try {
|
||||||
File image = new File(BrowserApp.getAppContext().getCacheDir(), hash + ".png");
|
File image = new File(BrowserApp.getContext().getCacheDir(), hash + ".png");
|
||||||
fos = new FileOutputStream(image);
|
fos = new FileOutputStream(image);
|
||||||
icon.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
icon.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
||||||
fos.flush();
|
fos.flush();
|
||||||
|
@ -176,7 +176,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
||||||
|
|
||||||
BrowserApp.getAppComponent().getBookmarkPage().buildBookmarkPage(null);
|
BrowserApp.getBookmarkPage().buildBookmarkPage(null);
|
||||||
mWebView.loadUrl(Constants.FILE + bookmarkWebPage, mRequestHeaders);
|
mWebView.loadUrl(Constants.FILE + bookmarkWebPage, mRequestHeaders);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class LightningWebClient extends WebViewClient {
|
|||||||
mLightningView = lightningView;
|
mLightningView = lightningView;
|
||||||
mAdBlock = AdBlock.getInstance(activity);
|
mAdBlock = AdBlock.getInstance(activity);
|
||||||
mAdBlock.updatePreference();
|
mAdBlock.updatePreference();
|
||||||
mEventBus = BrowserApp.getAppComponent().getBus();
|
mEventBus = BrowserApp.getBus();
|
||||||
mIntentUtils = new IntentUtils(activity);
|
mIntentUtils = new IntentUtils(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user