diff options
author | Andres Morales <anmorales@google.com> | 2014-11-13 08:34:33 -0800 |
---|---|---|
committer | Andres Morales <anmorales@google.com> | 2014-11-13 08:34:33 -0800 |
commit | dceae917c7aeb73dfce10ab5e2e9143fb988c4a8 (patch) | |
tree | fe8a2305c7157d8cd9a63ac72732632a233b7752 | |
parent | b82d80d891077ccd74729e4143925a66eb89eef2 (diff) | |
download | android_packages_apps_Nfc-dceae917c7aeb73dfce10ab5e2e9143fb988c4a8.tar.gz android_packages_apps_Nfc-dceae917c7aeb73dfce10ab5e2e9143fb988c4a8.tar.bz2 android_packages_apps_Nfc-dceae917c7aeb73dfce10ab5e2e9143fb988c4a8.zip |
Make BT pairing strings localizable
Bug:18207126
Change-Id: I8600e5d8cde75074205d822b819b4fb08e7e4a1d
-rwxr-xr-x | res/values/strings.xml | 25 | ||||
-rw-r--r-- | src/com/android/nfc/handover/BluetoothPeripheralHandover.java | 35 |
2 files changed, 35 insertions, 25 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 923e4322..1ca995d0 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -29,14 +29,25 @@ <string name="beam_handover_not_supported">The receiver\'s device doesn\'t support large file transfer via beam.</string> <string name="beam_try_again">Bring devices together again</string> - <string name="connecting_peripheral">Connecting</string> - <string name="connected_peripheral">Connected</string> - <string name="connect_peripheral_failed">Could not connect</string> - <string name="disconnecting_peripheral">Disconnecting</string> - <string name="disconnected_peripheral">Disconnected</string> - <string name="pairing_peripheral">Pairing</string> - <string name="pairing_peripheral_failed">Could not pair</string> + <!-- String referring to the device being connected when there is no name for the device --> + <string name="device">device</string> + <!-- Toast string informing the user that the device is connecting [CHAR_LIMIT=35] --> + <string name="connecting_peripheral">Connecting <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device is connected [CHAR_LIMIT=35] --> + <string name="connected_peripheral">Connected <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device failed to connect [CHAR_LIMIT=35] --> + <string name="connect_peripheral_failed">Could not connect <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device is disconnecting [CHAR_LIMIT=35] --> + <string name="disconnecting_peripheral">Disconnecting <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device is disconnected [CHAR_LIMIT=35] --> + <string name="disconnected_peripheral">Disconnected <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device is pairing [CHAR_LIMIT=35] --> + <string name="pairing_peripheral">Pairing <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that the device failed to pair [CHAR_LIMIT=35] --> + <string name="pairing_peripheral_failed">Could not pair <xliff:g id="device_name">%1$s</xliff:g></string> + <!-- Toast string informing the user that BT could not be enabled [CHAR_LIMIT=35] --> <string name="failed_to_enable_bt">Could not enable Bluetooth</string> + <!-- Dialog string informing the user that BT could not be enabled [CHAR_LIMIT=75] --> <string name="confirm_pairing">Are you sure you want to pair the Bluetooth device <xliff:g id="device_name">%1$s</xliff:g>?</string> <string name="pair_yes">Yes</string> <string name="pair_no">No</string> diff --git a/src/com/android/nfc/handover/BluetoothPeripheralHandover.java b/src/com/android/nfc/handover/BluetoothPeripheralHandover.java index 24bd9e5e..3ac09e62 100644 --- a/src/com/android/nfc/handover/BluetoothPeripheralHandover.java +++ b/src/com/android/nfc/handover/BluetoothPeripheralHandover.java @@ -222,8 +222,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList != BluetoothProfile.STATE_DISCONNECTED) { mHidResult = RESULT_PENDING; mInput.disconnect(mDevice); - toast(mContext.getString(R.string.disconnecting_peripheral) + " " + - mName + "..."); + toast(getToastString(R.string.disconnecting_peripheral)); break; } else { mHidResult = RESULT_DISCONNECTED; @@ -244,8 +243,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList mA2dpResult = RESULT_DISCONNECTED; } if (mA2dpResult == RESULT_PENDING || mHfpResult == RESULT_PENDING) { - toast(mContext.getString(R.string.disconnecting_peripheral) + " " + - mName + "..."); + toast(getToastString(R.string.disconnecting_peripheral)); break; } } @@ -254,7 +252,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList case STATE_DISCONNECTING: if (mTransport == BluetoothDevice.TRANSPORT_LE) { if (mHidResult == RESULT_DISCONNECTED) { - toast(mContext.getString(R.string.disconnected_peripheral) + " " + mName); + toast(getToastString(R.string.disconnected_peripheral)); complete(false); } @@ -265,7 +263,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList break; } if (mA2dpResult == RESULT_DISCONNECTED && mHfpResult == RESULT_DISCONNECTED) { - toast(mContext.getString(R.string.disconnected_peripheral) + " " + mName); + toast(getToastString(R.string.disconnected_peripheral)); } complete(false); break; @@ -275,6 +273,10 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList } + private String getToastString(int resid) { + return mContext.getString(resid, mName != null ? mName : R.string.device); + } + boolean getProfileProxys() { if (mTransport == BluetoothDevice.TRANSPORT_LE) { @@ -326,8 +328,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList != BluetoothProfile.STATE_CONNECTED) { mHidResult = RESULT_PENDING; mInput.connect(mDevice); - toast(mContext.getString(R.string.connecting_peripheral) + " " - + mName + "..."); + toast(getToastString(R.string.connecting_peripheral)); break; } else { mHidResult = RESULT_CONNECTED; @@ -347,8 +348,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList mA2dpResult = RESULT_CONNECTED; } if (mA2dpResult == RESULT_PENDING || mHfpResult == RESULT_PENDING) { - toast(mContext.getString(R.string.connecting_peripheral) + " " - + mName + "..."); + toast(getToastString(R.string.connecting_peripheral)); break; } } @@ -359,12 +359,11 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList if (mHidResult == RESULT_PENDING) { break; } else if (mHidResult == RESULT_CONNECTED) { - toast(mContext.getString(R.string.connected_peripheral) + " " + mName); + toast(getToastString(R.string.connected_peripheral)); mDevice.setAlias(mName); complete(true); } else { - toast (mContext.getString(R.string.connect_peripheral_failed) + " " - + mName); + toast (getToastString(R.string.connect_peripheral_failed)); complete(false); } } else { @@ -374,12 +373,12 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList } if (mA2dpResult == RESULT_CONNECTED || mHfpResult == RESULT_CONNECTED) { // we'll take either as success - toast(mContext.getString(R.string.connected_peripheral) + " " + mName); + toast(getToastString(R.string.connected_peripheral)); if (mA2dpResult == RESULT_CONNECTED) startTheMusic(); mDevice.setAlias(mName); complete(true); } else { - toast (mContext.getString(R.string.connect_peripheral_failed) + " " + mName); + toast (getToastString(R.string.connect_peripheral_failed)); complete(false); } } @@ -389,9 +388,9 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList void startBonding() { mState = STATE_BONDING; - toast(mContext.getString(R.string.pairing_peripheral) + " " + mName + "..."); + toast(getToastString(R.string.pairing_peripheral)); if (!mDevice.createBond(mTransport)) { - toast(mContext.getString(R.string.pairing_peripheral_failed) + " " + mName); + toast(getToastString(R.string.pairing_peripheral_failed)); complete(false); } } @@ -413,7 +412,7 @@ public class BluetoothPeripheralHandover implements BluetoothProfile.ServiceList if (bond == BluetoothDevice.BOND_BONDED) { nextStepConnect(); } else if (bond == BluetoothDevice.BOND_NONE) { - toast(mContext.getString(R.string.pairing_peripheral_failed) + " " + mName); + toast(getToastString(R.string.pairing_peripheral_failed)); complete(false); } } else if (BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(action) && |