private void layout() {
    Rect frame = camera.getFrame(viewfinder.getWidth(), viewfinder.getHeight());
    if (frame == null) {
      return;
    }

    Log.i(TAG, "Frame = " + frame + ", " + viewfinder.getWidth());
    ViewGroup.LayoutParams p = bottomView.getLayoutParams();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview);
    p.height = surfaceView.getHeight() - frame.bottom;
    p.width = frame.width();
    bottomView.setLayoutParams(p);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && hasNavBar(this)) {
      // Don't draw over nav bar
      bottomView.setPadding(0, 0, 0, getNavBarHeight());
    }

    bottomView.requestLayout();
    viewfinder.invalidate();
  }
Example #2
0
 void setKeyboardVisibility(Configuration c) {
   boolean landscape = (c.orientation == Configuration.ORIENTATION_LANDSCAPE);
   if (landscape != prevLandscape || keyboard == null) {
     // Must recreate KeyboardView on orientation change because it
     // caches the x,y for its preview popups
     // http://code.google.com/p/android/issues/detail?id=4559
     if (keyboard != null) mainLayout.removeView(keyboard);
     keyboard = new SmallKeyboard(this, undoEnabled, redoEnabled);
     keyboard.setId(R.id.keyboard);
     RelativeLayout.LayoutParams lp =
         new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
     RelativeLayout.LayoutParams glp =
         new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
     if (landscape) {
       lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
       lp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.LEFT_OF, R.id.keyboard);
     } else {
       lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
       lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       lp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.ABOVE, R.id.keyboard);
     }
     mainLayout.updateViewLayout(gameView, glp);
     mainLayout.addView(keyboard, lp);
   }
   keyboard.setKeys(
       (c.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)
           ? (maybeUndoRedo + maybeMenu)
           : lastKeys,
       lastArrowMode);
   prevLandscape = landscape;
   mainLayout.requestLayout();
 }
  /** Smart item expansion. */
  private void expandItem(int position) {
    final int first = getFirstVisiblePosition();
    RelativeLayout v = (RelativeLayout) getChildAt(position - first);
    if (v != null && mFloatView != null) {
      // Log.d("mobeta", "  expanding item "+position);
      ViewGroup.LayoutParams lp = v.getLayoutParams();

      int oldHeight = lp.height;
      if (lp.height == mItemHeightCollapsed && position == mSrcDragPos) {
        // expanding collapsed src item
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      } else if (lp.height == ViewGroup.LayoutParams.WRAP_CONTENT && position != mExpDragPos) {
        // expanding normal item
        lp.height = v.getHeight() + mFloatViewHeight;

        // must set gravity in this case
        if (position > mSrcDragPos) {
          v.setGravity(Gravity.TOP);
        } else {
          v.setGravity(Gravity.BOTTOM);
        }

        // what if expanding first position?
        // if (position == first && mDragState == SRC_ABOVE) {
        // setSelectionFromTop(first, getChildAt(0).getTop() -
        // mFloatViewHeight + getPaddingTop());
        // }

      } else {
        Log.d("mobeta", "expand item skipped");
      }

      if (lp.height != oldHeight) {
        v.requestLayout();
      }
    }
  }
Example #4
0
 @Override
 public void requestLayout() {
   if (!mLayoutBlocked) super.requestLayout();
 }