Skip to content

Commit e77e228

Browse files
committed
fix #32
1 parent 9da9b4d commit e77e228

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/src/main/java/studio/carbonylgroup/textfieldboxestest/MainActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {
2525
setContentView(R.layout.activity_main);
2626

2727
// final ExtendedEditText t = findViewById(R.id.extendedEditText);
28-
// final TextFieldBoxes tfb = findViewById(R.id.text_field_boxes3);
28+
// final TextFieldBoxes tfb = findViewById(R.id.text_field_boxes2);
2929

3030
final Button darkButton = findViewById(R.id.dark_button);
3131

textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ protected void onFinishInflate() {
218218

219219
super.onFinishInflate();
220220

221+
222+
221223
this.editText = findEditTextChild();
222224
if (editText == null) return;
223225
this.addView(LayoutInflater.from(getContext()).inflate(R.layout.text_field_boxes_layout, this, false));
@@ -249,12 +251,15 @@ protected void onFinishInflate() {
249251
this.labelTopMargin = RelativeLayout.LayoutParams.class
250252
.cast(this.floatingLabel.getLayoutParams()).topMargin;
251253

254+
final FrameLayout mainBody = this;
255+
252256
this.panel.setOnClickListener(new OnClickListener() {
253257
@Override
254258
public void onClick(View v) {
255259
if (!isActivated()) activate(true);
256260
setHasFocus(true);
257261
inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
262+
mainBody.performClick();
258263
}
259264
});
260265

@@ -264,6 +269,7 @@ public void onClick(View v) {
264269
if (!isActivated()) activate(true);
265270
setHasFocus(true);
266271
inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
272+
mainBody.performClick();
267273
}
268274
});
269275

@@ -288,7 +294,7 @@ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
288294
public void afterTextChanged(Editable editable) {
289295

290296
if (!activated && !editable.toString().isEmpty()) activate(true);
291-
if (activated && editable.toString().isEmpty()) deactivate();
297+
if (activated && editable.toString().isEmpty() && !hasFocus) deactivate();
292298
if (!doNotRemoveError) {
293299
removeError();
294300
updateCounterText();

0 commit comments

Comments
 (0)