예제 #1
0
 private void checkBoundaries(LayoutParams params) {
   if (params.y < this.BOTTOM_BORDER_PX) {
     params.y = this.BOTTOM_BORDER_PX;
   }
   if (params.y > this.windowSize.y - this.TOP_BORDER_PX) {
     params.y = this.windowSize.y - this.TOP_BORDER_PX;
   }
   this.windowManager.updateViewLayout(this.rootView, params);
 }
 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);
 }
예제 #3
0
  private void setDefaultLocation() {
    wmParams.x = defaultOffsetX;
    wmParams.y = defaultOffsetY;

    wmParams.width = defaultWidth;
    wmParams.height = defaultHeight;
  }
  @Override
  protected void displayAD() {
    if (null == mWindowManager) {
      mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }
    lpWindow = new LayoutParams();
    lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT;
    lpWindow.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
    lpWindow.gravity = Gravity.TOP;
    Point point = new Point();
    mWindowManager.getDefaultDisplay().getRealSize(point);
    lpWindow.x = 0;
    lpWindow.y = 0;

    lpWindow.width = point.x;
    lpWindow.height =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.advanced_float_window_height));
    lpWindow.format = PixelFormat.RGBA_8888;

    if (null == mRootView) {
      if (null == mInflater) {
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      mRootView = mInflater.inflate(R.layout.advanced_banner_window, null);
    }
    initViews();
    initDatas();
  }
 @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;
 }
예제 #6
0
 private void updateLayoutParamsForPosiion(View anchor, LayoutParams p, int yOffset) {
   this.measureFloater();
   int measuredHeight = this.mPopupView.getMeasuredHeight();
   int paddingBottom = this.mPopupView.mMarker.getPaddingBottom();
   anchor.getLocationInWindow(this.mDrawingLocation);
   p.x = 0;
   p.y = this.mDrawingLocation[1] - measuredHeight + yOffset + paddingBottom;
   p.width = this.screenSize.x;
   p.height = measuredHeight;
 }
 private void setupParams() {
   int iconSize = AppHelper.getFinalSize(context);
   int pX = AppHelper.getPositionX(context);
   int pY = AppHelper.getPositionY(context);
   rParams.width = MATCH_PARENT;
   rParams.height = iconSize;
   mParams.width = iconSize;
   mParams.height = iconSize;
   if (AppHelper.isSavePositionEnabled(context)) {
     mParams.x = pX;
     mParams.y = pY;
     rParams.y = pY + iconSize;
     rParams.x = pX;
   } else {
     mParams.x = 0;
     mParams.y = 100;
     rParams.x = 0;
     rParams.y = 100 + iconSize;
   }
 }
예제 #8
0
  public void setAsPOPLeftWindow() {
    wmParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;

    wmParams.x = 0;
    wmParams.y = 0;

    int w = mScreenWidth / 2;
    int h = (int) ((float) mScreenHeight / mScreenWidth * mScreenWidth / 2);
    setWindowSize(w, h);

    setTVLocation(new float[] {0, mScreenHeight / 2 - h / 2});
  }
  public UserInfoDialog(Context context) {
    super(context, R.style.Dialog);
    setContentView(R.layout.user_center_content);

    // 设置点击对话框之外能消失
    setCanceledOnTouchOutside(true);
    // 设置window属性
    lp = getWindow().getAttributes();
    lp.gravity = Gravity.TOP;
    lp.dimAmount = 0; // 去背景遮盖
    lp.alpha = 1.0f;
    lp.y = 55;
    getWindow().setAttributes(lp);
  }
예제 #10
0
 public void setMenuItem(int x, int y, int resId) {
   ImageView item = new ImageView(ctx);
   item.setImageResource(resId);
   item.setVisibility(View.GONE);
   menuItems[y * xGrids + x] = item;
   mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
   int xGrid = mDisplayMetrics.widthPixels / xGrids;
   int yGrid = mDisplayMetrics.heightPixels / yGrids;
   float xOffset = ((float) xGrids - 1) / 2;
   float yOffset = ((float) yGrids - 1) / 2;
   itemLayoutParams.x = (int) ((x - xOffset) * xGrid);
   itemLayoutParams.y = (int) ((y - yOffset) * yGrid);
   mWindowManager.addView(item, itemLayoutParams);
 }
예제 #11
0
파일: SerFloat.java 프로젝트: zhl3391/face
 private void initFloatView() {
   wmParams = new LayoutParams();
   wmParams.format = PixelFormat.RGBA_8888;
   wmParams.x = PreSetting.getInstance().getFloatViewX();
   wmParams.y = PreSetting.getInstance().getFloatViewY();
   wmParams.width = LayoutParams.WRAP_CONTENT;
   wmParams.height = LayoutParams.WRAP_CONTENT;
   wmParams.flags = LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_NOT_FOCUSABLE;
   wmParams.type = LayoutParams.TYPE_PHONE;
   wmParams.windowAnimations = android.R.style.Animation_Translucent;
   LayoutInflater inflater = LayoutInflater.from(getApplication());
   mFloatView = inflater.inflate(R.layout.layout_floatbutton, null);
   mFloatView.setOnTouchListener(onTouchListener);
   mFloatView.setOnClickListener(onClickListener);
   ((ButtonFloatSmall) mFloatView).setRippleColor(Color.TRANSPARENT);
   //		((ButtonFloatSmall)mFloatView).getBackground().setAlpha(50);
 }
예제 #12
0
 private void addTabViewToWindow(View view, int x, int y, int w, int h, Boolean touchable) {
   int flags = 16843544;
   if (!touchable.booleanValue()) {
     flags = 16843544 | 16;
   }
   LayoutParams params = new LayoutParams(-2, -2, 2007, flags, -3);
   params.gravity = 51;
   params.width = w;
   params.height = h;
   params.x = x;
   params.y = y;
   try {
     Field privateFlags = params.getClass().getDeclaredField("privateFlags");
     privateFlags.setInt(params, privateFlags.getInt(params) | 64);
   } catch (NoSuchFieldException ex) {
     ex.printStackTrace();
   } catch (IllegalAccessException ex2) {
     ex2.printStackTrace();
   }
   getWindowManager().addView(view, params);
 }
예제 #13
0
  @Override
  protected void displayAD() {
    if (null == mWindowManager) {
      mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }
    LayoutParams lpWindow = new LayoutParams();
    lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT;
    lpWindow.flags = LayoutParams.FLAG_DIM_BEHIND;
    lpWindow.dimAmount = 0.8f;
    lpWindow.gravity = Gravity.CENTER;
    Point point = new Point();
    mWindowManager.getDefaultDisplay().getRealSize(point);
    lpWindow.x = 0;
    lpWindow.y = 0;

    lpWindow.width =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_width));
    lpWindow.height =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_height));
    lpWindow.format = PixelFormat.RGBA_8888;

    if (null == mRootView) {
      if (null == mInflater) {
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      mRootView = mInflater.inflate(R.layout.simple_window, null);
    }
    mWindowManager.addView(mRootView, lpWindow);
    initViews();
    initDatas();
    super.displayAD();

    SharedPreferences sp = mContext.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE);
    sp.edit().putLong(AMConstants.SP_LAST_AD_STAMP, System.currentTimeMillis()).commit();

    AdDisplayUploadRequest request = new AdDisplayUploadRequest(null);
    request.start(mAD.getDisplayPager());
  }
예제 #14
0
파일: SerFloat.java 프로젝트: zhl3391/face
 @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;
   }
 }
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.hire_comment:
      case R.id.hire_comment_num:
        if (!mCommentLayout.isShown()) {
          showCommentView();
        } else {
          hideCommentView();
        }
        break;

      case R.id.hire_share:
        if (mShareDialog == null) {
          mShareDialog = new Dialog(DetailHireActivity.this, R.style.login_dialog);
          mShareDialog.setCanceledOnTouchOutside(true);
          Window win = mShareDialog.getWindow();
          LayoutParams params = new LayoutParams();
          params.width = LayoutParams.MATCH_PARENT;
          params.height = LayoutParams.WRAP_CONTENT;
          params.x = 0;
          params.y = 0;
          win.setAttributes(params);
          mShareDialog.setContentView(R.layout.dialog_share);
          mShareDialog.findViewById(R.id.share_by_sina).setOnClickListener(this);
          mShareDialog.findViewById(R.id.share_by_weixin).setOnClickListener(this);
          mShareDialog.findViewById(R.id.share_by_tencent).setOnClickListener(this);
          mShareDialog.findViewById(R.id.share_by_email).setOnClickListener(this);
          mShareDialog.findViewById(R.id.share_cancel).setOnClickListener(this);
          mShareDialog.findViewById(R.id.share_layout).setOnClickListener(this);
        }
        mShareDialog.show();
        break;
      case R.id.share_by_sina:
        mShareDialog.dismiss();
        break;
      case R.id.share_by_weixin:
        mShareDialog.dismiss();
        break;
      case R.id.share_by_tencent:
        mShareDialog.dismiss();
        break;
      case R.id.share_by_email:
        mShareDialog.dismiss();
        break;
      case R.id.share_cancel:
      case R.id.share_layout:
        mShareDialog.dismiss();
        break;
      case R.id.comment_send:
        String content = mContent.getText().toString();
        if (TextUtils.isEmpty(content)) {
          UIHelper.showToastShort(DetailHireActivity.this, getString(R.string.no_comment));
          return;
        }
        CommonUtils.hideSystemKeyBoard(DetailHireActivity.this, mContent);
        mContent.setText("");
        break;
      case R.id.hire_introduction:
        if (!mCompanyLayout.isShown()) {
          showCompanyView();
        } else {
          hideCompanyView();
        }
        break;
      case R.id.hire_add:
        if (mSelectDialog == null) {
          mSelectDialog = new Dialog(DetailHireActivity.this, R.style.login_dialog);
          mSelectDialog.setCanceledOnTouchOutside(true);
          Window win = mSelectDialog.getWindow();
          LayoutParams params = new LayoutParams();
          params.width = LayoutParams.MATCH_PARENT;
          params.height = LayoutParams.WRAP_CONTENT;
          params.x = 0;
          params.y = 0;
          win.setAttributes(params);
          mSelectDialog.setContentView(R.layout.dailog_select);
          ListView mListView = (ListView) mSelectDialog.findViewById(R.id.select_listview);
          SelectAdapter myAdapter = new SelectAdapter(DetailHireActivity.this);
          mListView.setAdapter(myAdapter);
          mSelectDialog.findViewById(R.id.select_cancel).setOnClickListener(this);
          mSelectDialog.findViewById(R.id.select_layout).setOnClickListener(this);
        }
        mSelectDialog.show();
        break;
      case R.id.select_layout:
        mSelectDialog.dismiss();
        break;
      case R.id.select_cancel:
        mSelectDialog.dismiss();
        break;

      case R.id.hire_contact:
        if (mContactDialog == null) {
          mContactDialog = new Dialog(DetailHireActivity.this, R.style.login_dialog);
          mContactDialog.setCanceledOnTouchOutside(true);
          Window win = mContactDialog.getWindow();
          LayoutParams params = new LayoutParams();
          params.width = LayoutParams.MATCH_PARENT;
          params.height = LayoutParams.WRAP_CONTENT;
          params.x = 0;
          params.y = 0;
          win.setAttributes(params);
          mContactDialog.setContentView(R.layout.dialog_contact);
          mContactDialog.findViewById(R.id.contact_by_call).setOnClickListener(this);
          mContactDialog.findViewById(R.id.contact_by_mail).setOnClickListener(this);
          mContactDialog.findViewById(R.id.contact_by_address).setOnClickListener(this);
          mContactDialog.findViewById(R.id.contact_cancel).setOnClickListener(this);
          mContactDialog.findViewById(R.id.contact_layout).setOnClickListener(this);
        }
        mContactDialog.show();
        break;
      case R.id.contact_by_call:
        CommonUtils.toCall(DetailHireActivity.this, "63074459");
        break;
      case R.id.contact_by_mail:
        CommonUtils.sendEmail(DetailHireActivity.this, String.valueOf(R.string.email_location));
        break;
      case R.id.contact_by_address:
        CommonUtils.showMapByWeb(
            DetailHireActivity.this,
            20,
            30,
            String.valueOf(R.string.map_title),
            String.valueOf(R.string.map_location));
        break;
      case R.id.contact_layout:
      case R.id.contact_cancel:
        mContactDialog.dismiss();
        break;
      default:
        break;
    }
  }
예제 #16
0
 @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
 public void refreshTabIcon() {
   if (this.tabAddedToWindow.booleanValue()) {
     Log.d("SwipeTab", "refreshTabIcon");
     LayoutParams layoutParamsMaxView = (LayoutParams) this.swipeTabTouchView.getLayoutParams();
     layoutParamsMaxView.y = getTabVerticalOffset();
     if (this.tabSizeState == eTabSizeState.FullSize) {
       layoutParamsMaxView.flags &= -17;
     } else {
       layoutParamsMaxView.flags |= 16;
     }
     layoutParamsMaxView.width =
         (int) this.context.getResources().getDimension(R.dimen.tab_maximized_width);
     if (getTabGravity() == 5) {
       layoutParamsMaxView.x = this.screenWidth - layoutParamsMaxView.width;
     } else {
       layoutParamsMaxView.x = 0;
     }
     getWindowManager().updateViewLayout(this.swipeTabTouchView, layoutParamsMaxView);
     LayoutParams layoutParamsMinView =
         (LayoutParams) this.swipeTabMinimizedTouchView.getLayoutParams();
     layoutParamsMinView.y = getTabVerticalOffset();
     if (this.tabSizeState == eTabSizeState.Minimized) {
       layoutParamsMinView.flags &= -17;
     } else {
       layoutParamsMinView.flags |= 16;
     }
     layoutParamsMinView.width =
         (int) this.context.getResources().getDimension(R.dimen.tab_minimized_touch_width);
     if (this.settings.getTabDisplayState().equals(TAB_DISPLAY_STATE_MESSAGE_ONLY)) {
       layoutParamsMinView.width = 0;
     }
     if (getTabGravity() == 5) {
       layoutParamsMinView.x = this.screenWidth - layoutParamsMinView.width;
     } else {
       layoutParamsMinView.x = 0;
     }
     getWindowManager().updateViewLayout(this.swipeTabMinimizedTouchView, layoutParamsMinView);
     float smallWidth = this.context.getResources().getDimension(R.dimen.tab_minimized_width);
     if (this.settings.getTabDisplayState().equals(TAB_DISPLAY_STATE_MESSAGE_ONLY)) {
       smallWidth = 0.0f;
     }
     float largeWidth = this.context.getResources().getDimension(R.dimen.tab_width);
     float renderWidth = this.context.getResources().getDimension(R.dimen.tab_maximized_width);
     float marginFromEdge = renderWidth - largeWidth;
     LayoutParams layoutParamsRenderView = (LayoutParams) this.swipeRenderView.getLayoutParams();
     layoutParamsRenderView.y = getTabVerticalOffset();
     this.swipeTabView.setScaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
     this.swipeTabView.setScaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
     if (getTabGravity() == 5) {
       layoutParamsRenderView.x = (int) ((this.screenWidth) - renderWidth);
       if (this.tabSizeState == eTabSizeState.FullSize) {
         this.swipeTabView.setX(marginFromEdge);
       } else {
         this.swipeTabView.setX((largeWidth - smallWidth) + marginFromEdge);
       }
     } else {
       layoutParamsRenderView.x = 0;
       if (this.tabSizeState == eTabSizeState.FullSize) {
         this.swipeTabView.setX(0.0f);
       } else {
         this.swipeTabView.setX((-largeWidth) + smallWidth);
       }
     }
     if (!this.relocationManager.isInProgress()) {
       if (this.inboxViewManager.isTabVisible().booleanValue()) {
         this.swipeTabView.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(0);
       } else {
         this.swipeTabView.animate().alpha(0.0f).setDuration(0);
       }
     }
     getWindowManager().updateViewLayout(this.swipeRenderView, layoutParamsRenderView);
     setupClickHandlers();
   }
 }
예제 #17
0
 public void setWindowPadding(int x, int y) {
   wmParams.x = x;
   wmParams.y = y;
 }
예제 #18
0
        @Override
        public boolean onTouch(final View v, MotionEvent event) {
          mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
          int xGrid = mDisplayMetrics.widthPixels / xGrids;
          int yGrid = mDisplayMetrics.heightPixels / yGrids;
          float xOffset = ((float) xGrids - 1) / 2;
          float yOffset = ((float) yGrids - 1) / 2;

          switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
              initialX = navigatorLayoutParams.x;
              initialY = navigatorLayoutParams.y;
              initialTouchX = event.getRawX();
              initialTouchY = event.getRawY();
              onLongClickLauncher =
                  new TimerTask() {
                    @Override
                    public void run() {
                      onLongClickHandler.sendEmptyMessage(0);
                    }
                  };
              timer.schedule(onLongClickLauncher, longClickDelay);
              return true;
            case MotionEvent.ACTION_UP:
              if (!isMoving) {
                navigatorLayoutParams.x = initialX;
                navigatorLayoutParams.y = initialY;
                mWindowManager.updateViewLayout(navigator, navigatorLayoutParams);
                if (onLongClickLauncher.cancel()) v.performClick();
              } else {
                int xPos = Math.round((navigatorLayoutParams.x + xOffset * xGrid) / xGrid);
                int yPos = Math.round((navigatorLayoutParams.y + yOffset * yGrid) / yGrid);
                navigatorLayoutParams.x = (int) ((xPos - xOffset) * xGrid);
                navigatorLayoutParams.y = (int) ((yPos - yOffset) * yGrid);

                mWindowManager.updateViewLayout(navigator, navigatorLayoutParams);
                menuHandler.obtainMessage(menuId, xPos, yPos).sendToTarget();
                onLongClickLauncher.cancel();
                isMoving = false;
              }
              if (!isMoving)
                for (int x = 0; x < xGrids; x++)
                  for (int y = 0; y < yGrids; y++)
                    if (menuItems[y * xGrids + x] != null) {
                      menuItems[y * xGrids + x].setVisibility(View.GONE);
                    }
              return true;
            case MotionEvent.ACTION_MOVE:
              navigatorLayoutParams.x = initialX + (int) (event.getRawX() - initialTouchX);
              navigatorLayoutParams.y = initialY + (int) (event.getRawY() - initialTouchY);
              mWindowManager.updateViewLayout(navigator, navigatorLayoutParams);

              if (!isMoving) {
                int deltaX = navigatorLayoutParams.x - initialX;
                int deltaY = navigatorLayoutParams.y - initialY;
                if (!((Math.abs(deltaX) < (xGrid / 4)) && (Math.abs(deltaY) < (yGrid / 4)))) {
                  onLongClickLauncher.cancel();
                  isMoving = true;
                }
              }

              if (isMoving)
                for (int x = 0; x < xGrids; x++)
                  for (int y = 0; y < yGrids; y++)
                    if (menuItems[y * xGrids + x] != null) {
                      itemLayoutParams.x = (int) ((x - xOffset) * xGrid);
                      itemLayoutParams.y = (int) ((y - yOffset) * yGrid);
                      menuItems[y * xGrids + x].setVisibility(View.VISIBLE);
                      mWindowManager.updateViewLayout(menuItems[y * xGrids + x], itemLayoutParams);
                    }
              return true;
          }
          return false;
        }