Fix Bluetooth enable dialog to match Android style guide.

When an app requests to enable Bluetooth and/or Bluetooth discovery,
we show a dialog for user confirmation. Remove the dialog title,
update the message text and button labels to be more descriptive,
and use the standard dialog layout instead of a custom layout.

Also fixes the button layout on the Bluetooth permission test app so
that the "Discoverable" button doesn't wrap to two lines.

Bug: 6001468
Change-Id: I731e2f31b4c822395fc3f83584a092550d9ae7d3
This commit is contained in:
Jake Hamby
2012-06-11 17:04:14 -07:00
parent e9f89cfbf5
commit 95c1003f1c
6 changed files with 32 additions and 70 deletions

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, 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.
*/
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="20dip"
android:paddingEnd="20dip"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</ScrollView>

View File

@@ -23,6 +23,12 @@
<!-- Strings for Dialog create button -->
<string name="create">Create</string>
<!-- Strings for Dialog allow button -->
<string name="allow">Allow</string>
<!-- Strings for Dialog deny button -->
<string name="deny">Deny</string>
<!-- Device Info --> <skip />
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
<string name="device_info_default">Unknown</string>
@@ -216,8 +222,6 @@
<!-- Used as setting title (for checkbox) on second screen after selecting Bluetooth settings -->
<string name="bluetooth">Bluetooth</string>
<!-- Bluetooth settings screen, check box label when the Bluetooth device can be seen by others -->
<string name="bluetooth_visibility">Discoverable</string>
<!-- Bluetooth settings screen, summary after selecting Discoverable check box [CHAR LIMIT=50] -->
<string name="bluetooth_is_discoverable">Visible to all nearby Bluetooth devices (<xliff:g id="discoverable_time_period">%1$s</xliff:g>)</string>
<!-- Bluetooth settings screen, summary when Discoverable duration is set to "forever" [CHAR LIMIT=50] -->
@@ -226,12 +230,8 @@
<string name="bluetooth_not_visible_to_other_devices">Not visible to other Bluetooth devices</string>
<!-- Bluetooth settings screen, summary text when not discoverable with paired devices [CHAR LIMIT=50] -->
<string name="bluetooth_only_visible_to_paired_devices">Only visible to paired devices</string>
<!-- Bluetooth settings screen, Discoverable checkbox summary text -->
<string name="bluetooth_not_discoverable">Make device discoverable</string>
<!-- Bluetooth settings screen, option name to pick discoverability timeout duration (a list dialog comes up) -->
<string name="bluetooth_visibility_timeout">Visibility timeout</string>
<!-- Bluetooth settings screen, Discoverable timout list dialog summary text -->
<string name="bluetooth_visibility_timeout_summary">Set how long device will be discoverable</string>
<!-- Bluetooth settings screen, check box label whether or not to allow
bluetooth voice dialing when lock screen is up-->
<string name="bluetooth_lock_voice_dialing">Lock voice dialing</string>
@@ -303,29 +303,26 @@
<!-- Strings for BluetoothDevicePicker -->
<string name="device_picker">Bluetooth device chooser</string>
<!-- Strings for dialog title when asking to the user whether to allow an app to enable discovery mode -->
<string name="bluetooth_permission_request">"Bluetooth permission request"</string>
<!-- Strings for asking to the user whether to allow an app to enable bluetooth -->
<string name="bluetooth_ask_enablement">"An app wants to turn on Bluetooth. Allow?"</string>
<string name="bluetooth_ask_enablement">An app wants to turn on Bluetooth.</string>
<!-- Strings for asking to the user whether to allow an app to enable discovery mode -->
<string name="bluetooth_ask_discovery" product="tablet">"An app on your tablet wants to make your tablet discoverable by other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Allow?"</string>
<string name="bluetooth_ask_discovery" product="tablet">An app wants to make your tablet visible to other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
<!-- Strings for asking to the user whether to allow an app to enable discovery mode -->
<string name="bluetooth_ask_discovery" product="default">"An app on your phone wants to make your phone discoverable by other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Allow?"</string>
<string name="bluetooth_ask_discovery" product="default">An app wants to make your phone visible to other Bluetooth devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
<!-- Strings for asking to the user whether to allow an app to enable lasting discovery mode -->
<string name="bluetooth_ask_lasting_discovery" product="tablet">"An app on your tablet wants to make your tablet \u201calways discoverable\u201d by other Bluetooth devices. Allow?"</string>
<string name="bluetooth_ask_lasting_discovery" product="default">"An app on your phone wants to make your phone \u201calways discoverable\u201d by other Bluetooth devices. Allow?"</string>
<string name="bluetooth_ask_lasting_discovery" product="tablet">An app wants to make your tablet visible to other Bluetooth devices. You can change this later in Bluetooth settings.</string>
<string name="bluetooth_ask_lasting_discovery" product="default">An app wants to make your phone visible to other Bluetooth devices. You can change this later in Bluetooth settings.</string>
<!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
<string name="bluetooth_ask_enablement_and_discovery" product="tablet">"An app on your tablet wants to turn on Bluetooth and make your tablet discoverable by other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Allow?"</string>
<string name="bluetooth_ask_enablement_and_discovery" product="tablet">An app wants to turn on Bluetooth and make your tablet visible to other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
<!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
<string name="bluetooth_ask_enablement_and_discovery" product="default">"An app on your phone wants to turn on Bluetooth and make your phone discoverable by other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds. Allow?"</string>
<string name="bluetooth_ask_enablement_and_discovery" product="default">An app wants to turn on Bluetooth and make your phone visible to other devices for <xliff:g id="timeout">%1$d</xliff:g> seconds.</string>
<!-- Strings for asking to the user whether to allow an app to enable bluetooth and discovery mode -->
<string name="bluetooth_ask_enablement_and_lasting_discovery" product="tablet">"An app on your tablet wants to turn on Bluetooth and make your tablet discoverable by other devices. Allow?"</string>
<string name="bluetooth_ask_enablement_and_lasting_discovery" product="default">"An app on your phone wants to turn on Bluetooth and make your phone discoverable by other devices. Allow?"</string>
<string name="bluetooth_ask_enablement_and_lasting_discovery" product="tablet">An app wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.</string>
<string name="bluetooth_ask_enablement_and_lasting_discovery" product="default">An app wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.</string>
<!-- Strings for msg to display to user while bluetooth is turning on [CHAR LIMIT=60] -->
<string name="bluetooth_turning_on">"Turning Bluetooth on\u2026"</string>

View File

@@ -149,8 +149,6 @@ public class RequestPermissionActivity extends Activity implements
private void createDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setTitle(getString(R.string.bluetooth_permission_request));
if (mNeededToEnableBluetooth) {
// RequestPermissionHelperActivity has gotten confirmation from user
@@ -167,8 +165,8 @@ public class RequestPermissionActivity extends Activity implements
builder.setMessage(
getString(R.string.bluetooth_ask_discovery, mTimeout));
}
builder.setPositiveButton(getString(R.string.yes), this);
builder.setNegativeButton(getString(R.string.no), this);
builder.setPositiveButton(getString(R.string.allow), this);
builder.setNegativeButton(getString(R.string.deny), this);
}
mDialog = builder.create();

View File

@@ -72,26 +72,20 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
void createDialog() {
final AlertController.AlertParams p = mAlertParams;
p.mIconId = android.R.drawable.ic_dialog_info;
p.mTitle = getString(R.string.bluetooth_permission_request);
View view = getLayoutInflater().inflate(R.layout.bluetooth_discoverable, null);
p.mView = view;
TextView tv = (TextView) view.findViewById(R.id.message);
if (mEnableOnly) {
tv.setText(getString(R.string.bluetooth_ask_enablement));
p.mMessage = getString(R.string.bluetooth_ask_enablement);
} else {
if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
tv.setText(getString(R.string.bluetooth_ask_enablement_and_lasting_discovery));
p.mMessage = getString(R.string.bluetooth_ask_enablement_and_lasting_discovery);
} else {
tv.setText(getString(R.string.bluetooth_ask_enablement_and_discovery, mTimeout));
p.mMessage = getString(R.string.bluetooth_ask_enablement_and_discovery, mTimeout);
}
}
p.mPositiveButtonText = getString(R.string.yes);
p.mPositiveButtonText = getString(R.string.allow);
p.mPositiveButtonListener = this;
p.mNegativeButtonText = getString(R.string.no);
p.mNegativeButtonText = getString(R.string.deny);
p.mNegativeButtonListener = this;
setupAlert();

View File

@@ -32,19 +32,19 @@
style="@android:style/ButtonBar">
<Button android:id="@+id/enable"
android:layout_width="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/enable" />
<Button android:id="@+id/discoverable"
android:layout_width="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/discoverable" />
<Button android:id="@+id/scan"
android:layout_width="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/start_scan" />

View File

@@ -36,6 +36,9 @@ public class BluetoothRequestPermissionTest extends Activity {
BluetoothAdapter mAdapter;
private ArrayAdapter<String> mMsgAdapter;
// Discoverable button alternates between 20 second timeout and no timeout.
private boolean mDiscoveryWithTimeout = true;
private class BtOnClickListener implements OnClickListener {
final boolean mEnableOnly; // enable or enable + discoverable
@@ -103,7 +106,10 @@ public class BluetoothRequestPermissionTest extends Activity {
} else {
addMsg("Starting activity to enable bt + discovery");
i.setAction(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
i.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 20);
// Discoverability duration toggles between 20 seconds and no timeout.
int timeout = (mDiscoveryWithTimeout ? 20 : 0);
i.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, timeout);
mDiscoveryWithTimeout = !mDiscoveryWithTimeout;
}
startActivityForResult(i, 1);
}