Search in sources :

Example 1 with LightningView

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();
            }
        }
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView) WebView(android.webkit.WebView)

Example 2 with LightningView

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));
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 3 with LightningView

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);
                }
            }
        });
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 4 with LightningView

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();
}
Also used : LightningView(acr.browser.lightning.view.LightningView)

Example 5 with LightningView

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;
    }
}
Also used : LightningView(acr.browser.lightning.view.LightningView) Intent(android.content.Intent)

Aggregations

LightningView (acr.browser.lightning.view.LightningView)28 Intent (android.content.Intent)3 IOException (java.io.IOException)3 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)2 Dialog (android.app.Dialog)2 DialogInterface (android.content.DialogInterface)2 Bundle (android.os.Bundle)2 BookmarkPage (acr.browser.lightning.constant.BookmarkPage)1 DownloadsPage (acr.browser.lightning.constant.DownloadsPage)1 HistoryPage (acr.browser.lightning.constant.HistoryPage)1 StartPage (acr.browser.lightning.constant.StartPage)1 UIController (acr.browser.lightning.controller.UIController)1 HistoryItem (acr.browser.lightning.database.HistoryItem)1 DownloadEntry (acr.browser.lightning.database.downloads.DownloadEntry)1 BookmarksFragment (acr.browser.lightning.fragment.BookmarksFragment)1 TabsFragment (acr.browser.lightning.fragment.TabsFragment)1 IntentUtils (acr.browser.lightning.utils.IntentUtils)1 DownloadManager (android.app.DownloadManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ClipData (android.content.ClipData)1