Loading packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml +7 −6 Original line number Diff line number Diff line Loading @@ -116,22 +116,23 @@ android:orientation="horizontal" android:gravity="center" > <include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/bluetooth" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="4dip" android:visibility="gone" /> <include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/battery" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="6dip" android:paddingLeft="4dip" /> </LinearLayout> </LinearLayout> Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +32 −7 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class BluetoothController extends BroadcastReceiver { private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>(); private int mIconId = R.drawable.stat_sys_data_bluetooth; private int mContentDescriptionId = 0; private boolean mEnabled; public BluetoothController(Context context) { Loading @@ -44,6 +45,11 @@ public class BluetoothController extends BroadcastReceiver { filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); context.registerReceiver(this, filter); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); handleAdapterStateChange(adapter.getState()); handleConnectionStateChange(adapter.getConnectionState()); refreshViews(); } public void addIconView(ImageView v) { Loading @@ -52,24 +58,43 @@ public class BluetoothController extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED); int contentDescriptionResId = 0; final String action = intent.getAction(); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { handleAdapterStateChange( intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)); } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { handleConnectionStateChange( intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED)); } refreshViews(); } if (state == BluetoothAdapter.STATE_CONNECTED) { public void handleAdapterStateChange(int adapterState) { mEnabled = (adapterState == BluetoothAdapter.STATE_ON); } public void handleConnectionStateChange(int connectionState) { final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED); if (connected) { mIconId = R.drawable.stat_sys_data_bluetooth_connected; contentDescriptionResId = R.string.accessibility_bluetooth_connected; mContentDescriptionId = R.string.accessibility_bluetooth_connected; } else { mIconId = R.drawable.stat_sys_data_bluetooth; contentDescriptionResId = R.string.accessibility_bluetooth_disconnected; mContentDescriptionId = R.string.accessibility_bluetooth_disconnected; } } public void refreshViews() { int N = mIconViews.size(); for (int i=0; i<N; i++) { ImageView v = mIconViews.get(i); v.setImageResource(mIconId); v.setVisibility(mEnabled ? View.VISIBLE : View.GONE); v.setContentDescription(mContext.getString(contentDescriptionResId)); v.setContentDescription((mContentDescriptionId == 0) ? null : mContext.getString(mContentDescriptionId)); } } } Loading
packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml +7 −6 Original line number Diff line number Diff line Loading @@ -116,22 +116,23 @@ android:orientation="horizontal" android:gravity="center" > <include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/bluetooth" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="4dip" android:visibility="gone" /> <include layout="@layout/signal_cluster_view" android:id="@+id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/battery" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingLeft="6dip" android:paddingLeft="4dip" /> </LinearLayout> </LinearLayout> Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java +32 −7 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class BluetoothController extends BroadcastReceiver { private ArrayList<ImageView> mIconViews = new ArrayList<ImageView>(); private int mIconId = R.drawable.stat_sys_data_bluetooth; private int mContentDescriptionId = 0; private boolean mEnabled; public BluetoothController(Context context) { Loading @@ -44,6 +45,11 @@ public class BluetoothController extends BroadcastReceiver { filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); context.registerReceiver(this, filter); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); handleAdapterStateChange(adapter.getState()); handleConnectionStateChange(adapter.getConnectionState()); refreshViews(); } public void addIconView(ImageView v) { Loading @@ -52,24 +58,43 @@ public class BluetoothController extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED); int contentDescriptionResId = 0; final String action = intent.getAction(); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { handleAdapterStateChange( intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)); } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { handleConnectionStateChange( intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED)); } refreshViews(); } if (state == BluetoothAdapter.STATE_CONNECTED) { public void handleAdapterStateChange(int adapterState) { mEnabled = (adapterState == BluetoothAdapter.STATE_ON); } public void handleConnectionStateChange(int connectionState) { final boolean connected = (connectionState == BluetoothAdapter.STATE_CONNECTED); if (connected) { mIconId = R.drawable.stat_sys_data_bluetooth_connected; contentDescriptionResId = R.string.accessibility_bluetooth_connected; mContentDescriptionId = R.string.accessibility_bluetooth_connected; } else { mIconId = R.drawable.stat_sys_data_bluetooth; contentDescriptionResId = R.string.accessibility_bluetooth_disconnected; mContentDescriptionId = R.string.accessibility_bluetooth_disconnected; } } public void refreshViews() { int N = mIconViews.size(); for (int i=0; i<N; i++) { ImageView v = mIconViews.get(i); v.setImageResource(mIconId); v.setVisibility(mEnabled ? View.VISIBLE : View.GONE); v.setContentDescription(mContext.getString(contentDescriptionResId)); v.setContentDescription((mContentDescriptionId == 0) ? null : mContext.getString(mContentDescriptionId)); } } }