Applied Material Spec to Bluetooth pairing dialog.

Bug: 17018290
Change-Id: I621164245e6ad8213a689ea4919c619a9ee4f189
This commit is contained in:
PauloftheWest
2014-08-15 06:05:42 -07:00
parent 18fbf724aa
commit e49c30e533
5 changed files with 111 additions and 40 deletions

View File

@@ -29,15 +29,61 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/message" android:id="@+id/message_caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginTop="20dip" android:layout_marginTop="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="20dip"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="@*android:color/secondary_text_material_light" />
<TextView
android:id="@+id/message_subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<TextView
android:id="@+id/pairing_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:text="@string/bluetooth_pairing_key_msg"
android:visibility="gone"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="@*android:color/secondary_text_material_light" />
<TextView
android:id="@+id/pairing_subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:visibility="gone"
android:textAppearance="@android:style/TextAppearance.Material.Headline" />
<TextView
android:id="@+id/pairing_code_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:text="@string/bluetooth_enter_passkey_msg"
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textColor="@*android:color/secondary_text_material_light"
android:visibility="gone" />
</LinearLayout> </LinearLayout>

View File

@@ -29,22 +29,31 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/message" android:id="@+id/message_caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginTop="20dip" android:layout_marginTop="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="20dip"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="@android:style/TextAppearance.Material.Caption" />
<TextView
android:id="@+id/message_subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
<EditText <EditText
android:id="@+id/text" android:id="@+id/text"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:inputType="textPassword" android:inputType="textPassword"
android:singleLine="true" /> android:singleLine="true" />
@@ -53,8 +62,8 @@
android:text="@string/bluetooth_pin_values_hint" android:text="@string/bluetooth_pin_values_hint"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
@@ -63,8 +72,8 @@
android:text="@string/bluetooth_enable_alphanumeric_pin" android:text="@string/bluetooth_enable_alphanumeric_pin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:gravity="center" android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
@@ -72,8 +81,8 @@
android:id="@+id/message_below_pin" android:id="@+id/message_below_pin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dip" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="20dip" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />

View File

@@ -219,6 +219,7 @@
<!-- Bluetooth Preferences --> <!-- Bluetooth Preferences -->
<dimen name="bluetooth_dialog_padding">8dip</dimen> <dimen name="bluetooth_dialog_padding">8dip</dimen>
<integer name="bluetooth_name_length">32</integer> <integer name="bluetooth_name_length">32</integer>
<dimen name="bluetooth_pairing_padding">20dp</dimen>
<dimen name="wifi_divider_height">1px</dimen> <dimen name="wifi_divider_height">1px</dimen>

View File

@@ -1131,10 +1131,12 @@
<string name="bluetooth_pairing_request">Bluetooth pairing request</string> <string name="bluetooth_pairing_request">Bluetooth pairing request</string>
<!-- Message when bluetooth dialog for pin entry is showing. [CHAR LIMIT=NONE] --> <!-- Message when bluetooth dialog for pin entry is showing. [CHAR LIMIT=NONE] -->
<string name="bluetooth_enter_pin_msg">To pair with:<xliff:g id="bold">&lt;br>&lt;b></xliff:g><xliff:g id="device_name">%1$s</xliff:g><xliff:g id="end_bold">&lt;/b>&lt;br>&lt;br></xliff:g>Type the device\'s required PIN:</string> <string name="bluetooth_enter_pin_msg">Device</string>
<!-- Message when bluetooth is informing the user of the pairing key. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_key_msg">Pairing code</string>
<!-- Message when bluetooth dialog for passkey entry is showing. [CHAR LIMIT=NONE] --> <!-- Message when bluetooth dialog for passkey entry is showing. [CHAR LIMIT=NONE] -->
<string name="bluetooth_enter_passkey_msg">To pair with:<xliff:g id="bold">&lt;br>&lt;b></xliff:g><xliff:g id="device_name">%1$s</xliff:g><xliff:g id="end_bold">&lt;/b>&lt;br>&lt;br></xliff:g>Type the device\'s required passkey:</string> <string name="bluetooth_enter_passkey_msg">Type the pairing code then press Return or Enter</string>
<!-- Checkbox label for alphanumeric PIN entry (default is numeric PIN). [CHAR LIMIT=50] --> <!-- Checkbox label for alphanumeric PIN entry (default is numeric PIN). [CHAR LIMIT=50] -->
<string name="bluetooth_enable_alphanumeric_pin">PIN contains letters or symbols</string> <string name="bluetooth_enable_alphanumeric_pin">PIN contains letters or symbols</string>

View File

@@ -175,7 +175,8 @@ public final class BluetoothPairingDialog extends AlertActivity implements
private View createPinEntryView(String deviceName) { private View createPinEntryView(String deviceName) {
View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null); View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null);
TextView messageView = (TextView) view.findViewById(R.id.message); TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption);
TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead);
TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin); TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin);
CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin); CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin);
mPairingView = (EditText) view.findViewById(R.id.text); mPairingView = (EditText) view.findViewById(R.id.text);
@@ -194,7 +195,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
break; break;
case BluetoothDevice.PAIRING_VARIANT_PASSKEY: case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
messageId1 = R.string.bluetooth_enter_passkey_msg; messageId1 = R.string.bluetooth_enter_pin_msg;
messageId2 = R.string.bluetooth_enter_passkey_other_device; messageId2 = R.string.bluetooth_enter_passkey_other_device;
// Maximum of 6 digits for passkey // Maximum of 6 digits for passkey
maxLength = BLUETOOTH_PASSKEY_MAX_LENGTH; maxLength = BLUETOOTH_PASSKEY_MAX_LENGTH;
@@ -206,9 +207,8 @@ public final class BluetoothPairingDialog extends AlertActivity implements
return null; return null;
} }
// HTML escape deviceName, Format the message string, then parse HTML style tags messageViewCaption.setText(messageId1);
String messageText = getString(messageId1, Html.escapeHtml(deviceName)); messageViewContent.setText(deviceName);
messageView.setText(Html.fromHtml(messageText));
messageView2.setText(messageId2); messageView2.setText(messageId2);
mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER); mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER);
mPairingView.setFilters(new InputFilter[] { mPairingView.setFilters(new InputFilter[] {
@@ -219,33 +219,46 @@ public final class BluetoothPairingDialog extends AlertActivity implements
private View createView(CachedBluetoothDeviceManager deviceManager) { private View createView(CachedBluetoothDeviceManager deviceManager) {
View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_confirm, null); View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_confirm, null);
// Escape device name to avoid HTML injection. // Escape device name to avoid HTML injection.
String name = Html.escapeHtml(deviceManager.getName(mDevice)); String name = Html.escapeHtml(deviceManager.getName(mDevice));
TextView messageView = (TextView) view.findViewById(R.id.message); TextView messageViewCaption = (TextView) view.findViewById(R.id.message_caption);
TextView messageViewContent = (TextView) view.findViewById(R.id.message_subhead);
TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption);
TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead);
TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message);
String messageText; // formatted string containing HTML style tags String messageCaption = null;
String pairingContent = null;
switch (mType) { switch (mType) {
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY:
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN:
case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION: case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION:
messageText = getString(R.string.bluetooth_confirm_passkey_msg, messageCaption = getString(R.string.bluetooth_enter_pin_msg);
name, mPairingKey); pairingContent = mPairingKey;
break; break;
case BluetoothDevice.PAIRING_VARIANT_CONSENT: case BluetoothDevice.PAIRING_VARIANT_CONSENT:
case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT: case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT:
messageText = getString(R.string.bluetooth_incoming_pairing_msg, name); messageCaption = getString(R.string.bluetooth_enter_pin_msg);
break;
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY:
case BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN:
messageText = getString(R.string.bluetooth_display_passkey_pin_msg, name,
mPairingKey);
break; break;
default: default:
Log.e(TAG, "Incorrect pairing type received, not creating view"); Log.e(TAG, "Incorrect pairing type received, not creating view");
return null; return null;
} }
messageView.setText(Html.fromHtml(messageText));
if (messageViewCaption != null) {
messageViewCaption.setText(messageCaption);
messageViewContent.setText(name);
}
if (pairingContent != null) {
pairingViewCaption.setVisibility(View.VISIBLE);
pairingViewContent.setVisibility(View.VISIBLE);
pairingViewContent.setText(pairingContent);
messagePairing.setVisibility(View.VISIBLE);
}
return view; return view;
} }