Пример #1
0
 @Override
 public boolean dispatchKeyEvent(KeyEvent event) {
   if (isLoading) return super.dispatchKeyEvent(event);
   int action = event.getAction();
   if (action == KeyEvent.ACTION_DOWN) {
     int keyCode = event.getKeyCode();
     switch (keyCode) {
       case KeyEvent.KEYCODE_MENU:
         Log.d(TAG, "menu");
         currentView.loadUrl(Notice.MENUKEY);
         break;
       case KeyEvent.KEYCODE_BACK:
         if (currentView.equals(views.get("start"))) {
           if (lastBack == 0) {
             lastBack = System.currentTimeMillis();
           } else { // 两次back,退出
             if (System.currentTimeMillis() - lastBack < 1000) {
               Log.d(TAG, "back in start twice:finish");
               finish();
             }
             lastBack = System.currentTimeMillis();
           }
         }
         currentView.loadUrl(Notice.BACKKEY);
         return true;
     }
   }
   return super.dispatchKeyEvent(event);
 }
  @TargetApi(8)
  private void load() {
    final String uri = getPath();
    final WebSettings settings = wv.getSettings();

    if (uri.endsWith(".swf") && ActivityUtil.isGreaterThan_2_1()) // android 2.2
    {
      wv.setWebChromeClient(new WebChromeClient());
      // settings.setPluginState(PluginState.ON);
      wv.loadUrl(uri);

      getSupportActionBar().setTitle("查看视频");
    } else { // images

      settings.setSupportZoom(true);
      settings.setBuiltInZoomControls(true);
      settings.setUseWideViewPort(true);
      if (ActivityUtil.isGreaterThan_2_1()) settings.setLoadWithOverviewMode(true);
      // settings.setUserAgentString(IPHONE_UA);
      wv.setWebViewClient(
          new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
              // TODO Auto-generated method stub
              return false;
            }
          });
      wv.loadUrl(uri);
      getSupportActionBar().setTitle("查看图片");
    }
  }
  private void setupWebView() {
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            if (progress == 100) mProgressContainer.setVisibility(ProgressBar.GONE);
          }
        });
    mWebView.setWebViewClient(new ProgressWebViewClient());
    mWebView.setInitialScale(1);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.getSettings().setDisplayZoomControls(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setLoadWithOverviewMode(true);
    mWebView.getSettings().setUseWideViewPort(true);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.getSettings().setAppCacheEnabled(true);
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

    if (DataUtils.isNetworkAvailable(this)) {
      showHideOfflineLayout(false);
      if (mPost.postType == Post.PostType.STORY) {
        String strippedUrl = mPost.url.split("\\?")[0].split("#")[0];
        mWebView.loadUrl(strippedUrl.endsWith(KEY_PDF) ? URL_GOOGLE_DOCS + mPost.url : mPost.url);
      } else {
        mWebView.loadUrl(mPost.url);
      }
    } else {
      showHideOfflineLayout(true);
    }
  }
Пример #4
0
  /**
   * Check if this activity was launched from a local notification, and send details to application
   */
  private void checkLaunchedFromNotification() {
    if (this.lastIntentExtras != null) {
      LOG.Log(Module.GUI, "Activity was launched from Notification Manager... ");
      final String message = lastIntentExtras.getString(NotificationUtils.EXTRA_MESSAGE);
      final String notificationSound =
          this.lastIntentExtras.getString(NotificationUtils.EXTRA_SOUND);
      final String customJSONString =
          this.lastIntentExtras.getString(NotificationUtils.EXTRA_CUSTOM_JSON);
      final String notificationId =
          lastIntentExtras.getString(NotificationUtils.EXTRA_NOTIFICATION_ID);
      final String notificationType = lastIntentExtras.getString(NotificationUtils.EXTRA_TYPE);
      LOG.Log(Module.GUI, notificationType + " Notification ID = " + notificationId);

      NotificationData notif = new NotificationData();
      notif.setAlertMessage(message);
      notif.setSound(notificationSound);
      notif.setCustomDataJsonString(customJSONString);

      if (notificationType != null
          && notificationType.equals(NotificationUtils.NOTIFICATION_TYPE_LOCAL)) {
        appView.loadUrl(
            "javascript:try{Unity.OnLocalNotificationReceived("
                + JSONSerializer.serialize(notif)
                + ")}catch(e){}");
      } else if (notificationType != null
          && notificationType.equals(NotificationUtils.NOTIFICATION_TYPE_REMOTE)) {
        appView.loadUrl(
            "javascript:try{Unity.OnRemoteNotificationReceived("
                + JSONSerializer.serialize(notif)
                + ")}catch(e){}");
      }

      this.lastIntentExtras = null;
    }
  }
Пример #5
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fun_everyday, container, false);
    menu = (ImageButton) view.findViewById(R.id.btn_header_left);
    menu.setOnClickListener(this);

    TextView headText = (TextView) view.findViewById(R.id.title_header_mid);
    headText.setText(R.string.text_menu_story);

    String url = "http://www.molegegu.com/im/webview.htm";

    mWebView = (WebView) view.findViewById(R.id.sub_xeb_webview);
    mWebView.loadUrl(url);
    mWebView.setWebViewClient(
        new WebViewClient() {

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });

    mProgressBar = (ProgressBar) view.findViewById(R.id.loadProgress);
    mWebView = (WebView) view.findViewById(R.id.sub_xeb_webview);
    mWebView.loadUrl(url);
    mWebView.setWebViewClient(
        new WebViewClient() {

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });
    // set the webview
    WebSettings settings = mWebView.getSettings();
    settings.setSupportZoom(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("GBK");
    settings.setTextSize(TextSize.NORMAL);
    settings.setJavaScriptEnabled(true);
    settings.setUseWideViewPort(true);
    mWebView.setInitialScale(80);
    mWebView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress > 0 && newProgress < 100) {
              mProgressBar.setVisibility(View.VISIBLE);
              mProgressBar.setProgress(newProgress);
            } else if (newProgress == 100) {
              mProgressBar.setVisibility(View.GONE);
            }
          }
        });
    mWebView.requestFocusFromTouch();
    return view;
  }
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.help);

    webView = (WebView) findViewById(R.id.help_contents);
    webView.setWebViewClient(new HelpClient(this));

    Intent intent = getIntent();
    String page = intent.getStringExtra(REQUESTED_PAGE_KEY);

    // Show an OK button.
    View doneButton = findViewById(R.id.done_button);
    doneButton.setOnClickListener(doneListener);

    if (page.equals(DEFAULT_PAGE)) {
      doneButton.setVisibility(View.VISIBLE);
    } else {
      doneButton.setVisibility(View.GONE);
    }

    // Froyo has a bug with calling onCreate() twice in a row, which causes the What's New page
    // that's auto-loaded on first run to appear blank. As a workaround we only call restoreState()
    // if a valid URL was loaded at the time the previous activity was torn down.
    if (icicle != null && icicle.getBoolean(WEBVIEW_STATE_PRESENT, false)) {
      webView.restoreState(icicle);
    } else if (intent != null && page != null && page.length() > 0) {
      webView.loadUrl(BASE_URL + page);
    } else {
      webView.loadUrl(BASE_URL + DEFAULT_PAGE);
    }
  }
Пример #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ali);

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    String tag = bundle.getString("tag");
    if ("ali".equals(tag)) {
      startAlipay(bundle);
      finish();
    } else if ("download".equals(tag)) {
      String apkurl = bundle.getString("data");
      webView.loadUrl(apkurl);
      finish();

    } else if ("bbs".equals(tag)) {
      String url = bundle.getString("data");
      webView.setWebViewClient(new WebViewClient());
      webView.loadUrl(url);
    }
  }
    @Override
    public void onPageFinished(WebView view, String url) {
      if (PRINT_DIALOG_URL.equals(url)) {
        // Submit print document.
        view.loadUrl(
            "javascript:printDialog.setPrintDocument(printDialog.createPrintDocument("
                + "window."
                + JS_INTERFACE
                + ".getType(),window."
                + JS_INTERFACE
                + ".getTitle(),"
                + "window."
                + JS_INTERFACE
                + ".getContent(),window."
                + JS_INTERFACE
                + ".getEncoding()))");

        // Add post messages listener.
        view.loadUrl(
            "javascript:window.addEventListener('message',"
                + "function(evt){window."
                + JS_INTERFACE
                + ".onPostMessage(evt.data)}, false)");
      }
    }
Пример #9
0
  private void init() {
    webView = (WebView) findViewById(R.id.webView);
    // WebView加载的是本地资源
    //        webView.loadUrl("file:///android_asset/example.html");
    // WebView加载的是Web资源
    webView.loadUrl("http://www.baidu.com");
    webView.loadUrl(url);
    // 覆盖WebView默认通过第三方或者是系统浏览器打开网页的行为,使得网页可以在VebView中打开
    webView.setWebViewClient(
        new WebViewClient() {
          // 返回值为true的时候,控制网页在WebView中打开,当WebView为false的时候,调用第三方或者是系统的浏览器打开
          // WebViewClient帮助WebView处理一些页面控制和请求通知
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });
    // 启用JavaScript
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    // WebView加载页面优先使用缓存加载,其次从网络中获取
    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

    webView.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public void onProgressChanged(WebView view, int newProgress) {
            // newProgress 是1-100之间的整数
            if (newProgress == 100) {
              // 网页加载完毕
              closeDialog(newProgress);
            } else {
              // 网页正在加载
              openDialog(newProgress);
            }
          }

          private void openDialog(int newProgress) {
            if (dialog == null) {
              dialog = new ProgressDialog(MainActivity.this);
              dialog.setTitle("正在加载");
              dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // 横向进度条
              dialog.setProgress(newProgress);
              dialog.show();
            } else {
              dialog.setProgress(newProgress);
            }
          }

          private void closeDialog(int newProgress) {
            if (dialog != null && dialog.isShowing()) {
              dialog.dismiss();
              dialog = null;
            }
          }
        });
  }
Пример #10
0
 public void switchPage(String pageId, String toolbarHeight) {
   if (toolbarHeight != null && !toolbarHeight.equals("")) {
     int height = Integer.parseInt(toolbarHeight);
     pluginManager.exec("JustepAppPortal", "setToolbarHeight", "", "[" + height + "]", false);
   }
   toolbarWebView.loadUrl("javascript:changeState(\"" + pageId + "\")");
   contentWebView.loadUrl("javascript:switchPageTo(\"" + pageId + "\")");
 }
Пример #11
0
 void fail() {
   // Do we need to know why?  How would we handle this?
   if (id != "global") {
     mAppView.loadUrl("javascript:navigator.geolocation.fail(" + id + ")");
   } else {
     mAppView.loadUrl("javascript:navigator.geolocation.fail()");
   }
 }
  protected Long doInBackground(String... bookSlugs) {

    String bookSlug = bookSlugs[0];
    URL url = null;

    try {
      url =
          new URL(
              Config.getInstance().getParameter("repositoryUrl")
                  + "/publicBooks/"
                  + bookSlug
                  + ".etb");
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }

    HttpURLConnection urlConnection = null;

    try {
      urlConnection = (HttpURLConnection) url.openConnection();
      urlConnection.setRequestMethod("GET");
      urlConnection.connect();
      File SDCardRoot = Environment.getExternalStorageDirectory();
      File file = new File(SDCardRoot + "/eTextBook", bookSlug + ".etb");

      FileOutputStream fileOutput = new FileOutputStream(file);
      InputStream inputStream = urlConnection.getInputStream();

      int totalSize = urlConnection.getContentLength();

      byte[] buffer = new byte[1024];
      int bufferLength = 0;
      int downloadedSize = 0;
      int progress = 0;
      while ((bufferLength = inputStream.read(buffer)) > 0) {
        fileOutput.write(buffer, 0, bufferLength);
        downloadedSize += bufferLength;
        progress = downloadedSize * 100 / totalSize;
        this.webView.loadUrl("javascript:app.updateUploadingProgress('" + progress + "')");
        if (downloadedSize == totalSize) {
          player.loadBooksFromArchive();
          webView.loadUrl("javascript:app.setStorageBooks(" + player.getBookList() + ")");
          webView.loadUrl("javascript:app.drawShelfs()");
          webView.loadUrl("javascript:app.switchScreen('shelf')");
          webView.loadUrl("javascript:app.updateUploadingProgress('0')");
          fileOutput.close();
          inputStream.close();
          webView.loadUrl("javascript:app.downloadComplete()");
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    EventService service =
        new EventServiceImpl(
            getString(R.string.thing_broker_server),
            getString(R.string.thing_broker_port),
            null,
            false);
    Event event = new Event();
    event.setThingId(getString(R.string.thing_broker_thing_name));
    Map<String, String> gameInfo = new HashMap<String, String>();

    if (resultCode == RESULT_OK) {
      if (data.getStringExtra("method").equals("nfc")) {
        nfc_upload = data.getStringExtra("uploadResult");
        System.out.println("NFC upload result: " + nfc_upload);
        if (nfc_upload != null && !nfc_upload.equals("")) {
          webView.loadUrl("javascript:gotNFC('" + nfc_upload + "');");
        }

      } else if (data.getStringExtra("method").equals("qr")) {
        System.out.println("QR value");
        qr_upload = data.getStringExtra("qr_result");
        player = data.getStringExtra("playernumber");
        if (qr_upload != null && !qr_upload.equals("")) {
          webView.loadUrl("javascript:gotQR('" + qr_upload + "');");

          gameInfo.put("type", "qrResult");
          gameInfo.put("player", player);
          gameInfo.put("value", qr_upload);
          event.setInfo(gameInfo);
          service.postEvent(STANDARD_MESSAGE, (ThingBrokerRequestListener) this, event, true);
        }

      } else if (data.getStringExtra("method").equals("accel")) {
        System.out.println("ACCEL");
        accelerometer_rate = data.getDoubleExtra("accel_rate", 5.0);
        accelerometer_enabled = true;
        player = data.getStringExtra("playernumber");
        startAccelUpload();
        System.out.println("start accel Upload");
      } else if (data.getStringExtra("method").equals("upload")) {
        System.out.println("Upload this shit now");
        uploadDimensionsTest = data.getStringExtra("uploadResult");
        System.out.println("Upload Dimension Test" + uploadDimensionsTest);
        if (uploadDimensionsTest != null && !uploadDimensionsTest.equals("")) {
          webView.loadUrl("javascript:gotImage('" + uploadDimensionsTest + "');");
        }
        System.out.println("uploadDimesnions passed over");
      }
    }
  }
Пример #14
0
  public void refresh() {
    webView.clearView();
    webView.loadUrl("about:blank");
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_action_view, null);

    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.refresh);
    iv.startAnimation(rotation);

    refreshItem.setActionView(iv);
    webView.loadUrl(getWeiboOAuthUrl());
  }
  public void setToHidden() {
    if (mPreview != null) {
      mPreview.stopPreview();
    }

    mWebView = new WebView(ContShooting.this);
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.getSettings().setAppCacheEnabled(false);
    FrameLayout layout = (FrameLayout) findViewById(R.id.linear);
    layout.setLayoutParams(
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, 1));
    layout.addView(mWebView);

    if (Locale.getDefault().equals(Locale.JAPAN)) {
      mWebView.loadUrl(URL_JP);
    } else {
      mWebView.loadUrl(URL_OTHER);
    }

    FrameLayout frame = (FrameLayout) findViewById(R.id.camera_parent);
    /*
    int hide_width = mWidth / 4;
    int hide_height = hide_width * (4/3);
    */
    /*
     * 隠しモードのプレビューサイズ設定
     * 大=1/4, 小=1/6, 無し=1*1
     */
    int denom = 4;
    if (mHiddenSizeIdx == 2) {
      denom = 6;
    }
    int hide_width = mWidth / denom;
    int hide_height = hide_width / 3 * 4;

    if (mHiddenSizeIdx == 3) {
      hide_height = 1;
      hide_width = 1;
    }
    frame.setLayoutParams(new FrameLayout.LayoutParams(hide_width, hide_height, Gravity.BOTTOM));

    displayHideMode();
    mMaskFlag = true;
    setTitle(R.string.sc_hidden);

    if (mPreview != null) {
      mPreview.startPreview();
    }
  }
  // Change the page
  // Update Webview, Toolbar, Refresh button...
  void changePage(Pages newPage) {
    actual = newPage;

    // Handle tabs
    tabs.removeAllTabs();
    if (newPage.tabs != null && newPage.tabs.contains("||")) {
      showTabs();
      for (String s : newPage.tabs.split("\\|\\|")) {
        tabs.addTab(tabs.newTab().setText(s));
      }
      if (newPage.url != null) {
        newPage.actualURL = newPage.url.split("\\|\\|")[0];
      }
      if (newPage.localPage != null) {
        newPage.actualAlternativeURL = newPage.localPage.split("\\|\\|")[0];
      }

      // There are no tabs...
    } else {
      hideTabs();
      newPage.actualURL = newPage.url;
      newPage.actualAlternativeURL = newPage.localPage;
    }

    // Enable JS for the webview
    webView.getSettings().setJavaScriptEnabled(true);

    // Load URL to the webview...
    if (newPage.url != null) {
      webView.loadUrl(newPage.actualURL);
    } else {
      if (newPage.localPage != null) // ...Or use local page
      webView.loadUrl("file:///android_asset/" + newPage.actualAlternativeURL);
    }

    // Update Toolbar and Statusbar
    toolbar.setBackgroundColor(newPage.actionBarColor.value);
    drawerLayout.setBackgroundColor(newPage.actionBarColor.value);
    drawerLayout.closeDrawers();
    toolbar.setTitle(newPage.title);

    // Show refresh button
    if (refreshButton != null) {
      if (newPage.refreshButton) {
        refreshButton.setVisible(true);
      } else {
        refreshButton.setVisible(false);
      }
    }

    actual = newPage;
  }
Пример #17
0
 @Override
 public void run() {
   if (!pageQueue.isEmpty()) {
     lastURL = (String) pageQueue.remove();
     webPageView.loadUrl(lastURL);
     webPageView.setVisibility(View.VISIBLE);
   } else if (actionEnable && lastURL != blankPage) {
     lastURL = blankPage;
     webPageView.loadUrl(lastURL);
     webPageView.setVisibility(View.INVISIBLE);
   }
   mHandler.postDelayed(openWebPage, 100);
 }
Пример #18
0
 protected void killWebViewLowMemory(WebView mWebView) {
   // http://stackoverflow.com/questions/3815090/webview-and-html5-video
   if (mWebView == null) {
     if (block.getVisibility() != View.GONE && block != null) {
       block.setVisibility(View.GONE);
       block.loadUrl("about:blank");
       block.destroy();
     }
   } else if (mWebView.getVisibility() != View.GONE) {
     mWebView.setVisibility(View.GONE);
     mWebView.loadUrl("about:blank");
     mWebView.destroy();
   }
 }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   switch (position) {
     case 0:
       mWebview.loadUrl("http://www.sina.com.cn");
       break;
     case 1:
       mWebview.loadUrl("http://www.qq.com");
       break;
     case 2:
       mWebview.loadUrl("http://www.baidu.com");
       break;
   }
   mSlidingPaneLayout.closePane();
 }
 @Override
 public boolean shouldOverrideUrlLoading(WebView view, String url) {
   if (url.startsWith(ZXING_URL)) {
     Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
     intentScan.putExtra("SCAN_MODE", "QR_CODE_MODE");
     try {
       startActivityForResult(intentScan, ZXING_SCAN_REQUEST);
     } catch (ActivityNotFoundException error) {
       view.loadUrl(url);
     }
   } else {
     view.loadUrl(url);
   }
   return false;
 }
Пример #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.jincheon_webview);
    jincheon = (WebView) findViewById(R.id.jincheon_web);
    jincheon.setWebViewClient(new myWebClient());
    jincheon_progress = (ProgressBar) findViewById(R.id.jincheon_pb);

    // Set Settings... Plugin ..etc
    // some warning is wrong, just go on away.
    jincheon.getSettings().setPluginsEnabled(true);
    jincheon.getSettings().setJavaScriptEnabled(true);
    jincheon.getSettings().setBuiltInZoomControls(true);
    jincheon.getSettings().setLoadWithOverviewMode(true);
    jincheon.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    jincheon.getSettings().setSupportMultipleWindows(true);
    jincheon.getSettings().setSupportZoom(true);
    jincheon.getSettings().setLoadsImagesAutomatically(true);
    jincheon.getSettings().setUseWideViewPort(true);
    jincheon.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);

    // Load Url
    if (savedInstanceState == null) {
      // 진천 카테고리 접속
      jincheon.loadUrl("http://green-navi.tistory.com/m/post/list?categoryId=525722");
    }
  }
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    webView = (WebView) view.findViewById(R.id.webview);
    webView.loadUrl(Config.getServerUrl() + "/datenschutz");
  }
Пример #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 保持屏幕亮
    //		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //				WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    webview = (WebView) super.findViewById(R.id.webView);
    progress = (ProgressBar) super.findViewById(R.id.progress);
    // progress.setVisibility(View.GONE);
    webview.setWebChromeClient(new WebChromeClientImpl(handler));
    webview.setWebViewClient(wc);
    // webview.setInitialScale(25);
    ws = webview.getSettings();
    ws.setJavaScriptCanOpenWindowsAutomatically(true);
    ws.setJavaScriptEnabled(true);
    ws.setPluginState(PluginState.ON);
    ws.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    Log.i("---", "加载");
    // ws.setSupportZoom(true);
    // ws.setBuiltInZoomControls(true);//设置支持缩放
    // ws.setUseWideViewPort(true);
    webview.loadUrl("http://aaaadc.com");
    // webview.loadUrl("http://www.oceanthree.hk/apps_shop/app_index.php");

  }
 /** 填充数据 */
 private void initData() {
   // Sku2 defaultSku = product.getSkuList().get(0);
   txtName.setText(product.getName());
   txtDesc.setText(product.getDesc());
   txtPrice.setText(product.getPrice());
   txtPriceMarket.setText("市场价:" + product.getPrice());
   txtSalesAmount.setText(product.getBuyerCount() + "人购买");
   initViewPager(); // 图片循环
   initServiceList(); // 服务列表
   initPromotionList(); // 促销列表
   initCommentList(); // 评论列表
   mWebView.loadUrl("http://www.baidu.com");
   ViewTreeObserver vto2 = txtPriceMarket.getViewTreeObserver();
   vto2.addOnGlobalLayoutListener(
       new ViewTreeObserver.OnGlobalLayoutListener() {
         @Override
         public void onGlobalLayout() {
           txtPriceMarket.getViewTreeObserver().removeGlobalOnLayoutListener(this);
           View view = findViewById(R.id.product_details_price_market_line);
           view.setVisibility(View.VISIBLE);
           ViewGroup.LayoutParams params = view.getLayoutParams();
           params.width = txtPriceMarket.getWidth();
           view.setLayoutParams(params);
         }
       });
 }
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Bundle bundle = getIntent().getExtras();
    String url = bundle.getString("url");
    String title = bundle.getString("title");
    current_url = url;

    WebViewActivity.this.setTitle(title);

    final Context myApp = this;
    setContentView(R.layout.activity_webview);

    CookieSyncManager.createInstance(myApp);

    WebSettings settings = getWebView().getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    // settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);

    final WebView webview = (WebView) getWebView();
    webview.setWebViewClient(new MyWebViewClient());
    webview.setWebChromeClient(new MyWebChromeClient());

    webview.loadUrl(url);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_browser);

    Tracker t = ((SyncForICloud) getApplication()).getTracker(TrackerName.APP_TRACKER);
    t.setScreenName("Sync for iCloud Contacts: Browser");
    t.send(new HitBuilders.AppViewBuilder().build());

    WebView webview = (WebView) findViewById(R.id.webView1);
    webview.loadUrl("http://www.me.com/");
    webview
        .getSettings()
        .setUserAgentString(
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36");
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });
  }
Пример #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_subscription_info);
    setTitle("Info");

    getActionBar().setDisplayHomeAsUpEnabled(true);

    sithApplication = (SithApplication) this.getApplication();

    progress = new ProgressDialog(this);

    WebView webView = (WebView) findViewById(R.id.subscription_webview);
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(
        "http://t1.gstatic.com/images?q=tbn:ANd9GcRSYyf9iaNHuq19vtoPu3_IFArLwWV1MG2JjFgHPL0cqYhGTgwr");

    type = (TextView) findViewById(R.id.sub_type);
    description = (TextView) findViewById(R.id.sub_description);
    startTime = (TextView) findViewById(R.id.sub_starttime);
    endTime = (TextView) findViewById(R.id.sub_endtime);
    moods = (TextView) findViewById(R.id.sub_moods);
    activeSubscriptions = (TextView) findViewById(R.id.sub_active_count);
    subscribeButton = (Button) findViewById(R.id.subscribe_button);

    // Fonts
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Medium.ttf");
    type.setTypeface(tf);

    init(getIntent().getExtras().getString("subscriptionID"));
  }
Пример #28
0
  protected void loadWebviewAuth(
      final AlertDialog dialog,
      final WebView webview,
      @Size(3) final String[] auth,
      final OsmOAuth.AuthType type) {
    if (auth == null) {
      // TODO show some dialog
      return;
    }

    final String authUrl = auth[0];
    webview.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (OsmOAuth.shouldReloadWebviewUrl(url)) {
              webview.loadUrl(authUrl);
            } else if (url.contains(OsmOAuth.URL_PARAM_VERIFIER)) {
              finishWebviewAuth(auth[1], auth[2], getVerifierFromUrl(url), type);
              dialog.cancel();
              return true;
            }

            return false;
          }

          private String getVerifierFromUrl(String authUrl) {
            UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
            sanitizer.setAllowUnregisteredParamaters(true);
            sanitizer.parseUrl(authUrl);
            return sanitizer.getValue(OsmOAuth.URL_PARAM_VERIFIER);
          }
        });
    webview.loadUrl(authUrl);
  }
Пример #29
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.terms);

    WebView termsWebView = (WebView) findViewById(R.id.termsWebView);
    termsWebView.getSettings().setJavaScriptEnabled(true);

    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    final Activity activity = this;

    termsWebView.setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            activity.setProgress(progress * 1000);
          }
        });

    termsWebView.setWebChromeClient(
        new WebChromeClient() {
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingURL) {
            Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
          }
        });

    termsWebView.loadUrl(getString(R.string.termsURL));
  }
Пример #30
0
 public void showHelp(String topic) {
   final Dialog d = new Dialog(this, android.R.style.Theme);
   final WebView wv = new WebView(this);
   d.setOnKeyListener(
       new DialogInterface.OnKeyListener() {
         public boolean onKey(DialogInterface di, int key, KeyEvent evt) {
           if (evt.getAction() != KeyEvent.ACTION_DOWN || key != KeyEvent.KEYCODE_BACK)
             return false;
           if (wv.canGoBack()) wv.goBack();
           else d.cancel();
           return true;
         }
       });
   d.setContentView(wv);
   wv.setWebChromeClient(
       new WebChromeClient() {
         public void onReceivedTitle(WebView w, String title) {
           d.setTitle(title);
         }
         // onReceivedTitle doesn't happen on back button :-(
         public void onProgressChanged(WebView w, int progress) {
           if (progress == 100) d.setTitle(w.getTitle());
         }
       });
   wv.getSettings().setBuiltInZoomControls(true);
   wv.loadUrl(MessageFormat.format(getString(R.string.docs_url), new Object[] {topic}));
   d.show();
 }