Merge "Ensure NFC tile has a label even when unavailble."
This commit is contained in:
committed by
Android (Google) Code Review
commit
99ae103961
@@ -25,6 +25,7 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.provider.Settings;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
@@ -77,6 +78,9 @@ public class NfcTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (getAdapter() == null) {
|
||||
return;
|
||||
}
|
||||
if (!getAdapter().isEnabled()) {
|
||||
getAdapter().enable();
|
||||
} else {
|
||||
@@ -96,13 +100,13 @@ public class NfcTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
final Drawable mEnable = mContext.getDrawable(R.drawable.ic_qs_nfc_enabled);
|
||||
final Drawable mDisable = mContext.getDrawable(R.drawable.ic_qs_nfc_disabled);
|
||||
|
||||
if (getAdapter() == null) return;
|
||||
state.value = getAdapter().isEnabled();
|
||||
state.value = getAdapter() != null && getAdapter().isEnabled();
|
||||
state.state = getAdapter() == null
|
||||
? Tile.STATE_UNAVAILABLE
|
||||
: state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
state.icon = ResourceIcon.get(
|
||||
state.value ? R.drawable.ic_qs_nfc_enabled : R.drawable.ic_qs_nfc_disabled);
|
||||
state.label = mContext.getString(R.string.quick_settings_nfc_label);
|
||||
state.icon = new DrawableIcon(state.value ? mEnable : mDisable);
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.contentDescription = state.label;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user