• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

development


Commit MetaInfo

修訂3695fe3a4242504d523d0222306775ada5cd6430 (tree)
時間2011-01-14 09:59:47
作者Jake Hamby <jhamby@goog...>
CommiterJake Hamby

Log Message

Fix BT chat sample app to use Honeycomb action bar.

The BT chat app previously used a custom title, which is no longer
supported in Honeycomb with the default theme. It also required the
option menu, which has been replaced with the action bar.

Fixed the app to use the standard Honeycomb style and action bar.

Bug: 3098795
Change-Id: I8f8656b261c6e15cc6b0b2f445087ff3baabb4d4

Change Summary

差異

--- a/samples/BluetoothChat/AndroidManifest.xml
+++ b/samples/BluetoothChat/AndroidManifest.xml
@@ -33,7 +33,7 @@
3333 </activity>
3434 <activity android:name=".DeviceListActivity"
3535 android:label="@string/select_device"
36- android:theme="@android:style/Theme.Dialog"
36+ android:theme="@android:style/Theme.Holo.Dialog"
3737 android:configChanges="orientation|keyboardHidden" />
3838 </application>
3939 </manifest>
--- a/samples/BluetoothChat/res/menu/option_menu.xml
+++ b/samples/BluetoothChat/res/menu/option_menu.xml
@@ -16,8 +16,10 @@
1616 <menu xmlns:android="http://schemas.android.com/apk/res/android">
1717 <item android:id="@+id/scan"
1818 android:icon="@android:drawable/ic_menu_search"
19- android:title="@string/connect" />
19+ android:title="@string/connect"
20+ android:showAsAction="ifRoom" />
2021 <item android:id="@+id/discoverable"
2122 android:icon="@android:drawable/ic_menu_mylocation"
22- android:title="@string/discoverable" />
23+ android:title="@string/discoverable"
24+ android:showAsAction="ifRoom" />
2325 </menu>
--- a/samples/BluetoothChat/res/values/strings.xml
+++ b/samples/BluetoothChat/res/values/strings.xml
@@ -14,7 +14,7 @@
1414 limitations under the License.
1515 -->
1616
17-<resources>
17+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1818 <string name="app_name">Bluetooth Chat</string>
1919
2020 <!-- BluetoothChat -->
@@ -22,7 +22,7 @@
2222 <string name="not_connected">You are not connected to a device</string>
2323 <string name="bt_not_enabled_leaving">Bluetooth was not enabled. Leaving Bluetooth Chat.</string>
2424 <string name="title_connecting">connecting...</string>
25- <string name="title_connected_to">connected: </string>
25+ <string name="title_connected_to">connected to <xliff:g id="device_name">%1$s</xliff:g></string>
2626 <string name="title_not_connected">not connected</string>
2727
2828 <!-- DeviceListActivity -->
--- a/samples/BluetoothChat/src/com/example/android/BluetoothChat/BluetoothChat.java
+++ b/samples/BluetoothChat/src/com/example/android/BluetoothChat/BluetoothChat.java
@@ -16,6 +16,7 @@
1616
1717 package com.example.android.BluetoothChat;
1818
19+import android.app.ActionBar;
1920 import android.app.Activity;
2021 import android.bluetooth.BluetoothAdapter;
2122 import android.bluetooth.BluetoothDevice;
@@ -63,7 +64,6 @@ public class BluetoothChat extends Activity {
6364 private static final int REQUEST_ENABLE_BT = 2;
6465
6566 // Layout Views
66- private TextView mTitle;
6767 private ListView mConversationView;
6868 private EditText mOutEditText;
6969 private Button mSendButton;
@@ -86,14 +86,7 @@ public class BluetoothChat extends Activity {
8686 if(D) Log.e(TAG, "+++ ON CREATE +++");
8787
8888 // Set up the window layout
89- requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
9089 setContentView(R.layout.main);
91- getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
92-
93- // Set up the custom title
94- mTitle = (TextView) findViewById(R.id.title_left_text);
95- mTitle.setText(R.string.app_name);
96- mTitle = (TextView) findViewById(R.id.title_right_text);
9790
9891 // Get local Bluetooth adapter
9992 mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -236,6 +229,16 @@ public class BluetoothChat extends Activity {
236229 }
237230 };
238231
232+ private final void setStatus(int resId) {
233+ final ActionBar actionBar = getActionBar();
234+ actionBar.setSubtitle(resId);
235+ }
236+
237+ private final void setStatus(CharSequence subTitle) {
238+ final ActionBar actionBar = getActionBar();
239+ actionBar.setSubtitle(subTitle);
240+ }
241+
239242 // The Handler that gets information back from the BluetoothChatService
240243 private final Handler mHandler = new Handler() {
241244 @Override
@@ -245,16 +248,15 @@ public class BluetoothChat extends Activity {
245248 if(D) Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
246249 switch (msg.arg1) {
247250 case BluetoothChatService.STATE_CONNECTED:
248- mTitle.setText(R.string.title_connected_to);
249- mTitle.append(mConnectedDeviceName);
251+ setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
250252 mConversationArrayAdapter.clear();
251253 break;
252254 case BluetoothChatService.STATE_CONNECTING:
253- mTitle.setText(R.string.title_connecting);
255+ setStatus(R.string.title_connecting);
254256 break;
255257 case BluetoothChatService.STATE_LISTEN:
256258 case BluetoothChatService.STATE_NONE:
257- mTitle.setText(R.string.title_not_connected);
259+ setStatus(R.string.title_not_connected);
258260 break;
259261 }
260262 break;
@@ -293,7 +295,7 @@ public class BluetoothChat extends Activity {
293295 // Get the device MAC address
294296 String address = data.getExtras()
295297 .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
296- // Get the BLuetoothDevice object
298+ // Get the BluetoothDevice object
297299 BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
298300 // Attempt to connect to the device
299301 mChatService.connect(device);
@@ -305,7 +307,7 @@ public class BluetoothChat extends Activity {
305307 // Bluetooth is now enabled, so set up a chat session
306308 setupChat();
307309 } else {
308- // User did not enable Bluetooth or an error occured
310+ // User did not enable Bluetooth or an error occurred
309311 Log.d(TAG, "BT not enabled");
310312 Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
311313 finish();
--- a/samples/BluetoothChat/src/com/example/android/BluetoothChat/DeviceListActivity.java
+++ b/samples/BluetoothChat/src/com/example/android/BluetoothChat/DeviceListActivity.java
@@ -64,7 +64,7 @@ public class DeviceListActivity extends Activity {
6464 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
6565 setContentView(R.layout.device_list);
6666
67- // Set result CANCELED incase the user backs out
67+ // Set result CANCELED in case the user backs out
6868 setResult(Activity.RESULT_CANCELED);
6969
7070 // Initialize the button to perform device discovery