private void actionDelete() { if (urlType == URLTYPE.FEED) { BusProvider.getInstance().post(new UnSaveStoryEvent(DDGControlVar.currentFeedObject.getId())); } else if (urlType == URLTYPE.SERP) { BusProvider.getInstance() .post(new UnSaveSearchEvent(DDGUtils.getQueryIfSerp(mainWebView.getUrl()))); } }
private void actionExternalBrowser() { String webViewUrl = mainWebView.getUrl(); if (webViewUrl == null) { webViewUrl = ""; } Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webViewUrl)); DDGUtils.execIntentIfSafe(getActivity(), browserIntent); }
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (headerMenu != null) { MenuItem backItem = headerMenu.findItem(R.id.action_back); MenuItem forwardItem = headerMenu.findItem(R.id.action_forward); backItem.setEnabled(mainWebView.canGoBack()); forwardItem.setEnabled(mainWebView.canGoForward()); } if (menu == null) { return; } // MenuItem reloadItem = menu.findItem(R.id.action_reload); // reloadItem.setVisible(true); MenuItem saveItem = menu.findItem(R.id.action_add_favorite); MenuItem deleteItem = menu.findItem(R.id.action_remove_favorite); switch (urlType) { case FEED: if (DDGControlVar.currentFeedObject != null) { if (DDGControlVar.currentFeedObject.isSaved()) { saveItem.setVisible(false); deleteItem.setVisible(true); } else { saveItem.setVisible(true); deleteItem.setVisible(false); } } else { saveItem.setVisible(false); deleteItem.setVisible(false); } break; case SERP: String webViewUrl = mainWebView.getUrl(); if (webViewUrl == null) { webViewUrl = ""; } String query = DDGUtils.getQueryIfSerp(webViewUrl); if (DDGApplication.getDB().isSavedSearch(query)) { saveItem.setVisible(false); deleteItem.setVisible(true); } else { saveItem.setVisible(true); deleteItem.setVisible(false); } break; case WEBPAGE: default: saveItem.setVisible(false); deleteItem.setVisible(false); break; } webMenu = menu; }
public void showWebUrl(String url) { if (DDGControlVar.useExternalBrowser == DDGConstants.ALWAYS_EXTERNAL) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); DDGUtils.execIntentIfSafe(context, browserIntent); return; } if (isStorySessionOrStoryUrl()) { DDGControlVar.mDuckDuckGoContainer.lastFeedUrl = url; if (DDGControlVar.currentFeedObject != null) { urlType = URLTYPE.FEED; } } else if (DDGUtils.isSerpUrl(url)) { urlType = URLTYPE.SERP; } else { urlType = URLTYPE.WEBPAGE; } if (!savedState) { mainWebView.setIsReadable(false); mainWebView.loadUrl(url); } }
private void handleShareButtonClick() { // XXX should make Page Options button disabled if the page is not loaded yet // url = null case String webViewUrl = mainWebView.getUrl(); if (webViewUrl == null) { webViewUrl = ""; } // direct displaying after feed item is clicked // the rest will arrive as SESSION_BROWSE // so we should save this feed item with target redirected URL if (isStorySessionOrStoryUrl()) { DDGControlVar.mDuckDuckGoContainer.lastFeedUrl = webViewUrl; if (DDGControlVar.currentFeedObject != null) { new WebViewStoryMenuDialog(context, DDGControlVar.currentFeedObject, mainWebView.isReadable) .show(); // } } else if (DDGUtils.isSerpUrl(webViewUrl)) { new WebViewQueryMenuDialog(context, webViewUrl).show(); } else { new WebViewWebPageMenuDialog(context, webViewUrl).show(); } }
public void searchWebTerm(String term) { DDGControlVar.mDuckDuckGoContainer.sessionType = SESSIONTYPE.SESSION_SEARCH; DDGApplication.getDB().insertRecentSearch(term); // DDGControlVar.mDuckDuckGoContainer.historyAdapter.sync(); if (DDGControlVar.useExternalBrowser == DDGConstants.ALWAYS_EXTERNAL) { DDGUtils.searchExternal(context, term); return; } urlType = URLTYPE.SERP; if (!savedState) { String baseUrl; if (DDGControlVar.regionString.equals("wt-wt")) { // default if (PreferencesManager.getEnableJavascript()) { baseUrl = DDGConstants.SEARCH_URL; } else { baseUrl = DDGConstants.SEARCH_URL_JAVASCRIPT_DISABLED; } mainWebView.loadUrl(baseUrl + URLEncoder.encode(term)); } else { if (PreferencesManager.getEnableJavascript()) { baseUrl = DDGConstants.SEARCH_URL; } else { baseUrl = DDGConstants.SEARCH_URL_JAVASCRIPT_DISABLED; } mainWebView.loadUrl( baseUrl + URLEncoder.encode(term) + "&kl=" + URLEncoder.encode(DDGControlVar.regionString)); } } }