Skip to content

Commit 0f167d7

Browse files
committed
Restore bluetooth icons on tablets.
- status bar - notification panel header area Bug: 5385369 Change-Id: I382b9e4fbd3dd440919484c70d50b00ce85a8fa1
1 parent 27812a8 commit 0f167d7

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,23 @@
116116
android:orientation="horizontal"
117117
android:gravity="center"
118118
>
119+
<include layout="@layout/signal_cluster_view"
120+
android:id="@+id/signal_cluster"
121+
android:layout_width="wrap_content"
122+
android:layout_height="wrap_content"
123+
/>
119124
<ImageView
120125
android:id="@+id/bluetooth"
121126
android:layout_height="wrap_content"
122127
android:layout_width="wrap_content"
128+
android:paddingLeft="4dip"
123129
android:visibility="gone"
124130
/>
125-
<include layout="@layout/signal_cluster_view"
126-
android:id="@+id/signal_cluster"
127-
android:layout_width="wrap_content"
128-
android:layout_height="wrap_content"
129-
/>
130131
<ImageView
131132
android:id="@+id/battery"
132133
android:layout_height="wrap_content"
133134
android:layout_width="wrap_content"
134-
android:paddingLeft="6dip"
135+
android:paddingLeft="4dip"
135136
/>
136137
</LinearLayout>
137138
</LinearLayout>

packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class BluetoothController extends BroadcastReceiver {
3535
private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>();
3636

3737
private int mIconId = R.drawable.stat_sys_data_bluetooth;
38+
private int mContentDescriptionId = 0;
3839
private boolean mEnabled;
3940

4041
public BluetoothController(Context context) {
@@ -44,6 +45,11 @@ public BluetoothController(Context context) {
4445
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
4546
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
4647
context.registerReceiver(this, filter);
48+
49+
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
50+
handleAdapterStateChange(adapter.getState());
51+
handleConnectionStateChange(adapter.getConnectionState());
52+
refreshViews();
4753
}
4854

4955
public void addIconView(ImageView v) {
@@ -52,24 +58,43 @@ public void addIconView(ImageView v) {
5258

5359
@Override
5460
public void onReceive(Context context, Intent intent) {
55-
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
56-
BluetoothAdapter.STATE_DISCONNECTED);
57-
int contentDescriptionResId = 0;
61+
final String action = intent.getAction();
62+
63+
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
64+
handleAdapterStateChange(
65+
intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR));
66+
} else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
67+
handleConnectionStateChange(
68+
intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
69+
BluetoothAdapter.STATE_DISCONNECTED));
70+
}
71+
refreshViews();
72+
}
5873

59-
if (state == BluetoothAdapter.STATE_CONNECTED) {
74+
public void handleAdapterStateChange(int adapterState) {
75+
mEnabled = (adapterState == BluetoothAdapter.STATE_ON);
76+
}
77+
78+
public void handleConnectionStateChange(int connectionState) {
79+
final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED);
80+
if (connected) {
6081
mIconId = R.drawable.stat_sys_data_bluetooth_connected;
61-
contentDescriptionResId = R.string.accessibility_bluetooth_connected;
82+
mContentDescriptionId = R.string.accessibility_bluetooth_connected;
6283
} else {
6384
mIconId = R.drawable.stat_sys_data_bluetooth;
64-
contentDescriptionResId = R.string.accessibility_bluetooth_disconnected;
85+
mContentDescriptionId = R.string.accessibility_bluetooth_disconnected;
6586
}
87+
}
6688

89+
public void refreshViews() {
6790
int N = mIconViews.size();
6891
for (int i=0; i<N; i++) {
6992
ImageView v = mIconViews.get(i);
7093
v.setImageResource(mIconId);
7194
v.setVisibility(mEnabled ? View.VISIBLE : View.GONE);
72-
v.setContentDescription(mContext.getString(contentDescriptionResId));
95+
v.setContentDescription((mContentDescriptionId == 0)
96+
? null
97+
: mContext.getString(mContentDescriptionId));
7398
}
7499
}
75100
}

0 commit comments

Comments
 (0)