@Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    //		super.onLayout(changed, l, t, r, b);
    int mImgWidth;
    if (mImg.getVisibility() == View.GONE) {
      mImgWidth = 0;
    } else {
      mImgWidth = mImg.getDrawable().getIntrinsicWidth();
    }
    int mImgHeight = mImg.getDrawable().getIntrinsicHeight();

    //		if (false) {
    //			Log.d(TAG, "mImgWidth " + mImgWidth);
    //			Log.d(TAG, "mImgHeight " + mImgHeight);
    //			Log.d(TAG, "mMeasuredWidth " + mMeasuredWidth);
    //			Log.d(TAG, "mMeasuredHeight " + mMeasuredHeight);
    //		}
    mImg.layout(
        mMeasuredWidth - 10 - mImgWidth,
        (mMeasuredHeight - mImgHeight) / 2,
        mMeasuredWidth - 10,
        (mMeasuredHeight + mImgHeight) / 2);
    mEdt.layout(
        0,
        (mMeasuredHeight - mEdt.getMeasuredHeight()) / 2,
        mMeasuredWidth - 12 - mImgWidth,
        (mMeasuredHeight + mEdt.getMeasuredHeight()) / 2);
  }
 protected void toggleFaceImage() {
   if (faceNormal.getVisibility() == View.VISIBLE) {
     showSelectedFaceImage();
   } else {
     showNormalFaceImage();
   }
 }
          @Override
          public void onClick(View v) {
            if (startButton.getVisibility() == View.VISIBLE) {
              startButton.setVisibility(View.INVISIBLE);
            }

            if (upAnimation.isStarted()) {
              upAnimation.cancel();
            }

            if (startPosition == 0) {
              startPosition = bird.getTop();
            }

            isUpAnimationCancelled = false;
            isDownEndByClick = true;
            // bird.layout(bird.getLeft(), 228, bird.getRight(), 228 + bird.getMeasuredHeight());
            bird.layout(
                bird.getLeft(),
                (int) bird.getY(),
                bird.getRight(),
                (int) bird.getY() + bird.getMeasuredHeight());
            bird.setTranslationY(0);
            upAnimation.start();
          }
 private void flipCardImage() {
   FlipAnimator animator = new FlipAnimator(cardImage, backCardImage);
   if (cardImage.getVisibility() == View.GONE) {
     animator.reverse();
   }
   cardImage.startAnimation(animator);
 }
Example #5
0
  protected void updateMargins() {
    //noinspection ConstantConditions
    final int margin = getResources().getDimensionPixelSize(R.dimen.space_normal);

    final boolean titleVisible = title_TV.getVisibility() == VISIBLE;
    final boolean secondaryTitleVisible = secondaryTitle_TV.getVisibility() == VISIBLE;
    final boolean subTitleVisible = subTitle_TV.getVisibility() == VISIBLE;
    final boolean contentVisible = content_FL.getVisibility() == VISIBLE;
    final boolean iconVisible = icon_IV.getVisibility() == VISIBLE;

    MarginLayoutParams lp = (MarginLayoutParams) subTitle_TV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) content_FL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) icon_IV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) listContainer_LL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin =
        titleVisible || secondaryTitleVisible || subTitleVisible || contentVisible || iconVisible
            ? margin
            : 0;
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.sendPicture) {
      menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small));
      menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium));
      menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large));
      //			Not a good idea, very big pictures cause Out of Memory exceptions, slow display, ...
      //			menu.add(0, MENU_PICTURE_REAL, 0, getString(R.string.share_picture_size_real));
    } else {
      menu.add(v.getId(), MENU_DELETE_MESSAGE, 0, getString(R.string.delete));
      ImageView iv = (ImageView) v.findViewById(R.id.image);
      if (iv != null && iv.getVisibility() == View.VISIBLE) {
        if (!useLinphoneMessageStorage) {
          menu.add(v.getId(), MENU_SAVE_PICTURE, 0, getString(R.string.save_picture));
        }
      } else {
        menu.add(v.getId(), MENU_COPY_TEXT, 0, getString(R.string.copy_text));
      }

      LinphoneChatMessage msg = getMessageForId(v.getId());
      if (msg != null && msg.getStatus() == LinphoneChatMessage.State.NotDelivered) {
        menu.add(v.getId(), MENU_RESEND_MESSAGE, 0, getString(R.string.retry));
      }
    }
  }
  @Override
  public void setIcon(Drawable icon) {
    final boolean showIcon = mItemData.shouldShowIcon() || mForceShowIcon;
    if (!showIcon && !mPreserveIconSpacing) {
      return;
    }

    if (mIconView == null && icon == null && !mPreserveIconSpacing) {
      return;
    }

    if (mIconView == null) {
      insertIconView();
    }

    if (icon != null || mPreserveIconSpacing) {
      mIconView.setImageDrawable(showIcon ? icon : null);

      if (mIconView.getVisibility() != View.VISIBLE) {
        mIconView.setVisibility(View.VISIBLE);
      }
    } else {
      mIconView.setVisibility(View.GONE);
    }
  }
Example #8
0
 @Override
 public void setChecked(boolean checked) {
   if (icon.getVisibility() == View.VISIBLE) {
     this.setBackgroundResource(
         (checked) ? R.drawable.bordergreenlight : R.drawable.bordergreenwhite);
     this.checked = checked;
   }
 }
  /**
   * Aligns the Twitter icon the parent bottom right. Aligns the G+ icon to the left of the Twitter
   * icon if it is present. Otherwise, aligns the G+ icon to the parent bottom right.
   */
  private void determineSocialIconPlacement(ImageView plusOneIcon, ImageView twitterIcon) {
    if (plusOneIcon.getVisibility() == View.VISIBLE) {
      // Set the dimensions of the G+ button.
      int socialIconDimension = getResources().getDimensionPixelSize(R.dimen.social_icon_box_size);
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(socialIconDimension, socialIconDimension);
      params.addRule(RelativeLayout.BELOW, R.id.speaker_abstract);
      params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

      if (twitterIcon.getVisibility() == View.VISIBLE) {
        params.addRule(RelativeLayout.LEFT_OF, R.id.twitter_icon_box);
      } else {
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      }
      plusOneIcon.setLayoutParams(params);
    }
  }
Example #10
0
  private void showOrHideEmptyView() {
    final boolean show = cryptoCustomerCommunityInformationList.isEmpty();
    final int animationResourceId = show ? android.R.anim.fade_in : android.R.anim.fade_out;

    Animation anim = AnimationUtils.loadAnimation(getActivity(), animationResourceId);
    if (show
        && (noUsers.getVisibility() == View.GONE || noUsers.getVisibility() == View.INVISIBLE)) {
      noUsers.setAnimation(anim);
      noUsers.setVisibility(View.VISIBLE);
      recyclerView.setVisibility(View.INVISIBLE);

    } else if (!show && noUsers.getVisibility() == View.VISIBLE) {
      noUsers.setAnimation(anim);
      noUsers.setVisibility(View.GONE);
      recyclerView.setVisibility(View.VISIBLE);
    }
  }
Example #11
0
  @Override
  public boolean onTouchEvent(final MotionEvent event) {
    final ImageView imageView = (ImageView) this.findViewById(R.id.imageView1);

    if (imageView.getVisibility() == View.VISIBLE) imageView.setVisibility(View.INVISIBLE);
    else scene.onTouch(this.mGLView, event, imageView);
    return true;
  }
Example #12
0
 /** 打开 */
 public void minimize() {
   if (mHeaderView.getVisibility() == View.VISIBLE) {
     if (onFlagAreaExpandLis != null) {
       onFlagAreaExpandLis.onFlagAreaExpand();
     }
     smoothSlideTo(1.0f);
   }
 }
 private void onLoadCloudDataFailed() {
   // Show the cloud not loaded message
   animateFadeOutFadeIn(
       mLoadingView.getVisibility() == View.VISIBLE
           ? mLoadingView
           : (mImageView.getVisibility() == View.VISIBLE) ? mImageView : mSearchResults,
       mFailedView);
   showMenuItems(false);
 }
  public void playVoice(String filePath) {
    if (!(new File(filePath).exists())) {
      return;
    }
    AudioManager audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);

    mediaPlayer = new MediaPlayer();
    if (EMChatManager.getInstance().getChatOptions().getUseSpeaker()) {
      audioManager.setMode(AudioManager.MODE_NORMAL);
      audioManager.setSpeakerphoneOn(true);
      mediaPlayer.setAudioStreamType(AudioManager.STREAM_RING);
    } else {
      audioManager.setSpeakerphoneOn(false); // 关闭扬声器
      // 把声音设定成Earpiece(听筒)出来,设定为正在通话中
      audioManager.setMode(AudioManager.MODE_IN_CALL);
      mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
    }
    try {
      mediaPlayer.setDataSource(filePath);
      mediaPlayer.prepare();
      mediaPlayer.setOnCompletionListener(
          new MediaPlayer.OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
              // TODO Auto-generated method stub
              mediaPlayer.release();
              mediaPlayer = null;
              stopPlayVoice(); // stop animation
            }
          });
      isPlaying = true;
      currentPlayListener = this;
      currentMessage = message;
      mediaPlayer.start();
      showAnimation();
      try {
        // 如果是接收的消息
        if (!message.isAcked && message.direct == EMMessage.Direct.RECEIVE) {
          message.isAcked = true;
          if (iv_read_status != null && iv_read_status.getVisibility() == View.VISIBLE) {
            // 隐藏自己未播放这条语音消息的标志
            iv_read_status.setVisibility(View.INVISIBLE);
            EMChatDB.getInstance().updateMessageAck(message.getMsgId(), true);
          }
          // 告知对方已读这条消息
          if (chatType != ChatType.GroupChat)
            EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
        }
      } catch (Exception e) {
        message.isAcked = false;
      }
    } catch (Exception e) {
    }
  }
Example #15
0
  private void startAnimation() {
    if (progressBar.getVisibility() == View.VISIBLE) {}

    if (null != iv_animation && iv_animation.getVisibility() == View.VISIBLE) {
      if (null != animationDrawable) {
        if (!animationDrawable.isRunning()) {
          animationDrawable.start();
        }
      }
    }
  }
  private void renderHealth() {
    if (mHealth.getVisibility() == View.GONE) {
      mHealth.setVisibility(View.VISIBLE);
    }

    TorrentHealth health =
        TorrentHealth.calculate(
            sMovie.torrents.get(mSelectedQuality).seeds,
            sMovie.torrents.get(mSelectedQuality).peers);
    mHealth.setImageResource(health.getImageResource());
  }
Example #17
0
  // when the activity ends save the data below.
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    // standard call NEVER DELETE
    super.onSaveInstanceState(savedInstanceState);
    // Save UI state changes to the savedInstanceState.
    // This bundle will be passed to onCreate if the process is
    // killed and restarted.

    // Save if the picture is visable or not; true if invisible
    savedInstanceState.putBoolean("arms", (ArmsPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("ears", (EarsPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("eyebrows", (EyebrowsPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("eyes", (EyesPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("glasses", (GlassesPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("hat", (HatPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("mouth", (MouthPic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("mustache", (MustachePic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("nose", (NosePic.getVisibility() == View.INVISIBLE));
    savedInstanceState.putBoolean("shoes", (ShoesPic.getVisibility() == View.INVISIBLE));
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == Activity.RESULT_OK && resultCode == REQUEST_PLAYER_ONLINE_VIDEO_ACTIVITY) {

      if (progressView != null && progressView.getVisibility() != View.GONE) {
        progressView.setVisibility(View.GONE);
        progressLayout.setVisibility(View.GONE);
      }
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int contentLeft = left;
    int contentRight = right;
    bottom = bottom - top;
    top = 0;

    int height = bottom - top;

    if (leftImage != null && leftImage.getVisibility() != GONE) {
      int w = leftImage.getMeasuredWidth();
      int h = leftImage.getMeasuredHeight();
      int leftMargin = LEFT_MARGIN;

      contentLeft += w + leftMargin;
      int offset = (height - h) / 2;
      leftImage.layout(left + leftMargin, top + offset, left + leftMargin + w, top + offset + h);
    }

    if (rightImage != null && rightImage.getVisibility() != GONE) {
      int w = rightImage.getMeasuredWidth();
      int h = rightImage.getMeasuredHeight();
      int rightMargin = RIGHT_MARGIN;

      contentRight -= w + rightMargin;
      int offset = (height - h) / 2;
      rightImage.layout(
          right - w - rightMargin, top + offset, right - rightMargin, top + offset + h);
    }

    if (hasControls) {
      contentLeft = left + LEFT_MARGIN;
      contentRight = right - RIGHT_MARGIN;
    }

    if (content != null) {
      content.layout(contentLeft, top, contentRight, bottom);
    }
  }
  private void selectShade(int position) {
    ImageView shellSelected;

    for (int i = 0; i < shadeAdapter.getItemCount(); i++) {
      if (recyclerView.getChildAt(i) != null) {
        shellSelected = ((ImageView) recyclerView.getChildAt(i).findViewById(R.id.shell_selected));
        if (shellSelected.getVisibility() == View.VISIBLE) {
          shellSelected.setVisibility(View.GONE);
        }
      }
    }

    GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager();

    if (getSelectionMode() == SelectionModeEnum.SINGLE_SELECTION_MODE) {

      View view = recyclerView.getChildAt(position - layoutManager.findFirstVisibleItemPosition());

      if (shadeAdapter.getSelectedShade() == position) {
        shadeAdapter.setSelectedShade(-1);

        view.findViewById(R.id.shell_selected).setVisibility(View.INVISIBLE);

      } else {
        shadeAdapter.setSelectedShade(position);

        view.findViewById(R.id.shell_selected).setVisibility(View.VISIBLE);
      }

    } else if (getSelectionMode() == SelectionModeEnum.MULTIPLE_SELECTION_MODE) {

      if (selected.contains(position)) {
        selected.remove((Integer) position);

      } else {
        selected.add(position);
      }

      shadeAdapter.setSelected(selected);

      for (int item : shadeAdapter.getSelected()) {

        if (item >= layoutManager.findFirstVisibleItemPosition()
            && item <= layoutManager.findLastVisibleItemPosition()) {

          View view = recyclerView.getChildAt(item - layoutManager.findFirstVisibleItemPosition());
          view.findViewById(R.id.shell_selected).setVisibility(View.VISIBLE);
        }
      }
    }
  }
Example #21
0
 public final void showInvisibleViews() {
   if (View.INVISIBLE == mHeaderText.getVisibility()) {
     mHeaderText.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mHeaderProgress.getVisibility()) {
     mHeaderProgress.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mHeaderImage.getVisibility()) {
     mHeaderImage.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mSubHeaderText.getVisibility()) {
     mSubHeaderText.setVisibility(View.VISIBLE);
   }
 }
 /* (non-Javadoc)
  * @see android.view.View#onTouchEvent(android.view.MotionEvent)
  */
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   if (checkIndicator != null
       && checkIndicator.getVisibility() == View.VISIBLE
       && isPointInsideView(event, checkIndicator)) {
     checkIndicator.onTouchEvent(event);
     return true;
   } else if (contextMenuButton != null
       && contextMenuButton.getVisibility() == View.VISIBLE
       && isPointInsideView(event, contextMenuButton)) {
     contextMenuButton.onTouchEvent(event);
     return true;
   } else {
     return super.onTouchEvent(event);
   }
 }
Example #23
0
 /** 关闭 */
 public void maximize() {
   if (mHeaderView.getVisibility() == View.VISIBLE) {
     if (!isUnderEnterprise) {
       if (Constants.hasEnterpriseAccountLoggedIn()) {
         ImageLoader.getInstance()
             .displayImage(
                 Constants.userInfo.getEnterprise().getLogo(),
                 mHeaderView,
                 DisplayImageOptionsUtil.flagDisplayOpts);
       } else {
         mHeaderView.setImageResource(R.drawable.flag);
       }
     } else {
       mHeaderView.setImageResource(R.drawable.flag);
     }
     mBgView.setVisibility(View.GONE);
     smoothSlideTo(0.0f);
   }
 }
  @Override
  public void updateSecurityIcon(int securityLevel) {
    // ImageView#setImageResource is no-op if given resource is the current one.
    mSecurityButton.setImageResource(
        LocationBarLayout.getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsScheme()));

    if (mSecurityIconType == securityLevel) return;
    mSecurityIconType = securityLevel;

    if (securityLevel == ConnectionSecurityLevel.NONE) {
      // TODO(yusufo): Add an animator for hiding as well.
      mSecurityButton.setVisibility(GONE);
    } else if (mSecurityButton.getVisibility() != View.VISIBLE) {
      if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnimator.cancel();
      mSecurityButtonShowAnimator.start();
      mUrlBar.deEmphasizeUrl();
    }
    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
  }
  /**
   * Helper for showing and hiding {@link #mFooterDisambig}, which will correctly manage {@link
   * #mArrowDown} as needed.
   */
  private void setResolveVisible(boolean visible, CheckableImageView actionView) {
    // Show or hide the resolve list if needed
    boolean visibleNow = mFooterDisambig.getVisibility() == View.VISIBLE;

    if (mLastAction != null) mLastAction.setChecked(false);
    if (actionView != null) actionView.setChecked(true);
    mLastAction = actionView;

    // Bail early if already in desired state
    if (visible == visibleNow) return;

    mFooter.setVisibility(visible ? View.GONE : View.VISIBLE);
    mFooterDisambig.setVisibility(visible ? View.VISIBLE : View.GONE);

    if (visible) {
      // If showing list, then hide and save state of down arrow
      mWasDownArrow = mWasDownArrow || (mArrowDown.getVisibility() == View.VISIBLE);
      mArrowDown.setVisibility(View.INVISIBLE);
    } else {
      // If hiding list, restore any down arrow state
      mArrowDown.setVisibility(mWasDownArrow ? View.VISIBLE : View.INVISIBLE);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs_layout);

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost(); // The activity TabHost
    TabHost.TabSpec spec; // Resusable TabSpec for each tab
    Intent intent; // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, SearchActivity.class);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec =
        tabHost
            .newTabSpec("search")
            .setIndicator("Search", res.getDrawable(R.drawable.tabicon_search))
            .setContent(intent);
    tabHost.addTab(spec);

    // Do the same for the other tabs
    intent = new Intent().setClass(this, RecentSearchActivity.class);
    spec =
        tabHost
            .newTabSpec("recent")
            .setIndicator("Recent", res.getDrawable(R.drawable.tabicon_recent))
            .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, StarredMessagesActivity.class);
    spec =
        tabHost
            .newTabSpec("starred")
            .setIndicator("Starred", res.getDrawable(R.drawable.tabicon_star))
            .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);

    // TODO Disable tabs
    // tabHost.getTabWidget().getChildTabViewAt(1).setEnabled(false);
    // tabHost.getTabWidget().getChildTabViewAt(2).setEnabled(false);

    // holo seems to hide the icons on the tab so force them to show
    if (Build.VERSION.SDK_INT >= 11 /*HONEYCOMB*/) {
      View tab;
      ImageView image;
      TextView text;

      tab = tabHost.getTabWidget().getChildTabViewAt(0);
      image = (ImageView) tab.findViewById(android.R.id.icon);
      if (image != null && image.getVisibility() == View.GONE) {
        image.setImageDrawable(res.getDrawable(R.drawable.tabicon_search));
        image.setVisibility(View.VISIBLE);
      }
      text = (TextView) tab.findViewById(android.R.id.title);
      text.setSingleLine();

      tab = tabHost.getTabWidget().getChildTabViewAt(1);
      image = (ImageView) tab.findViewById(android.R.id.icon);
      if (image != null && image.getVisibility() == View.GONE) {
        image.setImageDrawable(res.getDrawable(R.drawable.tabicon_recent));
        image.setVisibility(View.VISIBLE);
      }
      text = (TextView) tab.findViewById(android.R.id.title);
      text.setSingleLine();

      tab = tabHost.getTabWidget().getChildTabViewAt(2);
      image = (ImageView) tab.findViewById(android.R.id.icon);
      if (image != null && image.getVisibility() == View.GONE) {
        image.setImageDrawable(res.getDrawable(R.drawable.tabicon_star));
        image.setVisibility(View.VISIBLE);
      }
      text = (TextView) tab.findViewById(android.R.id.title);
      text.setSingleLine();
    }
  }
Example #27
0
 public void setImageLogo(int resid) {
   if (mLogoView.getVisibility() != VISIBLE) {
     mLogoView.setVisibility(VISIBLE);
   }
   mLogoView.setImageResource(resid);
 }
 public void onClick(View v) {
   if (v == mTreeButton) {
     if (mAssistVisualizer != null) {
       mAssistVisualizer.logTree();
     }
   } else if (v == mTextButton) {
     if (mAssistVisualizer != null) {
       mAssistVisualizer.logText();
     }
   } else if (v == mOptionsCheck) {
     refreshOptions();
   } else if (v == mDisallowAssist) {
     int flags = getDisabledShowContext();
     if (mDisallowAssist.isChecked()) {
       flags |= SHOW_WITH_ASSIST;
     } else {
       flags &= ~SHOW_WITH_ASSIST;
     }
     setDisabledShowContext(flags);
   } else if (v == mDisallowScreenshot) {
     int flags = getDisabledShowContext();
     if (mDisallowScreenshot.isChecked()) {
       flags |= SHOW_WITH_SCREENSHOT;
     } else {
       flags &= ~SHOW_WITH_SCREENSHOT;
     }
     setDisabledShowContext(flags);
   } else if (v == mStartButton) {
     mState = STATE_LAUNCHING;
     updateState();
     startVoiceActivity(mStartIntent);
   } else if (v == mConfirmButton) {
     if (mPendingRequest instanceof ConfirmationRequest) {
       ((ConfirmationRequest) mPendingRequest).sendConfirmationResult(true, null);
       mPendingRequest = null;
       mState = STATE_LAUNCHING;
     } else if (mPendingRequest instanceof PickOptionRequest) {
       PickOptionRequest pick = (PickOptionRequest) mPendingRequest;
       int numReturn = mPendingOptions.length / 2;
       if (numReturn <= 0) {
         numReturn = 1;
       }
       VoiceInteractor.PickOptionRequest.Option[] picked =
           new VoiceInteractor.PickOptionRequest.Option[numReturn];
       for (int i = 0; i < picked.length; i++) {
         picked[i] = mPendingOptions[i * 2];
       }
       mPendingOptions = picked;
       if (picked.length <= 1) {
         pick.sendPickOptionResult(picked, null);
         mPendingRequest = null;
         mState = STATE_LAUNCHING;
       } else {
         pick.sendIntermediatePickOptionResult(picked, null);
         updatePickText();
       }
     } else if (mPendingRequest instanceof CommandRequest) {
       Bundle result = new Bundle();
       result.putString("key", "a result!");
       ((CommandRequest) mPendingRequest).sendResult(result);
       mPendingRequest = null;
       mState = STATE_LAUNCHING;
     }
   } else if (v == mAbortButton && mPendingRequest instanceof AbortVoiceRequest) {
     ((AbortVoiceRequest) mPendingRequest).sendAbortResult(null);
     mPendingRequest = null;
   } else if (v == mCompleteButton && mPendingRequest instanceof CompleteVoiceRequest) {
     ((CompleteVoiceRequest) mPendingRequest).sendCompleteResult(null);
     mPendingRequest = null;
   } else if (v == mScreenshot) {
     if (mFullScreenshot.getVisibility() != View.VISIBLE) {
       mFullScreenshot.setVisibility(View.VISIBLE);
     } else {
       mFullScreenshot.setVisibility(View.INVISIBLE);
     }
   }
   updateState();
 }
  private void updateLayoutParams() {
    int startMargin = 0;
    int locationBarLayoutChildIndex = -1;
    for (int i = 0; i < getChildCount(); i++) {
      View childView = getChildAt(i);
      if (childView.getVisibility() != GONE) {
        LayoutParams childLayoutParams = (LayoutParams) childView.getLayoutParams();
        if (ApiCompatibilityUtils.getMarginStart(childLayoutParams) != startMargin) {
          ApiCompatibilityUtils.setMarginStart(childLayoutParams, startMargin);
          childView.setLayoutParams(childLayoutParams);
        }
        if (childView == mLocationBarFrameLayout) {
          locationBarLayoutChildIndex = i;
          break;
        }
        int widthMeasureSpec;
        int heightMeasureSpec;
        if (childLayoutParams.width == LayoutParams.WRAP_CONTENT) {
          widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
        } else if (childLayoutParams.width == LayoutParams.MATCH_PARENT) {
          widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
        } else {
          widthMeasureSpec =
              MeasureSpec.makeMeasureSpec(childLayoutParams.width, MeasureSpec.EXACTLY);
        }
        if (childLayoutParams.height == LayoutParams.WRAP_CONTENT) {
          heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
        } else if (childLayoutParams.height == LayoutParams.MATCH_PARENT) {
          heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY);
        } else {
          heightMeasureSpec =
              MeasureSpec.makeMeasureSpec(childLayoutParams.height, MeasureSpec.EXACTLY);
        }
        childView.measure(widthMeasureSpec, heightMeasureSpec);
        startMargin += childView.getMeasuredWidth();
      }
    }

    assert locationBarLayoutChildIndex != -1;
    int locationBarLayoutEndMargin = 0;
    for (int i = locationBarLayoutChildIndex + 1; i < getChildCount(); i++) {
      View childView = getChildAt(i);
      if (childView.getVisibility() != GONE) {
        locationBarLayoutEndMargin += childView.getMeasuredWidth();
      }
    }
    LayoutParams urlLayoutParams = (LayoutParams) mLocationBarFrameLayout.getLayoutParams();

    if (ApiCompatibilityUtils.getMarginEnd(urlLayoutParams) != locationBarLayoutEndMargin) {
      ApiCompatibilityUtils.setMarginEnd(urlLayoutParams, locationBarLayoutEndMargin);
      mLocationBarFrameLayout.setLayoutParams(urlLayoutParams);
    }

    // Update left margin of mTitleUrlContainer here to make sure the security icon is always
    // placed left of the urlbar.
    LayoutParams lp = (LayoutParams) mTitleUrlContainer.getLayoutParams();
    if (mSecurityButton.getVisibility() == View.GONE) {
      lp.leftMargin = 0;
    } else {
      lp.leftMargin = mSecurityButton.getMeasuredWidth();
    }
    mTitleUrlContainer.setLayoutParams(lp);
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int w = MeasureSpec.getSize(widthMeasureSpec);
    int wMode = MeasureSpec.getMode(widthMeasureSpec);
    int h = MeasureSpec.getSize(heightMeasureSpec);
    int hMode = MeasureSpec.getMode(heightMeasureSpec);
    int imageHMargin = 0;

    int leftImageWidth = 0;
    int leftImageHeight = 0;
    if (leftImage != null && leftImage.getVisibility() != View.GONE) {
      measureChild(leftImage, widthMeasureSpec, heightMeasureSpec);
      leftImageWidth = leftImage.getMeasuredWidth();
      leftImageHeight = leftImage.getMeasuredHeight();
      imageHMargin += LEFT_MARGIN;
    }

    int rightImageWidth = 0;
    int rightImageHeight = 0;
    if (rightImage != null && rightImage.getVisibility() != View.GONE) {
      measureChild(rightImage, widthMeasureSpec, heightMeasureSpec);
      rightImageWidth = rightImage.getMeasuredWidth();
      rightImageHeight = rightImage.getMeasuredHeight();
      imageHMargin += RIGHT_MARGIN;
    }

    int adjustedWidth = w - leftImageWidth - rightImageWidth - imageHMargin;
    // int adjustedWidth = w;

    if (content != null) {
      measureChild(content, MeasureSpec.makeMeasureSpec(adjustedWidth, wMode), heightMeasureSpec);
      if (hMode == MeasureSpec.UNSPECIFIED) {
        TableViewProxy table = ((TableViewRowProxy) item.proxy).getTable();
        int minRowHeight = -1;
        if (table != null && table.hasProperty(TiC.PROPERTY_MIN_ROW_HEIGHT)) {
          minRowHeight =
              TiConvert.toTiDimension(
                      TiConvert.toString(table.getProperty(TiC.PROPERTY_MIN_ROW_HEIGHT)),
                      TiDimension.TYPE_HEIGHT)
                  .getAsPixels(this);
        }

        if (height == null) {
          h =
              Math.max(
                  h,
                  Math.max(
                      content.getMeasuredHeight(), Math.max(leftImageHeight, rightImageHeight)));
          h = Math.max(h, minRowHeight);
        } else {
          h = Math.max(minRowHeight, height.getAsPixels(this));
        }
        if (DBG) {
          Log.d(LCAT, "Row content measure (" + adjustedWidth + "x" + h + ")");
        }
        measureChild(
            content,
            MeasureSpec.makeMeasureSpec(adjustedWidth, wMode),
            MeasureSpec.makeMeasureSpec(h, hMode));
      }
    }

    setMeasuredDimension(w, Math.max(h, Math.max(leftImageHeight, rightImageHeight)));
  }