blob: 30b0e5afdf48880375d0c6feb626527bea3f7213 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package cgeo.geocaching.ui;
import cgeo.geocaching.utils.CryptUtils;
import org.eclipse.jdt.annotation.NonNull;
import android.text.Spannable;
import android.view.View;
import android.widget.TextView;
public class DecryptTextClickListener implements View.OnClickListener {
@NonNull private final TextView targetView;
public DecryptTextClickListener(@NonNull final TextView targetView) {
this.targetView = targetView;
}
@Override
public final void onClick(final View view) {
try {
// do not run the click listener if a link was clicked
if (targetView.getSelectionStart() != -1 || targetView.getSelectionEnd() != -1) {
return;
}
final CharSequence text = targetView.getText();
if (text instanceof Spannable) {
targetView.setText(CryptUtils.rot13((Spannable) text));
} else {
targetView.setText(CryptUtils.rot13((String) text));
}
} catch (final RuntimeException ignored) {
// nothing
}
}
}
|