List of usage examples for android.webkit WebView setBackgroundColor
@Override public void setBackgroundColor(int color)
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.UpgradeMessageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.apptentive_upgrade_message_interaction, container, false); ImageView iconView = (ImageView) v.findViewById(R.id.icon); Drawable icon = getIconDrawableResourceId(); if (icon != null) { iconView.setImageDrawable(icon); } else {/*from ww w . ja va 2 s. c om*/ iconView.setVisibility(View.GONE); } WebView webview = (WebView) v.findViewById(R.id.webview); webview.loadData(interaction.getBody(), "text/html", "UTF-8"); webview.setBackgroundColor(Color.TRANSPARENT); // Hack to keep webview background from being colored after load. // If branding is not desired, turn the view off. final View branding = v.findViewById(R.id.apptentive_branding_view); if (branding != null) { if (!interaction.isShowPoweredBy() || Configuration.load().isHideBranding(getContext())) { branding.setVisibility(View.GONE); } } return v; }
From source file:net.wespot.pim.view.InqDescriptionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); final View rootView = inflater.inflate(R.layout.fragment_section_description, container, false); WebView webView = (WebView) rootView.findViewById(R.id.description_description); TextView title = (TextView) rootView.findViewById(R.id.title_description); title.setText(R.string.inquiry_title_description); webView.setBackgroundColor(0x00000000); webView.loadDataWithBaseURL(null, INQ.inquiry.getCurrentInquiry().getDescription(), Constants.MIME_TYPE, Constants.ENCONDING, null);//from ww w .ja va2 s.co m return rootView; }
From source file:de.eidottermihi.rpicheck.fragment.QueryErrorMessagesDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { List<String> messages = this.getArguments().getStringArrayList(KEY_ERROR_MESSAGES); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.errormessages_dialog_title); WebView wv = new WebView(getActivity()); wv.loadDataWithBaseURL(null, this.createErrorMessages(messages), "text/html", "UTF-8", null); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { Compability.setViewLayerTypeSoftware(wv); }/*www . j a v a 2 s . c o m*/ wv.setBackgroundColor(0); builder.setView(wv); builder.setCancelable(false); builder.setPositiveButton("Ok", null); builder.setIcon(android.R.drawable.ic_dialog_info); return builder.create(); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); icon = (ImageView) findViewById(android.R.id.icon); sideNavigationView = (SideNavigationView) findViewById(R.id.side_navigation_view); sideNavigationView.setMenuItems(R.menu.side_navigation_menu); sideNavigationView.setMenuClickCallback(this); if (getIntent().hasExtra(EXTRA_TITLE)) { String title = getIntent().getStringExtra(EXTRA_TITLE); int resId = getIntent().getIntExtra(EXTRA_RESOURCE_ID, 0); setTitle(title);/* w w w. j av a 2 s. c o m*/ icon.setImageResource(resId); sideNavigationView.setMode(getIntent().getIntExtra(EXTRA_MODE, 0) == 0 ? Mode.LEFT : Mode.RIGHT); } StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); { String title = "http://meiriyiwen.com/index/mobile"; //setTitle(title); WebView uiwebview = (WebView) findViewById(R.id.meiriyiwenWeb); uiwebview.setBackgroundColor(Color.BLACK); uiwebview.setWebViewClient(new Callback()); uiwebview.getSettings().setBuiltInZoomControls(true); uiwebview.getSettings().setJavaScriptEnabled(true); uiwebview.loadUrl(title); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:org.sigimera.app.android.MainActivity.java
/** * Shows the about dialog.//from ww w . j av a 2s . c o m */ public final void showAboutDialog() { AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create(); dialog.setTitle("About"); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }); WebView wv = new WebView(this); wv.setBackgroundColor(Color.BLACK); StringBuffer strbuffer = new StringBuffer(); strbuffer.append("<small><font color='white'>"); strbuffer.append("<h3 style='text-align: center'>" + this.getString(R.string.app_name) + "</h3>"); strbuffer.append("<p>This is the official App of the Crises " + "Information Platform Sigimera. It provides " + "the following functionality:</p>"); strbuffer.append("<ul>"); strbuffer.append("<li>Get crises (natural disaster) information." + "Currently floods, earthquakes, cyclones " + "and volcanic erruptions.</li>"); strbuffer.append("<li>Get crises alerts via push notifications.</li>"); strbuffer.append("<li>Get new crises via push notifications.</li>"); strbuffer.append("<li>Manage your App via " + "<a href='http://www.sigimera.org/mobile_devices'>" + "<span style='color: #00FFFF'>mobile device management" + "website </span></a>."); strbuffer.append("</ul>"); strbuffer.append("<p>© 2013 <a href='http://www.sigimera.com'>" + "<span style='color: #00FFFF'>Sigimera Ltd.</span></a>. " + "All rights reserved.</p>"); wv.loadData(strbuffer.toString(), "text/html", "utf-8"); dialog.setView(wv); dialog.show(); }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
public static void showAboutDialog(final Context mContext) { LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = li.inflate(R.layout.about, null); String sVersionInfo = ""; try {/*from w w w . j a v a2 s . c om*/ PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0); sVersionInfo += pi.versionName; if (!pi.versionName.contains("" + pi.versionCode)) sVersionInfo += " (" + pi.versionCode + ")"; if (OpenExplorer.IS_DEBUG_BUILD) sVersionInfo += " *debug*"; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String sBuildTime = ""; try { sBuildTime = SimpleDateFormat.getInstance() .format(new Date(new ZipFile( mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), 0).sourceDir) .getEntry("classes.dex").getTime())); } catch (Exception e) { Logger.LogError("Couldn't get Build Time.", e); } WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); Display d = wm.getDefaultDisplay(); String sHardwareInfo = "Display:\n"; sHardwareInfo += "Size: " + d.getWidth() + "x" + d.getHeight() + "\n"; if (dm != null) sHardwareInfo += "Density: " + dm.density + "\n"; sHardwareInfo += "Rotation: " + d.getRotation() + "\n\n"; sHardwareInfo += getNetworkInfo(mContext); sHardwareInfo += getDeviceInfo(); ((TextView) view.findViewById(R.id.about_hardware)).setText(sHardwareInfo); final String sSubject = "Feedback for OpenExplorer " + sVersionInfo; OnClickListener email = new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); //intent.addCategory(Intent.CATEGORY_APP_EMAIL); intent.putExtra(android.content.Intent.EXTRA_TEXT, "\n" + getDeviceInfo()); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "brandroid64@gmail.com" }); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, sSubject); mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.s_chooser_email))); } }; OnClickListener viewsite = new OnClickListener() { public void onClick(View v) { mContext.startActivity( new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://brandroid.org/open/"))); } }; view.findViewById(R.id.about_email).setOnClickListener(email); view.findViewById(R.id.about_email_btn).setOnClickListener(email); view.findViewById(R.id.about_site).setOnClickListener(viewsite); view.findViewById(R.id.about_site_btn).setOnClickListener(viewsite); final View mRecentLabel = view.findViewById(R.id.about_recent_status_label); final WebView mRecent = (WebView) view.findViewById(R.id.about_recent); final OpenChromeClient occ = new OpenChromeClient(); occ.mStatus = (TextView) view.findViewById(R.id.about_recent_status); mRecent.setWebChromeClient(occ); mRecent.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { occ.mStatus.setVisibility(View.GONE); mRecent.setVisibility(View.GONE); mRecentLabel.setVisibility(View.GONE); } }); mRecent.setBackgroundColor(Color.TRANSPARENT); mRecent.loadUrl("http://brandroid.org/open/?show=recent"); ((TextView) view.findViewById(R.id.about_version)).setText(sVersionInfo); if (sBuildTime != "") ((TextView) view.findViewById(R.id.about_buildtime)).setText(sBuildTime); else ((TableRow) view.findViewById(R.id.row_buildtime)).setVisibility(View.GONE); fillShortcutsTable((TableLayout) view.findViewById(R.id.shortcuts_table)); final View tab1 = view.findViewById(R.id.tab1); final View tab2 = view.findViewById(R.id.tab2); final View tab3 = view.findViewById(R.id.tab3); ((Button) view.findViewById(R.id.btn_recent)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.VISIBLE); tab2.setVisibility(View.GONE); tab3.setVisibility(View.GONE); } }); ((Button) view.findViewById(R.id.btn_hardware)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.GONE); tab2.setVisibility(View.VISIBLE); tab3.setVisibility(View.GONE); } }); ((Button) view.findViewById(R.id.btn_shortcuts)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.GONE); tab2.setVisibility(View.GONE); tab3.setVisibility(View.VISIBLE); } }); AlertDialog mDlgAbout = new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setView(view) .create(); mDlgAbout.getWindow().getAttributes().windowAnimations = R.style.SlideDialogAnimation; mDlgAbout.getWindow().getAttributes().alpha = 0.9f; mDlgAbout.show(); }
From source file:im.vector.adapters.ImagesSliderAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = mLayoutInflater.inflate(R.layout.activity_image_web_view, null, false); // hide the pie chart final PieFractionView pieFractionView = (PieFractionView) view .findViewById(R.id.download_zoomed_image_piechart); pieFractionView.setVisibility(View.GONE); final WebView webView = (WebView) view.findViewById(R.id.image_webview); // black background view.setBackgroundColor(0xFF000000); webView.setBackgroundColor(0xFF000000); final SlidableImageInfo imageInfo = mListImageMessages.get(position); String mediaUrl = imageInfo.mImageUrl; final int rotationAngle = imageInfo.mRotationAngle; final String mimeType = imageInfo.mMimeType; final MXMediasCache mediasCache = Matrix.getInstance(this.context).getMediasCache(); File mediaFile = mediasCache.mediaCacheFile(mediaUrl, mimeType); // is the high picture already downloaded ? if (null != mediaFile) { if (mHighResMediaIndex.indexOf(position) < 0) { mHighResMediaIndex.add(position); }/* www.j ava2s. c o m*/ } else { // try to retrieve the thumbnail mediaFile = mediasCache.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"; webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); loadImage(webView, Uri.parse(mediaUri), viewportContent, css); container.addView(view, 0); return view; }
From source file:de.uni_weimar.m18.anatomiederstadt.element.LatexFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_latex, container, false); WebView latexView = (WebView) root.findViewById(R.id.latexWebView); latexView.getSettings().setJavaScriptEnabled(true); latexView.getSettings().setBuiltInZoomControls(false); TypedValue typedValue = new TypedValue(); Resources.Theme theme = getActivity().getTheme(); theme.resolveAttribute(R.color.windowBackgroundColor, typedValue, true); latexView.setBackgroundColor(typedValue.data); latexView.loadDataWithBaseURL("http://bar", "<script type='text/x-mathjax-config'>" + "MathJax.Hub.Config({ " + "messageStyle: 'none'," + "showMathMenu: false, " + "jax: ['input/TeX','output/HTML-CSS'], " + "extensions: ['tex2jax.js'], " + "TeX: { extensions: ['AMSmath.js','AMSsymbols.js'," + "'noErrors.js','noUndefined.js'] } " + "});</script>" + "<script type='text/javascript' " + "src='file:///android_asset/MathJax/MathJax.js'" + "></script><span id='math'></span>", "text/html", "utf-8", ""); Log.v(LOG_TAG, "Loading latexCode: " + mLatexCode); latexView.setWebViewClient(new WebViewClient() { private String mLatexCode = null; @Override/*from w w w. j a v a 2 s . co m*/ public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (Build.VERSION.SDK_INT < 19) { view.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\[" + doubleEscapeTeX(getLatexCode()) + "\\\\]'"); view.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);"); } else { view.evaluateJavascript("javascript:document.getElementById('math').innerHTML='\\\\[" + doubleEscapeTeX(getLatexCode()) + "\\\\]'", null); view.evaluateJavascript("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);", null); } } }); return root; }
From source file:org.jorge.cmp.ui.fragment.ArticleReaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { setHasOptionsMenu(Boolean.TRUE); final View ret = inflater.inflate(R.layout.fragment_article_reader, container, Boolean.FALSE); View mHeaderView = ret.findViewById(R.id.image); PicassoUtils.loadInto(mContext, mArticle.getImageUrl(), mDefaultImageId, (android.widget.ImageView) mHeaderView, TAG); final String title = mArticle.getTitle(); mHeaderView.setContentDescription(title); ((TextView) ret.findViewById(R.id.title)).setText(title); WebView contentView = (WebView) ret.findViewById(android.R.id.text1); WebSettings webViewSettings = contentView.getSettings(); contentView.setOverScrollMode(View.OVER_SCROLL_NEVER); webViewSettings.setJavaScriptCanOpenWindowsAutomatically(Boolean.TRUE); webViewSettings.setBuiltInZoomControls(Boolean.FALSE); contentView.setBackgroundColor(0x00000000); //I wonder why the default background is white contentView.loadData(mArticle.getPreviewText(), "text/html; charset=UTF-8", "UTF-8"); mActionBar = mActivity.getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); mActionBarBackgroundDrawable = new ColorDrawable( mContext.getResources().getColor(R.color.toolbar_background)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { mActionBarBackgroundDrawable.setCallback(mDrawableCallback); }//from w ww .jav a2s . c o m mActionBar.setBackgroundDrawable(mActionBarBackgroundDrawable); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mOriginalElevation = mActionBar.getElevation(); mActionBar.setElevation(0); //So that the shadow of the ActionBar doesn't show over // the article title } mActionBar.setTitle(mActivity.getString(R.string.section_title_article_reader)); StickyParallaxNotifyingScrollView scrollView = (StickyParallaxNotifyingScrollView) ret .findViewById(R.id.scroll_view); scrollView.setOnScrollChangedListener(mOnScrollChangedListener); scrollView.smoothScrollTo(0, 0); if (!mArticle.isRead()) { mMarkAsReadFab = (FloatingActionButton) ret.findViewById(R.id.fab_button_mark_as_read); mMarkAsReadFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { markArticleAsRead(mArticle); if (mMarkAsReadFab.isShown()) mMarkAsReadFab.hide(); } private void markArticleAsRead(FeedArticle article) { final Realm r = Realm.getInstanceByRealmId(ArticleReaderFragment.this.mAccount.getRealmEnum()); String l = PreferenceAssistant.readSharedString(mContext, PreferenceAssistant.PREF_LANG, null); if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } final Class newsClass = NewsListFragment.class; final Class communityClass = CommunityListFragment.class; final Class schoolClass = SchoolListFragment.class; String tableName; if (mClass == newsClass) { if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } tableName = SQLiteDAO.getNewsTableName(r, l); } else if (mClass == communityClass) { tableName = SQLiteDAO.getCommunityTableName(); } else if (mClass == schoolClass) { tableName = SQLiteDAO.getSchoolTableName(); } else { throw new IllegalArgumentException( "Feed list fragment class " + mClass.getCanonicalName() + " not recognized."); } new AsyncTask<Object, Void, Void>() { @Override protected Void doInBackground(Object... params) { SQLiteDAO.getInstance().markArticleAsRead((FeedArticle) params[0], (String) params[1]); return null; } }.executeOnExecutor(Executors.newSingleThreadExecutor(), article, tableName); article.markAsRead(); } }); mMarkAsReadFab.hide(); mMarkAsReadFab.setVisibility(View.VISIBLE); showMarkAsReadFabIfItProceeds(); } return ret; }
From source file:com.njlabs.amrita.aid.landing.Landing.java
public void checkForUpdates() { OkHttpClient client = new OkHttpClient.Builder().followRedirects(true).followSslRedirects(true).build(); Request.Builder request = new Request.Builder().url("https://api.codezero.xyz/aid/latest"); client.newCall(request.build()).enqueue(new Callback() { @Override// w w w. ja v a 2 s. co m public void onFailure(Call call, IOException e) { Ln.e(e); } @Override public void onResponse(Call call, final Response rawResponse) throws IOException { final String responseString = rawResponse.body().string(); ((Activity) baseContext).runOnUiThread(new Runnable() { @Override public void run() { JSONObject response; try { response = new JSONObject(responseString); String status = ""; status = response.getString("status"); if (status.equals("ok")) { Double Latest = 0.0; String Description = null; try { Latest = response.getDouble("version"); Description = response.getString("description"); } catch (JSONException e) { FirebaseCrash.report(e); } if (Latest > BuildConfig.VERSION_CODE) { AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(Landing.this); LayoutInflater factory = LayoutInflater.from(Landing.this); final View changelogView = factory.inflate(R.layout.webview_dialog, null); LinearLayout WebViewDialogLayout = (LinearLayout) changelogView .findViewById(R.id.WebViewDialogLayout); WebViewDialogLayout.setPadding(5, 5, 5, 5); WebView changelogWebView = (WebView) changelogView .findViewById(R.id.LicensesView); changelogWebView.loadData(String.format("%s", Description), "text/html", "utf-8"); changelogWebView.setPadding(5, 5, 5, 5); changelogWebView.setBackgroundColor(0); changelogWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); changelogWebView.setLongClickable(false); updateDialogBuilder.setView(changelogView).setCancelable(true) .setCancelable(false) .setNegativeButton("Dismiss", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setPositiveButton("Update Now", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri .parse("market://details?id=com.njlabs.amrita.aid"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); } }); AlertDialog alert = updateDialogBuilder.create(); alert.setTitle("Update Available"); alert.setIcon(R.mipmap.ic_launcher); alert.show(); } } } catch (Exception e) { Ln.e(e); } } }); } }); }