Пример #1
0
 @Override
 protected void onFinishInflate() {
   mTextPreview = (TextView) findViewById(R.id.text_preview);
   mTextPreview.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
   mImagePreview = (ImageView) findViewById(R.id.image_preview);
   mAttachmentName = (TextView) findViewById(R.id.attachment_name);
   mAttachmentIcon = (ImageView) findViewById(R.id.attachment_icon);
 }
 private void showPassword() {
   if (isShown) {
     passwordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
   } else {
     passwordEdit.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
   }
   isShown = !isShown;
   if (isShown) {
     showPassword.setImageResource(R.drawable.ic_hide);
   } else {
     showPassword.setImageResource(R.drawable.ic_show);
   }
 }
Пример #3
0
 public void showHidePassword(View view) {
   switch (view.getId()) {
     case R.id.login_show_button:
       showPasswordImgButton.setVisibility(View.GONE);
       hidePasswordImgButton.setVisibility(View.VISIBLE);
       passwordLogin.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
       break;
     case R.id.login_hide_button:
       hidePasswordImgButton.setVisibility(View.GONE);
       showPasswordImgButton.setVisibility(View.VISIBLE);
       passwordLogin.setTransformationMethod(PasswordTransformationMethod.getInstance());
       break;
   }
 }
Пример #4
0
 public void setText(String name, String text) {
   if (!mConformanceMode) {
     if (null == mScrollText) {
       mScrollText = new ScrollView(mContext);
       mScrollText.setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
       addView(
           mScrollText,
           new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0));
       if (DEBUG) {
         mScrollText.setBackgroundColor(0xFF00FF00);
       }
     }
     if (null == mTextView) {
       mTextView = new TextView(mContext);
       mTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
       mScrollText.addView(mTextView);
     }
     mScrollText.requestFocus();
   }
   mTextView.setVisibility(View.VISIBLE);
   mTextView.setText(text);
 }
Пример #5
0
  /**
   * Makes the SlideView working on MMSConformance Mode. The view will be re-layout to the linear
   * view.
   *
   * <p>This is Chinese requirement about mms conformance. The most popular Mms service in China is
   * newspaper which is MMS conformance, normally it mixes the image and text and has a number of
   * slides. The AbsoluteLayout doesn't have good user experience for this kind of message, for
   * example,
   *
   * <p>1. AbsoluteLayout exactly follows the smil's layout which is not optimized, and actually, no
   * other MMS applications follow the smil's layout, they adjust the layout according their screen
   * size. MMS conformance doc also allows the implementation to adjust the layout.
   *
   * <p>2. The TextView is fixed in the small area of screen, and other part of screen is empty once
   * there is no image in the current slide.
   *
   * <p>3. The TextView is scrollable in a small area of screen and the font size is small which
   * make the user experience bad.
   *
   * <p>The better UI for the MMS conformance message could be putting the image/video and text in a
   * linear layout view and making them scrollable together.
   *
   * <p>Another reason for only applying the LinearLayout to the MMS conformance message is that the
   * AbsoluteLayout has ability to play image and video in a same screen. which shouldn't be broken.
   */
  public void enableMMSConformanceMode(int textLeft, int textTop, int imageLeft, int imageTop) {
    mConformanceMode = true;
    if (mScrollViewPort == null) {
      mScrollViewPort =
          new ScrollView(mContext) {
            private int mBottomY;

            @Override
            protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
              super.onLayout(changed, left, top, right, bottom);
              if (getChildCount() > 0) {
                int childHeight = getChildAt(0).getHeight();
                int height = getHeight();
                mBottomY = height < childHeight ? childHeight - height : 0;
              }
            }

            @Override
            protected void onScrollChanged(int l, int t, int oldl, int oldt) {
              // Shows MediaController when the view is scrolled to the top/bottom of itself.
              if (t == 0 || t >= mBottomY) {
                if (mMediaController != null) {
                  mMediaController.show();
                }
              }
            }
          };
      mScrollViewPort.setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
      mViewPort = new LinearLayout(mContext);
      mViewPort.setOrientation(LinearLayout.VERTICAL);
      mViewPort.setGravity(Gravity.CENTER);
      mViewPort.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              if (mMediaController != null) {
                mMediaController.show();
              }
            }
          });
      mScrollViewPort.addView(
          mViewPort,
          new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
      addView(mScrollViewPort);
    }
    // Layout views to fit the LinearLayout from left to right, then top to
    // bottom.
    TreeMap<Position, View> viewsByPosition =
        new TreeMap<Position, View>(
            new Comparator<Position>() {
              public int compare(Position p1, Position p2) {
                int l1 = p1.mLeft;
                int t1 = p1.mTop;
                int l2 = p2.mLeft;
                int t2 = p2.mTop;
                int res = t1 - t2;
                if (res == 0) {
                  res = l1 - l2;
                }
                if (res == 0) {
                  // A view will be lost if return 0.
                  return -1;
                }
                return res;
              }
            });
    if (textLeft >= 0 && textTop >= 0) {
      mTextView = new TextView(mContext);
      mTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
      mTextView.setTextSize(18);
      mTextView.setPadding(5, 5, 5, 5);
      viewsByPosition.put(new Position(textLeft, textTop), mTextView);
    }

    if (imageLeft >= 0 && imageTop >= 0) {
      mImageView = new ImageView(mContext);
      mImageView.setPadding(0, 5, 0, 5);
      viewsByPosition.put(new Position(imageLeft, imageTop), mImageView);
      // According MMS Conformance Document, the image and video should use the same
      // region. So, put the VideoView below the ImageView.
      mVideoView = new VideoView(mContext);
      viewsByPosition.put(new Position(imageLeft + 1, imageTop), mVideoView);
    }
    for (View view : viewsByPosition.values()) {
      if (view instanceof VideoView) {
        mViewPort.addView(
            view,
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT,
                LayoutManager.getInstance().getLayoutParameters().getHeight()));
      } else {
        mViewPort.addView(
            view,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
      }
      view.setVisibility(View.GONE);
    }
  }
Пример #6
0
  private void bindCommonMessage() {
    if (mDownloadButton != null) {
      mDownloadButton.setVisibility(View.GONE);
      mDownloadingLabel.setVisibility(View.GONE);
    }
    // Since the message text should be concatenated with the sender's
    // address(or name), I have to display it here instead of
    // displaying it by the Presenter.
    mBodyTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());

    boolean isSelf = Sms.isOutgoingFolder(mMessageItem.mBoxId);
    String addr = isSelf ? null : mMessageItem.mAddress;
    updateAvatarView(addr, isSelf);

    // Get and/or lazily set the formatted message from/on the
    // MessageItem.  Because the MessageItem instances come from a
    // cache (currently of size ~50), the hit rate on avoiding the
    // expensive formatMessage() call is very high.
    CharSequence formattedMessage = mMessageItem.getCachedFormattedMessage();
    if (formattedMessage == null) {
      formattedMessage =
          formatMessage(
              mMessageItem,
              mMessageItem.mContact,
              mMessageItem.mBody,
              mMessageItem.mSubject,
              mMessageItem.mHighlight,
              mMessageItem.mTextContentType);
      mMessageItem.setCachedFormattedMessage(formattedMessage);
    }
    mBodyTextView.setText(formattedMessage);

    // Debugging code to put the URI of the image attachment in the body of the list item.
    if (DEBUG) {
      String debugText = null;
      if (mMessageItem.mSlideshow == null) {
        debugText = "NULL slideshow";
      } else {
        SlideModel slide = ((SlideshowModel) mMessageItem.mSlideshow).get(0);
        if (slide == null) {
          debugText = "NULL first slide";
        } else if (!slide.hasImage()) {
          debugText = "Not an image";
        } else {
          debugText = slide.getImage().getUri().toString();
        }
      }
      mBodyTextView.setText(mPosition + ": " + debugText);
    }

    // If we're in the process of sending a message (i.e. pending), then we show a "SENDING..."
    // string in place of the timestamp.
    mDateView.setText(
        mMessageItem.isSending()
            ? mContext.getResources().getString(R.string.sending_message)
            : mMessageItem.mTimestamp);

    if (mMessageItem.isSms()) {
      showMmsView(false);
      mMessageItem.setOnPduLoaded(null);
    } else {
      if (DEBUG) {
        Log.v(
            TAG,
            "bindCommonMessage for item: "
                + mPosition
                + " "
                + mMessageItem.toString()
                + " mMessageItem.mAttachmentType: "
                + mMessageItem.mAttachmentType);
      }
      if (mMessageItem.mAttachmentType != WorkingMessage.TEXT) {
        setImage(null, null);
        setOnClickListener(mMessageItem);
        drawPlaybackButton(mMessageItem);
      } else {
        showMmsView(false);
      }
      if (mMessageItem.mSlideshow == null) {
        mMessageItem.setOnPduLoaded(
            new MessageItem.PduLoadedCallback() {
              public void onPduLoaded(MessageItem messageItem) {
                if (DEBUG) {
                  Log.v(
                      TAG,
                      "PduLoadedCallback in MessageListItem for item: "
                          + mPosition
                          + " "
                          + (mMessageItem == null ? "NULL" : mMessageItem.toString())
                          + " passed in item: "
                          + (messageItem == null ? "NULL" : messageItem.toString()));
                }
                if (messageItem != null
                    && mMessageItem != null
                    && messageItem.getMessageId() == mMessageItem.getMessageId()) {
                  mMessageItem.setCachedFormattedMessage(null);
                  bindCommonMessage();
                }
              }
            });
      } else {
        if (mPresenter == null) {
          mPresenter =
              PresenterFactory.getPresenter(
                  "MmsThumbnailPresenter", mContext, this, mMessageItem.mSlideshow);
        } else {
          mPresenter.setModel(mMessageItem.mSlideshow);
          mPresenter.setView(this);
        }
        if (mImageLoadedCallback == null) {
          mImageLoadedCallback = new ImageLoadedCallback(this);
        } else {
          mImageLoadedCallback.reset(this);
        }
        mPresenter.present(mImageLoadedCallback);
      }
    }
    drawRightStatusIndicator(mMessageItem);

    requestLayout();
  }