use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method onCreateWindow.
/**
* This method handles the JavaScript callback to create a new tab.
* Basically this handles the event that JavaScript needs to create
* a popup.
*
* @param resultMsg the transport message used to send the URL to
* the newly created WebView.
*/
@Override
public synchronized void onCreateWindow(Message resultMsg) {
if (resultMsg == null) {
return;
}
if (newTab("", true)) {
LightningView newTab = mTabsManager.getTabAtPosition(mTabsManager.size() - 1);
if (newTab != null) {
final WebView webView = newTab.getWebView();
if (webView != null) {
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(webView);
resultMsg.sendToTarget();
}
}
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method searchTheWeb.
/**
* searches the web for the query fixing any and all problems with the input
* checks if it is a search, url, etc.
*/
private void searchTheWeb(@NonNull String query) {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (query.isEmpty()) {
return;
}
String searchUrl = mSearchText + UrlUtils.QUERY_PLACE_HOLDER;
query = query.trim();
if (currentTab != null) {
currentTab.stopLoading();
mPresenter.loadUrlInCurrentView(UrlUtils.smartUrlFilter(query, true, searchUrl));
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method bookmarkButtonClicked.
@Override
public void bookmarkButtonClicked() {
final LightningView currentTab = mTabsManager.getCurrentTab();
final String url = currentTab != null ? currentTab.getUrl() : null;
final String title = currentTab != null ? currentTab.getTitle() : null;
if (url == null) {
return;
}
if (!UrlUtils.isSpecialUrl(url)) {
mBookmarkManager.isBookmark(url).subscribeOn(Schedulers.io()).observeOn(Schedulers.main()).subscribe(new SingleOnSubscribe<Boolean>() {
@Override
public void onItem(@Nullable Boolean item) {
if (Boolean.TRUE.equals(item)) {
deleteBookmark(title, url);
} else {
addBookmark(title, url);
}
}
});
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method performExitCleanUp.
void performExitCleanUp() {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
WebUtils.clearCache(currentTab.getWebView());
Log.d(TAG, "Cache Cleared");
}
if (mPreferences.getClearHistoryExitEnabled() && !isIncognito()) {
WebUtils.clearHistory(this);
Log.d(TAG, "History Cleared");
}
if (mPreferences.getClearCookiesExitEnabled() && !isIncognito()) {
WebUtils.clearCookies(this);
Log.d(TAG, "Cookies Cleared");
}
if (mPreferences.getClearWebStorageExitEnabled() && !isIncognito()) {
WebUtils.clearWebStorage();
Log.d(TAG, "WebStorage Cleared");
} else if (isIncognito()) {
// We want to make sure incognito mode is secure
WebUtils.clearWebStorage();
}
mSuggestionsAdapter.clearCache();
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method onClick.
/**
* Handle the click event for the views that are using
* this class as a click listener. This method should
* distinguish between the various views using their IDs.
*
* @param v the view that the user has clicked
*/
@Override
public void onClick(View v) {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab == null) {
return;
}
switch(v.getId()) {
case R.id.arrow_button:
if (mSearch != null && mSearch.hasFocus()) {
currentTab.requestFocus();
} else if (mShowTabsInDrawer) {
mDrawerLayout.openDrawer(getTabDrawer());
} else {
currentTab.loadHomepage();
}
break;
case R.id.button_next:
currentTab.findNext();
break;
case R.id.button_back:
currentTab.findPrevious();
break;
case R.id.button_quit:
currentTab.clearFindMatches();
mSearchBar.setVisibility(View.GONE);
break;
case R.id.action_reading:
Intent read = new Intent(this, ReadingActivity.class);
read.putExtra(Constants.LOAD_READING_URL, currentTab.getUrl());
startActivity(read);
break;
case R.id.action_toggle_desktop:
currentTab.toggleDesktopUA(this);
currentTab.reload();
closeDrawers(null);
break;
}
}
Aggregations