use snackbar when copying to clipboard

This commit is contained in:
Andrew Dolgov 2017-06-05 19:15:50 +03:00
parent b8b0b73ffb
commit 4f35eb65a5

View File

@ -216,16 +216,22 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
@SuppressLint({ "NewApi", "ServiceCast" }) @SuppressLint({ "NewApi", "ServiceCast" })
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void copyToClipboard(String str) { public void copyToClipboard(String str) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(str); clipboard.setText(str);
} else { } else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(str); clipboard.setText(str);
} }
Toast toast = Toast.makeText(this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT); Snackbar.make(findViewById(android.R.id.content), R.string.text_copied_to_clipboard, Snackbar.LENGTH_SHORT)
toast.show(); .setAction(R.string.dialog_close, new View.OnClickListener() {
@Override
public void onClick(View v) {
}
})
.show();
} }
protected void setAppTheme(SharedPreferences prefs) { protected void setAppTheme(SharedPreferences prefs) {