List of usage examples for android.webkit WebIconDatabase getInstance
public static WebIconDatabase getInstance()
From source file:com.linkbubble.MainService.java
@Override public void onCreate() { mDestroyAllActivities = true;/* ww w . j a v a2s.c o m*/ mRestoreComplete = false; setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark : R.style.MainServiceThemeLight); super.onCreate(); Fabric.with(this, new Crashlytics()); CrashTracking.log("MainService.onCreate()"); showDefaultNotification(); Config.init(this); Settings.get().onOrientationChange(); try { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } catch (RuntimeException exc) { CrashTracking.logHandledException(exc); } MainApplication.mDestroyActivitySharedLock = new Object(); MainApplication.mActivityDestroyed = false; MainController.create(this, new MainController.EventHandler() { @Override public void onDestroy() { Settings.get().saveBubbleRestingPoint(); stopSelf(); CrashTracking.log("MainService.onCreate(): onDestroy()"); } }); //Intent i = new Intent(); //i.setData(Uri.parse("https://t.co/uxMl3bWtMP")); //i.setData(Uri.parse("http://t.co/oOyu7GBZMU")); //i.setData(Uri.parse("http://goo.gl/abc57")); //i.setData(Uri.parse("https://bitly.com/QtQET")); //i.setData(Uri.parse("http://www.duckduckgo.com")); //openUrl("https://www.duckduckgo.com"); //openUrl("http://www.duckduckgo.com", true); //openUrl("https://t.co/uxMl3bWtMP", true); IntentFilter filter = new IntentFilter(); filter.addAction(BCAST_CONFIGCHANGED); registerReceiver(mBroadcastReceiver, filter); registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mScreenReceiver, filter); MainApplication.registerForBus(this, this); }
From source file:com.lemon.lime.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getBatteryPercentage();//ww w .j a v a 2 s .c om setContentView(R.layout.activity_main); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); mWebView = (ObservableWebView) findViewById(R.id.activity_main_webview); mWebView.setScrollViewCallbacks(this); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.bar, null); getSupportActionBar().setCustomView(v); WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mWebView.reload(); } }); swipeLayout.setColorSchemeResources(R.color.lili, R.color.colorPrimary, R.color.red); window = getWindow(); favicon = (ImageView) findViewById(R.id.favicon); editurl = (EditText) findViewById(R.id.editurl); mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); favicon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (lili == 5) { lilimode(); lili = 0; lilimode = true; } else { lili = lili + 1; } } }); editurl.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (event.getAction() == KeyEvent.ACTION_UP) { if (editurl.getText().toString().contains("file:///")) { filemgr(); } else if (editurl.getText().toString().contains("gaymode")) { gaymode(); } else if (editurl.getText().toString().contains("exitapp")) { finish(); } else if (editurl.getText().toString().contains("light")) { flash(); } if (isconnected()) { if (editurl.getText().toString().contains("http://") || editurl.getText().toString().contains("https://")) { mWebView.loadUrl(editurl.getText().toString()); } else if (editurl.getText().toString().contains(".com") || editurl.getText().toString().contains(".net") || editurl.getText().toString().contains(".org") || editurl.getText().toString().contains(".gov") || editurl.getText().toString().contains(".hu") || editurl.getText().toString().contains(".sk") || editurl.getText().toString().contains(".co.uk") || editurl.getText().toString().contains(".co.in") || editurl.getText().toString().contains(".cn") || editurl.getText().toString().contains(".it") || editurl.getText().toString().contains(".de") || editurl.getText().toString().contains(".aus") || editurl.getText().toString().contains(".hr") || editurl.getText().toString().contains(".cz") || editurl.getText().toString().contains(".xyz") || editurl.getText().toString().contains(".pl") || editurl.getText().toString().contains(".io")) { mWebView.loadUrl("http://" + editurl.getText().toString()); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0); } else { mWebView.loadUrl("https://www.google.com/search?q=" + editurl.getText().toString()); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0); } } return true; } return false; } return true; } }); // Enable Javascript WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setSupportMultipleWindows(true); if (isconnected()) { mWebView.loadUrl("http://google.com"); } else { final View coordinatorLayoutView = findViewById(R.id.snackbarPosition); mWebView.loadUrl("file:///android_asset/nonet.html"); Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.offline, Snackbar.LENGTH_LONG); snackbar.show(); } mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onReceivedIcon(WebView mWebView, Bitmap icon) { super.onReceivedIcon(mWebView, icon); favicon.setImageBitmap(icon); } public void onProgressChanged(WebView view, int progress) { activity.setProgress(progress * 100); int a = progress; if (lilimode) { editurl.setText("Liling: " + Integer.toString(a) + "?"); } else editurl.setText("Liming: " + Integer.toString(a) + "%"); if (progress == 100) { editurl.setHint(view.getTitle()); activity.setTitle(view.getTitle()); editurl.setText(view.getUrl()); fav(); //battery if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (level <= 20) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setNavigationBarColor(Color.RED); window.setStatusBarColor(Color.RED); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED)); } } } } }); mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView mWebView, String url) { swipeLayout.setRefreshing(false); } }); }
From source file:com.danielme.android.webviewdemo.WebViewDemoActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) @Override/*from w ww . java 2s .c om*/ public void onCreate(Bundle savedInstanceState) { setTitle("?"); AndroidUtil.removeStrict(); super.onCreate(savedInstanceState); setContentView(R.layout.main); historyStack = new LinkedList<Link>(); webview = (WebView) findViewById(R.id.webkit); faviconImageView = (ImageView) findViewById(R.id.favicon); urlEditText = (EditText) findViewById(R.id.url); progressBar = (ProgressBar) findViewById(R.id.progressbar); stopButton = ((Button) findViewById(R.id.stopButton)); //favicon, deprecated since Android 4.3 but it's still necesary O_O ? WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); freeQuotaSwitch = (Switch) findViewById(R.id.freeQuotaSwitch); leftQuotaText = (TextView) findViewById(R.id.leftQuota); SharedPreferences settings = getSharedPreferences("setting", 0); userid = settings.getString("userid", "123"); tenantid = Integer.parseInt(settings.getString("tenantid", "3")); // check balance long balance = updateLeftQuota(); freeQuotaSwitch.setChecked(balance > 0); tmMgr = new TMManager(); // javascript and zoom webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { webview.getSettings().setPluginState(PluginState.ON); } else { //IMPORTANT!! this method is no longer available since Android 4.3 //so the code doesn't compile anymore //webview.getSettings().setPluginsEnabled(true); } // downloads // webview.setDownloadListener(new CustomDownloadListener()); webview.setWebViewClient(new CustomWebViewClient()); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { progressBar.setProgress(0); FrameLayout progressBarLayout = (FrameLayout) findViewById(R.id.progressBarLayout); progressBarLayout.setVisibility(View.VISIBLE); WebViewDemoActivity.this.setProgress(progress * 1000); TextView progressStatus = (TextView) findViewById(R.id.progressStatus); progressStatus.setText(progress + " %"); progressBar.incrementProgressBy(progress); if (progress == 100) { progressBarLayout.setVisibility(View.GONE); } } @Override public void onReceivedTitle(WebView view, String title) { WebViewDemoActivity.this.setTitle( getString(R.string.app_name) + " - " + WebViewDemoActivity.this.webview.getTitle()); for (Link link : historyStack) { if (link.getUrl().equals(WebViewDemoActivity.this.webview.getUrl())) { link.setTitle(title); } } } @Override public void onReceivedIcon(WebView view, Bitmap icon) { faviconImageView.setImageBitmap(icon); view.getUrl(); boolean b = false; ListIterator<Link> listIterator = historyStack.listIterator(); while (!b && listIterator.hasNext()) { Link link = listIterator.next(); if (link.getUrl().equals(view.getUrl())) { link.setFavicon(icon); b = true; } } } }); //http://stackoverflow.com/questions/2083909/android-webview-refusing-user-input webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); }
From source file:org.zirco.ui.activities.MainActivity.java
@Override protected void onDestroy() { WebIconDatabase.getInstance().close(); if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(Constants.PREFERENCES_PRIVACY_CLEAR_CACHE_ON_EXIT, false)) { mCurrentWebView.clearCache(true); }//from w w w . j ava 2 s . c o m super.onDestroy(); }
From source file:com.dish.browser.activity.BrowserActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") private synchronized void initialize() { setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from www.java 2 s.c o m ActionBar actionBar = getSupportActionBar(); mPreferences = PreferenceManager.getInstance(); mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito(); mActivity = this; mWebViews.clear(); mClickHandler = new ClickHandler(this); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout); // initialize background ColorDrawable mBackground.setColor(((ColorDrawable) mToolbarLayout.getBackground()).getColor()); mUiLayout = (LinearLayout) findViewById(R.id.ui_layout); mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view); RelativeLayout newTab = (RelativeLayout) findViewById(R.id.new_tab_button); mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer); // Drawer stutters otherwise mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list); setNavigationDrawerWidth(); mWebpageBitmap = Utils.getWebpageBitmap(getResources(), mDarkTheme); mHomepage = mPreferences.getHomepage(); mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews); mDrawerListLeft.setAdapter(mTitleAdapter); mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext()); // set display options of the ActionBar actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.toolbar_content); View v = actionBar.getCustomView(); LayoutParams lp = v.getLayoutParams(); lp.width = LayoutParams.MATCH_PARENT; v.setLayoutParams(lp); mArrowDrawable = new DrawerArrowDrawable(this); mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow); // Use hardware acceleration for the animation mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null); mArrowImage.setImageDrawable(mArrowDrawable); LinearLayout arrowButton = (LinearLayout) actionBar.getCustomView().findViewById(R.id.arrow_button); arrowButton.setOnClickListener(this); mI2PHelper = new I2PAndroidHelper(this); RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back); back.setOnClickListener(this); RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward); forward.setOnClickListener(this); // create the search EditText in the ToolBar mSearch = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.search); mUntitledTitle = getString(R.string.untitled); mBackgroundColor = getResources().getColor(R.color.primary_color); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy); } else { Theme theme = getTheme(); mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete, theme); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh, theme); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy, theme); } int iconBounds = Utils.convertDpToPixels(24); mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds); mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds); mCopyIcon.setBounds(0, 0, iconBounds, iconBounds); mIcon = mRefreshIcon; SearchClass search = new SearchClass(); mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); mSearch.setOnKeyListener(search.new KeyListener()); mSearch.setOnFocusChangeListener(search.new FocusChangeListener()); mSearch.setOnEditorActionListener(search.new EditorActionListener()); mSearch.setOnTouchListener(search.new TouchListener()); mSystemBrowser = getSystemBrowser(); Thread initialize = new Thread(new Runnable() { @Override public void run() { initializeSearchSuggestions(mSearch); } }); initialize.run(); newTab.setOnClickListener(this); newTab.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { String url = mPreferences.getSavedUrl(); if (url != null) { newTab(url, true); Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show(); } mPreferences.setSavedUrl(null); return true; } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END); mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START); initializeTabs(); if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } checkForProxy(); }
From source file:org.zirco.ui.activities.MainActivity.java
/** * Initialize the Web icons database.//ww w. ja va 2s. co m */ private void initializeWebIconDatabase() { final WebIconDatabase db = WebIconDatabase.getInstance(); db.open(getDir("icons", 0).getPath()); }
From source file:dev.memento.MainActivity.java
private void initUI() { mDateChosenButton = (Button) findViewById(R.id.dateChosen); mDateDisplayedView = (TextView) findViewById(R.id.dateDisplayed); mNowButton = (Button) findViewById(R.id.nowButton); mNowButton.setEnabled(false);//from w ww .j a v a 2s . c o m mPageLoadingProgressBar = (ProgressBar) findViewById(R.id.pageLoadProgressBar); mPageLoadingProgressBar.setVisibility(View.GONE); mMementoProgressBar = (ProgressBar) findViewById(R.id.loadMementosProgressBar); mMementoProgressBar.setVisibility(View.GONE); mLocation = (AutoCompleteTextView) findViewById(R.id.locationEditText); // Load list of popular URLs so they are easier to enter String[] defaultSites = getResources().getStringArray(R.array.defaultWebsites); if (mLocationAdapter == null) mLocationAdapter = new LocationAutoCompleteAdapter(this, android.R.layout.simple_dropdown_item_1line, defaultSites); mLocation.setAdapter(mLocationAdapter); mLocation.setFocusableInTouchMode(true); mLocation.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // Go to URL if user presses enter if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { String url = Utilities.fixUrl(mLocation.getText().toString()); if (Utilities.isArchiveUrl(url)) { // Don't do anything but load the URL if (Log.LOG) Log.d(LOG_TAG, "Loading archive URL " + url); } else if (Utilities.isValidUrl(url)) { // Always bounce to the present when the user types a URL mOriginalUrl = url; if (Log.LOG) Log.d(LOG_TAG, "Browsing to NOW " + url); mLocationAdapter.add(url); resetMementoButtons(); mCurrentMemento = null; // Clear since we are visiting a different page in the present mMementos.clear(); surfToUrl(mOriginalUrl); // Hide the virtual keyboard ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mLocation.getWindowToken(), 0); mWebview.requestFocus(); return true; } else { MainActivity.this.showToast("Please enter a valid URL."); // Put focus back in text box mHandler.postDelayed(new Runnable() { @Override public void run() { mLocation.requestFocus(); // Select all text mLocation.setSelection(0, mLocation.getText().length()); } }, 200); return true; } } return false; } }); mNextButton = (ImageButton) findViewById(R.id.next); setImageButtonEnabled(false, mNextButton, R.drawable.next_item); mNextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Advance to next Memento Memento nextMemento = null; // This could happen if the index has not been set yet if (mMementos.getCurrentIndex() < 0) { int index = mMementos.getIndexByDate(mDateDisplayed); if (index < 0) { if (Log.LOG) Log.d(LOG_TAG, "Could not find Memento with date " + mDateDisplayed + " (" + mMementos.size() + " mementos). Try to find next another way."); // Try alternative way of getting the next memento nextMemento = mMementos.getNext(mDateDisplayed); } else { mMementos.setCurrentIndex(index); nextMemento = mMementos.getNext(); } } else { // Locate the next Memento in the list nextMemento = mMementos.getNext(); } if (nextMemento == null) { // This could happen if we got redirected to the memento and didn't know // it was the last memento, so the Next button was not disabled if (Log.LOG) Log.d(LOG_TAG, "Still could not find next Memento."); if (Log.LOG) Log.d(LOG_TAG, "Current index is " + mMementos.getCurrentIndex()); setImageButtonEnabled(false, mNextButton, R.drawable.next_item); } else { SimpleDateTime date = nextMemento.getDateTime(); //setChosenDate(nextMemento.getDateTime()); showToast("Time traveling to next Memento on " + date.dateFormatted()); if (Log.LOG) Log.d(LOG_TAG, "Going to next Memento on " + date); mDateDisplayed = date; mCurrentMemento = nextMemento; String redirectUrl = nextMemento.getUrl(); surfToUrl(redirectUrl); // Just in case it wasn't already enabled //mPreviousButton.setEnabled(true); MainActivity.this.setImageButtonEnabled(true, mPreviousButton, R.drawable.previous_item); // If this is the last memento, disable button if (mMementos.isLast(date)) setImageButtonEnabled(false, mNextButton, R.drawable.next_item); } } }); mPreviousButton = (ImageButton) findViewById(R.id.previous); setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item); mPreviousButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Advance to previous Memento Memento prevMemento = null; // This could happen if the index has not been set yet if (mMementos.getCurrentIndex() < 0) { int index = mMementos.getIndexByDate(mDateDisplayed); if (index < 0) { if (Log.LOG) Log.d(LOG_TAG, "Could not find Memento with date " + mDateDisplayed + " (" + mMementos.size() + " mementos). Try to find previous" + " another way."); // Try alternative way of getting the pervious memento prevMemento = mMementos.getPrevious(mDateDisplayed); } else { mMementos.setCurrentIndex(index); prevMemento = mMementos.getPrevious(); } } else { // Locate the prev Memento in the list prevMemento = mMementos.getPrevious(); } if (prevMemento == null) { if (Log.LOG) Log.d(LOG_TAG, "Still could not find previous Memento!"); if (Log.LOG) Log.d(LOG_TAG, "Current index is " + mMementos.getCurrentIndex()); setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item); } else { SimpleDateTime date = prevMemento.getDateTime(); showToast("Time traveling to previous Memento on " + date.dateFormatted()); if (Log.LOG) Log.d(LOG_TAG, "Going to previous Memento on " + date); mDateDisplayed = date; mCurrentMemento = prevMemento; String redirectUrl = prevMemento.getUrl(); surfToUrl(redirectUrl); // Just in case it wasn't already enabled setImageButtonEnabled(true, mNextButton, R.drawable.next_item); // If this is the first memento, disable button if (mMementos.isFirst(date)) setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item); } } }); // Idea to use placeholder and handle orientation changes ourself is from here: // http://www.devahead.com/blog/2012/01/preserving-the-state-of-an-android-webview-on-screen-orientation-change/ webViewPlaceholder = ((FrameLayout) findViewById(R.id.webViewPlaceholder)); if (mWebview == null) { mWebview = new WebView(this); mWebview.setLayoutParams( new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mWebview.getSettings().setSupportZoom(true); mWebview.getSettings().setBuiltInZoomControls(true); mWebview.getSettings().setLoadWithOverviewMode(true); // Setting to true allows the zoom-in to work, but problems moving around. // Sometimes the underlying webview library also set faults and crashes the app // http://stackoverflow.com/questions/17187338/android-fatal-signal-11-sigsegv-in-webviewcorethre // Safer to leave off although zoom won't work. //mWebview.getSettings().setUseWideViewPort(true); mWebview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); mWebview.setScrollbarFadingEnabled(true); mWebview.getSettings().setLoadsImagesAutomatically(true); mWebview.getSettings().setJavaScriptEnabled(true); mWebview.setWebViewClient(new MementoWebViewClient()); mWebview.setWebChromeClient(new MementoWebChromClient()); mWebview.getSettings().setUserAgentString(mUserAgent); // Must be declared before favicons will be received // http://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); surfToUrl(mCurrentUrl); // Get focus away from location field mWebview.requestFocus(); } webViewPlaceholder.addView(mWebview); mWebview.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // Hide the virtual keyboard ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mLocation.getWindowToken(), 0); return false; } }); }
From source file:com.dish.browser.activity.BrowserActivity.java
@SuppressWarnings("deprecation") public void clearHistory() { this.deleteDatabase(HistoryDatabase.DATABASE_NAME); WebViewDatabase m = WebViewDatabase.getInstance(this); m.clearFormData();/* www. j a v a 2 s .com*/ m.clearHttpAuthUsernamePassword(); if (API < 18) { m.clearUsernamePassword(); WebIconDatabase.getInstance().removeAllIcons(); } if (mSystemBrowser) { try { Browser.clearHistory(getContentResolver()); } catch (NullPointerException ignored) { } } Utils.trimCache(this); }
From source file:org.zirco.ui.activities.MainActivity.java
public void onPageFinished(String url) { updateUI();//from w ww . j av a 2s . c om if ((Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_ADBLOCKER_ENABLE, true)) && (!checkInAdBlockWhiteList(mCurrentWebView.getUrl()))) { mCurrentWebView.loadAdSweep(); } WebIconDatabase.getInstance().retainIconForPageUrl(mCurrentWebView.getUrl()); if (mUrlBarVisible) { startToolbarsHideRunnable(); } }