Bluetooth : fix UI bug: Disable "OK" button if friendly name is null
- If device's name is null, BT address is set as friendly name.
- so, fixed. if name field is null "OK" button is disabled.
Change-Id: I04b59ebf13d1b3203acf7345bd531cc6c563da0d
Signed-off-by: jhtop.kim <jhtop.kim@samsung.com>
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
old mode 100644
new mode 100755
index ecb7112..f7f21ff
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -30,7 +30,11 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
-
+import android.widget.EditText;
+import android.text.TextWatcher;
+import android.app.Dialog;
+import android.widget.Button;
+import android.text.Editable;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -53,7 +57,7 @@
//private static final String KEY_ALLOW_INCOMING = "allow_incoming";
public static final String EXTRA_DEVICE = "device";
-
+ private RenameEditTextPreference mRenameDeviceNamePref;
private LocalBluetoothManager mManager;
private CachedBluetoothDevice mCachedDevice;
private LocalBluetoothProfileManager mProfileManager;
@@ -65,7 +69,24 @@
= new HashMap<LocalBluetoothProfile, CheckBoxPreference>();
private AlertDialog mDisconnectDialog;
+ private class RenameEditTextPreference implements TextWatcher{
+ public void afterTextChanged(Editable s) {
+ Dialog d = mDeviceNamePref.getDialog();
+ if (d instanceof AlertDialog) {
+ ((AlertDialog) d).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(s.length() > 0);
+ }
+ }
+ // TextWatcher interface
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // not used
+ }
+
+ // TextWatcher interface
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // not used
+ }
+ }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -88,7 +109,7 @@
finish();
return; // TODO: test this failure path
}
-
+ mRenameDeviceNamePref = new RenameEditTextPreference();
mManager = LocalBluetoothManager.getInstance(getActivity());
CachedBluetoothDeviceManager deviceManager =
mManager.getCachedDeviceManager();
@@ -137,6 +158,15 @@
mCachedDevice.registerCallback(this);
refresh();
+ EditText et = mDeviceNamePref.getEditText();
+ if (et != null) {
+ et.addTextChangedListener(mRenameDeviceNamePref);
+ Dialog d = mDeviceNamePref.getDialog();
+ if (d instanceof AlertDialog) {
+ Button b = ((AlertDialog) d).getButton(AlertDialog.BUTTON_POSITIVE);
+ b.setEnabled(et.getText().length() > 0);
+ }
+ }
}
@Override