Esempio n. 1
0
 public void windowForwardAnalytics(EBrowserWindow curWind, EBrowserWindow nextWind) {
   if (!EBrowserActivity.analytics) {
     return;
   }
   String beEndUrl = curWind.getRelativeUrl();
   String beShowUrl = nextWind.getRelativeUrl();
   Map<String, EBrowserView> showPopTable = nextWind.getAllPopOver();
   int showSize = showPopTable.size();
   String[] beShowPopupUrls = new String[showSize];
   if (showSize > 0) {
     Set<Entry<String, EBrowserView>> set = showPopTable.entrySet();
     int counter = 0;
     for (Map.Entry<String, EBrowserView> enry : set) {
       EBrowserView temp = enry.getValue();
       String url = temp.getRelativeUrl();
       beShowPopupUrls[counter] = url;
       counter++;
     }
   }
   Map<String, EBrowserView> endPopTable = curWind.getAllPopOver();
   int endSize = endPopTable.size();
   String[] beEndPopupUrls = new String[endSize];
   if (endSize > 0) {
     Set<Entry<String, EBrowserView>> set = endPopTable.entrySet();
     int counter = 0;
     for (Map.Entry<String, EBrowserView> enry : set) {
       EBrowserView temp = enry.getValue();
       String url = temp.getRelativeUrl();
       beEndPopupUrls[counter] = url;
       counter++;
     }
   }
   mApp.disPatchWindowForward(beEndUrl, beShowUrl, beEndPopupUrls, beShowPopupUrls);
 }
 /**
  * @param flag
  * @param bgColor
  * @param baseUrl
  * @param mEBrowserView
  * @author wanglei
  * @createAt 20151124
  * @ps 与原EBrowserView的setBrwViewBackground类似,原方法只设置EBrowserView的背景
  *     当网页设置弹动效果后,上下滑动到边缘后,会露出EBrowserView下面的网页,故应给EBrowserView 父对象EBounceView设置背景,
  *     EBrowserView背景设成透明。
  */
 public void setBounceViewBackground(
     boolean flag, String bgColor, String baseUrl, EBrowserView mEBrowserView) {
   if (flag) {
     if (bgColor.startsWith("#") || bgColor.startsWith("rgb")) {
       int color = BUtility.parseColor(bgColor);
       setBackgroundColor(color);
     } else {
       String path =
           BUtility.makeRealPath(
               BUtility.makeUrl(mEBrowserView.getCurrentUrl(baseUrl), bgColor),
               mEBrowserView.getCurrentWidget().m_widgetPath,
               mEBrowserView.getCurrentWidget().m_wgtType);
       Bitmap bitmap = BUtility.getLocalImg(mContext, path);
       Drawable d = null;
       if (bitmap != null) {
         d = new BitmapDrawable(mContext.getResources(), bitmap);
       }
       int version = Build.VERSION.SDK_INT;
       if (version < 16) {
         setBackgroundDrawable(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       } else {
         setBackground(d);
         setBackgroundColor(Color.argb(0, 0, 0, 0));
       }
     }
   } else {
     setBackgroundColor(Color.TRANSPARENT);
   }
 }
Esempio n. 3
0
 @Override
 public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
   EBrowserView errorView = (EBrowserView) view;
   errorView.receivedError(errorCode, description, failingUrl);
   WWidgetData wgt = errorView.getCurrentWidget();
   printError(errorCode, description, failingUrl, wgt);
 }
Esempio n. 4
0
 @Override
 public void onPageStarted(WebView view, String url, Bitmap favicon) {
   mIsPageOnload = false;
   if (view == null) {
     return;
   }
   EBrowserView target = (EBrowserView) view;
   target.onPageStarted(target, url);
   if (null != mParms) {
     target.setQuery(mParms);
   }
   mParms = null;
   ESystemInfo info = ESystemInfo.getIntence();
   if (info.mFinished) {
     info.mScaled = true;
   }
   if (url != null) {
     mReferenceUrl = url;
     if (url.startsWith("http")) {
       EBrowserWindow bWindow = target.getBrowserWindow();
       if (bWindow != null && 1 == bWindow.getWidget().m_webapp) {
         bWindow.showProgress();
       }
     }
   }
 }
 private boolean bottomCanBounce() {
   float nowScale = mBrwView.getScaleWrap();
   int h1 = (int) (mBrwView.getContentHeight() * nowScale);
   int h2 = mBrwView.getScrollYWrap() + mBrwView.getHeightWrap();
   if (h1 <= h2 + 5) {
     return true;
   } else {
     return false;
   }
 }
  @Override
  public boolean onInterceptTouchEvent(MotionEvent e) {
    int action = e.getAction();
    if (mVelocityTracker == null) {
      mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(e);
    if (!mBounce) {
      switch (action) {
        case MotionEvent.ACTION_UP:
          handlerTracker();
          break;
      }
      return false;
    }

    int y = (int) e.getRawY();
    switch (action) {
      case MotionEvent.ACTION_DOWN:
        mLastY = y;
        break;
      case MotionEvent.ACTION_MOVE:
        int m = y - mLastY;
        boolean can = (m >= 0 ? m : -m) > mTouchSlop;
        if (m > 0 && !mBottomLoading && can && !mTopAutoRefresh) {
          if (topCanBounce()) {
            mIsTop = true;
            if (mTopNotify) {
              mBrwView.onBounceStateChange(
                  EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_PULL_RELOAD);
            }
            return true;
          }
        } else if (m < 0 && !mTopLoading && can) {
          if (bottomCanBounce()) {
            mIsBottom = true;
            if (mBottomNotify) {
              mBrwView.onBounceStateChange(
                  EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_PULL_RELOAD);
            }
            return true;
          }
        }
        mLastY = y;
        break;
      case MotionEvent.ACTION_UP:
        handlerTracker();
        break;
    }
    return false;
  }
 private boolean bottomCanBounce() {
   float nowScale = 1.0f;
   int versionA = Build.VERSION.SDK_INT;
   if (versionA <= 18) {
     nowScale = mBrwView.getScale();
   }
   int h1 = (int) (mBrwView.getContentHeight() * nowScale);
   int h2 = mBrwView.getScrollY() + mBrwView.getHeight();
   if (h1 <= h2 + 5) {
     return true;
   } else {
     return false;
   }
 }
 private boolean onTracker(int velocityX, int velocityY) {
   boolean trigger = false;
   if (isSupportSwipeCallback) {
     final int absY = (velocityY < 0) ? -velocityY : velocityY;
     final int absX = (velocityX < 0) ? -velocityX : velocityX;
     int rate = ESystemInfo.getIntence().mSwipeRate;
     if ((velocityX > rate) && (absX > absY)) {
       mBrwView.loadUrl(EUExScript.F_UEX_SCRIPT_SWIPE_RIGHT);
       trigger = true;
     } else if ((velocityX < -rate) && (absX > absY)) {
       mBrwView.loadUrl(EUExScript.F_UEX_SCRIPT_SWIPE_LEFT);
       trigger = true;
     }
   }
   return trigger;
 }
Esempio n. 9
0
 public void onAppPauseAnalytics(String beEndUrl, Map<String, EBrowserView> beEndPops) {
   if (!EBrowserActivity.analytics) {
     return;
   }
   int endSize = beEndPops.size();
   String[] beEndPopupUrls = new String[endSize];
   Set<Entry<String, EBrowserView>> set = beEndPops.entrySet();
   int counter = 0;
   for (Map.Entry<String, EBrowserView> enry : set) {
     EBrowserView temp = enry.getValue();
     String url = temp.getRelativeUrl();
     beEndPopupUrls[counter] = url;
     counter++;
   }
   mApp.disPatchAppPause(beEndUrl, null, beEndPopupUrls);
 }
 private boolean topCanBounce() {
   boolean b1 = mBrwView.getScrollYWrap() == 0;
   if (b1) {
     return true;
   } else {
     return false;
   }
 }
 private void topRefreshing() {
   if (mTopNotify) {
     mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_RELEASE_RELOAD);
   }
   mTopLoading = true;
   mTopState = F_VIEW_STATE_DRAG;
   int sy = getScrollY();
   int dist = mTopBund - sy;
   if (mShowTopView) {
     mHeaderView.setArrowVisibility(GONE);
     mHeaderView.setProgressBarVisibility(VISIBLE);
     mHeaderView.setTextVisibility(VISIBLE);
     mHeaderView.showLoadingText();
   }
   mScroller.startScroll(0, sy, 0, dist);
   postInvalidate();
   if (mTopNotify) {
     mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_LOADING);
   }
 }
Esempio n. 12
0
 public void windowOpenAnalytics(EBrowserWindow preWind, EBrwViewEntry entry) {
   if (!EBrowserActivity.analytics) {
     return;
   }
   String beEndUrl = preWind.getRelativeUrl();
   String beShowUrl = entry.mRelativeUrl;
   Map<String, EBrowserView> endPopTable = preWind.getAllPopOver();
   int size = endPopTable.size();
   String[] beEndPopupUrls = new String[size];
   if (size > 0) {
     Set<Entry<String, EBrowserView>> set = endPopTable.entrySet();
     int counter = 0;
     for (Map.Entry<String, EBrowserView> enry : set) {
       EBrowserView temp = enry.getValue();
       String url = temp.getRelativeUrl();
       beEndPopupUrls[counter] = url;
       counter++;
     }
   }
   mApp.disPatchWindowOpen(beEndUrl, beShowUrl, beEndPopupUrls);
 }
 private void bottomRefreshing() {
   if (mBottomNotify) {
     mBrwView.onBounceStateChange(
         EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_RELEASE_RELOAD);
   }
   mBottomLoading = true;
   mBottomState = F_VIEW_STATE_DRAG;
   int sy = getScrollY();
   int dist = sy - mBotomBund;
   if (mShowBottomView) {
     mTailView.setArrowVisibility(GONE);
     mTailView.setProgressBarVisibility(VISIBLE);
     mTailView.setTextVisibility(VISIBLE);
     mTailView.showLoadingText();
   }
   mScroller.startScroll(0, -sy, 0, dist);
   postInvalidate();
   if (mBottomNotify) {
     mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_LOADING);
   }
 }
Esempio n. 14
0
 @Override
 public void onPageStarted(WebView view, String url, Bitmap favicon) {
   EBrowserView target = (EBrowserView) view;
   mReferenceUrl = url;
   target.onPageStarted(target, url);
   if (null != mParms) {
     target.setQuery(mParms);
   }
   mParms = null;
   ESystemInfo info = ESystemInfo.getIntence();
   if (info.mFinished) {
     info.mScaled = true;
   }
   if (url.startsWith("http")) {
     EBrowserWindow bWindow = target.getBrowserWindow();
     WWidgetData wgt = bWindow.getWidget();
     if (1 == wgt.m_webapp) {
       bWindow.showProgress();
     }
   }
 }
 public void topBounceViewRefresh() {
   if (!mTopLoading) {
     scrollTo(0, mTopBund);
     if (mShowTopView) {
       mHeaderView.setArrowVisibility(GONE);
       mHeaderView.setProgressBarVisibility(VISIBLE);
       mHeaderView.setTextVisibility(VISIBLE);
       mHeaderView.showLoadingText();
     }
     mTopAutoRefresh = true;
     mTopLoading = true;
     if (mTopNotify) {
       mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_LOADING);
     }
   }
 }
Esempio n. 16
0
 @SuppressLint("NewApi")
 @Override
 public boolean shouldOverrideUrlLoading(WebView view, String url) {
   Activity activity = (Activity) view.getContext();
   if (url.startsWith("tel:")) {
     try {
       Intent intent = new Intent(Intent.ACTION_DIAL);
       intent.setData(Uri.parse(url));
       activity.startActivity(intent);
     } catch (Exception e) {
       e.printStackTrace();
     }
     return true;
   } else if (url.startsWith("geo:")) {
     try {
       Intent intent = new Intent(Intent.ACTION_VIEW);
       intent.setData(Uri.parse(url));
       activity.startActivity(intent);
     } catch (Exception e) {
       e.printStackTrace();
     }
     return true;
   } else if (url.startsWith("mailto:")) {
     try {
       Intent intent = new Intent(Intent.ACTION_VIEW);
       intent.setData(Uri.parse(url));
       activity.startActivity(intent);
     } catch (Exception e) {
       e.printStackTrace();
     }
     return true;
   } else if (url.startsWith("sms:")) {
     try {
       Intent intent = new Intent(Intent.ACTION_VIEW);
       String address = null;
       int parmIndex = url.indexOf('?');
       if (parmIndex == -1) {
         address = url.substring(4);
       } else {
         address = url.substring(4, parmIndex);
         Uri uri = Uri.parse(url);
         String query = uri.getQuery();
         if ((query != null) && (query.startsWith("body="))) {
           intent.putExtra("sms_body", query.substring(5));
         }
       }
       intent.setData(Uri.parse("sms:" + address));
       intent.putExtra("address", address);
       intent.setType("vnd.android-dir/mms-sms");
       activity.startActivity(intent);
     } catch (Exception e) {
       e.printStackTrace();
     }
     return true;
   }
   boolean isUrl = url.startsWith("file") || url.startsWith("http");
   if (!isUrl) {
     return true;
   }
   EBrowserView target = (EBrowserView) view;
   if (target.isObfuscation()) {
     target.updateObfuscationHistroy(url, EBrowserHistory.UPDATE_STEP_ADD, false);
   }
   if (target.shouldOpenInSystem()) {
     Intent intent = new Intent(Intent.ACTION_VIEW);
     intent.setData(Uri.parse(url));
     activity.startActivity(intent);
     return true;
   }
   int sdkVersion = Build.VERSION.SDK_INT;
   if (sdkVersion >= 11) {
     if (url.startsWith("file")) {
       int index = url.indexOf("?");
       if (index > 0) {
         mParms = url.substring(index + 1);
         url = url.substring(0, index);
       }
     }
   }
   String cUrl = view.getOriginalUrl();
   if (null != cUrl && url.startsWith("http") && sdkVersion >= 8) {
     Map<String, String> headers = new HashMap<String, String>();
     headers.put("Referer", cUrl);
     view.loadUrl(url, headers);
   } else {
     view.loadUrl(url);
   }
   return true;
 }
Esempio n. 17
0
 public void getBounce() {
   mBrwView.cbBounceState(mBounce ? 1 : 0);
 }
Esempio n. 18
0
  @Override
  public void onPageFinished(WebView view, String url) {
    EBrowserView target = (EBrowserView) view;
    if (url.startsWith("http")) {
      EBrowserWindow bWindow = target.getBrowserWindow();
      WWidgetData wgt = bWindow.getWidget();
      if (1 == wgt.m_webapp) {
        bWindow.hiddenProgress();
      }
    }
    String oUrl = view.getOriginalUrl();
    if (!mReferenceUrl.equals(url) || target.beDestroy() || !url.equals(oUrl)) {
      return;
    }
    ESystemInfo info = ESystemInfo.getIntence();

    int versionA = Build.VERSION.SDK_INT;

    if (!target.isWebApp()) { // 4.3及4.3以下手机
      if (!info.mScaled) {
        float nowScale = 1.0f;

        if (versionA <= 18) {
          nowScale = target.getScale();
        }

        info.mDefaultFontSize = (int) (info.mDefaultFontSize / nowScale);
        info.mScaled = true;
      }

      target.setDefaultFontSize(info.mDefaultFontSize);
    }

    if (!info.mFinished) {
      ((EBrowserActivity) target.getContext()).setContentViewVisible();
    }

    info.mFinished = true;
    target.loadUrl(EUExScript.F_UEX_SCRIPT);
    target.onPageFinished(target, url);

    EBrowserWindow win = target.getBrowserWindow();
    WWidgetData wgt = win.getWidget();

    if (wgt.m_appdebug == 1) {
      String debugUrlString =
          "http://" + wgt.m_logServerIp + ":30060/target/target-script-min.js#anonymous";
      String weinreString =
          "javascript:var x = document.createElement(\"SCRIPT\");x.setAttribute('src',\""
              + debugUrlString
              + "\""
              + ");document.body.appendChild(x);";
      target.loadUrl(weinreString);
    }

    CookieSyncManager.getInstance().sync();
  }
  public void setBounceParms(int type, JSONObject json, String guestId) {

    String imagePath = null;
    String textColor = null;
    String levelText = null;
    String pullToReloadText = null;
    String releaseToReloadText = null;
    String loadingText = null;
    String loadingImagePath = null;
    imagePath = json.optString("imagePath");
    if (null != imagePath) {
      imagePath =
          BUtility.makeRealPath(
              imagePath,
              mBrwView.getCurrentWidget().m_widgetPath,
              mBrwView.getCurrentWidget().m_wgtType);
    }
    textColor = json.optString("textColor");
    levelText = json.optString("levelText");
    pullToReloadText = json.optString("pullToReloadText");
    releaseToReloadText = json.optString("releaseToReloadText");
    loadingText = json.optString("loadingText");
    if (null != guestId && guestId.equals("donghang")) {
      loadingImagePath = json.optString("loadingImagePath");
      if (null != loadingImagePath) {
        loadingImagePath =
            BUtility.makeRealPath(
                loadingImagePath,
                mBrwView.getCurrentWidget().m_widgetPath,
                mBrwView.getCurrentWidget().m_wgtType);
      }
    }
    switch (type) {
      case EViewEntry.F_BOUNCE_TYPE_TOP:
        if (null != imagePath && 0 != imagePath.trim().length()) {
          mHeaderView.setArrowhead(imagePath);
        }
        if (null != loadingImagePath && 0 != loadingImagePath.trim().length()) {
          mHeaderView.setLoadingPic(loadingImagePath);
        }
        if ((null == textColor || 0 == textColor.trim().length())
            && (null == pullToReloadText || 0 == pullToReloadText.trim().length())
            && (null == releaseToReloadText || 0 == releaseToReloadText.trim().length())
            && (null == loadingText || 0 == loadingText.trim().length())) {
          mHeaderView.setContentEmpty(true);
        } else {
          if (null != textColor && 0 != textColor.trim().length()) {
            int color = mBrwView.parseColor(textColor);
            mHeaderView.setTextColor(color);
          }
          if (null != levelText && 0 != levelText.trim().length()) {
            mHeaderView.setLevelText(levelText);
          }
          if (null != releaseToReloadText && 0 != releaseToReloadText.trim().length()) {
            mHeaderView.setReleaseToReloadText(releaseToReloadText);
          }
          if (null != loadingText && 0 != loadingText.trim().length()) {
            mHeaderView.setLoadingText(loadingText);
          }
          if (null != pullToReloadText && 0 != pullToReloadText.trim().length()) {
            mHeaderView.setPullToReloadText(pullToReloadText);
          }
        }
        break;
      case EViewEntry.F_BOUNCE_TYPE_BOTTOM:
        if (null != imagePath && 0 != imagePath.trim().length()) {
          mTailView.setArrowhead(imagePath);
        }
        if (null != loadingImagePath && 0 != loadingImagePath.trim().length()) {
          mTailView.setLoadingPic(loadingImagePath);
        }
        if ((null == textColor || 0 == textColor.trim().length())
            && (null == pullToReloadText || 0 == pullToReloadText.trim().length())
            && (null == releaseToReloadText || 0 == releaseToReloadText.trim().length())
            && (null == loadingText || 0 == loadingText.trim().length())) {
          mTailView.setContentEmpty(true);
        } else {
          if (null != textColor && 0 != textColor.trim().length()) {
            int color = mBrwView.parseColor(textColor);
            mTailView.setTextColor(color);
          }
          if (null != levelText && 0 != levelText.trim().length()) {
            mTailView.setLevelText(levelText);
          }
          if (null != releaseToReloadText && 0 != releaseToReloadText.trim().length()) {
            mTailView.setReleaseToReloadText(releaseToReloadText);
          }
          if (null != loadingText && 0 != loadingText.trim().length()) {
            mTailView.setLoadingText(loadingText);
          }
          if (null != pullToReloadText && 0 != pullToReloadText.trim().length()) {
            mTailView.setPullToReloadText(pullToReloadText);
          }
        }
        break;
    }
  }
 public int getBounce() {
   int result = mBounce ? 1 : 0;
   mBrwView.cbBounceState(result);
   return result;
 }