use of com.auth0.sharelock.event.ClipboardSecretEvent in project sharelock-android by auth0.
the class ComposeActivity method onResume.
@Override
protected void onResume() {
super.onResume();
final int entryCount = getSupportFragmentManager().getBackStackEntryCount();
final ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (entryCount == 0 && clipboardManager.hasPrimaryClip() && clipboardManager.getPrimaryClip().getItemCount() > 0) {
final ClipData primaryClip = clipboardManager.getPrimaryClip();
final ClipData.Item item = primaryClip.getItemAt(0);
final String text = item.coerceToText(this).toString();
if (text.trim().length() > 0) {
final Snackbar snackbar = Snackbar.with(this).text(getString(R.string.paste_from_clipboard_prompt)).actionLabel(getString(R.string.paste_clipboard_action)).actionColorResource(R.color.sharelock_orange).actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
bus.postSticky(new ClipboardSecretEvent(text));
clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
}
}).duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);
SnackbarManager.show(snackbar);
}
}
}
Aggregations