Search in sources :

Example 51 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

the class DocumentClipper method getClipDataForDocuments.

/**
     * Returns ClipData representing the list of docs, or null if docs is empty,
     * or docs cannot be converted.
     */
@Nullable
public ClipData getClipDataForDocuments(List<DocumentInfo> docs) {
    final ContentResolver resolver = mContext.getContentResolver();
    final String[] mimeTypes = getMimeTypes(resolver, docs);
    ClipData clipData = null;
    for (DocumentInfo doc : docs) {
        if (clipData == null) {
            // TODO: figure out what this string should be.
            // Currently it is not displayed anywhere in the UI, but this might change.
            final String label = "";
            clipData = new ClipData(label, mimeTypes, new ClipData.Item(doc.derivedUri));
        } else {
            // TODO: update list of mime types in ClipData.
            clipData.addItem(new ClipData.Item(doc.derivedUri));
        }
    }
    return clipData;
}
Also used : ClipData(android.content.ClipData) ContentResolver(android.content.ContentResolver) DocumentInfo(com.android.documentsui.model.DocumentInfo) Nullable(android.support.annotation.Nullable)

Example 52 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

the class VoiceInteractionSessionConnection method deliverSessionDataLocked.

private void deliverSessionDataLocked(AssistDataForActivity assistDataForActivity) {
    Bundle assistData = assistDataForActivity.data.getBundle(VoiceInteractionSession.KEY_DATA);
    AssistStructure structure = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_STRUCTURE);
    AssistContent content = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_CONTENT);
    int uid = assistDataForActivity.data.getInt(Intent.EXTRA_ASSIST_UID, -1);
    if (uid >= 0 && content != null) {
        Intent intent = content.getIntent();
        if (intent != null) {
            ClipData data = intent.getClipData();
            if (data != null && Intent.isAccessUriMode(intent.getFlags())) {
                grantClipDataPermissions(data, intent.getFlags(), uid, mCallingUid, mSessionComponentName.getPackageName());
            }
        }
        ClipData data = content.getClipData();
        if (data != null) {
            grantClipDataPermissions(data, Intent.FLAG_GRANT_READ_URI_PERMISSION, uid, mCallingUid, mSessionComponentName.getPackageName());
        }
    }
    try {
        mSession.handleAssist(assistData, structure, content, assistDataForActivity.activityIndex, assistDataForActivity.activityCount);
    } catch (RemoteException e) {
    }
}
Also used : AssistContent(android.app.assist.AssistContent) Bundle(android.os.Bundle) AssistStructure(android.app.assist.AssistStructure) Intent(android.content.Intent) RemoteException(android.os.RemoteException) ClipData(android.content.ClipData)

Example 53 with ClipData

use of android.content.ClipData in project libgdx by libgdx.

the class AndroidClipboard method getContents.

@Override
public String getContents() {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
        if (clipboard.getText() == null)
            return null;
        return clipboard.getText().toString();
    } else {
        ClipData clip = honeycombClipboard.getPrimaryClip();
        if (clip == null)
            return null;
        CharSequence text = clip.getItemAt(0).getText();
        if (text == null)
            return null;
        return text.toString();
    }
}
Also used : ClipData(android.content.ClipData)

Example 54 with ClipData

use of android.content.ClipData in project facebook-android-sdk by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    gameController = new GameController(this, getIntent());
    board = (GridView) findViewById(R.id.board);
    validNumbers = (GridView) findViewById(R.id.valid_numbers);
    gameController.setBoardView(board);
    gameController.setSelectionView(validNumbers);
    Button newGame = (Button) findViewById(R.id.new_board);
    newGame.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            gameController.newGame();
        }
    });
    Button clearBoard = (Button) findViewById(R.id.clear_board);
    clearBoard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            gameController.clearBoard();
        }
    });
    final ShareButton share = (ShareButton) findViewById(R.id.share_button);
    share.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            share.setShareContent(getLinkContent());
        }
    });
    final SendButton send = (SendButton) findViewById(R.id.send_button);
    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            send.setShareContent(getLinkContent());
        }
    });
    Button copy = (Button) findViewById(R.id.copy_button);
    copy.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newUri(getContentResolver(), "Iconicus", gameController.getShareUri());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(MainActivity.this, R.string.link_copied, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) SendButton(com.facebook.share.widget.SendButton) ShareButton(com.facebook.share.widget.ShareButton) Button(android.widget.Button) SendButton(com.facebook.share.widget.SendButton) GridView(android.widget.GridView) View(android.view.View) ShareButton(com.facebook.share.widget.ShareButton) ClipData(android.content.ClipData)

Example 55 with ClipData

use of android.content.ClipData in project Hummingbird-for-Android by xiprox.

the class AnimeDetailsActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch(id) {
        case R.id.action_copy_title:
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(getResources().getString(R.string.toast_copy_title), anime.getTitle());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(AnimeDetailsActivity.this, getResources().getString(R.string.toast_copy_title) + " \"" + anime.getTitle() + "\"", Toast.LENGTH_SHORT).show();
            break;
        case R.id.action_share:
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            String messageBody = getString(R.string.content_sharing_text);
            messageBody = messageBody.replace("{anime-name}", anime.getTitle()).replace("{anime-url}", "https://hummingbird.me/anime/" + anime.getSlug());
            intent.putExtra(Intent.EXTRA_TEXT, messageBody);
            startActivity(Intent.createChooser(intent, getResources().getString(R.string.action_share)));
            break;
        case R.id.action_remove:
            String contentText = getString(R.string.content_remove_are_you_sure);
            contentText = contentText.replace("{anime-name}", anime.getTitle());
            new MaterialDialog.Builder(this).positiveText(R.string.yes).negativeText(R.string.no).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).content(contentText).callback(new MaterialDialog.ButtonCallback() {

                @Override
                public void onPositive(MaterialDialog materialDialog) {
                    new RemoveTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            }).show();
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : ClipboardManager(android.content.ClipboardManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Intent(android.content.Intent) ClipData(android.content.ClipData)

Aggregations

ClipData (android.content.ClipData)343 ClipboardManager (android.content.ClipboardManager)190 Intent (android.content.Intent)83 Uri (android.net.Uri)65 View (android.view.View)38 MenuItem (android.view.MenuItem)34 TextView (android.widget.TextView)34 ArrayList (java.util.ArrayList)29 Paint (android.graphics.Paint)24 ImageView (android.widget.ImageView)20 Context (android.content.Context)19 DialogInterface (android.content.DialogInterface)19 PendingIntent (android.app.PendingIntent)16 Bundle (android.os.Bundle)16 RemoteException (android.os.RemoteException)14 SpannableStringBuilder (android.text.SpannableStringBuilder)14 SuppressLint (android.annotation.SuppressLint)12 TargetApi (android.annotation.TargetApi)12 Drawable (android.graphics.drawable.Drawable)11 RecyclerView (android.support.v7.widget.RecyclerView)11