summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth/BluetoothSettings.java
diff options
context:
space:
mode:
authorPauloftheWest <paulofthewest@google.com>2014-08-03 15:17:45 -0700
committerPauloftheWest <paulofthewest@google.com>2014-08-07 11:31:25 -0700
commit689d2ce29b3093c32d1d2b70caa6fb36a4ecefcb (patch)
tree9654a446b3c6d4aa55fb35efb1bd51e5d97612df /src/com/android/settings/bluetooth/BluetoothSettings.java
parentff150032e3c369513b0ba85b09aff1d8933c7ad3 (diff)
downloadpackages_apps_Settings-689d2ce29b3093c32d1d2b70caa6fb36a4ecefcb.zip
packages_apps_Settings-689d2ce29b3093c32d1d2b70caa6fb36a4ecefcb.tar.gz
packages_apps_Settings-689d2ce29b3093c32d1d2b70caa6fb36a4ecefcb.tar.bz2
Changed a Bluetooth device's settings from an activity to a dialog.
+ Replace the “Paired bluetooth device” screen with a “Pair device” dialog + Add device name text field at the top + Replace “Unpair” list item with a “Forget" button at bottom of dialog + Change “Profiles” section header to “Use for” + Remove status under profile titles + Move checkboxes to left side of labels Bug: 15719219 Change-Id: I3b0e8c82c761fae98f16508b9fd9c58aff651f80
Diffstat (limited to 'src/com/android/settings/bluetooth/BluetoothSettings.java')
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java75
1 files changed, 64 insertions, 11 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index f1125bc..7441c8c 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -18,28 +18,39 @@ package com.android.settings.bluetooth;
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
+import android.app.Activity;
+import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceCategory;
+import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.EditText;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Index;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.widget.SwitchBar;
@@ -64,6 +75,8 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
"android.btopp.intent.action.OPEN_RECEIVED_FILES";
+ private static View mSettingsDialogView = null;
+
private BluetoothEnabler mBluetoothEnabler;
private PreferenceGroup mPairedDevicesCategory;
@@ -371,20 +384,60 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
private final View.OnClickListener mDeviceProfilesListener = new View.OnClickListener() {
public void onClick(View v) {
// User clicked on advanced options icon for a device in the list
- if (v.getTag() instanceof CachedBluetoothDevice) {
- if (isUiRestricted()) return;
-
- CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
+ if (!(v.getTag() instanceof CachedBluetoothDevice)) {
+ Log.w(TAG, "onClick() called for other View: " + v);
+ return;
+ }
- Bundle args = new Bundle(1);
- args.putParcelable(DeviceProfilesSettings.EXTRA_DEVICE, device.getDevice());
+ final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
+ final Activity activity = getActivity();
+ DeviceProfilesSettings profileFrag = (DeviceProfilesSettings)activity.
+ getFragmentManager().findFragmentById(R.id.bluetooth_fragment_settings);
- ((SettingsActivity) getActivity()).startPreferencePanel(
- DeviceProfilesSettings.class.getName(), args,
- R.string.bluetooth_device_advanced_title, null, null, 0);
- } else {
- Log.w(TAG, "onClick() called for other View: " + v); // TODO remove
+ if (mSettingsDialogView != null){
+ ViewGroup parent = (ViewGroup) mSettingsDialogView.getParent();
+ if (parent != null) {
+ parent.removeView(mSettingsDialogView);
+ }
+ }
+ if (profileFrag == null) {
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_picker, null);
+ profileFrag = (DeviceProfilesSettings)activity.getFragmentManager()
+ .findFragmentById(R.id.bluetooth_fragment_settings);
}
+
+ final View dialogLayout = mSettingsDialogView;
+ AlertDialog.Builder settingsDialog = new AlertDialog.Builder(activity);
+ profileFrag.setDevice(device);
+ final EditText deviceName = (EditText)dialogLayout.findViewById(R.id.name);
+ deviceName.setText(device.getName(), TextView.BufferType.EDITABLE);
+ settingsDialog.setView(dialogLayout);
+ settingsDialog.setTitle(R.string.bluetooth_preference_paired_devices);
+ settingsDialog.setPositiveButton(R.string.okay,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ EditText deviceName = (EditText)dialogLayout.findViewById(R.id.name);
+ device.setName(deviceName.getText().toString());
+ }
+ });
+ final Context context = v.getContext();
+ settingsDialog.setNegativeButton(R.string.forget,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ device.unpair();
+ com.android.settings.bluetooth.Utils.updateSearchIndex(activity,
+ BluetoothSettings.class.getName(), device.getName(),
+ context.getResources().getString(R.string.bluetooth_settings),
+ R.drawable.ic_settings_bluetooth2, false);
+ }
+ });
+
+ AlertDialog dialog = settingsDialog.create();
+ dialog.create();
+ dialog.show();
}
};