Fix lint problems and other code style problems, also fixed sluggish navigation drawer issues
This commit is contained in:
parent
0c57e14f05
commit
d60fe82b4a
@ -21,7 +21,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:gravity="left|center_vertical"
|
||||
android:hint="@+string/search_hint"
|
||||
android:hint="@string/search_hint"
|
||||
android:imeOptions="actionGo"
|
||||
android:inputType="textUri"
|
||||
android:paddingBottom="1dp"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="@dimen/navigation_width"
|
||||
android:layout_height="match_parent"
|
||||
@ -13,7 +13,6 @@
|
||||
android:id="@+id/new_tab_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="?attr/listBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal" >
|
||||
@ -49,14 +48,13 @@
|
||||
android:id="@+id/view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@+id/new_tab_button"
|
||||
android:background="@color/gray_list_bg" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/lineView"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_below="@+id/view"
|
||||
android:choiceMode="singleChoice"
|
||||
android:dividerHeight="1dp"
|
||||
@ -66,14 +64,12 @@
|
||||
android:id="@+id/lineView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_above="@+id/linearLayout1"
|
||||
android:background="@color/gray_list_bg" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2" >
|
||||
@ -119,4 +115,4 @@
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -61,7 +61,7 @@ public class AnimatedProgressBar extends LinearLayout {
|
||||
* @param attrs is the attribute set passed by the constructor
|
||||
*/
|
||||
private void init(final Context context, AttributeSet attrs) {
|
||||
this.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
this.setLayerType(LAYER_TYPE_NONE, null);
|
||||
TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AnimatedProgressBar, 0, 0);
|
||||
int backgroundColor;
|
||||
int progressColor;
|
||||
|
@ -360,10 +360,9 @@ public class BookmarkManager {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
File bookmarksImport = file;
|
||||
List<HistoryItem> list = new ArrayList<HistoryItem>();
|
||||
try {
|
||||
BufferedReader bookmarksReader = new BufferedReader(new FileReader(bookmarksImport));
|
||||
BufferedReader bookmarksReader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
int number = 0;
|
||||
while ((line = bookmarksReader.readLine()) != null) {
|
||||
|
@ -77,7 +77,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private ListView mDrawerListLeft;
|
||||
private RelativeLayout mDrawerLeft;
|
||||
private LinearLayout mDrawerLeft;
|
||||
private LinearLayout mDrawerRight;
|
||||
private ListView mDrawerListRight;
|
||||
private RelativeLayout mNewTab;
|
||||
@ -171,15 +171,20 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
// mProgressBar.setVisibility(View.GONE);
|
||||
// TODO
|
||||
mNewTab = (RelativeLayout) findViewById(R.id.new_tab_button);
|
||||
mDrawerLeft = (RelativeLayout) findViewById(R.id.left_drawer);
|
||||
mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer);
|
||||
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Drawer
|
||||
// stutters
|
||||
// otherwise
|
||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list);
|
||||
mDrawerListLeft.setDivider(null);
|
||||
mDrawerListLeft.setDividerHeight(0);
|
||||
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer);
|
||||
mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list);
|
||||
mDrawerListRight.setDivider(null);
|
||||
mDrawerListRight.setDividerHeight(0);
|
||||
|
||||
setNavigationDrawerWidth();
|
||||
mDrawerLayout.setDrawerListener(new DrawerLocker());
|
||||
|
||||
@ -232,6 +237,11 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
|
||||
mArrowDrawable = new DrawerArrowDrawable(this);
|
||||
mArrowImage = (ImageView) mActionBar.getCustomView().findViewById(R.id.arrow);
|
||||
mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Use a
|
||||
// hardware
|
||||
// layer for
|
||||
// the
|
||||
// animation
|
||||
mArrowImage.setImageDrawable(mArrowDrawable);
|
||||
LinearLayout arrowButton = (LinearLayout) mActionBar.getCustomView().findViewById(
|
||||
R.id.arrow_button);
|
||||
@ -399,17 +409,22 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
@Override
|
||||
public void onFocusChange(View v, final boolean hasFocus) {
|
||||
if (!hasFocus && mCurrentView != null) {
|
||||
if (mCurrentView != null) {
|
||||
if (mCurrentView.getProgress() < 100) {
|
||||
setIsLoading();
|
||||
} else {
|
||||
setIsFinishedLoading();
|
||||
}
|
||||
if (mCurrentView.getProgress() < 100) {
|
||||
setIsLoading();
|
||||
} else {
|
||||
setIsFinishedLoading();
|
||||
}
|
||||
updateUrl(mCurrentView.getUrl(), true);
|
||||
} else if (hasFocus) {
|
||||
updateUrl(mCurrentView.getUrl(), false);
|
||||
mSearch.selectAll();
|
||||
String url = mCurrentView.getUrl();
|
||||
if (url == null || url.startsWith(Constants.FILE)) {
|
||||
mSearch.setText("");
|
||||
} else {
|
||||
mSearch.setText(url);
|
||||
}
|
||||
((AutoCompleteTextView) v).selectAll(); // Hack to make sure
|
||||
// the text gets
|
||||
// selected
|
||||
mIcon = mCopyIcon;
|
||||
mSearch.setCompoundDrawables(null, null, mCopyIcon, null);
|
||||
}
|
||||
@ -578,8 +593,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
if (mCurrentView != null) {
|
||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl()
|
||||
.toString());
|
||||
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Utils.showToast(mContext,
|
||||
mContext.getResources().getString(R.string.message_link_copied));
|
||||
@ -653,7 +667,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
.setNegativeButton(R.string.no, dialogClickListener).show();
|
||||
|
||||
return true;
|
||||
} else if (oh.isOrbotInstalled() & useProxy == true) {
|
||||
} else if (oh.isOrbotInstalled() & useProxy) {
|
||||
initializeTor();
|
||||
return true;
|
||||
} else {
|
||||
@ -691,19 +705,23 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
.getLayoutParams();
|
||||
params.width = maxWidth;
|
||||
mDrawerLeft.setLayoutParams(params);
|
||||
mDrawerLeft.requestLayout();
|
||||
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
|
||||
.getLayoutParams();
|
||||
paramsRight.width = maxWidth;
|
||||
mDrawerRight.setLayoutParams(paramsRight);
|
||||
mDrawerRight.requestLayout();
|
||||
} else {
|
||||
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft
|
||||
.getLayoutParams();
|
||||
params.width = width;
|
||||
mDrawerLeft.setLayoutParams(params);
|
||||
mDrawerLeft.requestLayout();
|
||||
DrawerLayout.LayoutParams paramsRight = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerRight
|
||||
.getLayoutParams();
|
||||
paramsRight.width = width;
|
||||
mDrawerRight.setLayoutParams(paramsRight);
|
||||
mDrawerRight.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,7 +747,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
|
||||
String mem = mPreferences.getString(PreferenceConstants.URL_MEMORY, "");
|
||||
mEditPrefs.putString(PreferenceConstants.URL_MEMORY, "");
|
||||
mEditPrefs.putString(PreferenceConstants.URL_MEMORY, "").apply();
|
||||
String[] array = Utils.getArray(mem);
|
||||
int count = 0;
|
||||
for (int n = 0; n < array.length; n++) {
|
||||
@ -899,8 +917,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
if (mCurrentView != null) {
|
||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl()
|
||||
.toString());
|
||||
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Utils.showToast(mContext,
|
||||
mContext.getResources().getString(R.string.message_link_copied));
|
||||
@ -1006,6 +1023,31 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
});
|
||||
}
|
||||
|
||||
private void showCloseDialog(final int position) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext,
|
||||
android.R.layout.simple_dropdown_item_1line);
|
||||
adapter.add(mContext.getString(R.string.close_tab));
|
||||
adapter.add(mContext.getString(R.string.close_all_tabs));
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
deleteTab(position);
|
||||
break;
|
||||
case 1:
|
||||
closeBrowser();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* The click listener for ListView in the navigation drawer
|
||||
*/
|
||||
@ -1025,28 +1067,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext,
|
||||
android.R.layout.simple_dropdown_item_1line);
|
||||
adapter.add(mContext.getString(R.string.close_tab));
|
||||
adapter.add(mContext.getString(R.string.close_all_tabs));
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
deleteTab(position);
|
||||
break;
|
||||
case 1:
|
||||
closeBrowser();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
showCloseDialog(position);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1339,10 +1360,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
Log.d(Constants.TAG, "Cookies Cleared");
|
||||
|
||||
}
|
||||
if (reference != null) {
|
||||
reference.pauseTimers();
|
||||
reference.onDestroy();
|
||||
}
|
||||
reference.pauseTimers();
|
||||
reference.onDestroy();
|
||||
mCurrentView = null;
|
||||
mTitleAdapter.notifyDataSetChanged();
|
||||
finish();
|
||||
@ -1362,33 +1381,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
@Override
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false)
|
||||
&& mCurrentView != null && !isIncognito()) {
|
||||
mCurrentView.clearCache(true);
|
||||
Log.d(Constants.TAG, "Cache Cleared");
|
||||
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, false)
|
||||
&& !isIncognito()) {
|
||||
clearHistory();
|
||||
Log.d(Constants.TAG, "History Cleared");
|
||||
|
||||
}
|
||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, false)
|
||||
&& !isIncognito()) {
|
||||
clearCookies();
|
||||
Log.d(Constants.TAG, "Cookies Cleared");
|
||||
|
||||
}
|
||||
mCurrentView = null;
|
||||
for (int n = 0; n < mWebViews.size(); n++) {
|
||||
if (mWebViews.get(n) != null) {
|
||||
mWebViews.get(n).onDestroy();
|
||||
}
|
||||
}
|
||||
mWebViews.clear();
|
||||
mTitleAdapter.notifyDataSetChanged();
|
||||
finish();
|
||||
showCloseDialog(mDrawerListLeft.getCheckedItemPosition());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1502,8 +1495,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
s = s + mWebViews.get(n).getUrl() + "|$|SEPARATOR|$|";
|
||||
}
|
||||
}
|
||||
mEditPrefs.putString(PreferenceConstants.URL_MEMORY, s);
|
||||
mEditPrefs.commit();
|
||||
mEditPrefs.putString(PreferenceConstants.URL_MEMORY, s).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1822,8 +1814,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} finally {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
// if it exists, retrieve it from the cache
|
||||
@ -1850,6 +1841,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (mIcon == null) {
|
||||
@ -1878,7 +1870,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
|
||||
@Override
|
||||
public void updateUrl(String url, boolean shortUrl) {
|
||||
if (url == null) {
|
||||
if (url == null || mSearch == null || mSearch.hasFocus()) {
|
||||
return;
|
||||
}
|
||||
if (shortUrl) {
|
||||
@ -1940,7 +1932,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (mHistoryHandler == null && !mHistoryHandler.isOpen()) {
|
||||
if (mHistoryHandler == null || !mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new HistoryDatabaseHandler(mContext);
|
||||
}
|
||||
mHistoryHandler.visitHistoryItem(url, title);
|
||||
|
@ -57,11 +57,7 @@ public class HistoryDatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
if (mDatabase != null) {
|
||||
return mDatabase.isOpen();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return mDatabase != null && mDatabase.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -184,10 +180,8 @@ public class HistoryDatabaseHandler extends SQLiteOpenHelper {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_URL, item.getUrl());
|
||||
values.put(KEY_TITLE, item.getTitle());
|
||||
int n = mDatabase.update(TABLE_HISTORY, values, KEY_ID + " = ?",
|
||||
return mDatabase.update(TABLE_HISTORY, values, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(item.getId()) });
|
||||
// updating row
|
||||
return n;
|
||||
}
|
||||
|
||||
// Getting items Count
|
||||
|
@ -140,11 +140,7 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
if (!mTitle.equals(that.mTitle)) {
|
||||
return false;
|
||||
}
|
||||
if (!mUrl.equals(that.mUrl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return mUrl.equals(that.mUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,8 +19,6 @@ public class IntentUtils {
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
private BrowserController mController;
|
||||
|
||||
static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile("(?i)"
|
||||
+ // switch on case insensitive matching
|
||||
"("
|
||||
@ -29,8 +27,7 @@ public class IntentUtils {
|
||||
+ ")" + "(.*)");
|
||||
|
||||
public IntentUtils(BrowserController controller) {
|
||||
mController = controller;
|
||||
mActivity = mController.getActivity();
|
||||
mActivity = controller.getActivity();
|
||||
}
|
||||
|
||||
public boolean startActivityForUrl(WebView tab, String url) {
|
||||
@ -69,6 +66,7 @@ public class IntentUtils {
|
||||
return true;
|
||||
}
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -90,14 +90,13 @@ public class LightningView {
|
||||
if (API > 15) {
|
||||
mWebView.setBackground(null);
|
||||
mWebView.getRootView().setBackground(null);
|
||||
} else {
|
||||
} else if (mWebView.getRootView() != null) {
|
||||
mWebView.getRootView().setBackgroundDrawable(null);
|
||||
}
|
||||
mWebView.setWillNotCacheDrawing(false);
|
||||
mWebView.setAlwaysDrawnWithCacheEnabled(true);
|
||||
mWebView.setScrollbarFadingEnabled(true);
|
||||
mWebView.setSaveEnabled(true);
|
||||
|
||||
mWebView.setWebChromeClient(new LightningChromeClient(activity));
|
||||
mWebView.setWebViewClient(new LightningWebClient(activity));
|
||||
mWebView.setDownloadListener(new LightningDownloadListener(activity));
|
||||
@ -395,9 +394,6 @@ public class LightningView {
|
||||
if (API > 16) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(true);
|
||||
}
|
||||
if (API < 19) {
|
||||
settings.setDatabasePath(context.getCacheDir() + "/databases");
|
||||
}
|
||||
if (API >= Build.VERSION_CODES.LOLLIPOP && !mBrowserController.isIncognito()) {
|
||||
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
|
||||
} else if (API >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
@ -411,20 +407,24 @@ public class LightningView {
|
||||
settings.setDomStorageEnabled(false);
|
||||
}
|
||||
settings.setAppCacheEnabled(true);
|
||||
settings.setAppCachePath(context.getCacheDir().toString());
|
||||
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
settings.setGeolocationDatabasePath(context.getFilesDir().toString());
|
||||
settings.setAllowFileAccess(true);
|
||||
settings.setDatabaseEnabled(true);
|
||||
settings.setSupportZoom(true);
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setDisplayZoomControls(false);
|
||||
settings.setAllowContentAccess(true);
|
||||
settings.setAllowFileAccess(true);
|
||||
settings.setDefaultTextEncodingName("utf-8");
|
||||
if (API > 16) {
|
||||
settings.setAllowFileAccessFromFileURLs(false);
|
||||
settings.setAllowUniversalAccessFromFileURLs(false);
|
||||
}
|
||||
|
||||
settings.setAppCachePath(context.getDir("appcache", 0).getPath());
|
||||
settings.setGeolocationDatabasePath(context.getDir("geolocation", 0).getPath());
|
||||
if (API < Build.VERSION_CODES.KITKAT) {
|
||||
settings.setDatabasePath(context.getDir("databases", 0).getPath());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isShown() {
|
||||
@ -471,11 +471,11 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public void setNormalRendering() {
|
||||
mWebView.setLayerType(View.LAYER_TYPE_NONE, mPaint);
|
||||
mWebView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
|
||||
public void setSoftwareRendering() {
|
||||
mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, mPaint);
|
||||
mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
|
||||
public void setColorMode(int mode) {
|
||||
@ -483,6 +483,9 @@ public class LightningView {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
mPaint.setColorFilter(null);
|
||||
// setSoftwareRendering(); // Some devices get segfaults
|
||||
// in the WebView with Hardware Acceleration enabled,
|
||||
// the only fix is to disable hardware rendering
|
||||
setNormalRendering();
|
||||
mInvertPage = false;
|
||||
break;
|
||||
@ -652,6 +655,16 @@ public class LightningView {
|
||||
mActivity = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||
if (mAdBlock.isAd(request.getUrl().getHost())) {
|
||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
||||
}
|
||||
|
||||
return super.shouldInterceptRequest(view, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||
if (mAdBlock.isAd(url)) {
|
||||
@ -766,7 +779,7 @@ public class LightningView {
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (view.isShown()) {
|
||||
mBrowserController.updateUrl(url, true);
|
||||
view.invalidate();
|
||||
view.postInvalidate();
|
||||
}
|
||||
if (view.getTitle() == null || view.getTitle().isEmpty()) {
|
||||
mTitle.setTitle(mActivity.getString(R.string.untitled));
|
||||
@ -785,7 +798,6 @@ public class LightningView {
|
||||
mBrowserController.updateUrl(url, false);
|
||||
mBrowserController.showActionBar();
|
||||
}
|
||||
|
||||
mTitle.setFavicon(mWebpageBitmap);
|
||||
mBrowserController.update();
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ public class MainActivity extends BrowserActivity {
|
||||
|
||||
@Override
|
||||
public synchronized void initializeTabs() {
|
||||
super.initializeTabs();
|
||||
restoreOrNewTab();
|
||||
// if incognito mode use newTab(null, true); instead
|
||||
}
|
||||
|
@ -162,13 +162,10 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
FilterResults results = new FilterResults();
|
||||
if (constraint == null) {
|
||||
if (constraint == null || constraint.toString() == null) {
|
||||
return results;
|
||||
}
|
||||
String query = constraint.toString().toLowerCase(Locale.getDefault());
|
||||
if (query == null) {
|
||||
return results;
|
||||
}
|
||||
if (mUseGoogle && !mIncognito && !mIsExecuting) {
|
||||
new RetrieveSearchSuggestions().execute(query);
|
||||
}
|
||||
@ -269,11 +266,10 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
try {
|
||||
download.close();
|
||||
} catch (IOException e) {
|
||||
return filter;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user