@SuppressLint("SetJavaScriptEnabled")
  private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDefaultTextEncodingName("utf-8");
    mWebView.setWebViewClient(
        new WebViewClient() {
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            AppLog.e(T.EDITOR, description);
          }
        });
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          public boolean onConsoleMessage(ConsoleMessage cm) {
            AppLog.e(
                T.EDITOR,
                cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
          }

          @Override
          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            AppLog.e(T.EDITOR, message);
            return true;
          }

          @Override
          public void onConsoleMessage(String message, int lineNumber, String sourceId) {
            AppLog.e(T.EDITOR, message + " -- from line " + lineNumber + " of " + sourceId);
          }
        });
    String htmlEditor = getHtmlEditor();
    mWebView.loadDataWithBaseURL("file:///android_asset/", htmlEditor, "text/html", "utf-8", "");
  }
Exemple #2
0
  /**
   * Create a dialog containing (parts of the) change log.
   *
   * @param full If this is {@code true} the full change log is displayed. Otherwise only changes
   *     for versions newer than the last version are displayed.
   * @return A dialog containing the (partial) change log.
   */
  protected Dialog getDialog(boolean full) {
    WebView wv = new WebView(mContext);
    // wv.setBackgroundColor(0); // transparent
    wv.loadDataWithBaseURL(null, getLog(full), "text/html", "UTF-8", null);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(mContext);
    builder
        .title(
            mContext
                .getResources()
                .getString(full ? R.string.changelog_full_title : R.string.changelog_title))
        .customView(wv, false)
        .positiveText(mContext.getResources().getString(R.string.changelog_ok_button))
        .onPositive(
            new MaterialDialog.SingleButtonCallback() {
              @Override
              public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                updateVersionInPreferences();
              }
            })
        .onNegative(
            new MaterialDialog.SingleButtonCallback() {
              @Override
              public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                getFullLogDialog().show();
              }
            });
    if (!full) {
      // Show "More…" button if we're only displaying a partial change log.
      builder.negativeText(R.string.changelog_show_full);
    }

    return builder.build();
  }
 /** * 初始化内容控件 */
 private void initWeb() {
   // TODO Auto-generated method stub
   String release = android.os.Build.VERSION.RELEASE;
   release = release.substring(0, 3);
   if ("4.4".equals(release)) {
     web_content.setWebViewClient(new MyWebViewClient());
   } else {
     web_content.setVisibility(View.VISIBLE);
     WebSettings ws = web_content.getSettings();
     ws.setJavaScriptEnabled(true);
     ws.setAllowFileAccess(true);
     ws.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
     ws.setDefaultTextEncodingName("utf-8");
     ws.setTextSize(TextSize.NORMAL);
     ws.setAppCacheEnabled(false);
     ws.setDomStorageEnabled(true);
     if (android.os.Build.VERSION.SDK_INT >= 8) {
       ws.setPluginState(PluginState.ON);
     }
     ws.setRenderPriority(RenderPriority.HIGH);
     web_content.setWebViewClient(new WebViewClientDemo());
     web_content.setWebChromeClient(new WebViewChromeClientDemo());
     web_content.loadDataWithBaseURL("", unit.getIntroduce(), "text/html", "utf-8", null);
   }
 }
  private void displayNews() {
    if (currentNews == null) return;

    String headHtml = "<html><body  style='padding:20px'>";

    // Set Title
    String title = currentNews.getTitle();
    String titleHtml = "<strong><font color='#5cc790' size='5'>" + title + "</font></strong><br/>";

    // Set date
    String dateString = Singleton.news_DateFormatter.format(currentNews.getStartDate());
    String pmName = currentNews.getPmName();
    if (!pmName.equals("null")) {
      dateString += " | " + pmName;
    }
    String dateHtml = "<p><font color='#c6c6c6' size='2.5'>" + dateString + "</font></p><br/>";

    String conHtml = "<p style='line-height: 130%'>" + currentNews.getContent() + "</p>";

    String bottomHtml = "</body></html>";

    String totalHtml = headHtml + titleHtml + dateHtml + currentNews.getContent() + bottomHtml;
    Log.e("test", totalHtml);

    webView.loadDataWithBaseURL("", totalHtml, "text/html", "UTF-8", "");
  }
 private void updateUI() {
   if (mModelInfo != null) {
     byte[] htmlContent = Base64.decode(mModelInfo.content, Base64.DEFAULT);
     Logger.i(TAG, "ContractContent = " + new String(htmlContent));
     mWebView.loadDataWithBaseURL(null, new String(htmlContent), "text/html", "UTF-8", null);
   }
 }
  @SuppressWarnings("deprecation")
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    WebView webView = new WebView(getActivity());
    // TextView text = new TextView(getActivity());
    // text.setGravity(Gravity.CENTER);
    // text.setText(mContent);
    // text.setTextSize(13 * getResources().getDisplayMetrics().scaledDensity);
    // text.setPadding(20, 20, 20, 20);
    // text.setTextColor(getResources().getColor(R.color.colorFuenteAzul));
    webView.getSettings().setDefaultFontSize(19);
    webView.loadDataWithBaseURL(null, mContent, "text/html", "utf-8", null);

    LinearLayout layout = new LinearLayout(getActivity());
    int px =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
    layout.setLayoutParams(new LayoutParams(px, LayoutParams.MATCH_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(webView);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
      layout.setBackgroundDrawable(getResources().getDrawable(R.drawable.rounded_border));
    } else {
      layout.setBackground(getResources().getDrawable(R.drawable.rounded_border));
    }

    return layout;
  }
  private void setData() {
    webView.setVisibility(View.VISIBLE);
    WebSettings settings = webView.getSettings();
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setDefaultFontSize(16);
    webView.requestFocusFromTouch(); // 支持获取手势焦点
    webView.setWebViewClient(
        new WebViewClient() { // 打开网页时不调用系统浏览器, 而是在本WebView中显示
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });

    webView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            return super.onJsAlert(view, url, message, result);
          }
        });

    webView.loadDataWithBaseURL(null, CONTENT, "text/html", "UTF-8", null);
    dialog.cancel();
  }
  /**
   * Creates the root view of the fragement, set title, the version number and the listener for the
   * download button.
   *
   * @return The fragment's root view.
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = getLayoutView();

    versionHelper = new VersionHelper(versionInfo.toString(), this);

    TextView nameLabel = (TextView) view.findViewById(UpdateView.NAME_LABEL_ID);
    nameLabel.setText(getAppName());

    TextView versionLabel = (TextView) view.findViewById(UpdateView.VERSION_LABEL_ID);
    versionLabel.setText(
        "Version " + versionHelper.getVersionString() + "\n" + versionHelper.getFileInfoString());

    Button updateButton = (Button) view.findViewById(UpdateView.UPDATE_BUTTON_ID);
    updateButton.setOnClickListener(this);

    WebView webView = (WebView) view.findViewById(UpdateView.WEB_VIEW_ID);
    webView.clearCache(true);
    webView.destroyDrawingCache();
    webView.loadDataWithBaseURL(
        Constants.BASE_URL, versionHelper.getReleaseNotes(), "text/html", "utf-8", null);

    return view;
  }
  public static void loadContentAdaptiveScreen(Context mContext, WebView webview, String content) {
    final String mimeType = "text/html";
    final String encoding = "UTF-8";
    webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

    webview.loadDataWithBaseURL("", content, mimeType, encoding, "");
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gallery_details);

    // get gallery item details from db
    GalleryManager gm = new GalleryManager(this);
    Cursor c = gm.getDetailsFromDb(getIntent().getStringExtra("id"));

    if (!c.moveToNext()) return;

    String name = c.getString(c.getColumnIndex("name"));
    String image = c.getString(c.getColumnIndex("image"));

    TextView tv = (TextView) findViewById(R.id.infos);
    tv.setText(name);

    WebView browser = (WebView) findViewById(R.id.webView);
    // activate zoom controls
    browser.getSettings().setBuiltInZoomControls(true);
    browser.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

    String data = "<body style='margin:0px;'><img src='" + image + "'/></body>";
    browser.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", null);
  }
Exemple #11
0
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_historical, container, false);
      WebView webView = (WebView) rootView.findViewById(R.id.historical_webView);
      webView.getSettings().setJavaScriptEnabled(true);
      String baseURL = "https://inspired-photon-127022.appspot.com/";
      webView.loadUrl("javascript:var symbol='" + ResultActivity.symbol + "';");
      // Use the html file in assets to render the WebView
      StringBuilder html = new StringBuilder();
      try {
        BufferedReader in =
            new BufferedReader(
                new InputStreamReader(getResources().getAssets().open("HighCharts.html")));
        String line;
        while ((line = in.readLine()) != null) {
          html.append(line);
        }
        in.close();
        webView.loadDataWithBaseURL(baseURL, html.toString(), "text/html", "utf-8", null);
      } catch (IOException e) {
        Log.d(DEBUG_TAG, "Failed to open WebView");
      }

      return rootView;
    }
  private void updateMarker(MapPos pos, Map<String, String> toolTips) {

    if (clickMarker != null) {

      String text = "";
      if (toolTips.containsKey(UtfGridHelper.TEMPLATED_TEASER_KEY)) {
        // strio HTML from the teaser, so it can be shown in normal
        //              String strippedTeaser =
        // android.text.Html.fromHtml(toolTips.get(UtfGridHelper.TEMPLATED_TEASER_KEY).replaceAll("\\<.*?>","")).toString().replaceAll("\\p{C}", "").trim();
        //              Toast.makeText(activity, strippedTeaser, Toast.LENGTH_SHORT).show();
        //                Log.debug("show label ")
        text = toolTips.get(UtfGridHelper.TEMPLATED_TEASER_KEY);
      } else if (toolTips.containsKey("ADMIN")) {
        text = toolTips.get("ADMIN");
      }

      clickMarker.setMapPos(pos);
      mapView.selectVectorElement(clickMarker);
      WebView webView = ((WebView) ((ViewLabel) clickMarker.getLabel()).getView());
      Log.debug("showing html: " + text);
      webView.loadDataWithBaseURL(
          "file:///android_asset/",
          UiUtils.HTML_HEAD + text + UiUtils.HTML_FOOT,
          "text/html",
          "UTF-8",
          null);

      clickMarker.userData = toolTips;
    }
  }
  private void GetQuestion(Integer _id) {

    openDatabaseConnection();

    String WhereStatement = "_id " + "= " + String.valueOf(_id);
    String[] Columns = {"QUESTION"};

    Cursor c = myDbHelper.query("QUESTIONITEMS", Columns, WhereStatement, null, null, null, null);

    if (c.getCount() > 0) {

      c.moveToPosition(0);

      Question = c.getString(0);
    }
    // file remove extension
    String TrimmedQuestion = Question.subSequence(0, Question.lastIndexOf('.')).toString();

    Uri path = Uri.parse("file:///android_asset/QImages/" + TrimmedQuestion + ".jpeg");
    String HTML = "<img src=\"" + path.toString() + "\"" + " width=\"100%\"" + " />";

    final String mimeType = "text/html";
    final String encoding = "utf-8";

    QuestionHeaderBox.loadDataWithBaseURL("fakeit://not required", HTML, mimeType, encoding, null);

    // QuestionHeaderBox.getSettings().setInitialScale(75);
    c.close();
    myDbHelper.close();
  }
  private void updateViews() {
    if (mTitle != null) {
      // Link the title to the entry URL
      SpannableString link = new SpannableString(mTitle);
      if (mUrl != null) {
        int start = 0;
        int end = mTitle.length();
        int flags = 0;
        link.setSpan(new URLSpan(mUrl), start, end, flags);
      }
      mTitleView.setText(link);

      // Show the content, or the summary if no content is available.
      String body =
          !TextUtils.isEmpty(mContent) ? mContent : !TextUtils.isEmpty(mSummary) ? mSummary : "";

      // Show the feed title in the window decorator.
      if (!TextUtils.isEmpty(mTitle)) {
        setTitle(mTitle);
      } else {
        Context context = getContext();
        setTitle(context.getText(R.string.atom_title_entry));
      }

      // Use loadDataWithBaseURL instead of loadData for unsanitized HTML:
      // http://code.google.com/p/android/issues/detail?id=1733
      mContentView.clearView();
      mContentView.loadDataWithBaseURL(null, body, MIME_TYPE, ENCODING, null);
    }
  }
  /**
   * Initialize this {@link ScriptResolver}. Loads the .js script from the given path and sets the
   * appropriate base URL.
   */
  private void init() {
    String baseurl = "http://fake.bla.blu";
    if (getScriptFilePath().contains("officialfm.js")) {
      baseurl = BASEURL_OFFICIALFM;
    } else if (getScriptFilePath().contains("exfm.js")) {
      baseurl = BASEURL_EXFM;
    } else if (getScriptFilePath().contains("jamendo-resolver.js")) {
      baseurl = BASEURL_JAMENDO;
    } else if (getScriptFilePath().contains("soundcloud.js")) {
      baseurl = BASEURL_SOUNDCLOUD;
    }

    mScriptEngine.loadDataWithBaseURL(
        baseurl,
        "<!DOCTYPE html>"
            + "<html>"
            + "<body>"
            + "<script src=\"file:///android_asset/js/tomahawk_android.js\" type=\"text/javascript\"></script>"
            + "<script src=\"file:///android_asset/js/tomahawk.js        \" type=\"text/javascript\"></script>"
            + "<script src=\"file:///android_asset/"
            + mScriptFilePath
            + "\" type=\"text/javascript\"></script>"
            + "</body>"
            + "</html>",
        "text/html",
        null,
        null);
  }
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_fragment_kqnhnt);
    Bundle extras = new Bundle();
    extras.putString("appname", "lich_van_lien_2016");
    extras.putString("appcat", "productivity");
    extras.putString("jb", "" + RootSupport.isDeviceRooted());

    AdMobExtras adExtra = new AdMobExtras(extras);

    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder()
            .addNetworkExtras(adExtra)
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("EDA8BB96AFAC4D787093E74267389265")
            .addTestDevice("3D7268CC8E6A7666958991A316D08A88")
            .addTestDevice("7AFC6206AD04A3073968C664E902FF5D")
            .addTestDevice("780C9B0B7E4E49713CFE54EEF2C2F0E7")
            .addTestDevice("48A720DA7ABCF53ECC3A00DEB6983B97")
            .build();
    mAdView.loadAd(adRequest);
    iv_back = (ImageView) findViewById(R.id.iv_back);
    iv_share = (ImageView) findViewById(R.id.iv_share);
    iv_back.setOnClickListener(this);
    iv_share.setOnClickListener(this);
    wv_ketqua_nhnt = (WebView) findViewById(R.id.wv_ketqua_nhnt);

    // VanTrinhNamDataBaseHelper vanTrinhNamDataBaseHelper = new
    // VanTrinhNamDataBaseHelper(this);
    // Bundle mBundle =getIntent().getExtras().getBundle("Bundle");
    // tv_ngaySinhDuongLich.setText(mBundle.getString("NGAY") + " - " +
    // mBundle.getString("THANG") + " - " + mBundle.getString("NAM"));
    // Calendar calendar = Calendar.getInstance();
    // CalendarUtil calendarUtil = new CalendarUtil();
    // int[] convert =
    // calendarUtil.convertSolar2Lunar(Integer.parseInt(mBundle.getString("NGAY")),
    // Integer.parseInt(mBundle.getString("THANG")),
    // Integer.parseInt(mBundle.getString("NAM")), 7);
    // calendar.set(Calendar.DAY_OF_MONTH, convert[0]);
    // calendar.set(Calendar.MONTH, convert[1] - 1);
    // calendar.set(Calendar.YEAR, convert[2]);
    //		Toast.makeText(getApplicationContext(),
    //				NguHanhNgayTotFragment.thongtin, Toast.LENGTH_LONG).show();
    //		String str = NguHanhNgayTotFragment.thongtin;
    //		html = "<html><body><font color ='#000000'" + NguHanhNgayTotFragment.thongtin
    //				+ "</font></body></html>";
    wv_ketqua_nhnt.getSettings().setJavaScriptEnabled(true);
    wv_ketqua_nhnt.getResources().getDimensionPixelSize(R.dimen.text_size_large);
    wv_ketqua_nhnt.loadDataWithBaseURL(
        null, NguHanhNgayTotFragment.thongtin, "text/html", "utf-8", null);
    // wv_ketqua_vantrinhnam.setBackgroundColor(Color.BLACK);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      wv_ketqua_nhnt.setAlpha(0.7f);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_post_content, container, false);
    // View view = inflater.inflate(R.layout.activity_post_single, container, false);
    swipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.swipe_post_container);
    swipeRefreshLayout.setAddStatesFromChildren(false);
    // 设置刷新时动画的颜色,可以设置4个
    swipeRefreshLayout.setColorSchemeResources(
        android.R.color.holo_blue_light,
        android.R.color.holo_red_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_green_light);
    swipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {

          @Override
          public void onRefresh() {
            // Toast.makeText(getApplication(), "正在刷新", Toast.LENGTH_SHORT);
            // TODO Auto-generated method stub
            new Handler()
                .postDelayed(
                    new Runnable() {

                      @Override
                      public void run() {
                        // TODO Auto-generated method stub
                        //   Toast.makeText(getApplication(), "刷新完成", Toast.LENGTH_SHORT);
                        swipeRefreshLayout.setRefreshing(false);
                      }
                    },
                    3000);
          }
        });

    postContentView = ((WebView) rootView.findViewById(R.id.post_Content));
    WebSettings Settings = postContentView.getSettings();
    Settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    Settings.setJavaScriptEnabled(true);
    Settings.setAllowFileAccess(true);
    mWebView = new MappingWebView(postContentView);
    // postContentView.addJavascriptInterface(mWebView, "JwebView");
    postContentView.addJavascriptInterface(this, "shareButton");

    basehtml = LocalFileReader.getFromAssets("index.html", getContext());

    String iniHtml =
        basehtml.replaceAll(contentReplace, "<div style=\"text-align:center\">文章加载中,请稍候……</div>");

    postContentView.loadDataWithBaseURL(null, iniHtml, "text/html", "utf-8", null);
    postContentView.setWebViewClient(new BYBlogWebViewClient(getContext()));
    SinglePostRequstAsyncTask task = new SinglePostRequstAsyncTask(1586, "王柏元的博客", "王柏元", "");
    task.execute("?ope=getPostContent&postid=" + postid);
    if (BYBlog.speaker == null) BYBlog.speaker = new TextToSpeech(getActivity(), null);

    //        }

    return rootView;
  }
 /**
  * Load ad from OpenX server using the parameters that were set previously and the supplied
  * zoneID. This will not work if the required parameter delivery_url was not set.
  *
  * @see #load()
  * @param zoneID ID of OpenX zone to load ads from.
  */
 public void load(int zoneID) {
   // check required parameters
   if (deliveryURL != null) {
     webView.loadDataWithBaseURL(null, getZoneTemplate(zoneID), "text/html", "utf-8", null);
   } else {
     Log.w(LOGTAG, "deliveryURL is empty");
   }
 }
 private void webViewLoadData(StringBuilder sb) {
   if (webView1 != null && sb != null) {
     Log.d(TAG, "formatPageContent() has fixed this issue");
     MyWebViewClient wvc = new MyWebViewClient();
     webView1.setWebViewClient(wvc);
     webView1.loadDataWithBaseURL("", sb.toString(), "text/html", "UTF-8", "");
   }
 }
Exemple #20
0
  private void startAlipay(Bundle bundle) {
    // TODO Auto-generated method stub

    String data = bundle.getString("data");

    webView.loadDataWithBaseURL(null, data, "text/html", "utf-8", null);
    // webView.loadData(data, "text/html", "utf-8");
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    orientation = newConfig.orientation;
    String html = String.format(WEB_HTML, getMaxWidth(), imageUrl);
    webViewer.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
  }
 private void updateMarker(MapPos pos, String text) {
   if (clickMarker != null) {
     clickMarker.setMapPos(pos);
     mapView.selectVectorElement(clickMarker);
     WebView webView = ((WebView) ((ViewLabel) clickMarker.getLabel()).getView());
     Log.debug("showing html: " + text);
     webView.loadDataWithBaseURL("file:///android_asset/", text, "text/html", "UTF-8", null);
   }
 }
 public void loadData(String paramString1, String paramString2, String paramString3) {
   this.url = null;
   this.initTime = null;
   this.connectionInitFromSession = 0L;
   this.responseTime = 0L;
   this.httpResponse = null;
   this.startLoad = new Date();
   super.loadDataWithBaseURL(this.url, paramString1, paramString2, paramString3, "");
 }
Exemple #24
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  protected void onCreate(final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_reader);

    final int apiVersion = android.os.Build.VERSION.SDK_INT;
    if (apiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      getActionBar().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
      getActionBar().setStackedBackgroundDrawable(new ColorDrawable(Color.WHITE));
    }

    syndicationName = getIntent().getStringExtra("syndicationName");

    if (TextUtils.isEmpty(syndicationName)) {
      getActionBar().setTitle(Html.fromHtml("<b><u>" + getTitle().toString() + "</u><b>"));
    } else {
      getActionBar().setTitle(Html.fromHtml("<b><u>" + syndicationName + "</u><b>"));
    }

    publicationTitle = getIntent().getStringExtra("title");
    if (!TextUtils.isEmpty(publicationTitle)) {
      final TextView tv = (TextView) findViewById(R.id.reader_title);
      tv.setTypeface(TypeFaceSingleton.getInstance(this).getUserTypeFace(), Typeface.BOLD);

      tv.setText(publicationTitle);
      getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    }

    getActionBar().setBackgroundDrawable(new ColorDrawable(0xeeeeee));
    getActionBar().setStackedBackgroundDrawable(new ColorDrawable(0xeeeeee));

    final String text = getIntent().getStringExtra("read");
    link = getIntent().getStringExtra("link");
    isFavorite = getIntent().getBooleanExtra("isFavorite", false);
    publicationId = getIntent().getIntExtra("publicationId", -1);
    syndicationId = getIntent().getIntExtra("syndicationId", -1);

    final WebView webView = (WebView) findViewById(R.id.reader);
    final WebSettings settings = webView.getSettings();
    settings.setAllowFileAccess(true);
    settings.setDefaultTextEncodingName("utf-8");

    // For enable video
    webView.setWebChromeClient(new WebChromeClient());

    settings.setJavaScriptEnabled(true);

    settings.setDefaultFontSize(
        TypeFaceSingleton.getInstance(getApplicationContext()).getUserFontSize());

    webView.loadDataWithBaseURL(null, getHtmlData(text), "text/html", "utf-8", null);

    publicationRepository = new PublicationRepository(this);
  }
 // 加载数据
 private void setData(Content data) {
   mContent = data;
   mContentTitle.setText(mContent.getTitle());
   mAuthor.setText(getString(R.string.label_author) + mContent.getAuthor());
   mSource.setText(getString(R.string.label_resource) + mContent.getSource());
   mCreateTime.setText(mContent.getCreatedAt().split(" ")[0]);
   mWebView.loadDataWithBaseURL(
       null, WebViewHelper.getWebViewHtml(mContent), "text/html", "UTF-8", null);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mViewHolder = inflater.inflate(R.layout.fragment_statistics, container, false);
    summaryTypeSpinner = (Spinner) mViewHolder.findViewById(R.id.dashboard_stat_type_spinner);
    summaryValue1 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_number_1);
    summaryValue2 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_number_2);
    summaryValue3 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_number_3);
    summaryInterest = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_roi_value);
    summaryDefault = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_default_value);
    summaryName1 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_name_1);
    summaryName2 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_name_2);
    summaryName3 = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_name_3);
    summaryInterestName = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_roi);
    summaryDefaultName = (TextView) mViewHolder.findViewById(R.id.dashboard_summary_default);
    transactionAmount = (TextView) mViewHolder.findViewById(R.id.dashboard_transaction_amount);
    transactionCredit = (TextView) mViewHolder.findViewById(R.id.dashboard_credit);
    transactionDebit = (TextView) mViewHolder.findViewById(R.id.dashboard_debit);
    transactionRatio = (ArcProgress) mViewHolder.findViewById(R.id.dashboard_arc_progress);
    chartsWebView = (WebView) mViewHolder.findViewById(R.id.dashboard_graph_holder);
    webViewProgress = (ProgressBar) mViewHolder.findViewById(R.id.dashboard_graph_loader);

    graphUtil = new GraphUtil();
    chartsWebView.setWebViewClient(new AppWebViewClient(webViewProgress));
    chartsWebView.getSettings().setJavaScriptEnabled(true);

    transactionRatio.setMax(1200);
    transactionAmount.setText(getString(R.string.rupee) + "1200");
    transactionCredit.setText(getString(R.string.rupee) + "500");
    transactionDebit.setText(getString(R.string.rupee) + "700");

    chartsWebView.loadDataWithBaseURL(
        "file:///android_asset/", graphUtil.getGraphHTML(), "text/html", "UTF-8", "");

    mViewHolder
        .findViewById(R.id.dashboard_view_transaction_history)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getActivity(), TransactionHistoryActivity.class));
              }
            });

    summaryTypeSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateLable(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    return mViewHolder;
  }
 @AfterViews
 protected void initTermsActivity() {
   Global.initWebView(webView);
   try {
     webView.loadDataWithBaseURL(
         null, Global.readTextFile(getAssets().open("terms.html")), "text/html", "UTF-8", null);
   } catch (Exception e) {
     Global.errorLog(e);
   }
 }
  private void displayAboutDialog() {
    String appName = getString(R.string.app_name);
    int year = Calendar.getInstance().get(Calendar.YEAR);

    String version = "?";
    try {
      PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
      version = pi.versionName;
    } catch (PackageManager.NameNotFoundException e) {
      Log.w(TAG, "Package name not found", e);
    }

    WebView wv = new WebView(this);
    String html =
        "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"
            + "<img src=\"file:///android_res/mipmap/ic_launcher.png\" alt=\""
            + appName
            + "\"/>"
            + "<h1>"
            + String.format(
                getString(R.string.about_title_fmt),
                "<a href=\"" + getString(R.string.app_webpage_url))
            + "\">"
            + appName
            + "</a>"
            + "</h1><p>"
            + appName
            + " "
            + String.format(getString(R.string.debug_version_fmt), version)
            + "</p><p>"
            + String.format(
                getString(R.string.app_revision_fmt),
                "<a href=\""
                    + getString(R.string.app_revision_url)
                    + "\">"
                    + getString(R.string.app_revision_url)
                    + "</a>")
            + "</p><hr/><p>"
            + String.format(getString(R.string.app_copyright_fmt), year)
            + "</p><hr/><p>"
            + getString(R.string.app_license);

    wv.loadDataWithBaseURL("file:///android_res/drawable/", html, "text/html", "utf-8", null);
    new AlertDialog.Builder(this)
        .setView(wv)
        .setCancelable(true)
        .setPositiveButton(
            R.string.ok,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
              }
            })
        .show();
  }
Exemple #29
0
 @Override
 public void showItHomeArticle(ItHomeArticle itHomeArticle) {
   if (TextUtils.isEmpty(itHomeArticle.getDetail())) {
     wvIt.loadUrl(itHomeItem.getUrl());
   } else {
     String data =
         WebUtil.BuildHtmlWithCss(itHomeArticle.getDetail(), new String[] {"news.css"}, false);
     wvIt.loadDataWithBaseURL(
         WebUtil.BASE_URL, data, WebUtil.MIME_TYPE, WebUtil.ENCODING, itHomeItem.getUrl());
   }
 }
 @Test
 public void shouldRecordLastLoadDataWithBaseURL() throws Exception {
   webView.loadDataWithBaseURL(
       "base/url", "<html><body><h1>Hi</h1></body></html>", "text/html", "utf-8", "history/url");
   ShadowWebView.LoadDataWithBaseURL lastLoadData = shadowOf(webView).getLastLoadDataWithBaseURL();
   assertThat(lastLoadData.baseUrl).isEqualTo("base/url");
   assertThat(lastLoadData.data).isEqualTo("<html><body><h1>Hi</h1></body></html>");
   assertThat(lastLoadData.mimeType).isEqualTo("text/html");
   assertThat(lastLoadData.encoding).isEqualTo("utf-8");
   assertThat(lastLoadData.historyUrl).isEqualTo("history/url");
 }