Search in sources :

Example 1 with ClipboardManager

use of android.text.ClipboardManager in project cw-advandroid by commonsguy.

the class IPClipper method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    try {
        String addr = getLocalIPAddress();
        if (addr == null) {
            Toast.makeText(this, "IP address not available -- are you online?", Toast.LENGTH_LONG).show();
        } else {
            ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            cm.setText(addr);
            Toast.makeText(this, "IP Address clipped!", Toast.LENGTH_SHORT).show();
        }
    } catch (Exception e) {
        Log.e("IPClipper", "Exception getting IP address", e);
        Toast.makeText(this, "Could not obtain IP address", Toast.LENGTH_LONG).show();
    }
}
Also used : ClipboardManager(android.text.ClipboardManager) SocketException(java.net.SocketException)

Example 2 with ClipboardManager

use of android.text.ClipboardManager in project cw-omnibus by commonsguy.

the class IPClipper method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
        String addr = getLocalIPAddress();
        if (addr == null) {
            Toast.makeText(this, "IP address not available -- are you online?", Toast.LENGTH_LONG).show();
        } else {
            ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            try {
                cm.setText(addr);
                Toast.makeText(this, "IP Address clipped!", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                Log.e(getClass().getSimpleName(), "Exception clipping IP", e);
                Toast.makeText(this, "Exception: " + e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    } catch (Exception e) {
        Log.e("IPClipper", "Exception getting IP address", e);
        Toast.makeText(this, "Could not obtain IP address", Toast.LENGTH_LONG).show();
    }
    finish();
}
Also used : ClipboardManager(android.text.ClipboardManager) SocketException(java.net.SocketException)

Example 3 with ClipboardManager

use of android.text.ClipboardManager in project Signal-Android by WhisperSystems.

the class ConversationFragment method handleCopyMessage.

private void handleCopyMessage(final Set<MessageRecord> messageRecords) {
    List<MessageRecord> messageList = new LinkedList<>(messageRecords);
    Collections.sort(messageList, new Comparator<MessageRecord>() {

        @Override
        public int compare(MessageRecord lhs, MessageRecord rhs) {
            if (lhs.getDateReceived() < rhs.getDateReceived())
                return -1;
            else if (lhs.getDateReceived() == rhs.getDateReceived())
                return 0;
            else
                return 1;
        }
    });
    StringBuilder bodyBuilder = new StringBuilder();
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    boolean first = true;
    for (MessageRecord messageRecord : messageList) {
        String body = messageRecord.getDisplayBody().toString();
        if (body != null) {
            if (!first)
                bodyBuilder.append('\n');
            bodyBuilder.append(body);
            first = false;
        }
    }
    String result = bodyBuilder.toString();
    if (!TextUtils.isEmpty(result))
        clipboard.setText(result);
}
Also used : ClipboardManager(android.text.ClipboardManager) MessageRecord(org.thoughtcrime.securesms.database.model.MessageRecord) MediaMmsMessageRecord(org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord) LinkedList(java.util.LinkedList)

Example 4 with ClipboardManager

use of android.text.ClipboardManager in project CircleDemo by Naoki2015.

the class CommentDialog method onClick.

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.copyTv:
            if (mCommentItem != null) {
                ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                clipboard.setText(mCommentItem.getContent());
            }
            dismiss();
            break;
        case R.id.deleteTv:
            if (mPresenter != null && mCommentItem != null) {
                mPresenter.deleteComment(mCirclePosition, mCommentItem.getId());
            }
            dismiss();
            break;
        default:
            break;
    }
}
Also used : ClipboardManager(android.text.ClipboardManager)

Example 5 with ClipboardManager

use of android.text.ClipboardManager in project AndroidSDK-RecipeBook by gabu.

the class Recipe014 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    String text;
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    if (clipboard.hasText()) {
        text = clipboard.getText().toString();
        Log.d(TAG, text);
    }
    text = "sets by application!";
    clipboard.setText(text);
}
Also used : ClipboardManager(android.text.ClipboardManager)

Aggregations

ClipboardManager (android.text.ClipboardManager)15 Intent (android.content.Intent)5 View (android.view.View)2 ImageView (android.widget.ImageView)2 SocketException (java.net.SocketException)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Editable (android.text.Editable)1 Spanned (android.text.Spanned)1 TextPaint (android.text.TextPaint)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AdapterView (android.widget.AdapterView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1 PopupWindow (android.widget.PopupWindow)1 ScrollView (android.widget.ScrollView)1