commit
aacb904ac4
@ -1014,11 +1014,11 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
mCurrentView.setIsForgroundTab(false);
|
mCurrentView.setForegroundTab(false);
|
||||||
mCurrentView.onPause();
|
mCurrentView.onPause();
|
||||||
}
|
}
|
||||||
mCurrentView = view;
|
mCurrentView = view;
|
||||||
mCurrentView.setIsForgroundTab(true);
|
mCurrentView.setForegroundTab(true);
|
||||||
if (view.getWebView() != null) {
|
if (view.getWebView() != null) {
|
||||||
updateUrl(view.getUrl());
|
updateUrl(view.getUrl());
|
||||||
updateProgress(view.getProgress());
|
updateProgress(view.getProgress());
|
||||||
@ -1587,7 +1587,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
LightningView web = data.get(position);
|
LightningView web = data.get(position);
|
||||||
holder.txtTitle.setText(web.getTitle());
|
holder.txtTitle.setText(web.getTitle());
|
||||||
if (web.getIsForgroundTab()) {
|
if (web.isForegroundTab()) {
|
||||||
holder.txtTitle.setTextAppearance(context, R.style.boldText);
|
holder.txtTitle.setTextAppearance(context, R.style.boldText);
|
||||||
} else {
|
} else {
|
||||||
holder.txtTitle.setTextAppearance(context, R.style.normalText);
|
holder.txtTitle.setTextAppearance(context, R.style.normalText);
|
||||||
|
@ -7,6 +7,7 @@ public class BrowserApp extends Application {
|
|||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
context = getApplicationContext();
|
context = getApplicationContext();
|
||||||
|
@ -15,16 +15,14 @@ public class ClickHandler extends Handler {
|
|||||||
try {
|
try {
|
||||||
mBrowserController = (BrowserController) context;
|
mBrowserController = (BrowserController) context;
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new ClassCastException(context.toString()
|
throw new ClassCastException(context + " must implement BrowserController");
|
||||||
+ " must implement BrowserController");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
super.handleMessage(msg);
|
super.handleMessage(msg);
|
||||||
String url = null;
|
String url = msg.getData().getString("url");
|
||||||
url = msg.getData().getString("url");
|
|
||||||
mBrowserController.longClickPage(url);
|
mBrowserController.longClickPage(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,9 @@ package acr.browser.lightning;
|
|||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
public class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
public Constants() {
|
private Constants() {
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
|
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
|
||||||
|
@ -93,7 +93,7 @@ public class DownloadHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needed == false) {
|
if (!needed) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +160,9 @@ public class DownloadHandler {
|
|||||||
webAddress = new WebAddress(url);
|
webAddress = new WebAddress(url);
|
||||||
webAddress.setPath(encodePath(webAddress.getPath()));
|
webAddress.setPath(encodePath(webAddress.getPath()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// This only happens for very bad urls, we want to chatch the
|
// This only happens for very bad urls, we want to catch the
|
||||||
// exception here
|
// exception here
|
||||||
Log.e(LOGTAG, "Exception trying to parse url:" + url);
|
Log.e(LOGTAG, "Exception while trying to parse url '" + url + '\'', e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +204,7 @@ public class DownloadHandler {
|
|||||||
final DownloadManager manager
|
final DownloadManager manager
|
||||||
= (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
|
= (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
new Thread("Browser download") {
|
new Thread("Browser download") {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
manager.enqueue(request);
|
manager.enqueue(request);
|
||||||
}
|
}
|
||||||
|
@ -101,4 +101,47 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
public int compareTo(HistoryItem another) {
|
public int compareTo(HistoryItem another) {
|
||||||
return mTitle.compareTo(another.mTitle);
|
return mTitle.compareTo(another.mTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || ((Object) this).getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryItem that = (HistoryItem) o;
|
||||||
|
|
||||||
|
if (mId != that.mId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mImageId != that.mImageId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (mBitmap != null ? !mBitmap.equals(that.mBitmap) : that.mBitmap != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!mTitle.equals(that.mTitle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!mUrl.equals(that.mUrl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
|
||||||
|
int result = mId;
|
||||||
|
result = 31 * result + mUrl.hashCode();
|
||||||
|
result = 31 * result + mTitle.hashCode();
|
||||||
|
result = 31 * result + (mBitmap != null ? mBitmap.hashCode() : 0);
|
||||||
|
result = 31 * result + mImageId;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class IntentUtils {
|
|||||||
PackageManager pm = mActivity.getPackageManager();
|
PackageManager pm = mActivity.getPackageManager();
|
||||||
List<ResolveInfo> handlers = pm.queryIntentActivities(intent,
|
List<ResolveInfo> handlers = pm.queryIntentActivities(intent,
|
||||||
PackageManager.GET_RESOLVED_FILTER);
|
PackageManager.GET_RESOLVED_FILTER);
|
||||||
if (handlers == null || handlers.size() == 0) {
|
if (handlers == null || handlers.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (ResolveInfo resolveInfo : handlers) {
|
for (ResolveInfo resolveInfo : handlers) {
|
||||||
|
@ -61,9 +61,9 @@ public class LightningView {
|
|||||||
|
|
||||||
private AdBlock mAdBlock;
|
private AdBlock mAdBlock;
|
||||||
|
|
||||||
private boolean isForgroundTab = false;
|
private boolean isForegroundTab;
|
||||||
|
|
||||||
private IntentUtils mIntentUtils = null;
|
private IntentUtils mIntentUtils;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@ -81,7 +81,7 @@ public class LightningView {
|
|||||||
try {
|
try {
|
||||||
mBrowserController = (BrowserController) activity;
|
mBrowserController = (BrowserController) activity;
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new ClassCastException(activity.toString()
|
throw new ClassCastException(activity
|
||||||
+ " must implement BrowserController");
|
+ " must implement BrowserController");
|
||||||
}
|
}
|
||||||
mIntentUtils = new IntentUtils(mBrowserController);
|
mIntentUtils = new IntentUtils(mBrowserController);
|
||||||
@ -109,11 +109,11 @@ public class LightningView {
|
|||||||
new CustomGestureListener());
|
new CustomGestureListener());
|
||||||
mWebView.setOnTouchListener(new OnTouchListener() {
|
mWebView.setOnTouchListener(new OnTouchListener() {
|
||||||
|
|
||||||
float mLocation = 0;
|
float mLocation;
|
||||||
|
|
||||||
float mY = 0;
|
float mY;
|
||||||
|
|
||||||
int mAction = 0;
|
int mAction;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent arg1) {
|
public boolean onTouch(View view, MotionEvent arg1) {
|
||||||
@ -142,10 +142,8 @@ public class LightningView {
|
|||||||
initializeSettings(mWebView.getSettings(), activity);
|
initializeSettings(mWebView.getSettings(), activity);
|
||||||
initializePreferences(activity);
|
initializePreferences(activity);
|
||||||
|
|
||||||
if (url != null) {
|
if (url != null && !url.trim().isEmpty()) {
|
||||||
if (!url.equals("")) {
|
mWebView.loadUrl(url);
|
||||||
mWebView.loadUrl(url);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (mHomepage.startsWith("about:home")) {
|
if (mHomepage.startsWith("about:home")) {
|
||||||
mSettings.setUseWideViewPort(false);
|
mSettings.setUseWideViewPort(false);
|
||||||
@ -159,7 +157,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getHomepage() {
|
public String getHomepage() {
|
||||||
String home = "";
|
String home;
|
||||||
home = HomepageVariables.HEAD;
|
home = HomepageVariables.HEAD;
|
||||||
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -394,11 +392,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShown() {
|
public boolean isShown() {
|
||||||
if (mWebView != null) {
|
return mWebView != null && mWebView.isShown();
|
||||||
return mWebView.isShown();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void onPause() {
|
public synchronized void onPause() {
|
||||||
@ -413,13 +407,13 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsForgroundTab(boolean isForground) {
|
public void setForegroundTab(boolean isForeground) {
|
||||||
isForgroundTab = isForground;
|
isForegroundTab = isForeground;
|
||||||
mBrowserController.update();
|
mBrowserController.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsForgroundTab() {
|
public boolean isForegroundTab() {
|
||||||
return isForgroundTab;
|
return isForegroundTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgress() {
|
public int getProgress() {
|
||||||
@ -449,10 +443,8 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void requestFocus() {
|
public void requestFocus() {
|
||||||
if (mWebView != null) {
|
if (mWebView != null && !mWebView.hasFocus()) {
|
||||||
if (!mWebView.hasFocus()) {
|
mWebView.requestFocus();
|
||||||
mWebView.requestFocus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,19 +516,11 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGoBack() {
|
public boolean canGoBack() {
|
||||||
if (mWebView != null) {
|
return mWebView != null && mWebView.canGoBack();
|
||||||
return mWebView.canGoBack();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGoForward() {
|
public boolean canGoForward() {
|
||||||
if (mWebView != null) {
|
return mWebView != null && mWebView.canGoForward();
|
||||||
return mWebView.canGoForward();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebView getWebView() {
|
public WebView getWebView() {
|
||||||
@ -583,11 +567,8 @@ public class LightningView {
|
|||||||
public WebResourceResponse shouldInterceptRequest(WebView view,
|
public WebResourceResponse shouldInterceptRequest(WebView view,
|
||||||
String url) {
|
String url) {
|
||||||
if (mAdBlock.isAd(url)) {
|
if (mAdBlock.isAd(url)) {
|
||||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||||
"".getBytes());
|
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
|
||||||
"text/plain", "utf-8", EMPTY);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useProxy = mPreferences.getBoolean(
|
boolean useProxy = mPreferences.getBoolean(
|
||||||
@ -650,12 +631,12 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cType != null && cType.startsWith("text")) {
|
if (cType != null && cType.startsWith("text")) {
|
||||||
InputStream fStream = null;
|
InputStream fStream;
|
||||||
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(
|
BufferedInputStream bis = new BufferedInputStream(
|
||||||
conn.getInputStream());
|
conn.getInputStream());
|
||||||
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
||||||
int read = 0;
|
int read;
|
||||||
int bufSize = 2048;
|
int bufSize = 2048;
|
||||||
byte[] buffer = new byte[bufSize];
|
byte[] buffer = new byte[bufSize];
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -681,10 +662,7 @@ public class LightningView {
|
|||||||
fStream = new ReplacingInputStream(fStream,
|
fStream = new ReplacingInputStream(fStream,
|
||||||
"\"poster\"".getBytes(), "\"foo\"".getBytes());
|
"\"poster\"".getBytes(), "\"foo\"".getBytes());
|
||||||
|
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
return new WebResourceResponse(cType, cEnc, fStream);
|
||||||
cType, cEnc, fStream);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}/**
|
}/**
|
||||||
* else if (mDoLeakHardening) { WebResourceResponse response =
|
* else if (mDoLeakHardening) { WebResourceResponse response =
|
||||||
* new WebResourceResponse( cType, cEnc, conn.getInputStream());
|
* new WebResourceResponse( cType, cEnc, conn.getInputStream());
|
||||||
@ -700,11 +678,8 @@ public class LightningView {
|
|||||||
Log.e(Constants.TAG, "Error filtering stream", e);
|
Log.e(Constants.TAG, "Error filtering stream", e);
|
||||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
||||||
"".getBytes());
|
"".getBytes());
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
||||||
"text/plain", "utf-8", EMPTY);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -714,7 +689,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
if (view.getTitle() == null) {
|
if (view.getTitle() == null) {
|
||||||
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
||||||
} else if (view.getTitle().length() > 0) {
|
} else if (!view.getTitle().isEmpty()) {
|
||||||
mTitle.setTitle(view.getTitle());
|
mTitle.setTitle(view.getTitle());
|
||||||
} else {
|
} else {
|
||||||
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
||||||
@ -912,7 +887,7 @@ public class LightningView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedTitle(WebView view, String title) {
|
public void onReceivedTitle(WebView view, String title) {
|
||||||
if (title.length() > 0) {
|
if (!title.isEmpty()) {
|
||||||
mTitle.setTitle(title);
|
mTitle.setTitle(title);
|
||||||
} else {
|
} else {
|
||||||
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
||||||
@ -929,7 +904,7 @@ public class LightningView {
|
|||||||
builder.setTitle(mActivity.getString(R.string.location));
|
builder.setTitle(mActivity.getString(R.string.location));
|
||||||
String org = null;
|
String org = null;
|
||||||
if (origin.length() > 50) {
|
if (origin.length() > 50) {
|
||||||
org = (String) origin.subSequence(0, 50) + "...";
|
org = origin.subSequence(0, 50) + "...";
|
||||||
} else {
|
} else {
|
||||||
org = origin;
|
org = origin;
|
||||||
}
|
}
|
||||||
@ -1004,7 +979,7 @@ public class LightningView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onShowCustomView(View view, CustomViewCallback callback) {
|
public void onShowCustomView(View view, CustomViewCallback callback) {
|
||||||
// While these lines might look like they work, in practive,
|
// While these lines might look like they work, in practice,
|
||||||
// Full-screen videos won't work correctly. I may test this out some more
|
// Full-screen videos won't work correctly. I may test this out some more
|
||||||
// if (view instanceof FrameLayout) {
|
// if (view instanceof FrameLayout) {
|
||||||
// FrameLayout frame = (FrameLayout) view;
|
// FrameLayout frame = (FrameLayout) view;
|
||||||
@ -1028,7 +1003,7 @@ public class LightningView {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void onShowCustomView(View view, int requestedOrientation,
|
public void onShowCustomView(View view, int requestedOrientation,
|
||||||
CustomViewCallback callback) {
|
CustomViewCallback callback) {
|
||||||
// While these lines might look like they work, in practive,
|
// While these lines might look like they work, in practice,
|
||||||
// Full-screen videos won't work correctly. I may test this out some more
|
// Full-screen videos won't work correctly. I may test this out some more
|
||||||
// if (view instanceof FrameLayout) {
|
// if (view instanceof FrameLayout) {
|
||||||
// FrameLayout frame = (FrameLayout) view;
|
// FrameLayout frame = (FrameLayout) view;
|
||||||
@ -1046,7 +1021,6 @@ public class LightningView {
|
|||||||
|
|
||||||
super.onShowCustomView(view, requestedOrientation, callback);
|
super.onShowCustomView(view, requestedOrientation, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Title {
|
public class Title {
|
||||||
@ -1073,9 +1047,10 @@ public class LightningView {
|
|||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = "";
|
mTitle = "";
|
||||||
|
} else {
|
||||||
|
mTitle = title;
|
||||||
}
|
}
|
||||||
mTitle = title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitleAndFavicon(String title, Bitmap favicon) {
|
public void setTitleAndFavicon(String title, Bitmap favicon) {
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class PreferenceConstants {
|
public final class PreferenceConstants {
|
||||||
|
|
||||||
|
private PreferenceConstants() {
|
||||||
|
}
|
||||||
|
|
||||||
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
|
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
|
||||||
|
|
||||||
|
@ -3,14 +3,15 @@ package acr.browser.lightning;
|
|||||||
import java.io.FilterInputStream;
|
import java.io.FilterInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Deque;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class ReplacingInputStream extends FilterInputStream {
|
public class ReplacingInputStream extends FilterInputStream {
|
||||||
|
|
||||||
LinkedList<Integer> inQueue = new LinkedList<Integer>();
|
Deque<Integer> inQueue = new LinkedList<Integer>();
|
||||||
|
|
||||||
LinkedList<Integer> outQueue = new LinkedList<Integer>();
|
Deque<Integer> outQueue = new LinkedList<Integer>();
|
||||||
|
|
||||||
final byte[] search, replacement;
|
final byte[] search, replacement;
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
/**
|
/**
|
||||||
* Returns false. REFilterInputStream does not support mark() and reset() methods.
|
* Returns false. REFilterInputStream does not support mark() and reset() methods.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean markSupported() {
|
public boolean markSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -77,6 +79,7 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
/**
|
/**
|
||||||
* Reads from the stream into the provided array.
|
* Reads from the stream into the provided array.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
int i;
|
int i;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
@ -45,7 +45,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private boolean mIncognito = false;
|
private boolean mIncognito;
|
||||||
|
|
||||||
public SearchAdapter(Context context, boolean incognito) {
|
public SearchAdapter(Context context, boolean incognito) {
|
||||||
mDatabaseHandler = new DatabaseHandler(context);
|
mDatabaseHandler = new DatabaseHandler(context);
|
||||||
@ -278,13 +278,13 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
if (xpp.getName().equals("suggestion")) {
|
if ("suggestion".equals(xpp.getName())) {
|
||||||
String suggestion = xpp.getAttributeValue(null,
|
String suggestion = xpp.getAttributeValue(null,
|
||||||
"data");
|
"data");
|
||||||
filter.add(new HistoryItem(mContext
|
filter.add(new HistoryItem(mContext
|
||||||
.getString(R.string.suggestion)
|
.getString(R.string.suggestion)
|
||||||
+ " \""
|
+ " \""
|
||||||
+ suggestion + "\"", suggestion,
|
+ suggestion + '"', suggestion,
|
||||||
R.drawable.ic_search));
|
R.drawable.ic_search));
|
||||||
counter++;
|
counter++;
|
||||||
if (counter >= 5) {
|
if (counter >= 5) {
|
||||||
|
@ -5,24 +5,24 @@ package acr.browser.lightning;
|
|||||||
|
|
||||||
public class SettingsController {
|
public class SettingsController {
|
||||||
|
|
||||||
static boolean clearHistory = false;
|
private static boolean clearHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects
|
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects
|
||||||
* to clear the history from the disk in advanced settings
|
* to clear the history from the disk in advanced settings
|
||||||
*/
|
*/
|
||||||
static void setClearHistory(boolean choice) {
|
public static void setClearHistory(boolean choice) {
|
||||||
clearHistory = choice;
|
clearHistory = choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the choice
|
* return the choice
|
||||||
*/
|
*/
|
||||||
static boolean getClearHistory() {
|
public static boolean getClearHistory() {
|
||||||
if (clearHistory) {
|
if (clearHistory) {
|
||||||
clearHistory = false;
|
clearHistory = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return clearHistory;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,10 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Utils {
|
public final class Utils {
|
||||||
|
|
||||||
|
private Utils() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void downloadFile(final Activity activity, final String url, final String userAgent,
|
public static void downloadFile(final Activity activity, final String url, final String userAgent,
|
||||||
final String contentDisposition, final boolean privateBrowsing) {
|
final String contentDisposition, final boolean privateBrowsing) {
|
||||||
@ -31,7 +34,7 @@ public class Utils {
|
|||||||
public static synchronized void addBookmark(Context context, String title, String url) {
|
public static synchronized void addBookmark(Context context, String title, String url) {
|
||||||
File book = new File(context.getFilesDir(), "bookmarks");
|
File book = new File(context.getFilesDir(), "bookmarks");
|
||||||
File bookUrl = new File(context.getFilesDir(), "bookurl");
|
File bookUrl = new File(context.getFilesDir(), "bookurl");
|
||||||
if ((title.equals("Bookmarks") || title.equals("History")) && url.startsWith("file://")) {
|
if (("Bookmarks".equals(title) || "History".equals(title)) && url.startsWith("file://")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -102,8 +105,7 @@ public class Utils {
|
|||||||
*/
|
*/
|
||||||
public static int convertToDensityPixels(Context context, int densityPixels) {
|
public static int convertToDensityPixels(Context context, int densityPixels) {
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
int pixels = (int) (densityPixels * scale + 0.5f);
|
return (int) (densityPixels * scale + 0.5f);
|
||||||
return pixels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDomainName(String url) {
|
public static String getDomainName(String url) {
|
||||||
@ -169,6 +171,6 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The directory is now empty so delete it
|
// The directory is now empty so delete it
|
||||||
return dir.delete();
|
return dir != null && dir.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ import java.util.regex.Pattern;
|
|||||||
import static android.util.Patterns.GOOD_IRI_CHAR;
|
import static android.util.Patterns.GOOD_IRI_CHAR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
|
||||||
*
|
|
||||||
* Web Address Parser
|
* Web Address Parser
|
||||||
*
|
*
|
||||||
* This is called WebAddress, rather than URL or URI, because it attempts to
|
* This is called WebAddress, rather than URL or URI, because it attempts to
|
||||||
@ -54,14 +52,13 @@ public class WebAddress {
|
|||||||
/* anchor */".*", Pattern.CASE_INSENSITIVE);
|
/* anchor */".*", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parses given uriString.
|
* Parses given URI-like string.
|
||||||
*/
|
*/
|
||||||
public WebAddress(String address) throws Exception {
|
public WebAddress(String address) {
|
||||||
if (address == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// android.util.Log.d(LOGTAG, "WebAddress: " + address);
|
if (address == null) {
|
||||||
|
throw new IllegalArgumentException("address can't be null");
|
||||||
|
}
|
||||||
|
|
||||||
mScheme = "";
|
mScheme = "";
|
||||||
mHost = "";
|
mHost = "";
|
||||||
@ -71,73 +68,73 @@ public class WebAddress {
|
|||||||
|
|
||||||
Matcher m = sAddressPattern.matcher(address);
|
Matcher m = sAddressPattern.matcher(address);
|
||||||
String t;
|
String t;
|
||||||
if (m.matches()) {
|
if (!m.matches()) {
|
||||||
t = m.group(MATCH_GROUP_SCHEME);
|
throw new IllegalArgumentException("Parsing of address '" +
|
||||||
if (t != null) {
|
address + "' failed");
|
||||||
mScheme = t.toLowerCase(Locale.ROOT);
|
}
|
||||||
}
|
|
||||||
t = m.group(MATCH_GROUP_AUTHORITY);
|
|
||||||
if (t != null) {
|
|
||||||
mAuthInfo = t;
|
|
||||||
}
|
|
||||||
t = m.group(MATCH_GROUP_HOST);
|
|
||||||
if (t != null) {
|
|
||||||
mHost = t;
|
|
||||||
}
|
|
||||||
t = m.group(MATCH_GROUP_PORT);
|
|
||||||
if (t != null && t.length() > 0) {
|
|
||||||
// The ':' character is not returned by the regex.
|
|
||||||
try {
|
|
||||||
mPort = Integer.parseInt(t);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t = m.group(MATCH_GROUP_PATH);
|
|
||||||
if (t != null && t.length() > 0) {
|
|
||||||
/*
|
|
||||||
* handle busted myspace frontpage redirect with missing initial
|
|
||||||
* "/"
|
|
||||||
*/
|
|
||||||
if (t.charAt(0) == '/') {
|
|
||||||
mPath = t;
|
|
||||||
} else {
|
|
||||||
mPath = "/" + t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
t = m.group(MATCH_GROUP_SCHEME);
|
||||||
// nothing found... outa here
|
if (t != null) {
|
||||||
throw new Exception();
|
mScheme = t.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
t = m.group(MATCH_GROUP_AUTHORITY);
|
||||||
|
if (t != null) {
|
||||||
|
mAuthInfo = t;
|
||||||
|
}
|
||||||
|
t = m.group(MATCH_GROUP_HOST);
|
||||||
|
if (t != null) {
|
||||||
|
mHost = t;
|
||||||
|
}
|
||||||
|
t = m.group(MATCH_GROUP_PORT);
|
||||||
|
if (t != null && !t.isEmpty()) {
|
||||||
|
// The ':' character is not returned by the regex.
|
||||||
|
try {
|
||||||
|
mPort = Integer.parseInt(t);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
throw new RuntimeException("Parsing of port number failed", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t = m.group(MATCH_GROUP_PATH);
|
||||||
|
if (t != null && !t.isEmpty()) {
|
||||||
|
/*
|
||||||
|
* handle busted myspace frontpage redirect with missing initial
|
||||||
|
* "/"
|
||||||
|
*/
|
||||||
|
if (t.charAt(0) == '/') {
|
||||||
|
mPath = t;
|
||||||
|
} else {
|
||||||
|
mPath = '/' + t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get port from scheme or scheme from port, if necessary and possible
|
* Get port from scheme or scheme from port, if necessary and possible
|
||||||
*/
|
*/
|
||||||
if (mPort == 443 && mScheme.equals("")) {
|
if (mPort == 443 && "".equals(mScheme)) {
|
||||||
mScheme = "https";
|
mScheme = "https";
|
||||||
} else if (mPort == -1) {
|
} else if (mPort == -1) {
|
||||||
if (mScheme.equals("https")) {
|
if ("https".equals(mScheme)) {
|
||||||
mPort = 443;
|
mPort = 443;
|
||||||
} else {
|
} else {
|
||||||
mPort = 80; // default
|
mPort = 80; // default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mScheme.equals("")) {
|
if ("".equals(mScheme)) {
|
||||||
mScheme = "http";
|
mScheme = "http";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
String port = "";
|
String port = "";
|
||||||
if ((mPort != 443 && mScheme.equals("https"))
|
if ((mPort != 443 && "https".equals(mScheme))
|
||||||
|| (mPort != 80 && mScheme.equals("http"))) {
|
|| (mPort != 80 && "http".equals(mScheme))) {
|
||||||
port = ":" + Integer.toString(mPort);
|
port = ':' + Integer.toString(mPort);
|
||||||
}
|
}
|
||||||
String authInfo = "";
|
String authInfo = "";
|
||||||
if (mAuthInfo.length() > 0) {
|
if (!mAuthInfo.isEmpty()) {
|
||||||
authInfo = mAuthInfo + "@";
|
authInfo = mAuthInfo + '@';
|
||||||
}
|
}
|
||||||
|
|
||||||
return mScheme + "://" + authInfo + mHost + port + mPath;
|
return mScheme + "://" + authInfo + mHost + port + mPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user