Revision 1bdf3dc2
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/dialog/RubikDialogSetName.java | ||
---|---|---|
26 | 26 |
import android.support.v4.app.FragmentActivity; |
27 | 27 |
import android.support.v7.app.AlertDialog; |
28 | 28 |
import android.support.v7.app.AppCompatDialogFragment; |
29 |
import android.text.Editable; |
|
30 |
import android.text.TextWatcher; |
|
29 | 31 |
import android.view.LayoutInflater; |
30 | 32 |
import android.view.View; |
31 | 33 |
import android.view.Window; |
32 | 34 |
import android.view.WindowManager; |
35 |
import android.widget.Button; |
|
33 | 36 |
import android.widget.EditText; |
34 | 37 |
import android.widget.TextView; |
35 | 38 |
|
... | ... | |
53 | 56 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
54 | 57 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
55 | 58 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
59 |
|
|
60 |
AlertDialog dialog = (AlertDialog) getDialog(); |
|
61 |
if (dialog != null) |
|
62 |
{ |
|
63 |
Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE); |
|
64 |
positiveButton.setEnabled(false); |
|
65 |
} |
|
56 | 66 |
} |
57 | 67 |
|
58 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
96 | 106 |
} |
97 | 107 |
|
98 | 108 |
builder.setCancelable(true); |
99 |
EditText edit = view.findViewById(R.id.set_name); |
|
100 |
edit.requestFocus(); |
|
101 | 109 |
|
102 | 110 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
103 | 111 |
{ |
... | ... | |
126 | 134 |
}); |
127 | 135 |
|
128 | 136 |
builder.setView(view); |
129 |
Dialog dialog = builder.create(); |
|
137 |
final Dialog dialog = builder.create();
|
|
130 | 138 |
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); |
131 | 139 |
|
140 |
EditText edit = view.findViewById(R.id.set_name); |
|
141 |
edit.requestFocus(); |
|
142 |
|
|
143 |
edit.addTextChangedListener(new TextWatcher() |
|
144 |
{ |
|
145 |
@Override |
|
146 |
public void afterTextChanged(Editable s) {} |
|
147 |
|
|
148 |
@Override |
|
149 |
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} |
|
150 |
|
|
151 |
@Override |
|
152 |
public void onTextChanged(CharSequence s, int start, int before, int count) |
|
153 |
{ |
|
154 |
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(count>0); |
|
155 |
} |
|
156 |
}); |
|
157 |
|
|
132 | 158 |
return dialog; |
133 | 159 |
} |
134 | 160 |
} |
Also available in: Unified diff
The SetName Dialog should be finished.