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;
}
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) {
}
}
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();
}
}
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();
}
});
}
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);
}
Aggregations