Refactoring

pull/197/head
M66B 4 years ago
parent d31372050e
commit e487c27fb5

@ -2557,12 +2557,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void onCopy() { private void onCopy() {
ClipboardManager clipboard = ClipboardManager clipboard =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) { if (clipboard == null)
return;
ClipData clip = ClipData.newPlainText(title, text); ClipData clip = ClipData.newPlainText(title, text);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
} }
}
}); });
((ConstraintLayout) flow.getParent()).addView(button); ((ConstraintLayout) flow.getParent()).addView(button);
@ -3718,14 +3719,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void onActionCopyNote(TupleMessageEx message) { private void onActionCopyNote(TupleMessageEx message) {
if (TextUtils.isEmpty(message.notes))
return;
ClipboardManager clipboard = ClipboardManager clipboard =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null && !TextUtils.isEmpty(message.notes)) { if (clipboard == null)
return;
ClipData clip = ClipData.newPlainText(context.getString(R.string.app_name), message.notes); ClipData clip = ClipData.newPlainText(context.getString(R.string.app_name), message.notes);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
} }
}
private void onShow(final TupleMessageEx message, boolean full) { private void onShow(final TupleMessageEx message, boolean full) {
if (full && tvReformatted.getVisibility() == View.VISIBLE) { if (full && tvReformatted.getVisibility() == View.VISIBLE) {

@ -655,7 +655,9 @@ public class FragmentCompose extends FragmentBase {
ClipboardManager clipboard = ClipboardManager clipboard =
(ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) { if (clipboard == null)
return;
ClipData clip = ClipData.newHtmlText( ClipData clip = ClipData.newHtmlText(
getContext().getString(R.string.title_edit_signature_text), getContext().getString(R.string.title_edit_signature_text),
HtmlHelper.getText(getContext(), identity.signature), HtmlHelper.getText(getContext(), identity.signature),
@ -664,7 +666,6 @@ public class FragmentCompose extends FragmentBase {
ToastEx.makeText(getContext(), R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); ToastEx.makeText(getContext(), R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
} }
}
}); });
ibCloseRefHint.setOnClickListener(new View.OnClickListener() { ibCloseRefHint.setOnClickListener(new View.OnClickListener() {

@ -211,13 +211,14 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
public void onClick(View v) { public void onClick(View v) {
ClipboardManager clipboard = ClipboardManager clipboard =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) { if (clipboard == null)
return;
ClipData clip = ClipData.newPlainText(title, etLink.getText().toString()); ClipData clip = ClipData.newPlainText(title, etLink.getText().toString());
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
} }
}
}); });
cbSecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbSecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

Loading…
Cancel
Save