List of usage examples for android.webkit WebView setBackgroundColor
@Override public void setBackgroundColor(int color)
From source file:im.vector.adapters.VectorMediasViewerAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.adapter_vector_medias_viewer, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view.findViewById(R.id.media_slider_piechart); pieFractionView.setVisibility(View.GONE); final WebView imageWebView = (WebView) view.findViewById(R.id.media_slider_image_webview); final View videoLayout = view.findViewById(R.id.media_slider_videolayout); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); imageWebView.getSettings().setDisplayZoomControls(false); imageWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override//from www.j a v a2 s . com public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); thumbView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); // black background view.setBackgroundColor(0xFF000000); imageWebView.setBackgroundColor(0xFF000000); videoLayout.setBackgroundColor(0xFF000000); final SlidableMediaInfo mediaInfo = mMediasMessagesList.get(position); String mediaUrl = mediaInfo.mMediaUrl; if (mediaInfo.mMessageType.equals(Message.MSGTYPE_IMAGE)) { imageWebView.setVisibility(View.VISIBLE); imageWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); imageWebView.getSettings().setJavaScriptEnabled(true); imageWebView.getSettings().setLoadWithOverviewMode(true); imageWebView.getSettings().setUseWideViewPort(true); imageWebView.getSettings().setBuiltInZoomControls(true); videoLayout.setVisibility(View.GONE); final int rotationAngle = mediaInfo.mRotationAngle; final String mimeType = mediaInfo.mMimeType; File mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); } } else { // try to retrieve the thumbnail mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mMaxImageWidth, mMaxImageHeight, null); } // the thumbnail is not yet downloaded if (null == mediaFile) { // display nothing container.addView(view, 0); return view; } String mediaUri = "file://" + mediaFile.getPath(); String css = computeCss(mediaUri, mMaxImageWidth, mMaxImageHeight, rotationAngle); final String viewportContent = "width=640"; loadImage(imageWebView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); } else { loadVideo(position, view, mediaInfo.mThumbnailUrl, mediaUrl, mediaInfo.mMimeType); container.addView(view, 0); } // check if the media is downloading String downloadId = mMediasCache.downloadMedia(mContext, mSession.getHomeserverConfig(), mediaUrl, mediaInfo.mMimeType); if (null != downloadId) { pieFractionView.setVisibility(View.VISIBLE); pieFractionView.setFraction(mMediasCache.getProgressValueForDownloadId(downloadId)); pieFractionView.setTag(downloadId); mMediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { pieFractionView.setVisibility(View.GONE); MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMediasViewerAdapter.this.mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadProgress(String aDownloadId, DownloadStats stats) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setFraction(stats.mProgress); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setVisibility(View.GONE); } } }); } return view; }
From source file:im.neon.adapters.VectorMediasViewerAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.adapter_vector_medias_viewer, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view.findViewById(R.id.media_slider_piechart); pieFractionView.setVisibility(View.GONE); final WebView imageWebView = (WebView) view.findViewById(R.id.media_slider_image_webview); final View videoLayout = view.findViewById(R.id.media_slider_videolayout); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); imageWebView.getSettings().setDisplayZoomControls(false); imageWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override// w ww .ja v a 2 s . c om public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); thumbView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { VectorMediasViewerAdapter.this.onLongClick(); return true; } }); // black background view.setBackgroundColor(0xFF000000); imageWebView.setBackgroundColor(0xFF000000); videoLayout.setBackgroundColor(0xFF000000); final SlidableMediaInfo mediaInfo = mMediasMessagesList.get(position); String mediaUrl = mediaInfo.mMediaUrl; if (mediaInfo.mMessageType.equals(Message.MSGTYPE_IMAGE)) { imageWebView.setVisibility(View.VISIBLE); imageWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); imageWebView.getSettings().setJavaScriptEnabled(true); imageWebView.getSettings().setLoadWithOverviewMode(true); imageWebView.getSettings().setUseWideViewPort(true); imageWebView.getSettings().setBuiltInZoomControls(true); videoLayout.setVisibility(View.GONE); final int rotationAngle = mediaInfo.mRotationAngle; if (TextUtils.isEmpty(mediaInfo.mMimeType)) { mediaInfo.mMimeType = "image/jpeg"; } final String mimeType = mediaInfo.mMimeType; File mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); } } else { // try to retrieve the thumbnail mediaFile = mMediasCache.mediaCacheFile(mediaUrl, mMaxImageWidth, mMaxImageHeight, null); } // the thumbnail is not yet downloaded if (null == mediaFile) { // display nothing container.addView(view, 0); return view; } String mediaUri = "file://" + mediaFile.getPath(); String css = computeCss(mediaUri, mMaxImageWidth, mMaxImageHeight, rotationAngle); final String viewportContent = "width=640"; loadImage(imageWebView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); } else { loadVideo(position, view, mediaInfo.mThumbnailUrl, mediaUrl, mediaInfo.mMimeType); container.addView(view, 0); } // check if the media is downloading String downloadId = mMediasCache.downloadMedia(mContext, mSession.getHomeserverConfig(), mediaUrl, mediaInfo.mMimeType, mediaInfo.mEncryptedFileInfo); if (null != downloadId) { pieFractionView.setVisibility(View.VISIBLE); pieFractionView.setFraction(mMediasCache.getProgressValueForDownloadId(downloadId)); pieFractionView.setTag(downloadId); mMediasCache.addDownloadListener(downloadId, new MXMediaDownloadListener() { @Override public void onDownloadError(String downloadId, JsonElement jsonElement) { pieFractionView.setVisibility(View.GONE); MatrixError error = JsonUtils.toMatrixError(jsonElement); if ((null != error) && error.isSupportedErrorCode()) { Toast.makeText(VectorMediasViewerAdapter.this.mContext, error.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onDownloadProgress(String aDownloadId, DownloadStats stats) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setFraction(stats.mProgress); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(pieFractionView.getTag())) { pieFractionView.setVisibility(View.GONE); } } }); } return view; }
From source file:com.lcl.thumbweather.MainActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("ThumbWeather"); final WebView webView = new WebView(this); String about = "<p>A light,open source App.</p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; if (darkTheme) { // Style text color for dark theme about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:white;\n" + "}\n" + "a:link {color:cyan}\n" + "</style>" + about; }//from w w w. jav a 2 s. co m webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:ru.frostdev.weather.MainActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("About"); final WebView webView = new WebView(this); String about = "<p>A lightweight, opensource weather app.</p>" + "<p>Developed by <a href='FrostDev:mrfrost2035@gmail.com'>FrostDev</a></p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; if (darkTheme) { // Style text color for dark theme about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:white;\n" + "}\n" + "a:link {color:cyan}\n" + "</style>" + about; }/*from w w w . j a v a 2s. c o m*/ webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:com.forecast.weather.activities.MainActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Forecast Weather"); final WebView webView = new WebView(this); String about = "<p>Forecast weather app.</p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; TypedArray ta = obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary, R.attr.colorAccent }); String textColor = String.format("#%06X", (0xFFFFFF & ta.getColor(0, Color.BLACK))); String accentColor = String.format("#%06X", (0xFFFFFF & ta.getColor(1, Color.BLUE))); ta.recycle();/*from w w w. j av a 2 s .co m*/ about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:" + textColor + ";\n" + "}\n" + "a:link {color:" + accentColor + "}\n" + "</style>" + about; webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:ir.actfun.toofan.activities.NowWeatherPage.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Toofan"); final WebView webView = new WebView(this); String about = "<p>A lightweight, opensource weather app.</p>" + "<p>Developed by <a href='mailto:t.martykan@gmail.com'>Tomas Martykan</a></p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; if (darkTheme) { // Style text color for dark theme about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:white;\n" + "}\n" + "a:link {color:cyan}\n" + "</style>" + about; }/*from w w w . ja v a 2 s .co m*/ webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:com.nextgis.mobile.fragment.AttributesFragment.java
private void setAttributes() { if (mAttributes == null) return;//from www .j a va 2s . c o m mAttributes.removeAllViews(); int[] attrs = new int[] { android.R.attr.textColorPrimary }; TypedArray ta = getContext().obtainStyledAttributes(attrs); String textColor = Integer.toHexString(ta.getColor(0, Color.BLACK)).substring(2); ta.recycle(); final WebView webView = new WebView(getContext()); webView.setVerticalScrollBarEnabled(false); String data = "<!DOCTYPE html><html><head><meta charset='utf-8'><style>body{word-wrap:break-word;color:#" + textColor + ";font-family:Roboto Light,sans-serif;font-weight:300;line-height:1.15em}.flat-table{table-layout:fixed;margin-bottom:20px;width:100%;border-collapse:collapse;border:none;box-shadow:inset 1px -1px #ccc,inset -1px 1px #ccc}.flat-table td{box-shadow:inset -1px -1px #ccc,inset -1px -1px #ccc;padding:.5em}.flat-table tr{-webkit-transition:background .3s,box-shadow .3s;-moz-transition:background .3s,box-shadow .3s;transition:background .3s,box-shadow .3s}</style></head><body><table class='flat-table'><tbody>"; FragmentActivity activity = getActivity(); if (null == activity) return; ((MainActivity) activity).setSubtitle(String.format(getString(R.string.features_count_attributes), mItemPosition + 1, mFeatureIDs.size())); checkNearbyItems(); try { data = parseAttributes(data); } catch (RuntimeException e) { e.printStackTrace(); } data += "</tbody></table></body></html>"; webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null); mAttributes.addView(webView); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { webView.setBackgroundColor(Color.TRANSPARENT); } public boolean shouldOverrideUrlLoading(WebView view, String url) { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } }); IGISApplication app = (GISApplication) getActivity().getApplication(); final Map<String, Integer> mAttaches = new HashMap<>(); PhotoGallery.getAttaches(app, mLayer, mItemId, mAttaches, false); if (mAttaches.size() > 0) { final PhotoPicker gallery = new PhotoPicker(getActivity(), true); int px = ControlHelper.dpToPx(16, getResources()); gallery.setDefaultPreview(true); gallery.setPadding(px, 0, px, 0); gallery.post(new Runnable() { @Override public void run() { gallery.restoreImages(new ArrayList<>(mAttaches.keySet())); } }); mAttributes.addView(gallery); } }
From source file:com.cs528.style.style.weather.WeatherActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Style"); final WebView webView = new WebView(this); String about = "<p>Developed by KuangXIONG, Tengyang Jia, ZhaojunYang</p>" + "<p>A cloth suggestion application</p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Weather Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence." + "<p>Cloth Icons are <a href='http://pictofoundry.com/'>PictoFoundry Font Pack 2</a>, bought by TengyangJia</p>"; if (darkTheme) { // Style text color for dark theme about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:white;\n" + "}\n" + "a:link {color:cyan}\n" + "</style>" + about; }/* ww w.j a va 2 s. c om*/ webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:arc.noaa.weather.activities.MainActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Forecastie"); final WebView webView = new WebView(this); String about = "<p>A lightweight, opensource weather app.</p>" + "<p>Developed by <a href='mailto:t.martykan@gmail.com'>Tomas Martykan</a></p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; TypedArray ta = obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary, R.attr.colorAccent }); String textColor = String.format("#%06X", (0xFFFFFF & ta.getColor(0, Color.BLACK))); String accentColor = String.format("#%06X", (0xFFFFFF & ta.getColor(1, Color.BLUE))); ta.recycle();// ww w . j a v a2 s. c o m about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:" + textColor + ";\n" + "}\n" + "a:link {color:" + accentColor + "}\n" + "</style>" + about; webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:cz.suhail.Rainyday.activities.MainActivity.java
private void aboutDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Rainyday"); final WebView webView = new WebView(this); String about = "<p>A lightweight, opensource weather app.</p>" + "<p>Developed by <a href='https://www.suhailpurkar.io/'>Suhail Purkar</a></p>" + "<p>Data provided by <a href='http://openweathermap.org/'>OpenWeatherMap</a>, under the <a href='http://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons license</a>" + "<p>Icons are <a href='https://erikflowers.github.io/weather-icons/'>Weather Icons</a>, by <a href='http://www.twitter.com/artill'>Lukas Bischoff</a> and <a href='http://www.twitter.com/Erik_UX'>Erik Flowers</a>, under the <a href='http://scripts.sil.org/OFL'>SIL OFL 1.1</a> licence."; TypedArray ta = obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary, R.attr.colorAccent }); String textColor = String.format("#%06X", (0xFFFFFF & ta.getColor(0, Color.BLACK))); String accentColor = String.format("#%06X", (0xFFFFFF & ta.getColor(1, Color.BLUE))); ta.recycle();/*w w w . j av a2 s.c om*/ about = "<style media=\"screen\" type=\"text/css\">" + "body {\n" + " color:" + textColor + ";\n" + "}\n" + "a:link {color:" + accentColor + "}\n" + "</style>" + about; webView.setBackgroundColor(Color.TRANSPARENT); webView.loadData(about, "text/html", "UTF-8"); alert.setView(webView, 32, 0, 32, 0); alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }