Example usage for android.text InputType TYPE_TEXT_VARIATION_SHORT_MESSAGE

List of usage examples for android.text InputType TYPE_TEXT_VARIATION_SHORT_MESSAGE

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_VARIATION_SHORT_MESSAGE.

Prototype

int TYPE_TEXT_VARIATION_SHORT_MESSAGE

To view the source code for android.text InputType TYPE_TEXT_VARIATION_SHORT_MESSAGE.

Click Source Link

Document

Variation of #TYPE_CLASS_TEXT : entering a short, possibly informal message such as an instant message or a text message.

Usage

From source file:ir.occc.android.irc.activity.ConversationActivity.java

/**
 * On create/*  w w w.  j a  v a2 s .  c om*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    serverId = getIntent().getExtras().getInt("serverId");
    server = Yaaic.getInstance().getServerById(serverId);
    Settings settings = new Settings(this);

    // Finish activity if server does not exist anymore - See #55
    if (server == null) {
        this.finish();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setTitle(server.getTitle());

    setContentView(R.layout.irc_conversations);

    boolean isLandscape = (getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);

    EditText input = (EditText) findViewById(R.id.input);
    input.setOnKeyListener(inputKeyListener);

    pager = (ViewPager) findViewById(R.id.pager);

    pagerAdapter = new ConversationPagerAdapter(this, server);
    pager.setAdapter(pagerAdapter);

    final float density = getResources().getDisplayMetrics().density;

    indicator = (ConversationIndicator) findViewById(R.id.titleIndicator);
    indicator.setServer(server);
    indicator.setTypeface(Typeface.MONOSPACE);
    indicator.setViewPager(pager);

    indicator.setFooterColor(0xFF31B6E7);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(3 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setSelectedColor(0xFFFFFFFF);
    indicator.setSelectedBold(true);
    indicator.setBackgroundColor(0xFF181818);

    historySize = settings.getHistorySize();

    if (server.getStatus() == Status.PRE_CONNECTING) {
        server.clearConversations();
        pagerAdapter.clearConversations();
        server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
    }

    float fontSize = settings.getFontSize();
    indicator.setTextSize(fontSize * density);

    input.setTextSize(settings.getFontSize());
    input.setTypeface(Typeface.MONOSPACE);

    // Optimization : cache field lookups
    Collection<Conversation> mConversations = server.getConversations();

    for (Conversation conversation : mConversations) {
        // Only scroll to new conversation if it was selected before
        if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
            onNewConversation(conversation.getName());
        } else {
            createNewConversation(conversation.getName());
        }
    }

    int setInputTypeFlags = 0;

    setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;

    if (settings.autoCapSentences()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }

    if (isLandscape && settings.imeExtract()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    }

    if (!settings.imeExtract()) {
        input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    }

    input.setInputType(input.getInputType() | setInputTypeFlags);

    // Create a new scrollback history
    scrollback = new Scrollback();
}

From source file:org.sandholm.max.juttele.activity.ConversationActivity.java

/**
 * On create/* ww w.j ava  2  s  . c  o m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    serverId = getIntent().getExtras().getInt("serverId");
    server = Yaaic.getInstance().getServerById(serverId);
    Settings settings = new Settings(this);

    // Finish activity if server does not exist anymore - See #55
    if (server == null) {
        this.finish();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setTitle(server.getTitle());

    setContentView(R.layout.conversations);

    boolean isLandscape = (getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);

    EditText input = (EditText) findViewById(R.id.input);
    input.setOnKeyListener(inputKeyListener);

    input.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendMessage(v.getText().toString());

                // Workaround for a race condition in EditText
                // Instead of calling input.setText("");
                // See:
                // - https://github.com/pocmo/Yaaic/issues/67
                // - http://code.google.com/p/android/issues/detail?id=17508
                TextKeyListener.clear(v.getEditableText());
                return true;
            } else {
                return false;
            }
        }

    });
    input.setHint(server.getIdentity().getNickname());

    pager = (ViewPager) findViewById(R.id.pager);

    pagerAdapter = new ConversationPagerAdapter(this, server);
    pager.setAdapter(pagerAdapter);

    final float density = getResources().getDisplayMetrics().density;

    indicator = (ConversationIndicator) findViewById(R.id.titleIndicator);
    indicator.setServer(server);
    //indicator.setTypeface(Typeface.MONOSPACE);
    indicator.setViewPager(pager);

    //indicator.setFooterColor(0xFF31B6E7);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(3 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setSelectedColor(0xFFFFFFFF);
    indicator.setSelectedBold(true);
    //indicator.setBackgroundColor(0xFF181818);

    historySize = settings.getHistorySize();

    if (server.getStatus() == Status.PRE_CONNECTING) {
        server.clearConversations();
        pagerAdapter.clearConversations();
        server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
    }

    float fontSize = settings.getFontSize();
    indicator.setTextSize(fontSize * density);

    input.setTextSize(settings.getFontSize());
    //input.setTypeface(Typeface.MONOSPACE);

    // Optimization : cache field lookups
    Collection<Conversation> mConversations = server.getConversations();

    for (Conversation conversation : mConversations) {
        // Only scroll to new conversation if it was selected before
        if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
            onNewConversation(conversation.getName());
        } else {
            createNewConversation(conversation.getName());
        }
    }

    int setInputTypeFlags = 0;

    setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;

    if (settings.autoCapSentences()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }

    if (isLandscape && settings.imeExtract()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    }

    if (!settings.imeExtract()) {
        input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    }

    input.setInputType(input.getInputType() | setInputTypeFlags);

    // Create a new scrollback history
    scrollback = new Scrollback();
}

From source file:mbullington.dialogue.activity.ConversationActivity.java

/**
 * On create/*from  ww  w  .  j av a2  s. c  o m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    serverId = getIntent().getExtras().getInt("serverId");
    server = Dialogue.getInstance().getServerById(serverId);
    Settings settings = new Settings(this);

    // Finish activity if server does not exist anymore - See #55
    if (server == null) {
        this.finish();
    }

    setContentView(R.layout.conversations);
    ButterKnife.inject(this);

    Slide enterTransition = new Slide();
    enterTransition.excludeTarget(android.R.id.statusBarBackground, true);

    getWindow().setEnterTransition(enterTransition);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    toolbar.setNavigationIcon(R.drawable.back_arrow);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ConversationActivity.this.finish();
        }
    });

    setTitle(server.getTitle());

    boolean isLandscape = (getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);

    EditText input = (EditText) findViewById(R.id.input);
    input.setOnKeyListener(inputKeyListener);

    pager = (ViewPager) findViewById(R.id.pager);

    pagerAdapter = new ConversationPagerAdapter(this, server);
    pager.setAdapter(pagerAdapter);

    final float density = getResources().getDisplayMetrics().density;

    indicator = (ConversationIndicator) findViewById(R.id.titleIndicator);
    indicator.setServer(server);
    indicator.setTypeface(Typeface.MONOSPACE);
    indicator.setViewPager(pager);

    indicator.setFooterColor(0xFF31B6E7);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(3 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setSelectedColor(0xFFFFFFFF);
    indicator.setSelectedBold(true);
    indicator.setBackgroundColor(0xFF181818);

    historySize = settings.getHistorySize();

    if (server.getStatus() == Status.PRE_CONNECTING) {
        server.clearConversations();
        pagerAdapter.clearConversations();
        server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
    }

    float fontSize = settings.getFontSize();
    indicator.setTextSize(fontSize * density);

    input.setTextSize(settings.getFontSize());
    input.setTypeface(Typeface.MONOSPACE);

    // Optimization : cache field lookups
    Collection<Conversation> mConversations = server.getConversations();

    for (Conversation conversation : mConversations) {
        // Only scroll to new conversation if it was selected before
        if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
            onNewConversation(conversation.getName());
        } else {
            createNewConversation(conversation.getName());
        }
    }

    int setInputTypeFlags = 0;

    setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;

    if (settings.autoCapSentences()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }

    if (isLandscape && settings.imeExtract()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    }

    if (!settings.imeExtract()) {
        input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    }

    input.setInputType(input.getInputType() | setInputTypeFlags);

    // Create a new scrollback history
    scrollback = new Scrollback();
}

From source file:indrora.atomic.activity.ConversationActivity.java

/**
 * On create//from ww  w  .j  a  va  2  s.  com
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    _scheme = App.getColorScheme();

    serverId = getIntent().getExtras().getInt("serverId");
    server = Atomic.getInstance().getServerById(serverId);
    settings = new Settings(this);

    // Finish activity if server does not exist anymore - See #55
    if (server == null) {
        this.finish();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setTitle(server.getTitle());

    setContentView(R.layout.conversations);

    boolean isLandscape = (getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);

    EditText input = (EditText) findViewById(R.id.input);
    input.setOnKeyListener(inputKeyListener);

    // Fix from https://groups.google.com/forum/#!topic/yaaic/Z4bXZXvW7UM

    input.setOnClickListener(new EditText.OnClickListener() {
        public void onClick(View v) {
            openSoftKeyboard(v);
        }
    });

    pager = (ViewPager) findViewById(R.id.pager);

    pagerAdapter = new ConversationPagerAdapter(this, server);
    pager.setAdapter(pagerAdapter);

    final float density = getResources().getDisplayMetrics().density;

    indicator = (ConversationIndicator) findViewById(R.id.titleIndicator);
    indicator.setServer(server);
    indicator.setTypeface(Typeface.MONOSPACE);
    indicator.setViewPager(pager);

    indicator.setFooterColor(0xFF31B6E7);
    indicator.setFooterLineHeight(1 * density);
    indicator.setFooterIndicatorHeight(3 * density);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
    indicator.setSelectedColor(0xFFFFFFFF);
    indicator.setSelectedBold(true);
    indicator.setBackgroundColor(0xFF181818);

    indicator.setVisibility(View.GONE);

    indicator.setOnPageChangeListener(this);

    historySize = settings.getHistorySize();

    if (server.getStatus() == Status.PRE_CONNECTING) {
        server.clearConversations();
        pagerAdapter.clearConversations();
        server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
    }

    float fontSize = settings.getFontSize();
    indicator.setTextSize(fontSize * density);

    input.setTextSize(settings.getFontSize());
    input.setTypeface(Typeface.MONOSPACE);

    // Optimization : cache field lookups
    Collection<Conversation> mConversations = server.getConversations();

    for (Conversation conversation : mConversations) {
        // Only scroll to new conversation if it was selected before
        if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
            onNewConversation(conversation.getName());
        } else {
            createNewConversation(conversation.getName());
        }
    }

    int setInputTypeFlags = 0;

    setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;

    if (settings.autoCapSentences()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }

    if (isLandscape && settings.imeExtract()) {
        setInputTypeFlags |= InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
    }

    if (!settings.imeExtract()) {
        input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    }

    input.setInputType(input.getInputType() | setInputTypeFlags);

    // Add handling for tab-completing from the input box.

    int tabCompleteDrawableResource = (settings.getUseDarkColors() ? R.drawable.ic_tabcomplete_light
            : R.drawable.ic_tabcomplete_dark);
    // The drawable that makes up the actual clicky
    final Drawable tabcompleteDrawable = getResources().getDrawable(tabCompleteDrawableResource);
    // Set the bounds to the Intrinsic width
    // We'll resize this later (well, the input box will handle that for us)
    tabcompleteDrawable.setBounds(0, 0, tabcompleteDrawable.getIntrinsicWidth(),
            tabcompleteDrawable.getIntrinsicWidth());
    // Set the input compound drawables.
    input.setCompoundDrawables(null, null, tabcompleteDrawable, null);
    // Magic.
    final EditText tt = input;
    final ConversationActivity cv = this;
    input.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // This is where we handle some things.
            boolean tappedX = event
                    .getX() > (tt.getWidth() - tt.getPaddingRight() - tabcompleteDrawable.getIntrinsicWidth());

            if (event.getAction() == MotionEvent.ACTION_UP && tappedX) {
                cv.doNickCompletion(tt);
            }
            return false;
        }
    });

    setupColors();
    setupIndicator();

    // Create a new scrollback history
    scrollback = new Scrollback();

    if (getIntent().getExtras().containsKey(EXTRA_TARGET)) {
        ShuffleToHighlight(getIntent());
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    mIsSmsEnabled = MmsConfig.isSmsEnabled(this);
    super.onCreate(savedInstanceState);

    resetConfiguration(getResources().getConfiguration());

    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences((Context) ComposeMessageActivity.this);
    mGestureSensitivity = prefs.getInt(MessagingPreferenceActivity.GESTURE_SENSITIVITY_VALUE, 3);
    mEnableEmoticons = prefs.getBoolean(MessagingPreferenceActivity.ENABLE_EMOTICONS, true);
    boolean showGesture = prefs.getBoolean(MessagingPreferenceActivity.SHOW_GESTURE, false);
    int unicodeStripping = prefs.getInt(MessagingPreferenceActivity.UNICODE_STRIPPING_VALUE,
            MessagingPreferenceActivity.UNICODE_STRIPPING_LEAVE_INTACT);
    mInputMethod = Integer.parseInt(prefs.getString(MessagingPreferenceActivity.INPUT_TYPE,
            Integer.toString(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)));

    mLibrary = TemplateGesturesLibrary.getStore(this);

    int layout = R.layout.compose_message_activity;

    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(layout, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.setEventsInterceptionEnabled(true);
    gestureOverlayView.setGestureVisible(showGesture);
    gestureOverlayView.addOnGesturePerformedListener(this);
    setContentView(gestureOverlayView);//w  w  w  .ja va2 s.c  om
    setProgressBarVisibility(false);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
            | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    // Initialize members for UI elements.
    initResourceRefs();

    LengthFilter lengthFilter = new LengthFilter(MmsConfig.getMaxTextLimit());
    mTextEditor.setFilters(new InputFilter[] { lengthFilter });

    if (unicodeStripping != MessagingPreferenceActivity.UNICODE_STRIPPING_LEAVE_INTACT) {
        boolean stripNonDecodableOnly = unicodeStripping == MessagingPreferenceActivity.UNICODE_STRIPPING_NON_DECODABLE;
        mUnicodeFilter = new UnicodeFilter(stripNonDecodableOnly);
    }

    mContentResolver = getContentResolver();
    mBackgroundQueryHandler = new BackgroundQueryHandler(mContentResolver);

    initialize(savedInstanceState, 0);

    mMultiSensorManager = new MultiSensorManager((Context) ComposeMessageActivity.this, this);

    if (TRACE) {
        android.os.Debug.startMethodTracing("compose");
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
protected void onResume() {
    super.onResume();

    // OLD: get notified of presence updates to update the titlebar.
    // NEW: we are using ContactHeaderWidget which displays presence, but updating presence
    //      there is out of our control.
    //Contact.startPresenceObserver();

    addRecipientsListeners();// w  ww .jav  a 2 s . c  om

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("update title, mConversation=" + mConversation.toString());
    }

    // There seems to be a bug in the framework such that setting the title
    // here gets overwritten to the original title.  Do this delayed as a
    // workaround.
    mMessageListItemHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            ContactList recipients = isRecipientsEditorVisible()
                    ? mRecipientsEditor.constructContactsFromInput(false)
                    : getRecipients();
            updateTitle(recipients);
        }
    }, 100);

    // Load the selected input type
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences((Context) ComposeMessageActivity.this);
    mInputMethod = Integer.parseInt(prefs.getString(MessagingPreferenceActivity.INPUT_TYPE,
            Integer.toString(InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)));
    mTextEditor.setInputType(InputType.TYPE_CLASS_TEXT | mInputMethod | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);

    TelephonyManager tm = (TelephonyManager) getSystemService(Service.TELEPHONY_SERVICE);
    if (MessagingPreferenceActivity.getSmartCallEnabled((Context) ComposeMessageActivity.this)
            && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
        mMultiSensorManager.enable();
    }

    mIsRunning = true;
    updateThreadIdIfRunning();
    mConversation.markAsRead(true);
}