Improved text based settings changes validation
This commit is contained in:
parent
fdfb66e10c
commit
92c070117f
1 changed files with 15 additions and 17 deletions
|
@ -21,15 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.text.Editable;
|
import android.text.InputType;
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
|
||||||
public class TextSetting extends BasicSetting implements TextWatcher {
|
public class TextSetting extends BasicSetting {
|
||||||
private EditText mInput;
|
private EditText mInput;
|
||||||
|
|
||||||
public TextSetting(Context context) {
|
public TextSetting(Context context) {
|
||||||
|
@ -56,6 +56,7 @@ public class TextSetting extends BasicSetting implements TextWatcher {
|
||||||
super.init(attrs, defStyleAttr, defStyleRes);
|
super.init(attrs, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
mInput = mView.findViewById(R.id.setting_input);
|
mInput = mView.findViewById(R.id.setting_input);
|
||||||
|
mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
|
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
TypedArray a =
|
TypedArray a =
|
||||||
|
@ -70,21 +71,18 @@ public class TextSetting extends BasicSetting implements TextWatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mInput.addTextChangedListener(this);
|
mInput.setOnFocusChangeListener(
|
||||||
}
|
new OnFocusChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
if (!hasFocus) {
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onTextValueChanged(mInput.getText().toString());
|
mListener.onTextValueChanged(mInput.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
|
|
Loading…
Reference in a new issue