Skip to content

Commit abd6516

Browse files
DaneshGodFox
authored andcommitted
QuickSettings : Cleanup
Change-Id: I044f8c0914c725af5894ffb70e8ac54b6e19dc43
1 parent 3f9d1c1 commit abd6516

4 files changed

Lines changed: 11 additions & 30 deletions

File tree

packages/SystemUI/src/com/android/systemui/quicksettings/NfcTile.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.nfc.NfcAdapter;
6+
import android.nfc.NfcManager;
67
import android.util.Log;
78
import android.view.LayoutInflater;
89
import android.view.View;
@@ -23,7 +24,7 @@ public NfcTile(Context context, LayoutInflater inflater,
2324
QuickSettingsController qsc) {
2425
super(context, inflater, container, qsc);
2526

26-
setTileState(NFC_ADAPTER_UNKNOWN);
27+
setTileState(getNfcState());
2728

2829
mOnClick = new View.OnClickListener() {
2930
@Override
@@ -90,11 +91,13 @@ private void setTileState(int state) {
9091
}
9192

9293
private int getNfcState() {
93-
if (mNfcAdapter != null || (mNfcAdapter = NfcAdapter.getDefaultAdapter(mContext)) != null) {
94-
return mNfcAdapter.getAdapterState();
95-
} else {
96-
Log.d(TAG, "No NFC adapter available");
97-
return NFC_ADAPTER_UNKNOWN;
94+
if (mNfcAdapter == null) {
95+
try {
96+
mNfcAdapter = NfcAdapter.getNfcAdapter(mContext);
97+
} catch (UnsupportedOperationException e) {
98+
return NFC_ADAPTER_UNKNOWN;
99+
}
98100
}
101+
return mNfcAdapter.getAdapterState();
99102
}
100103
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,6 @@ public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
585585
}
586586
mQS.setService(this);
587587
mQS.setBar(mStatusBarView);
588-
mQS.setupQuickSettings();
589588

590589
// Start observing for changes
591590
mTilesChangedObserver = new TilesChangedObserver(mHandler);
@@ -2382,7 +2381,6 @@ else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
23822381
Slog.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration());
23832382
}
23842383
mDisplay.getSize(mCurrentDisplaySize);
2385-
23862384
updateResources();
23872385
repositionNavigationBar();
23882386
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
@@ -2677,10 +2675,7 @@ public TilesChangedObserver(Handler handler) {
26772675
@Override
26782676
public void onChange(boolean selfChange) {
26792677
if (mSettingsContainer != null) {
2680-
// Refresh the container
2681-
mSettingsContainer.removeAllViews();
2682-
mQS.setupQuickSettings();
2683-
mSettingsContainer.requestLayout();
2678+
mQS.updateResources();
26842679
}
26852680
}
26862681

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void loadTiles() {
249249
}
250250
}
251251

252-
void setupQuickSettings() {
252+
private void setupQuickSettings() {
253253
LayoutInflater inflater = LayoutInflater.from(mContext);
254254
// Clear out old receiver
255255
if (mReceiver != null) {

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,6 @@ public void setImeWindowStatus(boolean visible) {
8484
}
8585
}
8686

87-
public void setup(NetworkController networkController, BluetoothController bluetoothController,
88-
BatteryController batteryController, LocationController locationController) {
89-
if (mQS != null) {
90-
mQS.setupQuickSettings();
91-
}
92-
}
93-
94-
void updateResources() {
95-
if (mQS != null) {
96-
mQS.updateResources();
97-
}
98-
if (mQSContainer != null) {
99-
mQSContainer.updateResources();
100-
}
101-
requestLayout();
102-
}
103-
10487
@Override
10588
public void fling(float vel, boolean always) {
10689
GestureRecorder gr = ((PhoneStatusBarView) mBar).mBar.getGestureRecorder();

0 commit comments

Comments
 (0)