summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlinus_lee <llee@cyngn.com>2015-01-20 18:19:01 -0800
committerAdnan Begovic <adnan@cyngn.com>2015-10-26 16:11:14 -0700
commita7f6eb1a3752e472c115060cfe01812861d69501 (patch)
treedc72890cfccc0fd446bd25fe0071647ca5cf8879
parentaeca4295807a848a424db7cbb88e96d80bd528b7 (diff)
downloadpackages_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
-rw-r--r--res/layout/profile_name_dialog.xml1
-rw-r--r--res/values/cm_strings.xml1
-rw-r--r--src/com/android/settings/profiles/SetupActionsFragment.java28
3 files changed, 28 insertions, 2 deletions
diff --git a/res/layout/profile_name_dialog.xml b/res/layout/profile_name_dialog.xml
index 782df92..11ea1d3 100644
--- a/res/layout/profile_name_dialog.xml
+++ b/res/layout/profile_name_dialog.xml
@@ -34,6 +34,7 @@
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:hint="@string/rename_dialog_hint"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 8d899f9..75c5958 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -91,6 +91,7 @@
<string name="rename_dialog_message">Enter a new name</string>
<string name="duplicate_profile_name">Duplicate profile name!</string>
<string name="duplicate_appgroup_name">Duplicate app group name!</string>
+ <string name="rename_dialog_hint">Enter profile name</string>
<!-- Reset Profiles -->
<string name="profile_reset_title">Reset</string>
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