Fix method names, redundant initialization of variables, typos in comments and other improvements
This commit is contained in:
parent
a33f3a340a
commit
82d8af3057
@ -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);
|
||||||
|
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user