Skip to content

Commit 0349c6a

Browse files
xyyxneobuddy89
authored andcommitted
SystemUI: Add statusbar NFC icon
Co-authored-by: Pranav Vashi <neobuddy89@gmail.com> Change-Id: Ia2d191bc1ca99803fcdcb858ffe892b0a5cf86b7 Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 parent f620dd2 commit 0349c6a

5 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
Copyright (C) 2015 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
17+
android:width="24dp"
18+
android:height="24dp"
19+
android:viewportWidth="24.0"
20+
android:viewportHeight="24.0"
21+
android:tint="?android:attr/colorControlNormal">
22+
<path
23+
android:fillColor="#FFFFFFFF"
24+
android:pathData="M10.59,7.66C10.59,7.66 11.19,7.39 11.57,7.82C11.95,8.26 12.92,9.94 12.92,11.62C12.92,13.3 12.5,15.09 12.05,15.68C11.62,16.28
25+
11.19,16.28 10.86,16.06C10.54,15.85 5.5,12 5.23,11.89C4.95,11.78 4.85,12.05 5.12,13.5C5.39,15 4.95,15.41 4.57,15.47C4.2,15.5 3.06,15.2 3,12.16C2.95,9.13
26+
3.76,8.64 4.14,8.64C4.85,8.64 10.27,13.5 10.64,13.46C10.97,13.41 11.13,11.35 10.5,9.72C9.78,7.96 10.59,7.66 10.59,7.66M19.3,4.63C21.12,8.24 21,11.66
27+
21,12C21,12.34 21.12,15.76 19.3,19.37C19.3,19.37 18.83,19.92 18.12,19.59C17.42,19.26 17.66,18.4 17.66,18.4C17.66,18.4 19.14,15.55 19.1,12.05V12C19.14,8.5
28+
17.66,5.6 17.66,5.6C17.66,5.6 17.42,4.74 18.12,4.41C18.83,4.08 19.3,4.63 19.3,4.63M15.77,6.25C17.26,8.96 17.16,11.66 17.14,12C17.16,12.34 17.26,14.92
29+
15.77,17.85C15.77,17.85 15.3,18.4 14.59,18.07C13.89,17.74 14.13,16.88 14.13,16.88C14.13,16.88 15.09,15.5 15.24,12.05V12C15.14,8.53 14.13,7.23
30+
14.13,7.23C14.13,7.23 13.89,6.36 14.59,6.04C15.3,5.71 15.77,6.25 15.77,6.25Z"/>
31+
</vector>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
Copyright (C) 2016 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<inset xmlns:android="http://schemas.android.com/apk/res/android"
17+
android:insetLeft="2.5dp"
18+
android:insetRight="2.5dp">
19+
<vector
20+
android:width="17dp"
21+
android:height="17dp"
22+
android:viewportWidth="24"
23+
android:viewportHeight="24">
24+
25+
<path
26+
android:fillColor="#FFFFFFFF"
27+
android:pathData="M10.59,7.66C10.59,7.66 11.19,7.39 11.57,7.82C11.95,8.26 12.92,9.94 12.92,11.62C12.92,13.3
28+
12.5,15.09 12.05,15.68C11.62,16.28 11.19,16.28 10.86,16.06C10.54,15.85 5.5,12 5.23,11.89C4.95,11.78 4.85,12.05
29+
5.12,13.5C5.39,15 4.95,15.41 4.57,15.47C4.2,15.5 3.06,15.2 3,12.16C2.95,9.13 3.76,8.64 4.14,8.64C4.85,8.64 10.27,13.5
30+
10.64,13.46C10.97,13.41 11.13,11.35 10.5,9.72C9.78,7.96 10.59,7.66 10.59,7.66M19.3,4.63C21.12,8.24 21,11.66 21,12C21,12.34
31+
21.12,15.76 19.3,19.37C19.3,19.37 18.83,19.92 18.12,19.59C17.42,19.26 17.66,18.4 17.66,18.4C17.66,18.4 19.14,15.55 19.1,12.05V12C19.14,8.5
32+
17.66,5.6 17.66,5.6C17.66,5.6 17.42,4.74 18.12,4.41C18.83,4.08 19.3,4.63 19.3,4.63M15.77,6.25C17.26,8.96 17.16,11.66 17.14,12C17.16,12.34
33+
17.26,14.92 15.77,17.85C15.77,17.85 15.3,18.4 14.59,18.07C13.89,17.74 14.13,16.88 14.13,16.88C14.13,16.88 15.09,15.5 15.24,12.05V12C15.14,8.53
34+
14.13,7.23 14.13,7.23C14.13,7.23 13.89,6.36 14.59,6.04C15.3,5.71 15.77,6.25 15.77,6.25Z" />
35+
</vector>
36+
</inset>

packages/SystemUI/res/values/sun_strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
SPDX-License-Identifier: Apache-2.0
55
-->
66
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
7+
8+
<!-- Statusbar Icons -->
9+
<string name="status_bar_nfc">NFC</string>
710
<!-- Face unlock -->
811
<string name="face_unlock_recognizing">Recognizing face...</string>
912
</resources>

packages/SystemUI/res/xml/status_bar_prefs.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
android:title="@string/quick_settings_camera_label" />
6464

6565
<!-- nfc -->
66+
<com.android.systemui.tuner.StatusBarSwitch
67+
android:icon="@drawable/ic_statusbar_nfc"
68+
android:key="nfc"
69+
android:persistent="false"
70+
android:title="@string/status_bar_nfc" />
71+
6672
<!-- tty -->
6773
<!-- speakerphone -->
6874

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import android.net.ConnectivityManager;
3737
import android.net.Network;
3838
import android.net.NetworkCapabilities;
39+
import android.nfc.NfcAdapter;
3940
import android.os.Handler;
4041
import android.os.Looper;
4142
import android.os.Process;
@@ -135,6 +136,7 @@ public class PhoneStatusBarPolicy
135136
private final String mSlotScreenRecord;
136137
private final String mSlotConnectedDisplay;
137138
private final String mSlotFirewall;
139+
private final String mSlotNfc;
138140
private final int mDisplayId;
139141
private final SharedPreferences mSharedPreferences;
140142
private final DateFormatUtil mDateFormatUtil;
@@ -183,6 +185,8 @@ public class PhoneStatusBarPolicy
183185
private BluetoothController mBluetooth;
184186
private AlarmClockInfo mNextAlarm;
185187

188+
private NfcAdapter mAdapter;
189+
186190
@Inject
187191
public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController,
188192
CommandQueue commandQueue, BroadcastDispatcher broadcastDispatcher,
@@ -261,6 +265,7 @@ public PhoneStatusBarPolicy(Context context, StatusBarIconController iconControl
261265
mSlotScreenRecord = resources.getString(
262266
com.android.internal.R.string.status_bar_screen_record);
263267
mSlotFirewall = resources.getString(R.string.status_bar_firewall_slot);
268+
mSlotNfc = resources.getString(com.android.internal.R.string.status_bar_nfc);
264269

265270
mDisplayId = displayId;
266271
mSharedPreferences = sharedPreferences;
@@ -280,6 +285,7 @@ public void init() {
280285
filter.addAction(Intent.ACTION_PROFILE_REMOVED);
281286
filter.addAction(Intent.ACTION_PROFILE_ACCESSIBLE);
282287
filter.addAction(Intent.ACTION_PROFILE_INACCESSIBLE);
288+
filter.addAction(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
283289
mBroadcastDispatcher.registerReceiverWithHandler(mIntentReceiver, filter, mHandler);
284290
Observer<Integer> observer = ringer -> mHandler.post(this::updateVolumeZen);
285291

@@ -369,6 +375,12 @@ public void init() {
369375
mIconController.setIcon(mSlotFirewall, R.drawable.stat_sys_firewall, null);
370376
mIconController.setIconVisibility(mSlotFirewall, mFirewallVisible);
371377

378+
mIconController.setIcon(mSlotNfc, R.drawable.stat_sys_nfc,
379+
mResources.getString(R.string.status_bar_nfc));
380+
381+
mIconController.setIconVisibility(mSlotNfc, false);
382+
updateNfc();
383+
372384
mRotationLockController.addCallback(this);
373385
mBluetooth.addCallback(this);
374386
mProvisionedController.addCallback(this);
@@ -462,6 +474,17 @@ private String buildAlarmContentDescription() {
462474
return mResources.getString(R.string.accessibility_quick_settings_alarm, dateString);
463475
}
464476

477+
private NfcAdapter getAdapter() {
478+
if (mAdapter == null) {
479+
mAdapter = NfcAdapter.getDefaultAdapter(mContext);
480+
}
481+
return mAdapter;
482+
}
483+
484+
private final void updateNfc() {
485+
mIconController.setIconVisibility(mSlotNfc, getAdapter() != null && getAdapter().isEnabled());
486+
}
487+
465488
private void updateVolumeZen() {
466489
int zen = mZenController.getZen();
467490
if (!ModesUiIcons.isEnabled()) {
@@ -926,6 +949,9 @@ public void onReceive(Context context, Intent intent) {
926949
case AudioManager.ACTION_HEADSET_PLUG:
927950
updateHeadsetPlug(intent);
928951
break;
952+
case NfcAdapter.ACTION_ADAPTER_STATE_CHANGED:
953+
updateNfc();
954+
break;
929955
}
930956
}
931957
};

0 commit comments

Comments
 (0)