blob: d0c973950409cb1cce8d539826649c4173282492 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package cgeo.geocaching.settings;
import cgeo.geocaching.R;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class LogSignaturePreference extends DialogPreference {
private SettingsActivity settingsActivity;
private EditText editText;
public LogSignaturePreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public LogSignaturePreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
setDialogLayoutResource(R.layout.log_signature_preference_dialog);
}
@Override
protected void onBindDialogView(View view) {
settingsActivity = (SettingsActivity) this.getContext();
editText = (EditText) view.findViewById(R.id.signature_dialog_text);
editText.setText(getPersistedString(""));
settingsActivity.setSignatureTextView(editText);
Button templates = (Button) view.findViewById(R.id.signature_templates);
settingsActivity.registerForContextMenu(templates);
templates.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View templates) {
settingsActivity.openContextMenu(templates);
}
});
super.onBindDialogView(view);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
if (positiveResult) {
String text = editText.getText().toString();
persistString(text);
callChangeListener(text);
}
super.onDialogClosed(positiveResult);
}
}
|