/** アニメーションの処理を行います。 */
    @Override
    public void handleMessage(Message msg) {
      final FloatingView floatingView = mFloatingView.get();
      if (floatingView == null) {
        removeMessages(ANIMATION_IN_TOUCH);
        return;
      }

      final int animationCode = msg.what;
      final int animationType = msg.arg1;
      final WindowManager.LayoutParams params = floatingView.mParams;
      final WindowManager windowManager = floatingView.mWindowManager;

      // 状態変更またはアニメーションを開始した場合の初期化
      if (mIsChangeState || animationType == TYPE_FIRST) {
        // 状態変更時のみアニメーション時間を使う
        mStartTime = mIsChangeState ? SystemClock.uptimeMillis() : 0;
        mStartX = params.x;
        mStartY = params.y;
        mStartedCode = animationCode;
        mIsChangeState = false;
      }
      // 経過時間
      final float elapsedTime = SystemClock.uptimeMillis() - mStartTime;
      final float trackingTargetTimeRate = Math.min(elapsedTime / CAPTURE_DURATION_MILLIS, 1.0f);

      // 重なっていない場合のアニメーション
      if (mState == FloatingView.STATE_NORMAL) {
        final float basePosition = calcAnimationPosition(trackingTargetTimeRate);
        // 画面外へのオーバーを認める
        final Rect moveLimitRect = floatingView.mMoveLimitRect;
        // 最終的な到達点
        final float targetPositionX =
            Math.min(Math.max(moveLimitRect.left, (int) mTouchPositionX), moveLimitRect.right);
        final float targetPositionY =
            Math.min(Math.max(moveLimitRect.top, (int) mTouchPositionY), moveLimitRect.bottom);
        params.x = (int) (mStartX + (targetPositionX - mStartX) * basePosition);
        params.y = (int) (mStartY + (targetPositionY - mStartY) * basePosition);
        windowManager.updateViewLayout(floatingView, params);
        sendMessageAtTime(
            newMessage(animationCode, TYPE_UPDATE),
            SystemClock.uptimeMillis() + ANIMATION_REFRESH_TIME_MILLIS);
      }
      // 重なった場合のアニメーション
      else if (mState == FloatingView.STATE_INTERSECTING) {
        final float basePosition = calcAnimationPosition(trackingTargetTimeRate);
        // 最終的な到達点
        final float targetPositionX = mTargetPositionX - floatingView.getWidth() / 2;
        final float targetPositionY = mTargetPositionY - floatingView.getHeight() / 2;
        // 現在地からの移動
        params.x = (int) (mStartX + (targetPositionX - mStartX) * basePosition);
        params.y = (int) (mStartY + (targetPositionY - mStartY) * basePosition);
        windowManager.updateViewLayout(floatingView, params);
        sendMessageAtTime(
            newMessage(animationCode, TYPE_UPDATE),
            SystemClock.uptimeMillis() + ANIMATION_REFRESH_TIME_MILLIS);
      }
    }
  public void removeNote() {
    if (config.notes.size() <= 0) return;

    boolean removing = false;

    int noteCount = 0;
    for (int i = 0; i < config.notes.size(); i++) {
      SteamHUDNote note = config.notes.get(i);
      if (!note.removing) {
        noteCount = config.notes.size() - i - 1;
        note.removing = true;
        break;
      } else if (i == config.notes.size() - 1) {
        return;
      }
    }

    WindowManager.LayoutParams params = (WindowManager.LayoutParams) getLayoutParams();
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

    params.height = (int) (74 * noteCount * config.scaleFactor) + 1;

    wm.updateViewLayout(this, params);

    config.hudRender.invalidate();
  }
  /**
   * Updates the state of the popup window, if it is currently being displayed, from the currently
   * set state. This include: {@link #setClippingEnabled(boolean)}, {@link #setFocusable(boolean)},
   * {@link #setIgnoreCheekPress()}, {@link #setInputMethodMode(int)}, {@link
   * #setTouchable(boolean)}, and {@link #setAnimationStyle(int)}.
   */
  public void update() {
    if (!isShowing() || mContentView == null) {
      return;
    }

    WindowManager.LayoutParams p = (WindowManager.LayoutParams) mPopupView.getLayoutParams();

    boolean update = false;

    final int newAnim = computeAnimationResource();
    if (newAnim != p.windowAnimations) {
      p.windowAnimations = newAnim;
      update = true;
    }

    final int newFlags = computeFlags(p.flags);
    if (newFlags != p.flags) {
      p.flags = newFlags;
      update = true;
    }

    if (update) {
      mWindowManager.updateViewLayout(mPopupView, p);
    }
  }
  private void dragView(int x, int y) {
    if (mRemoveMode == SLIDE) {
      float alpha = 1.0f;
      int width = mDragView.getWidth();
      if (x > width / 2) {
        alpha = ((float) (width - x)) / (width / 2);
      }
      mWindowParams.alpha = alpha;
    }

    if (mRemoveMode == FLING || mRemoveMode == TRASH) {
      mWindowParams.x = x - mDragPointX + mXOffset;
    } else {
      mWindowParams.x = 0;
    }
    mWindowParams.y = y - mDragPointY + mYOffset;
    mWindowManager.updateViewLayout(mDragView, mWindowParams);

    if (mTrashcan != null) {
      int width = mDragView.getWidth();
      if (y > getHeight() * 3 / 4) {
        mTrashcan.setLevel(2);
      } else if (width > 0 && x > width / 4) {
        mTrashcan.setLevel(1);
      } else {
        mTrashcan.setLevel(0);
      }
    }
  }
 public void onEvent(EventsModel eventsModel) {
   if (eventsModel != null && eventsModel.getEventType() == EventType.SETTINGS_CHANGE) {
     setupParams();
     setupFloatingImage(true);
     animateHidden();
     EventTrackerHelper.sendEvent(
         "onEvent", "onLoadCompleteListener", "EventType.SETTINGS_CHANGE");
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.PREVIEW) {
     mParams.height = AppHelper.toPx(context, eventsModel.getPreviewSize());
     mParams.width = AppHelper.toPx(context, eventsModel.getPreviewSize());
     try {
       EventTrackerHelper.sendEvent("onEvent", "onLoadCompleteListener", "EventType.PREVIEW");
       if (windowManager != null) {
         windowManager.updateViewLayout(FloatingHorizontalLayout.this.view, mParams);
         new Handler()
             .postDelayed(
                 new Runnable() {
                   @Override
                   public void run() {
                     setupParams();
                     setupFloatingImage(true);
                   }
                 },
                 1500);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.FA_BACKGROUND) {
     setupBackground();
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.ICON_ALPHA) {
     animateHidden();
   }
 }
  /** 画面サイズから自位置を決定します。 */
  private void updateViewLayout() {
    cancelAnimation();

    // 前の画面座標を保存
    final int oldScreenHeight = mMetrics.heightPixels;
    final int oldScreenWidth = mMetrics.widthPixels;
    final int oldPositionLimitWidth = mPositionLimitRect.width();
    final int oldPositionLimitHeight = mPositionLimitRect.height();

    // 新しい座標情報に切替
    mWindowManager.getDefaultDisplay().getMetrics(mMetrics);
    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();
    final int newScreenWidth = mMetrics.widthPixels;
    final int newScreenHeight = mMetrics.heightPixels;

    // 移動範囲の設定
    mMoveLimitRect.set(-width, -height * 2, newScreenWidth + width, newScreenHeight + height);
    mPositionLimitRect.set(
        -mOverMargin,
        0,
        newScreenWidth - width + mOverMargin,
        newScreenHeight - mStatusBarHeight - height);

    // 縦横切替の場合
    if (oldScreenWidth != newScreenWidth || oldScreenHeight != newScreenHeight) {
      // 画面端に移動する場合は現在の位置から左右端を設定
      if (mMoveDirection == FloatingViewManager.MOVE_DIRECTION_DEFAULT) {
        // 右半分にある場合
        if (mParams.x > (newScreenWidth - width) / 2) {
          mParams.x = mPositionLimitRect.right;
        }
        // 左半分にある場合
        else {
          mParams.x = mPositionLimitRect.left;
        }
      }
      // 左端に移動
      else if (mMoveDirection == FloatingViewManager.MOVE_DIRECTION_LEFT) {
        mParams.x = mPositionLimitRect.left;
      }
      // 右端に移動
      else if (mMoveDirection == FloatingViewManager.MOVE_DIRECTION_RIGHT) {
        mParams.x = mPositionLimitRect.right;
      }
      // 画面端に移動しない場合は画面座標の比率から計算
      else {
        final int newX =
            (int) (mParams.x * mPositionLimitRect.width() / (float) oldPositionLimitWidth + 0.5f);
        mParams.x = Math.min(Math.max(mPositionLimitRect.left, newX), mPositionLimitRect.right);
      }

      // スクリーン位置の比率からY座標を設定(四捨五入)
      final int newY =
          (int) (mParams.y * mPositionLimitRect.height() / (float) oldPositionLimitHeight + 0.5f);
      mParams.y = Math.min(Math.max(mPositionLimitRect.top, newY), mPositionLimitRect.bottom);
      mWindowManager.updateViewLayout(this, mParams);
    }
  }
 protected void reduceToTriggerRegion() {
   mLayoutParams = (WindowManager.LayoutParams) getLayoutParams();
   mLayoutParams.y = mTriggerTop;
   mLayoutParams.height = mTriggerBottom;
   mLayoutParams.width = mTriggerWidth;
   mLayoutParams.flags = disableKeyEvents();
   mWM.updateViewLayout(this, mLayoutParams);
 }
 private void setupFloatingImage(boolean update) {
   if (AppHelper.getImage(context) != null && new File(AppHelper.getImage(context)).exists()) {
     floatingImage.setImageBitmap(BitmapFactory.decodeFile(AppHelper.getImage(context)));
   } else {
     floatingImage.setImageResource(R.mipmap.ic_launcher);
   }
   if (adapter != null) adapter.notifyDataSetChanged();
   if (update) {
     if (windowManager != null)
       try {
         windowManager.updateViewLayout(FloatingHorizontalLayout.this.floatingImage, mParams);
         windowManager.updateViewLayout(FloatingHorizontalLayout.this.view, rParams);
       } catch (Exception e) {
         e.printStackTrace();
       }
   }
 }
Beispiel #9
0
 private void onDrag(int x, int y) {
   if (dragImageView != null) {
     windowParams.alpha = 0.8f;
     windowParams.x = (x - mLastX - xtox) + dragItemView.getLeft() + 8;
     windowParams.y =
         (y - mLastY - ytoy) + dragItemView.getTop() + (int) (45 * Configure.screenDensity);
     windowManager.updateViewLayout(dragImageView, windowParams);
   }
 }
 protected void setTriggerWidth(int value) {
   mLayoutParams = (WindowManager.LayoutParams) this.getLayoutParams();
   mTriggerWidth = value;
   mLayoutParams.width = mTriggerWidth;
   try {
     mWM.updateViewLayout(this, mLayoutParams);
   } catch (Exception e) {
   }
 }
 protected void setBottomPercentage(float value) {
   mLayoutParams = (WindowManager.LayoutParams) this.getLayoutParams();
   mTriggerBottom = (int) (mViewHeight * value);
   mLayoutParams.height = mTriggerBottom;
   try {
     mWM.updateViewLayout(this, mLayoutParams);
   } catch (Exception e) {
   }
 }
 protected void expandFromTriggerRegion() {
   mLayoutParams = (WindowManager.LayoutParams) getLayoutParams();
   mLayoutParams.y = 0;
   Rect r = new Rect();
   getWindowVisibleDisplayFrame(r);
   mViewHeight = r.bottom - r.top;
   mLayoutParams.height = mViewHeight;
   mLayoutParams.width = LayoutParams.MATCH_PARENT;
   mLayoutParams.flags = enableKeyEvents();
   mWM.updateViewLayout(this, mLayoutParams);
 }
  public void addNote(SteamHUDNote note) {
    config.notes.add(note);

    WindowManager.LayoutParams params = (WindowManager.LayoutParams) getLayoutParams();
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

    params.height = (int) (74 * config.notes.size() * config.scaleFactor) + 1;

    wm.updateViewLayout(this, params);

    config.hudRender.invalidate();
  }
  private void dragTouchedListItem(int y) {
    WindowManager.LayoutParams dragViewParameters =
        (WindowManager.LayoutParams) dragView.getLayoutParams();
    dragViewParameters.y = y - dragView.getHeight() / 2;

    WindowManager windowManager = getWindowManager();
    try {
      windowManager.updateViewLayout(dragView, dragViewParameters);
    } catch (IllegalArgumentException e) {
      windowManager.addView(dragView, dragViewParameters);
    }
  }
 private void showRecycler() {
   int iconSize = AppHelper.getFinalSize(context);
   if (paramsF != null) {
     rParams.x = paramsF.x;
     if (paramsF.y + iconSize / 2 > szWindow.y / 2) {
       rParams.y = paramsF.y - iconSize;
     } else if (paramsF.y + iconSize / 2 <= szWindow.y / 2) {
       rParams.y = paramsF.y + iconSize;
     }
     windowManager.updateViewLayout(view, rParams);
   }
   view.setVisibility(View.VISIBLE);
 }
Beispiel #16
0
  private void drag(int x, int y) {
    if (mDragView != null) {
      final WindowManager.LayoutParams layoutParams =
          (WindowManager.LayoutParams) mDragView.getLayoutParams();
      layoutParams.x = x;
      layoutParams.y = y - mDragPointOffset;
      final WindowManager mWindowManager =
          (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

      mWindowManager.updateViewLayout(mDragView, layoutParams);

      if (mDragListener != null) mDragListener.onDrag(x, y, this);
    }
  }
  // move the drag view
  private void drag(int x, int y) {
    if (mDragView != null) {
      WindowManager.LayoutParams layoutParams =
          (WindowManager.LayoutParams) mDragView.getLayoutParams();
      layoutParams.x = x;
      layoutParams.y = y - mDragPointOffset;
      WindowManager mWindowManager =
          (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
      mWindowManager.updateViewLayout(mDragView, layoutParams);

      if (mDragListener != null)
        mDragListener.onDrag(x, y, null); // change null to "this" when ready to use
    }
  }
 private void apply(State state) {
   applyKeyguardFlags(state);
   applyForceStatusBarVisibleFlag(state);
   applyFocusableFlag(state);
   adjustScreenOrientation(state);
   applyHeight(state);
   applyUserActivityTimeout(state);
   applyInputFeatures(state);
   applyFitsSystemWindows(state);
   applyModalFlag(state);
   applyBrightness(state);
   if (mLp.copyFrom(mLpChanged) != 0) {
     mWindowManager.updateViewLayout(mStatusBarView, mLp);
   }
 }
Beispiel #19
0
 public void onLayoutChange(
     View v,
     int left,
     int top,
     int right,
     int bottom,
     int oldLeft,
     int oldTop,
     int oldRight,
     int oldBottom) {
   updateFloatingWindowLayout();
   if (mShowing) {
     mWindowManager.updateViewLayout(mDecor, mDecorLayoutParams);
   }
 }
 public void setSlippery(boolean newSlippery) {
   WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
   if (lp != null) {
     boolean oldSlippery = (lp.flags & WindowManager.LayoutParams.FLAG_SLIPPERY) != 0;
     if (!oldSlippery && newSlippery) {
       lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY;
     } else if (oldSlippery && !newSlippery) {
       lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY;
     } else {
       return;
     }
     WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
     wm.updateViewLayout(this, lp);
   }
 }
  private void update() {
    if (emojiKeyboardView != null) {
      WindowManager.LayoutParams params =
          new WindowManager.LayoutParams(
              WindowManager.LayoutParams.MATCH_PARENT,
              (keyboardHeight),
              WindowManager.LayoutParams.TYPE_PHONE,
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
              PixelFormat.TRANSLUCENT);
      params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
      windowManager.updateViewLayout(emojiKeyboardView, params);
    } else {

    }
  }
 /** 初回描画時の座標設定を行います。 */
 @Override
 public boolean onPreDraw() {
   getViewTreeObserver().removeOnPreDrawListener(this);
   // 画面端に移動しない場合は指定座標に移動
   if (mMoveDirection == FloatingViewManager.MOVE_DIRECTION_NONE) {
     mParams.x = mInitX;
     mParams.y = mInitY;
     moveTo(mInitX, mInitY, mInitX, mInitY, false);
   } else {
     mParams.x = 0;
     mParams.y = mMetrics.heightPixels - mStatusBarHeight - getMeasuredHeight();
     moveToEdge(false);
   }
   mIsDraggable = true;
   mWindowManager.updateViewLayout(this, mParams);
   return true;
 }
Beispiel #23
0
  private void dragView(int x, int y) {
    float alpha = 1.0f;
    int width = mDragView.getWidth();

    if (mRemoveMode == SLIDE_RIGHT) {
      if (x > width / 2) {
        alpha = ((float) (width - x)) / (width / 2);
      }
      mWindowParams.alpha = alpha;
    } else if (mRemoveMode == SLIDE_LEFT) {
      if (x < width / 2) {
        alpha = ((float) x) / (width / 2);
      }
      mWindowParams.alpha = alpha;
    }
    mWindowParams.y = y - mDragPoint + mCoordOffset;
    mWindowManager.updateViewLayout(mDragView, mWindowParams);
  }
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   paramsF = mParams;
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       initialX = paramsF.x;
       initialY = paramsF.y;
       initialTouchX = event.getRawX();
       initialTouchY = event.getRawY();
       animateShowing();
       break;
     case MotionEvent.ACTION_UP:
       if (AppHelper.isEdged(context)) {
         moveToEdge();
       } else {
         if (AppHelper.isSavePositionEnabled(context)) {
           AppHelper.savePosition(context, paramsF.y, paramsF.x);
         }
       }
       animateHidden();
       break;
     case MotionEvent.ACTION_MOVE:
       if (paramsF.y < 0) {
         paramsF.y = 0;
       }
       if (paramsF.y >= 0 || paramsF.y <= (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.x = initialX + (int) (event.getRawX() - initialTouchX);
         paramsF.y = initialY + (int) (event.getRawY() - initialTouchY);
         try {
           windowManager.updateViewLayout(FloatingHorizontalLayout.this.floatingImage, paramsF);
           if (view.isShown()) {
             showRecycler();
           }
         } catch (Exception e) {
           e.printStackTrace();
         }
         animateShowing();
       } else if (paramsF.y > (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.y = (szWindow.y - AppHelper.getFinalSize(context));
       }
       break;
   }
   return false;
 }
Beispiel #25
0
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        lastX = x;
        lastY = y;
        break;
      case MotionEvent.ACTION_MOVE:
        wmParams.x += (int) (x - lastX);
        wmParams.y += (int) (y - lastY);
        windowMgr.updateViewLayout(view, wmParams);
        lastX = x;
        lastY = y;
        break;
    }

    return true;
  }
  // move the drag view
  private void drag(int x, int y) {
    WindowManager.LayoutParams layoutParams =
        (WindowManager.LayoutParams) mDragView.getLayoutParams();
    layoutParams.x = mRemoveListener != null ? x : 0;
    layoutParams.y = y - mDragPointOffset;
    WindowManager mWindowManager =
        (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.updateViewLayout(mDragView, layoutParams);

    if (mRemoveListener != null
        && x > mDragView.getWidth() * 0.7
        && y - mDragItemY > 0
        && y - mDragItemY < mDragView.getHeight()) {
      mDragView.setBackgroundResource(R.drawable.alert);
    } else if (mRemoveListener != null) {
      mDragView.setBackgroundResource(android.R.drawable.alert_dark_frame);
    }

    if (mDragListener != null)
      mDragListener.onDrag(x, y, null); // change null to "this" when ready to use
  }
  public void onDrag(int x, int y) {
    if (mViewDragging != null) {
      windowParams.alpha = 0.8f;
      windowParams.x = (x - startDragX - touchOffsetX) + startDragX;
      windowParams.y = (y - startDragY - touchOffsetY) + startDragY;
      mWindowManager.updateViewLayout(mViewDragging, windowParams);
    }

    if (getCurGridView() != null) {
      // 将PagedView的坐标转化为gridView的坐标
      int gridViewX = x - getCurGridView().getDragGridOffsetLeft();
      int gridViewY = y - getCurGridView().getYDragGridOffsetTop();

      int pageX = x;
      int pageY = y;

      if (x > 0 && y > 0 && Configure.isChangingPage == false) {
        getCurGridView().onDrag(mViewDragging, pageX, pageY, gridViewX, gridViewY);
      }
    }
  }
  /**
   * 指定座標に移動します。<br>
   * 画面端の座標を超える場合は、自動的に画面端に移動します。
   *
   * @param currentX 現在のX座標(アニメーションの始点用に使用)
   * @param currentY 現在のY座標(アニメーションの始点用に使用)
   * @param goalPositionX 移動先のX座標
   * @param goalPositionY 移動先のY座標
   * @param withAnimation アニメーションを行う場合はtrue.行わない場合はfalse
   */
  private void moveTo(
      int currentX, int currentY, int goalPositionX, int goalPositionY, boolean withAnimation) {
    // 画面端からはみ出さないように調整
    goalPositionX =
        Math.min(Math.max(mPositionLimitRect.left, goalPositionX), mPositionLimitRect.right);
    goalPositionY =
        Math.min(Math.max(mPositionLimitRect.top, goalPositionY), mPositionLimitRect.bottom);
    // アニメーションを行う場合
    if (withAnimation) {
      // TODO:Y座標もアニメーションさせる
      mParams.y = goalPositionY;

      mMoveEdgeAnimator = ValueAnimator.ofInt(currentX, goalPositionX);
      mMoveEdgeAnimator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              mParams.x = (Integer) animation.getAnimatedValue();
              mWindowManager.updateViewLayout(FloatingView.this, mParams);
            }
          });
      // X軸のアニメーション設定
      mMoveEdgeAnimator.setDuration(MOVE_TO_EDGE_DURATION);
      mMoveEdgeAnimator.setInterpolator(mMoveEdgeInterpolator);
      mMoveEdgeAnimator.start();
    } else {
      // 位置が変化した時のみ更新
      if (mParams.x != goalPositionX || mParams.y != goalPositionY) {
        mParams.x = goalPositionX;
        mParams.y = goalPositionY;
        mWindowManager.updateViewLayout(FloatingView.this, mParams);
      }
    }
    // タッチ座標を初期化
    mLocalTouchX = 0;
    mLocalTouchY = 0;
    mScreenTouchDownX = 0;
    mScreenTouchDownY = 0;
    mIsMoveAccept = false;
  }
Beispiel #29
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       mOldX = event.getRawX();
       mOldY = event.getRawY();
       mIsDrag = false;
       mFloatView.getBackground().setAlpha(255);
       return false;
     case MotionEvent.ACTION_MOVE:
       int px = (int) (mOldX - event.getRawX());
       int py = (int) (mOldY - event.getRawY());
       if (Math.abs(px) >= 5 && Math.abs(py) >= 5) {
         mIsDrag = true;
       }
       if (mIsDrag) {
         wmParams.x = wmParams.x - px;
         wmParams.y = wmParams.y - py;
         if (wmParams.x > FaceApp.winWidth / 2) {
           wmParams.x = FaceApp.winWidth / 2;
         }
         if (wmParams.x < -FaceApp.winWidth / 2) {
           wmParams.x = -FaceApp.winWidth / 2;
         }
         mWindowManager.updateViewLayout(mFloatView, wmParams);
         mOldX = event.getRawX();
         mOldY = event.getRawY();
       }
       return false;
     case MotionEvent.ACTION_UP:
       PreSetting.getInstance().setFloatViewX(wmParams.x);
       PreSetting.getInstance().setFloatViewY(wmParams.y);
       return mIsDrag;
     default:
       return false;
   }
 }
 /** {@inheritDoc} */
 public void onWindowAttributesChanged(android.view.WindowManager.LayoutParams attrs) {
   if (mDecor != null) {
     mWindowManager.updateViewLayout(mDecor, attrs);
   }
 }