예제 #1
0
 private void setSelection() {
   if (DBG) {
     Log.d(LOG_TAG, "--- onSelect:" + mCurStart + "," + mCurEnd);
   }
   if (mCurStart >= 0
       && mCurStart <= mEST.getText().length()
       && mCurEnd >= 0
       && mCurEnd <= mEST.getText().length()) {
     if (mCurStart < mCurEnd) {
       mEST.setSelection(mCurStart, mCurEnd);
     } else {
       mEST.setSelection(mCurEnd, mCurStart);
     }
     mState = STATE_SELECTED;
   } else {
     Log.e(
         LOG_TAG,
         "Select is on, but cursor positions are illigal.:"
             + mEST.getText().length()
             + ","
             + mCurStart
             + ","
             + mCurEnd);
   }
 }
예제 #2
0
 private void changeAlign(Layout.Alignment align) {
   if (DBG) {
     Log.d(LOG_TAG, "--- changeAlign:" + align);
   }
   setStyledTextSpan(
       new AlignmentSpan.Standard(align),
       findLineStart(mEST.getText(), mCurStart),
       findLineEnd(mEST.getText(), mCurEnd));
 }
예제 #3
0
 private void setStyledTextSpan(Object span, int start, int end) {
   if (DBG) {
     Log.d(LOG_TAG, "--- setStyledTextSpan:" + mMode + "," + start + "," + end);
   }
   if (start < end) {
     mEST.getText().setSpan(span, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   } else {
     mEST.getText().setSpan(span, end, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   }
 }
예제 #4
0
 public String getHtml() {
   String htmlBody = Html.toHtml(mEST.getText());
   if (DBG) {
     Log.d(LOG_TAG, "--- getConvertedBody:" + htmlBody);
   }
   return htmlBody;
 }
예제 #5
0
 /* If the style of the span is added, add check case for that style */
 public boolean isStyledText() {
   Editable txt = mEST.getText();
   int len = txt.length();
   if (txt.getSpans(0, len - 1, ParagraphStyle.class).length > 0
       || txt.getSpans(0, len - 1, QuoteSpan.class).length > 0
       || txt.getSpans(0, len - 1, CharacterStyle.class).length > 0
       || mEST.mBackgroundColor != DEFAULT_BACKGROUND_COLOR) {
     return true;
   }
   return false;
 }
예제 #6
0
 private void insertImageSpan(ImageSpan span) {
   if (DBG) {
     Log.d(LOG_TAG, "--- insertImageSpan");
   }
   if (span != null) {
     Log.d(
         LOG_TAG,
         "--- insertimagespan:"
             + span.getDrawable().getIntrinsicHeight()
             + ","
             + span.getDrawable().getIntrinsicWidth());
     Log.d(LOG_TAG, "--- insertimagespan:" + span.getDrawable().getClass());
     int curpos = mEST.getSelectionStart();
     mEST.getText().insert(curpos, "\uFFFC");
     mEST.getText().setSpan(span, curpos, curpos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     mEST.notifyStateChanged(mMode, mState);
   } else {
     Log.e(LOG_TAG, "--- insertImageSpan: null span was inserted");
   }
 }
예제 #7
0
 public void onClearStyles() {
   if (DBG) {
     Log.d(LOG_TAG, "--- onClearStyles");
   }
   Editable txt = mEST.getText();
   int len = txt.length();
   Object[] styles = txt.getSpans(0, len, Object.class);
   for (Object style : styles) {
     if (style instanceof ParagraphStyle
         || style instanceof QuoteSpan
         || style instanceof CharacterStyle) {
       if (style instanceof ImageSpan) {
         int start = txt.getSpanStart(style);
         int end = txt.getSpanEnd(style);
         txt.replace(start, end, "");
       }
       txt.removeSpan(style);
     }
   }
   mEST.setBackgroundDrawable(mEST.mDefaultBackground);
   mEST.mBackgroundColor = DEFAULT_BACKGROUND_COLOR;
 }