FileDocCategorySizeDatePackage
EditStyledText.javaAPI DocAndroid 1.5 API52340Wed May 06 22:41:56 BST 2009com.android.internal.widget

EditStyledText

public class EditStyledText extends android.widget.EditText
EditStyledText extends EditText for managing the flow and status to edit the styled text. This manages the states and flows of editing, supports inserting image, import/export HTML.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
public static final int
MODE_NOTHING
The mode that no editing action is done.
public static final int
MODE_COPY
The mode of copy.
public static final int
MODE_PASTE
The mode of paste.
public static final int
MODE_SIZE
The mode of changing size.
public static final int
MODE_COLOR
The mode of changing color.
public static final int
MODE_SELECT
The mode of selection.
public static final int
MODE_ALIGN
The mode of changing alignment.
public static final int
MODE_CUT
The mode of changing cut.
public static final int
STATE_SELECT_OFF
The state that selection isn't started.
public static final int
STATE_SELECT_ON
The state that selection is started.
public static final int
STATE_SELECTED
The state that selection is done, but not fixed.
public static final int
STATE_SELECT_FIX
The state that selection is done and not fixed.
public static final int
HINT_MSG_NULL
The help message strings.
public static final int
HINT_MSG_COPY_BUF_BLANK
public static final int
HINT_MSG_SELECT_START
public static final int
HINT_MSG_SELECT_END
public static final int
HINT_MSG_PUSH_COMPETE
public static final int
DEFAULT_BACKGROUND_COLOR
The help message strings.
private EditStyledTextNotifier
mESTInterface
private EditorManager
mManager
EditStyledTextEditorManager manages the flow and status of each function for editing styled text.
private StyledTextConverter
mConverter
private StyledTextDialog
mDialog
private android.graphics.drawable.Drawable
mDefaultBackground
private int
mBackgroundColor
Constructors Summary
public EditStyledText(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
EditStyledText extends EditText for managing flow of each editing action.


                   
           
        super(context, attrs, defStyle);
        init();
    
public EditStyledText(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
        init();
    
public EditStyledText(android.content.Context context)

        super(context);
        init();
    
Methods Summary
public intgetBackgroundColor()
Get Background color of View.

return
The background color of View.

        return mBackgroundColor;
    
public intgetEditMode()
Get the mode of the action.

return
The mode of the action.

        return mManager.getEditMode();
    
public intgetForeGroundColor(int pos)
Get Foreground color of View.

return
The background color of View.

        if (DBG) {
            Log.d(LOG_TAG, "---getForeGroundColor: " + pos);
        }
        if (pos < 0 || pos > getText().length()) {
            Log.e(LOG_TAG, "---getForeGroundColor: Illigal position.");
            return DEFAULT_BACKGROUND_COLOR;
        } else {
            ForegroundColorSpan[] spans =
                getText().getSpans(pos, pos, ForegroundColorSpan.class);
            if (spans.length > 0) {
                return spans[0].getForegroundColor();
            } else {
                return DEFAULT_BACKGROUND_COLOR;
            }
        }
    
public java.lang.StringgetHtml()
Get the state of the selection.

return
The state of the selection.

        return mConverter.getHtml();
    
public java.lang.StringgetHtml(java.util.ArrayList uris)
Get the state of the selection.

param
uris The array of used uris.
return
The state of the selection.

        mConverter.getUriArray(uris, getText());
        return mConverter.getHtml();
    
public android.os.BundlegetInputExtras(boolean create)

        if (DBG) {
            Log.d(LOG_TAG, "---getInputExtras");
        }
        Bundle bundle = super.getInputExtras(create);
        if (bundle != null) {
            bundle = new Bundle();
        }
        bundle.putBoolean("allowEmoji", true);
        return bundle;
    
public intgetSelectState()
Get the state of the selection.

return
The state of the selection.

        return mManager.getSelectState();
    
private voidinit()
Initialize members.

        if (DBG) {
            Log.d(LOG_TAG, "--- init");
        }
        requestFocus();
        mDefaultBackground = getBackground();
        mBackgroundColor = DEFAULT_BACKGROUND_COLOR;
        mManager = new EditorManager(this);
        mConverter = new StyledTextConverter(this);
        mDialog = new StyledTextDialog(this);
        setMovementMethod(new StyledTextArrowKeyMethod(mManager));
        mManager.blockSoftKey();
        mManager.unblockSoftKey();
    
public booleanisEditting()
Check whether editing is started or not.

return
Whether editing is started or not.

        return mManager.isEditting();
    
public booleanisSoftKeyBlocked()
Check whether SoftKey is Blocked or not.

return
whether SoftKey is Blocked or not.

        return mManager.isSoftKeyBlocked();
    
public booleanisStyledText()
Check whether styled text or not.

return
Whether styled text or not.

        return mManager.isStyledText();
    
private voidnotifyStateChanged(int mode, int state)
Notify the event that the mode and state are changed.

param
mode Mode of the editing action.
param
state Mode of the selection state.

        if (mESTInterface != null) {
            mESTInterface.notifyStateChanged(mode, state);
        }
    
public voidonClearStyles()

        mManager.onClearStyles();
    
public voidonEndEdit()
End editing.

        mManager.onEndEdit();
    
public voidonFixSelectedItem()
Fix Selected Item.

        mManager.onFixSelectedItem();
    
public voidonInsertHorizontalLine()

        mManager.onInsertHorizontalLine();
    
public voidonInsertImage(android.net.Uri uri)
InsertImage to TextView by using URI

param
uri URI of the iamge inserted to TextView.

        mManager.onInsertImage(uri);
    
public voidonInsertImage(int resId)
InsertImage to TextView by using resource ID

param
resId Resource ID of the iamge inserted to TextView.

        mManager.onInsertImage(resId);
    
private voidonShowAlignAlert()
Show Alignment Selecting Dialog.

        mDialog.onShowAlignAlertDialog();
    
private voidonShowBackgroundColorAlert()
Show Background Color Selecting Dialog.

        mDialog.onShowBackgroundColorAlertDialog();
    
private voidonShowForegroundColorAlert()
Show Foreground Color Selecting Dialog.

        mDialog.onShowForegroundColorAlertDialog();
    
private voidonShowSizeAlert()
Show Size Selecting Dialog.

        mDialog.onShowSizeAlertDialog();
    
public voidonStartAlign()
Start changing "Alignment" action.

        mManager.onStartAlign();
    
public voidonStartBackgroundColor()
Start changing "BackgroundColor" action.

        mManager.onStartBackgroundColor();
    
public voidonStartColor()
Start changing "Color" action.

        mManager.onStartColor();
    
public voidonStartCopy()
Start "Copy" action.

        mManager.onStartCopy();
    
public voidonStartCut()
Start "Cut" action.

        mManager.onStartCut();
    
public voidonStartEdit()
Start editing. This function have to be called before other editing actions.

        mManager.onStartEdit();
    
public voidonStartPaste()
Start "Paste" action.

        mManager.onStartPaste();
    
public voidonStartSelect()
Start "Select" action.

        mManager.onStartSelect();
    
public voidonStartSelectAll()
Start "SelectAll" action.

        mManager.onStartSelectAll();
    
public voidonStartSize()
Start changing "Size" action.

        mManager.onStartSize();
    
public booleanonTouchEvent(android.view.MotionEvent event)

        if (mManager.isSoftKeyBlocked() &&
                event.getAction() == MotionEvent.ACTION_UP) {
            cancelLongPress();
        }
        final boolean superResult = super.onTouchEvent(event);
        if (event.getAction() == MotionEvent.ACTION_UP) {
            if (DBG) {
                Log.d(LOG_TAG, "--- onTouchEvent");
            }
            mManager.onCursorMoved();
        }
        return superResult;
    
public voidsetAlignAlertParams(java.lang.CharSequence aligntitle, java.lang.CharSequence[] alignnames)

        mDialog.setAlignAlertParams(aligntitle, alignnames);
    
public voidsetAlignment(Layout.Alignment align)
Set Alignment of the Item.

param
color The color of the Item.

        mManager.setAlignment(align);
    
public voidsetBackgroundColor(int color)
Set Background color of View.

param
color The background color of view.

        super.setBackgroundColor(color);
        mBackgroundColor = color;
    
public voidsetBuilder(android.app.AlertDialog.Builder builder)
Set Builder for AlertDialog.

param
builder Builder for opening Alert Dialog.

        mDialog.setBuilder(builder);
    
public voidsetColorAlertParams(java.lang.CharSequence colortitle, java.lang.CharSequence[] colornames, java.lang.CharSequence[] colorints)
Set Parameters for ColorAlertDialog.

param
colortitle Title for Alert Dialog.
param
colornames List of name of selecting color.
param
colorints List of int of color.

        mDialog.setColorAlertParams(colortitle, colornames, colorints);
    
private voidsetHintMessage(int msgId)
Notify hint messages what action is expected to calling class.

param
msgId Id of the hint message.

        if (mESTInterface != null) {
            mESTInterface.notifyHintMsg(msgId);
        }
    
public voidsetHtml(java.lang.String html)
Set html to EditStyledText.

param
html The html to be set.

        mConverter.SetHtml(html);
    
public voidsetItemColor(int color)
Set Color of the Item.

param
color The color of the Item.

        mManager.setItemColor(color);
    
public voidsetItemSize(int size)
Set Size of the Item.

param
size The size of the Item.

        mManager.setItemSize(size);
    
public voidsetNotifier(com.android.internal.widget.EditStyledText$EditStyledTextNotifier estInterface)
Set Notifier.

        mESTInterface = estInterface;
    
public voidsetSizeAlertParams(java.lang.CharSequence sizetitle, java.lang.CharSequence[] sizenames, java.lang.CharSequence[] sizedisplayints, java.lang.CharSequence[] sizesendints)
Set Parameters for SizeAlertDialog.

param
sizetitle Title for Alert Dialog.
param
sizenames List of name of selecting size.
param
sizedisplayints List of int of size displayed in TextView.
param
sizesendints List of int of size exported to HTML.

        mDialog.setSizeAlertParams(sizetitle, sizenames, sizedisplayints,
                sizesendints);