Browse Source

Fixed more bugs recently introduced. Hardened asynctasks against memory leaks. Fixed some other stuff

master
Anthony Restaino 9 years ago
parent
commit
72ee377a35
  1. 106
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 18
      app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java
  3. 2
      app/src/main/java/acr/browser/lightning/database/BookmarkLocalSync.java
  4. 30
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  5. 2
      app/src/main/java/acr/browser/lightning/object/SearchAdapter.java
  6. 20
      app/src/main/java/acr/browser/lightning/view/LightningView.java

106
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -161,11 +161,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private ValueCallback<Uri[]> mFilePathCallback; private ValueCallback<Uri[]> mFilePathCallback;
// Primatives // Primatives
private boolean mFullScreen, mColorMode, mDarkTheme, private boolean mFullScreen;
mIsNewIntent = false, private boolean mDarkTheme;
mIsFullScreen = false, private boolean mIsNewIntent = false;
mIsImmersive = false, private boolean mIsFullScreen = false;
mShowTabsInDrawer; private boolean mIsImmersive = false;
private boolean mShowTabsInDrawer;
private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor, private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor,
mCurrentUiColor = Color.BLACK; mCurrentUiColor = Color.BLACK;
private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath; private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath;
@ -405,7 +406,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if (!hasFocus && currentView != null) { if (!hasFocus && currentView != null) {
setIsLoading(currentView.getProgress() < 100); setIsLoading(currentView.getProgress() < 100);
updateUrl(currentView.getUrl(), true); updateUrl(currentView.getUrl(), true);
} else if (hasFocus) { } else if (hasFocus && currentView != null) {
String url = currentView.getUrl(); String url = currentView.getUrl();
if (url.startsWith(Constants.FILE)) { if (url.startsWith(Constants.FILE)) {
mSearch.setText(""); mSearch.setText("");
@ -559,11 +560,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private void initializePreferences() { private void initializePreferences() {
final LightningView currentView = tabsManager.getCurrentTab(); final LightningView currentView = tabsManager.getCurrentTab();
final WebView currentWebView = currentView.getWebView(); final WebView currentWebView = tabsManager.getCurrentWebView();
mFullScreen = mPreferences.getFullScreenEnabled(); mFullScreen = mPreferences.getFullScreenEnabled();
mColorMode = mPreferences.getColorModeEnabled(); boolean colorMode = mPreferences.getColorModeEnabled();
mColorMode &= !mDarkTheme; colorMode &= !mDarkTheme;
if (!isIncognito() && !mColorMode && !mDarkTheme && mWebpageBitmap != null) { if (!isIncognito() && !colorMode && !mDarkTheme && mWebpageBitmap != null) {
changeToolbarBackground(mWebpageBitmap, null); changeToolbarBackground(mWebpageBitmap, null);
} else if (!isIncognito() && currentView != null && !mDarkTheme } else if (!isIncognito() && currentView != null && !mDarkTheme
&& currentView.getFavicon() != null) { && currentView.getFavicon() != null) {
@ -731,9 +732,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
findInPage(); findInPage();
return true; return true;
case R.id.action_reading_mode: case R.id.action_reading_mode:
if (currentView != null) {
Intent read = new Intent(this, ReadingActivity.class); Intent read = new Intent(this, ReadingActivity.class);
read.putExtra(Constants.LOAD_READING_URL, currentView.getUrl()); read.putExtra(Constants.LOAD_READING_URL, currentView.getUrl());
startActivity(read); startActivity(read);
}
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -822,6 +825,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
final WebView currentWebView = currentView != null ? currentView.getWebView() : null; final WebView currentWebView = currentView != null ? currentView.getWebView() : null;
final LightningView newView = tabsManager.switchToTab(position); final LightningView newView = tabsManager.switchToTab(position);
final WebView newWebView = newView != null ? newView.getWebView() : null; final WebView newWebView = newView != null ? newView.getWebView() : null;
if (newView == null || newWebView == null) {
return;
}
// Set the background color so the color mode color doesn't show through // Set the background color so the color mode color doesn't show through
mBrowserFrame.setBackgroundColor(mBackgroundColor); mBrowserFrame.setBackgroundColor(mBackgroundColor);
@ -946,7 +952,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
} }
synchronized boolean newTab(String url, boolean show) { private synchronized boolean newTab(String url, boolean show) {
// Limit number of tabs for limited version of app // Limit number of tabs for limited version of app
if (!Constants.FULL_VERSION && tabsManager.size() >= 10) { if (!Constants.FULL_VERSION && tabsManager.size() >= 10) {
Utils.showSnackbar(this, R.string.max_tabs); Utils.showSnackbar(this, R.string.max_tabs);
@ -984,11 +990,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return; return;
} }
// What?
int current = tabsManager.positionOf(currentTab); int current = tabsManager.positionOf(currentTab);
if (current < 0) {
return;
}
if (!tabToDelete.getUrl().startsWith(Constants.FILE) && !isIncognito()) { if (!tabToDelete.getUrl().startsWith(Constants.FILE) && !isIncognito()) {
mPreferences.setSavedUrl(tabToDelete.getUrl()); mPreferences.setSavedUrl(tabToDelete.getUrl());
} }
@ -1016,9 +1019,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
showTab(position - 1); showTab(position - 1);
mEventBus.post(new BrowserEvents.TabsChanged()); mEventBus.post(new BrowserEvents.TabsChanged());
} else { } else {
tabsManager.deleteTab(position);
} }
} else { } else {
if (currentTab.getUrl().startsWith(Constants.FILE) || currentTab.getUrl().equals(mHomepage)) { if (currentTab != null && (currentTab.getUrl().startsWith(Constants.FILE)
|| currentTab.getUrl().equals(mHomepage))) {
closeActivity(); closeActivity();
} else { } else {
tabsManager.deleteTab(position); tabsManager.deleteTab(position);
@ -1130,7 +1135,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
void saveOpenTabs() { void saveOpenTabs() {
if (mPreferences.getRestoreLostTabsEnabled()) { if (mPreferences.getRestoreLostTabsEnabled()) {
final String s = tabsManager.tabsString(); final String s = tabsManager.tabsString();
mPreferences.setMemoryUrl(s.toString()); mPreferences.setMemoryUrl(s);
} }
} }
@ -1192,8 +1197,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
String searchUrl = mSearchText + UrlUtils.QUERY_PLACE_HOLDER; String searchUrl = mSearchText + UrlUtils.QUERY_PLACE_HOLDER;
query = query.trim(); query = query.trim();
currentTab.stopLoading();
if (currentTab != null) { if (currentTab != null) {
currentTab.stopLoading();
loadUrlInCurrentView(UrlUtils.smartUrlFilter(query, true, searchUrl)); loadUrlInCurrentView(UrlUtils.smartUrlFilter(query, true, searchUrl));
} }
} }
@ -1318,31 +1323,35 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* previously searched URLs * previously searched URLs
*/ */
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) { private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
final LightningView currentTab = tabsManager.getCurrentTab();
getUrl.setThreshold(1); getUrl.setThreshold(1);
getUrl.setDropDownWidth(-1); getUrl.setDropDownWidth(-1);
getUrl.setDropDownAnchor(R.id.toolbar_layout); getUrl.setDropDownAnchor(R.id.toolbar_layout);
getUrl.setOnItemClickListener(new OnItemClickListener() { getUrl.setOnItemClickListener(new OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
try { String url = null;
String url; CharSequence urlString = ((TextView) view.findViewById(R.id.url)).getText();
url = ((TextView) arg1.findViewById(R.id.url)).getText().toString(); if (urlString != null) {
if (url.startsWith(BrowserActivity.this.getString(R.string.suggestion))) { url = urlString.toString();
url = ((TextView) arg1.findViewById(R.id.title)).getText().toString(); }
} else { if (url == null || url.startsWith(BrowserActivity.this.getString(R.string.suggestion))) {
getUrl.setText(url); CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
if (searchString != null) {
url = searchString.toString();
}
}
if (url == null) {
return;
} }
getUrl.setText(url);
searchTheWeb(url); searchTheWeb(url);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
final LightningView currentTab = tabsManager.getCurrentTab();
if (currentTab != null) { if (currentTab != null) {
currentTab.requestFocus(); currentTab.requestFocus();
} }
} catch (NullPointerException e) {
Log.e("Browser Error: ", "NullPointerException on item click");
}
} }
}); });
@ -1521,7 +1530,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS); mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS);
decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
setFullscreen(true, true); setFullscreen(true, true);
if (currentTab != null) {
currentTab.setVisibility(View.GONE); currentTab.setVisibility(View.GONE);
}
if (view instanceof FrameLayout) { if (view instanceof FrameLayout) {
if (((FrameLayout) view).getFocusedChild() instanceof VideoView) { if (((FrameLayout) view).getFocusedChild() instanceof VideoView) {
mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild(); mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild();
@ -1633,18 +1644,22 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* the newly created WebView. * the newly created WebView.
*/ */
@Override @Override
public void onCreateWindow(Message resultMsg) { public synchronized void onCreateWindow(Message resultMsg) {
if (resultMsg == null) { if (resultMsg == null) {
return; return;
} }
if (newTab("", true)) { if (newTab("", true)) {
// TODO Review this LightningView newTab = tabsManager.getTabAtPosition(tabsManager.size() - 1);
final WebView webView = tabsManager.getTabAtPosition(tabsManager.size() - 1).getWebView(); if (newTab != null) {
final WebView webView = newTab.getWebView();
if (webView != null) {
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(webView); transport.setWebView(webView);
resultMsg.sendToTarget(); resultMsg.sendToTarget();
} }
} }
}
}
/** /**
* Closes the specified {@link LightningView}. This implements * Closes the specified {@link LightningView}. This implements
@ -1666,8 +1681,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
*/ */
@Override @Override
public void hideActionBar() { public void hideActionBar() {
final LightningView currentTab = tabsManager.getCurrentTab(); final WebView currentWebView = tabsManager.getCurrentWebView();
final WebView currentWebView = currentTab.getWebView();
if (mFullScreen) { if (mFullScreen) {
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) { if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout); mUiLayout.removeView(mToolbarLayout);
@ -1675,21 +1689,21 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mToolbarLayout.bringToFront(); mToolbarLayout.bringToFront();
Log.d(Constants.TAG, "Move view to browser frame"); Log.d(Constants.TAG, "Move view to browser frame");
mToolbarLayout.setTranslationY(0); mToolbarLayout.setTranslationY(0);
if (currentWebView != null) {
currentWebView.setTranslationY(mToolbarLayout.getHeight()); currentWebView.setTranslationY(mToolbarLayout.getHeight());
} }
if (mToolbarLayout == null || currentTab == null) }
if (mToolbarLayout == null || currentWebView == null)
return; return;
final int height = mToolbarLayout.getHeight(); final int height = mToolbarLayout.getHeight();
final WebView view = currentWebView;
if (mToolbarLayout.getTranslationY() > -0.01f) { if (mToolbarLayout.getTranslationY() > -0.01f) {
Animation show = new Animation() { Animation show = new Animation() {
@Override @Override
protected void applyTransformation(float interpolatedTime, Transformation t) { protected void applyTransformation(float interpolatedTime, Transformation t) {
float trans = (1.0f - interpolatedTime) * height; float trans = (1.0f - interpolatedTime) * height;
mToolbarLayout.setTranslationY(trans - height); mToolbarLayout.setTranslationY(trans - height);
if (view != null) currentWebView.setTranslationY(trans);
view.setTranslationY(trans);
} }
}; };
show.setDuration(250); show.setDuration(250);
@ -1791,25 +1805,27 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Override @Override
public void onClick(View v) { public void onClick(View v) {
final LightningView currentTab = tabsManager.getCurrentTab(); final LightningView currentTab = tabsManager.getCurrentTab();
final WebView currentWebView = currentTab.getWebView(); if (currentTab == null) {
return;
}
switch (v.getId()) { switch (v.getId()) {
case R.id.arrow_button: case R.id.arrow_button:
if (mSearch != null && mSearch.hasFocus()) { if (mSearch != null && mSearch.hasFocus()) {
currentTab.requestFocus(); currentTab.requestFocus();
} else if (mShowTabsInDrawer) { } else if (mShowTabsInDrawer) {
mDrawerLayout.openDrawer(mDrawerLeft); mDrawerLayout.openDrawer(mDrawerLeft);
} else if (currentTab != null) { } else {
currentTab.loadHomepage(); currentTab.loadHomepage();
} }
break; break;
case R.id.button_next: case R.id.button_next:
currentWebView.findNext(false); currentTab.findNext();
break; break;
case R.id.button_back: case R.id.button_back:
currentWebView.findNext(true); currentTab.findPrevious();
break; break;
case R.id.button_quit: case R.id.button_quit:
currentWebView.clearMatches(); currentTab.clearFindMatches();
mSearchBar.setVisibility(View.GONE); mSearchBar.setVisibility(View.GONE);
break; break;
case R.id.action_reading: case R.id.action_reading:
@ -1963,7 +1979,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Subscribe @Subscribe
public void bookmarkChanged(final BookmarkEvents.BookmarkChanged event) { public void bookmarkChanged(final BookmarkEvents.BookmarkChanged event) {
final LightningView currentTab = tabsManager.getCurrentTab(); final LightningView currentTab = tabsManager.getCurrentTab();
final WebView currentWebView = currentTab.getWebView();
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE) if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) { && currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
currentTab.loadBookmarkpage(); currentTab.loadBookmarkpage();
@ -1981,7 +1996,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Subscribe @Subscribe
public void bookmarkDeleted(final BookmarkEvents.Deleted event) { public void bookmarkDeleted(final BookmarkEvents.Deleted event) {
final LightningView currentTab = tabsManager.getCurrentTab(); final LightningView currentTab = tabsManager.getCurrentTab();
final WebView currentWebView = currentTab.getWebView();
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE) if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) { && currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
currentTab.loadBookmarkpage(); currentTab.loadBookmarkpage();

18
app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java

@ -21,6 +21,8 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView; import android.widget.TextView;
import java.lang.ref.WeakReference;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.constant.Constants; import acr.browser.lightning.constant.Constants;
@ -39,6 +41,7 @@ public class ReadingActivity extends AppCompatActivity {
private PreferenceManager mPreferences; private PreferenceManager mPreferences;
private int mTextSize; private int mTextSize;
private ProgressDialog mProgressDialog; private ProgressDialog mProgressDialog;
private PageLoader mLoaderReference;
private static final float XXLARGE = 30.0f; private static final float XXLARGE = 30.0f;
private static final float XLARGE = 26.0f; private static final float XLARGE = 26.0f;
@ -130,30 +133,34 @@ public class ReadingActivity extends AppCompatActivity {
} }
if (getSupportActionBar() != null) if (getSupportActionBar() != null)
getSupportActionBar().setTitle(Utils.getDomainName(mUrl)); getSupportActionBar().setTitle(Utils.getDomainName(mUrl));
new PageLoader(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mUrl); mLoaderReference = new PageLoader(this);
mLoaderReference.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mUrl);
return true; return true;
} }
private class PageLoader extends AsyncTask<String, Void, Void> { private class PageLoader extends AsyncTask<String, Void, Void> {
private final Activity mActivity; private final WeakReference<Activity> mActivityReference;
private String mTitleText; private String mTitleText;
private String mBodyText; private String mBodyText;
public PageLoader(Activity activity) { public PageLoader(Activity activity) {
mActivity = activity; mActivityReference = new WeakReference<>(activity);
} }
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
mProgressDialog = new ProgressDialog(mActivity); Activity activity = mActivityReference.get();
if (activity != null) {
mProgressDialog = new ProgressDialog(activity);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.setCancelable(false); mProgressDialog.setCancelable(false);
mProgressDialog.setIndeterminate(true); mProgressDialog.setIndeterminate(true);
mProgressDialog.setMessage(mActivity.getString(R.string.loading)); mProgressDialog.setMessage(activity.getString(R.string.loading));
mProgressDialog.show(); mProgressDialog.show();
} }
}
@Override @Override
protected Void doInBackground(String... params) { protected Void doInBackground(String... params) {
@ -224,6 +231,7 @@ public class ReadingActivity extends AppCompatActivity {
mProgressDialog.dismiss(); mProgressDialog.dismiss();
mProgressDialog = null; mProgressDialog = null;
} }
mLoaderReference.cancel(true);
super.onDestroy(); super.onDestroy();
} }

2
app/src/main/java/acr/browser/lightning/database/BookmarkLocalSync.java

@ -26,7 +26,7 @@ public class BookmarkLocalSync {
private final Context mContext; private final Context mContext;
public BookmarkLocalSync(Context context) { public BookmarkLocalSync(@NonNull Context context) {
mContext = context; mContext = context;
} }

30
app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java

@ -5,6 +5,7 @@ package acr.browser.lightning.fragment;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
@ -15,6 +16,7 @@ import android.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -45,9 +47,17 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE Manifest.permission.WRITE_EXTERNAL_STORAGE
}; };
private ImportBookmarksTask mImportTaskReference;
private static final File mPath = new File(Environment.getExternalStorageDirectory().toString()); private static final File mPath = new File(Environment.getExternalStorageDirectory().toString());
private class ImportBookmarksTask extends AsyncTask<Void, Void, Integer> { private class ImportBookmarksTask extends AsyncTask<Void, Void, Integer> {
private WeakReference<Activity> mActivityReference;
public ImportBookmarksTask(Activity activity) {
mActivityReference = new WeakReference<>(activity);
}
@Override @Override
protected Integer doInBackground(Void... params) { protected Integer doInBackground(Void... params) {
List<HistoryItem> list = null; List<HistoryItem> list = null;
@ -67,10 +77,11 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
@Override @Override
protected void onPostExecute(Integer num) { protected void onPostExecute(Integer num) {
super.onPostExecute(num); super.onPostExecute(num);
if (mActivity != null) { Activity activity = mActivityReference.get();
if (activity != null) {
int number = num; int number = num;
final String message = mActivity.getResources().getString(R.string.message_import); final String message = activity.getResources().getString(R.string.message_import);
Utils.showSnackbar(mActivity, number + " " + message); Utils.showSnackbar(activity, number + " " + message);
} }
} }
} }
@ -96,6 +107,9 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mActivity = null; mActivity = null;
if (mImportTaskReference != null) {
mImportTaskReference.cancel(false);
}
} }
private void initPrefs() { private void initPrefs() {
@ -124,9 +138,6 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_EXPORT: case SETTINGS_EXPORT:
// if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) {
// mBookmarkManager.exportBookmarks(getActivity());
// }
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS, PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
new PermissionsManager.PermissionResult() { new PermissionsManager.PermissionResult() {
@Override @Override
@ -141,10 +152,6 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
}); });
return true; return true;
case SETTINGS_IMPORT: case SETTINGS_IMPORT:
// if (PermissionsManager.checkPermissions(getActivity(), REQUIRED_PERMISSIONS)) {
// loadFileList(null);
// createDialog();
// }
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS, PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
new PermissionsManager.PermissionResult() { new PermissionsManager.PermissionResult() {
@Override @Override
@ -160,7 +167,8 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
}); });
return true; return true;
case SETTINGS_IMPORT_BROWSER: case SETTINGS_IMPORT_BROWSER:
new ImportBookmarksTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); mImportTaskReference = new ImportBookmarksTask(getActivity());
mImportTaskReference.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true; return true;
default: default:
return false; return false;

2
app/src/main/java/acr/browser/lightning/object/SearchAdapter.java

@ -414,7 +414,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
return connectivity.getActiveNetworkInfo(); return connectivity.getActiveNetworkInfo();
} }
private List<HistoryItem> getFilteredList() { private synchronized List<HistoryItem> getFilteredList() {
List<HistoryItem> list = new ArrayList<>(5); List<HistoryItem> list = new ArrayList<>(5);
synchronized (mBookmarks) { synchronized (mBookmarks) {
synchronized (mHistory) { synchronized (mHistory) {

20
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -582,6 +582,24 @@ public class LightningView {
} }
} }
public synchronized void findNext() {
if (mWebView != null) {
mWebView.findNext(true);
}
}
public synchronized void findPrevious() {
if (mWebView != null) {
mWebView.findNext(false);
}
}
public synchronized void clearFindMatches() {
if (mWebView != null) {
mWebView.clearMatches();
}
}
/** /**
* Used by {@link LightningWebClient} * Used by {@link LightningWebClient}
* *
@ -646,7 +664,7 @@ public class LightningView {
} }
@Nullable @Nullable
public WebView getWebView() { public synchronized WebView getWebView() {
return mWebView; return mWebView;
} }

Loading…
Cancel
Save