diff options
author | linus_lee <llee@cyngn.com> | 2015-01-20 18:19:01 -0800 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 16:11:14 -0700 |
commit | a7f6eb1a3752e472c115060cfe01812861d69501 (patch) | |
tree | dc72890cfccc0fd446bd25fe0071647ca5cf8879 /src/com/android/settings/profiles | |
parent | aeca4295807a848a424db7cbb88e96d80bd528b7 (diff) | |
download | packages_apps_Settings-a7f6eb1a3752e472c115060cfe01812861d69501.zip packages_apps_Settings-a7f6eb1a3752e472c115060cfe01812861d69501.tar.gz packages_apps_Settings-a7f6eb1a3752e472c115060cfe01812861d69501.tar.bz2 |
Settings: Enforce non-blank profile names
Change-Id: I2633c5a29461a098af82a4daf207b0e9a8686de2
Diffstat (limited to 'src/com/android/settings/profiles')
-rw-r--r-- | src/com/android/settings/profiles/SetupActionsFragment.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java index 485981a..7203b48 100644 --- a/src/com/android/settings/profiles/SetupActionsFragment.java +++ b/src/com/android/settings/profiles/SetupActionsFragment.java @@ -42,6 +42,9 @@ import android.os.Bundle; import android.provider.Settings; import android.telecom.TelecomManager; import android.telephony.TelephonyManager; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -50,6 +53,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; @@ -702,7 +706,7 @@ public class SetupActionsFragment extends SettingsPreferenceFragment entry.setText(mProfile.getName()); entry.setSelectAllOnFocus(true); - new AlertDialog.Builder(getActivity()) + final AlertDialog alertDialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.rename_dialog_title) .setView(dialogView) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @@ -715,7 +719,27 @@ public class SetupActionsFragment extends SettingsPreferenceFragment } }) .setNegativeButton(android.R.string.cancel, null) - .show(); + .create(); + + entry.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + final boolean empty = TextUtils.isEmpty(s.toString()); + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!empty); + } + }); + + alertDialog.show(); } @Override |