|
|
@ -56,6 +56,7 @@ import java.io.IOException; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
|
|
|
|
|
|
|
import acr.browser.lightning.R; |
|
|
|
import acr.browser.lightning.R; |
|
|
|
|
|
|
|
import acr.browser.lightning.app.BrowserApp; |
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
import acr.browser.lightning.constant.StartPage; |
|
|
|
import acr.browser.lightning.constant.StartPage; |
|
|
|
import acr.browser.lightning.controller.BrowserController; |
|
|
|
import acr.browser.lightning.controller.BrowserController; |
|
|
@ -90,7 +91,8 @@ public class LightningView { |
|
|
|
private static float mMaxFling; |
|
|
|
private static float mMaxFling; |
|
|
|
private static final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private static final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private static final int SCROLL_UP_THRESHOLD = Utils.dpToPx(10); |
|
|
|
private static final int SCROLL_UP_THRESHOLD = Utils.dpToPx(10); |
|
|
|
private static final float[] mNegativeColorArray = {-1.0f, 0, 0, 0, 255, // red
|
|
|
|
private static final float[] mNegativeColorArray = { |
|
|
|
|
|
|
|
-1.0f, 0, 0, 0, 255, // red
|
|
|
|
0, -1.0f, 0, 0, 255, // green
|
|
|
|
0, -1.0f, 0, 0, 255, // green
|
|
|
|
0, 0, -1.0f, 0, 255, // blue
|
|
|
|
0, 0, -1.0f, 0, 255, // blue
|
|
|
|
0, 0, 0, 1.0f, 0 // alpha
|
|
|
|
0, 0, 0, 1.0f, 0 // alpha
|
|
|
@ -505,14 +507,24 @@ public class LightningView { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void cacheFavicon(Bitmap icon) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Naive caching of the favicon according to the domain name of the URL |
|
|
|
|
|
|
|
* @param icon the icon to cache |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void cacheFavicon(final Bitmap icon) { |
|
|
|
if (icon == null) return; |
|
|
|
if (icon == null) return; |
|
|
|
|
|
|
|
final Uri uri = Uri.parse(getUrl()); |
|
|
|
String hash = String.valueOf(Utils.getDomainName(getUrl()).hashCode()); |
|
|
|
if (uri.getHost() == null) { |
|
|
|
Log.d(Constants.TAG, "Caching icon for " + Utils.getDomainName(getUrl())); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
String hash = String.valueOf(uri.getHost().hashCode()); |
|
|
|
|
|
|
|
Log.d(Constants.TAG, "Caching icon for " + uri.getHost()); |
|
|
|
FileOutputStream fos = null; |
|
|
|
FileOutputStream fos = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
File image = new File(mActivity.getCacheDir(), hash + ".png"); |
|
|
|
File image = new File(BrowserApp.getAppContext().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(); |
|
|
@ -522,6 +534,8 @@ public class LightningView { |
|
|
|
Utils.close(fos); |
|
|
|
Utils.close(fos); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("NewApi") |
|
|
|
@SuppressLint("NewApi") |
|
|
|
public synchronized void find(String text) { |
|
|
|
public synchronized void find(String text) { |
|
|
|