Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02b559b5 authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Ensure NFC tile has a label even when unavailble.

Change-Id: I9c9688616757c073fcea5b34ac704e21d5890a52
Fixes: 116614851
Test: manual
parent e36375ec
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -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;
    }