use of android.content.ClipDescription in project android_frameworks_base by AOSPA.
the class RemoteInput method getResultsFromIntent.
/**
* Get the remote input results bundle from an intent. The returned Bundle will
* contain a key/value for every result key populated by remote input collector.
* Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
* @param intent The intent object that fired in response to an action or content intent
* which also had one or more remote input requested.
*/
public static Bundle getResultsFromIntent(Intent intent) {
ClipData clipData = intent.getClipData();
if (clipData == null) {
return null;
}
ClipDescription clipDescription = clipData.getDescription();
if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
return null;
}
if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
}
return null;
}
use of android.content.ClipDescription in project android_frameworks_base by ResurrectionRemix.
the class RemoteInput method getResultsFromIntent.
/**
* Get the remote input results bundle from an intent. The returned Bundle will
* contain a key/value for every result key populated by remote input collector.
* Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
* @param intent The intent object that fired in response to an action or content intent
* which also had one or more remote input requested.
*/
public static Bundle getResultsFromIntent(Intent intent) {
ClipData clipData = intent.getClipData();
if (clipData == null) {
return null;
}
ClipDescription clipDescription = clipData.getDescription();
if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
return null;
}
if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
}
return null;
}
use of android.content.ClipDescription in project android_frameworks_base by crdroidandroid.
the class RemoteInput method getResultsFromIntent.
/**
* Get the remote input results bundle from an intent. The returned Bundle will
* contain a key/value for every result key populated by remote input collector.
* Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
* @param intent The intent object that fired in response to an action or content intent
* which also had one or more remote input requested.
*/
public static Bundle getResultsFromIntent(Intent intent) {
ClipData clipData = intent.getClipData();
if (clipData == null) {
return null;
}
ClipDescription clipDescription = clipData.getDescription();
if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
return null;
}
if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
}
return null;
}
use of android.content.ClipDescription in project krypton-android by kryptco.
the class MainActivity method checkClipboardForAppLinks.
private void checkClipboardForAppLinks() {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard == null) {
return;
}
ClipData clipData = clipboard.getPrimaryClip();
if (clipData == null) {
return;
}
ClipData.Item item = clipData.getItemAt(0);
if (item == null) {
return;
}
CharSequence pasteData = item.getText();
if (pasteData == null) {
Uri pasteUri = item.getUri();
if (pasteUri != null) {
pasteData = pasteUri.toString();
}
}
if (pasteData != null) {
String pasteString = pasteData.toString();
String[] toks = pasteString.split("\\s");
for (String tok : toks) {
if (tok.startsWith("krypton://")) {
Uri uri = Uri.parse(tok);
if (uri == null) {
continue;
}
// https://stackoverflow.com/questions/23418543/clear-all-clipboard-entries
// Attempt to clear secret link from clipboard
clipboard.setPrimaryClip(new ClipData(new ClipDescription("", new String[] {}), new ClipData.Item("")));
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("App Link Found on Clipboard");
alertDialog.setMessage(uri.toString());
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Process with Krypton", (dialog, which) -> {
dialog.dismiss();
Intent appLinkIntent = new Intent(this, TeamOnboardingActivity.class);
appLinkIntent.setAction("android.intent.action.VIEW");
appLinkIntent.setData(uri);
startActivity(appLinkIntent);
});
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Ignore", (dialog, which) -> dialog.dismiss());
alertDialog.show();
break;
}
}
}
}
use of android.content.ClipDescription in project AndroidUtilCode by Blankj.
the class ClipboardUtils method getLabel.
/**
* Return the label for clipboard.
*
* @return the label for clipboard
*/
public static CharSequence getLabel() {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
// noinspection ConstantConditions
ClipDescription des = cm.getPrimaryClipDescription();
if (des == null) {
return "";
}
CharSequence label = des.getLabel();
if (label == null) {
return "";
}
return label;
}
Aggregations