Esempio n. 1
0
  protected void setRightButtonText(String text) {
    RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view);
    rightView.removeAllViews();

    int padding = dp2px(6);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.setMargins(0, 0, dp2px(8), 0);
    TextView tv = new TextView(this);
    tv.setText(text);
    tv.setTextColor(0xFF666666);
    tv.setTextSize(16.f);
    tv.setLayoutParams(lp);
    tv.setBackgroundResource(R.drawable.btn_gray);
    tv.setPadding(2 * padding, padding, 2 * padding, padding);
    tv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onRightButtonClicked(v);
          }
        });

    rightView.addView(tv);
    rightView.setVisibility(View.VISIBLE);
  }
Esempio n. 2
0
  private RelativeLayout createPin() {
    final RelativeLayout pinLayout = new RelativeLayout(getContext());
    pinLayout.setVisibility(View.INVISIBLE);

    final Pin pin = new Pin(getContext());
    pin.setId(ID_PIN);
    final RelativeLayout.LayoutParams pinParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pinParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    pinParams.addRule(RelativeLayout.ALIGN_BOTTOM, ID_PIN_TEXT);
    pinParams.addRule(RelativeLayout.ALIGN_TOP, ID_PIN_TEXT);
    pin.setLayoutParams(pinParams);
    pinLayout.addView(pin);

    final TextView indicatorTextView = new TextView(getContext());
    indicatorTextView.setId(ID_PIN_TEXT);
    final RelativeLayout.LayoutParams indicatorParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicatorParams.addRule(RelativeLayout.LEFT_OF, ID_PIN);
    indicatorTextView.setLayoutParams(indicatorParams);
    indicatorTextView.setTextColor(Color.WHITE);
    indicatorTextView.setGravity(Gravity.CENTER);
    indicatorTextView.setBackgroundColor(GREY_LIGHT);
    pinLayout.addView(indicatorTextView);

    return pinLayout;
  }
Esempio n. 3
0
  /**
   * 点击事件逻辑
   *
   * @param v
   */
  public void widgetClick(View v) {
    switch (v.getId()) {

        // 清空聊天记录按钮
      case R.id.container_menu:
        {
          String st5 = getResources().getString(R.string.Whether_to_empty_all_chats);
          startActivityForResult(
              new Intent(this, AlertDialog.class)
                  .putExtra("titleIsCancel", true)
                  .putExtra("msg", st5)
                  .putExtra("cancel", true),
              REQUEST_CODE_EMPTY_HISTORY);
          break;
        }

      case R.id.btn_set_mode_voice:
        {
          // 点击录音部分视图显示状态变化
          hideKeyboard();
          edittext_layout.setVisibility(View.GONE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeKeyboard.setVisibility(View.VISIBLE);
          buttonSend.setVisibility(View.GONE);
          btnMore.setVisibility(View.VISIBLE);
          buttonPressToSpeak.setVisibility(View.VISIBLE);
          iv_emoticons_normal.setVisibility(View.VISIBLE);
          iv_emoticons_checked.setVisibility(View.INVISIBLE);
          btnContainer.setVisibility(View.VISIBLE);
          emojiIconContainer.setVisibility(View.GONE);
          break;
        }

      case R.id.btn_set_mode_keyboard:
        {
          // 点击键盘按钮图标显示状态变化
          edittext_layout.setVisibility(View.VISIBLE);
          more.setVisibility(View.GONE);
          v.setVisibility(View.GONE);
          buttonSetModeVoice.setVisibility(View.VISIBLE);
          mEditTextContent.requestFocus();
          buttonPressToSpeak.setVisibility(View.GONE);
          if (TextUtils.isEmpty(mEditTextContent.getText())) {
            btnMore.setVisibility(View.VISIBLE);
            buttonSend.setVisibility(View.GONE);
          } else {
            btnMore.setVisibility(View.GONE);
            buttonSend.setVisibility(View.VISIBLE);
          }
          break;
        }

      case R.id.btn_more:
        {
          // 点击更多按钮
          if (more.getVisibility() == View.GONE) {
            hideKeyboard();
            more.setVisibility(View.VISIBLE);
            btnContainer.setVisibility(View.VISIBLE);
            alarmPreview_layout.setVisibility(View.GONE);
            emojiIconContainer.setVisibility(View.GONE);
          } else if (emojiIconContainer.getVisibility() == View.VISIBLE) {
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          } else if (alarmPreview_layout.getVisibility() == View.VISIBLE) {
            alarmPreview_layout.setVisibility(View.GONE);
            btnContainer.setVisibility(View.VISIBLE);
          } else {
            more.setVisibility(View.GONE);
          }
          break;
        }

      case R.id.et_sendmessage:
        {
          listView.setSelection(listView.getCount() - 1);
          if (more.getVisibility() == View.VISIBLE) {
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
          }
          break;
        }

      default:
        break;
    }
  }
Esempio n. 4
0
  // shared image container
  private RelativeLayout getThumbView() {
    rlThumb = new RelativeLayout(getContext());
    rlThumb.setId(1);
    int dp_82 = dipToPx(getContext(), 82);
    int dp_98 = dipToPx(getContext(), 98);
    LayoutParams lpThumb = new LayoutParams(dp_82, dp_98);
    rlThumb.setLayoutParams(lpThumb);

    ivImage = new ImageView(getContext());
    int resId = getBitmapRes(activity, "ssdk_oks_btn_back_nor");
    if (resId > 0) {
      ivImage.setBackgroundResource(resId);
    }
    ivImage.setScaleType(ScaleType.CENTER_INSIDE);
    ivImage.setImageBitmap(image);

    int dp_4 = dipToPx(getContext(), 4);
    ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
    int dp_74 = dipToPx(getContext(), 74);
    RelativeLayout.LayoutParams lpImage = new RelativeLayout.LayoutParams(dp_74, dp_74);
    int dp_16 = dipToPx(getContext(), 16);
    int dp_8 = dipToPx(getContext(), 8);
    lpImage.setMargins(0, dp_16, dp_8, 0);
    ivImage.setLayoutParams(lpImage);
    ivImage.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (image != null && !image.isRecycled()) {
              PicViewer pv = new PicViewer();
              pv.setImageBitmap(image);
              pv.show(activity, null);
            }
          }
        });
    rlThumb.addView(ivImage);

    int dp_24 = dipToPx(getContext(), 24);
    progressBar = new ProgressBar(getContext());
    progressBar.setPadding(dp_24, dp_24, dp_24, dp_24);
    RelativeLayout.LayoutParams pb = new RelativeLayout.LayoutParams(dp_74, dp_74);
    pb.setMargins(0, dp_16, dp_8, 0);
    progressBar.setLayoutParams(pb);
    rlThumb.addView(progressBar);

    Button btn = new Button(getContext());
    btn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // remove the photo to share
            rlThumb.setVisibility(View.GONE);
            ivPin.setVisibility(View.GONE);
            removeImage(imgInfo);
          }
        });
    resId = getBitmapRes(activity, "ssdk_oks_img_cancel");
    if (resId > 0) {
      btn.setBackgroundResource(resId);
    }
    int dp_20 = dipToPx(getContext(), 20);
    RelativeLayout.LayoutParams lpBtn = new RelativeLayout.LayoutParams(dp_20, dp_20);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lpBtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    btn.setLayoutParams(lpBtn);
    rlThumb.addView(btn);

    if (!haveImage()) {
      rlThumb.setVisibility(View.GONE);
    }
    return rlThumb;
  }