diff options
-rw-r--r-- | res/layout/preference_start_widget.xml | 65 | ||||
-rwxr-xr-x | res/values/dimens.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 15 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/CachedBluetoothDevice.java | 6 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/DeviceProfilesSettings.java | 22 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/PbapServerProfile.java | 7 |
6 files changed, 104 insertions, 15 deletions
diff --git a/res/layout/preference_start_widget.xml b/res/layout/preference_start_widget.xml new file mode 100644 index 0000000..74fd57f --- /dev/null +++ b/res/layout/preference_start_widget.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:gravity="center_vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:background="?android:attr/selectableItemBackground"> + + <LinearLayout + android:id="@android:id/widget_frame" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:minWidth="@dimen/checkbox_widget_min_width" + android:gravity="center" + android:orientation="horizontal" /> + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1" + android:paddingTop="@dimen/checkbox_layout_padding" + android:paddingBottom="@dimen/checkbox_layout_padding"> + + <TextView + android:id="@+android:id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:singleLine="true" + android:textAppearance="@android:style/TextAppearance.Material.Subhead" + android:textColor="?android:attr/textColorPrimary" + android:ellipsize="marquee" + android:fadingEdge="horizontal" /> + + <TextView + android:id="@android:id/summary" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@android:id/title" + android:layout_alignStart="@android:id/title" + android:visibility="gone" + android:textAlignment="viewStart" + android:textAppearance="@android:style/TextAppearance.Material.Body1" + android:textColor="?android:attr/textColorSecondary" + android:maxLines="10" /> + + </RelativeLayout> + +</LinearLayout> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 5db1671..24144b8 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -204,4 +204,8 @@ <!-- Diameter of a round user icon --> <dimen name="user_icon_diameter">56dp</dimen> + <!-- CheckBoxPreference --> + <dimen name="checkbox_widget_min_width">58dip</dimen> + <dimen name="checkbox_layout_padding">16dip</dimen> + </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index a18835a..1d11022 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -390,9 +390,6 @@ <!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] --> <string name="bluetooth_map_acceptance_dialog_text">%1$s wants to access your messages. Give access to %2$s?</string> - - - <!-- Date & time settings screen title --> <string name="date_and_time">Date & time</string> <!-- The title of the activity to pick a time zone. --> @@ -1175,8 +1172,6 @@ <string name="bluetooth_preference_paired_dialog_title">Paired device</string> <!-- Bluetooth settings: Name label [CHAR LIMIT=40] --> <string name="bluetooth_preference_paired_dialog_name_label">Name</string> - <!-- Bluetooth settings: Use for label [CHAR LIMIT=40] --> - <string name="bluetooth_preference_paired_dialog_use_label">Use for</string> <!-- Bluetooth settings: Checkbox label for enable/disable internet connection. [CHAR LIMIT=40] --> <string name="bluetooth_preference_paired_dialog_internet_option">Internet connection</string> <!-- Bluetooth settings: Checkbox label for enable/disable keyboard connection. [CHAR LIMIT=40] --> @@ -1230,9 +1225,13 @@ <string name="bluetooth_profile_opp">File transfer</string> <!-- Bluetooth settings. The user-visible string that is used whenever referring to the HID profile. --> <string name="bluetooth_profile_hid">Input device</string> - <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40]--> + <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (accessing Internet through remote device). [CHAR LIMIT=40] --> <string name="bluetooth_profile_pan">Internet access</string> - <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40]--> + <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PBAP profile. [CHAR LIMIT=40] --> + <string name="bluetooth_profile_pbap">Contact sharing</string> + <!-- Bluetooth settings. The user-visible summary string that is used whenever referring to the PBAP profile (sharing contacts). [CHAR LIMIT=60] --> + <string name="bluetooth_profile_pbap_summary">Use for contact sharing</string> + <!-- Bluetooth settings. The user-visible string that is used whenever referring to the PAN profile (sharing this device's Internet connection). [CHAR LIMIT=40] --> <string name="bluetooth_profile_pan_nap">Internet connection sharing</string> <!-- Bluetooth settings. The user-visible string that is used whenever referring to the map profile. --> <string name="bluetooth_profile_map">Message Access</string> @@ -1257,7 +1256,7 @@ <!-- Bluetooth settings. Connection options screen. The summary of the online mode checkbox. This describes what the setting does in the context of the screen. --> <string name="bluetooth_device_advanced_online_mode_summary">Connect to Bluetooth device</string> <!-- Bluetooth settings. Connection options screen. The title of the header that is above all of the profiles. --> - <string name="bluetooth_device_advanced_profile_header_title">Profiles</string> + <string name="bluetooth_device_advanced_profile_header_title">Use for</string> <!-- Bluetooth settings. Connection options screen. Title for option to rename the device. [CHAR LIMIT=30] --> <string name="bluetooth_device_advanced_rename_device">Rename</string> <!-- Bluetooth settings. Connection options screen. Title for checkbox to enable incoming file transfers [CHAR LIMIT=30] --> diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index 1263797..3b64ade 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -76,11 +76,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // Following constants indicate the user's choices of Phone book/message access settings // User hasn't made any choice or settings app has wiped out the memory - final static int ACCESS_UNKNOWN = 0; + public final static int ACCESS_UNKNOWN = 0; // User has accepted the connection and let Settings app remember the decision - final static int ACCESS_ALLOWED = 1; + public final static int ACCESS_ALLOWED = 1; // User has rejected the connection and let Settings app remember the decision - final static int ACCESS_REJECTED = 2; + public final static int ACCESS_REJECTED = 2; // how many times did User reject the connection to make the rejected persist. final static int PERSIST_REJECTED_TIMES_LIMIT = 2; diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java index b50d2b4..fb7668f 100755 --- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java +++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java @@ -55,6 +55,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment private static final String KEY_RENAME_DEVICE = "rename_device"; private static final String KEY_PROFILE_CONTAINER = "profile_container"; private static final String KEY_UNPAIR = "unpair"; + private static final String KEY_PBAP_SERVER = "PBAP Server"; public static final String EXTRA_DEVICE = "device"; private RenameEditTextPreference mRenameDeviceNamePref; @@ -181,6 +182,16 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment Preference pref = createProfilePreference(profile); mProfileContainer.addPreference(pref); } + + final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice(); + // Only provide PBAP cabability if the client device has requested PBAP. + if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) { + final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile(); + CheckBoxPreference pbapPref = createProfilePreference(psp); + pbapPref.setChecked(pbapPermission == CachedBluetoothDevice.ACCESS_ALLOWED); + mProfileContainer.addPreference(pbapPref); + } + showOrHideProfileGroup(); } @@ -205,6 +216,7 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment */ private CheckBoxPreference createProfilePreference(LocalBluetoothProfile profile) { CheckBoxPreference pref = new CheckBoxPreference(getActivity()); + pref.setLayoutResource(R.layout.preference_start_widget); pref.setKey(profile.toString()); pref.setTitle(profile.getNameResource(mCachedDevice.getDevice())); pref.setPersistent(false); @@ -265,6 +277,15 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment private void onProfileClicked(LocalBluetoothProfile profile, CheckBoxPreference profilePref) { BluetoothDevice device = mCachedDevice.getDevice(); + if (profilePref.getKey().equals(KEY_PBAP_SERVER)) { + final int newPermission = mCachedDevice.getPhonebookPermissionChoice() + == CachedBluetoothDevice.ACCESS_ALLOWED ? CachedBluetoothDevice.ACCESS_REJECTED + : CachedBluetoothDevice.ACCESS_ALLOWED; + mCachedDevice.setPhonebookPermissionChoice(newPermission); + profilePref.setChecked(newPermission == CachedBluetoothDevice.ACCESS_ALLOWED); + return; + } + int status = profile.getConnectionStatus(device); boolean isConnected = status == BluetoothProfile.STATE_CONNECTED; @@ -351,7 +372,6 @@ public final class DeviceProfilesSettings extends SettingsPreferenceFragment */ profilePref.setEnabled(!mCachedDevice.isBusy()); profilePref.setChecked(profile.isPreferred(device)); - profilePref.setSummary(profile.getSummaryResourceForDevice(device)); } private LocalBluetoothProfile getProfileOf(Preference pref) { diff --git a/src/com/android/settings/bluetooth/PbapServerProfile.java b/src/com/android/settings/bluetooth/PbapServerProfile.java index 1f5ca32..87e51a5 100755 --- a/src/com/android/settings/bluetooth/PbapServerProfile.java +++ b/src/com/android/settings/bluetooth/PbapServerProfile.java @@ -118,16 +118,17 @@ final class PbapServerProfile implements LocalBluetoothProfile { } public int getNameResource(BluetoothDevice device) { - return 0; + return R.string.bluetooth_profile_pbap; } public int getSummaryResourceForDevice(BluetoothDevice device) { - return 0; + return R.string.bluetooth_profile_pbap_summary; } public int getDrawableResource(BluetoothClass btClass) { - return 0; + return R.drawable.ic_bt_cellphone; } + protected void finalize() { if (V) Log.d(TAG, "finalize()"); if (mService != null) { |