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

Commit 66239fbd authored by Jason Monk's avatar Jason Monk
Browse files

Remove UserBoolean

Animate when the view is visible because its much simpler

Change-Id: I18598faae643124ad014f77a2e8a9229ccb726ce
parent d5a204f1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -75,7 +75,8 @@ public class QSIconView extends ViewGroup {
            iv.setTag(R.id.qs_icon_tag, state.icon);
            if (d instanceof Animatable) {
                Animatable a = (Animatable) d;
                if (state.icon instanceof QSTile.AnimationIcon && !iv.isShown()) {
                a.start();
                if (!iv.isShown()) {
                    a.stop(); // skip directly to end state
                }
            }
+15 −37
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.systemui.qs;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
@@ -29,9 +27,20 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.qs.QSTile.State;
import com.android.systemui.statusbar.policy.*;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.policy.HotspotController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.Listenable;
import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;

import java.util.Collection;
import java.util.Objects;
@@ -389,11 +398,7 @@ public abstract class QSTile<TState extends State> implements Listenable {

        @Override
        public Drawable getDrawable(Context context) {
            Drawable d = context.getDrawable(mResId);
            if (d instanceof Animatable) {
                ((Animatable) d).start();
            }
            return d;
            return context.getDrawable(mResId);
        }

        @Override
@@ -408,41 +413,14 @@ public abstract class QSTile<TState extends State> implements Listenable {
    }

    protected class AnimationIcon extends ResourceIcon {
        private boolean mAllowAnimation;

        public AnimationIcon(int resId) {
            super(resId);
        }

        public void setAllowAnimation(boolean allowAnimation) {
            mAllowAnimation = allowAnimation;
        }

        @Override
        public Drawable getDrawable(Context context) {
            // workaround: get a clean state for every new AVD
            final AnimatedVectorDrawable d = (AnimatedVectorDrawable) context.getDrawable(mResId)
                    .getConstantState().newDrawable();
            d.start();
            if (mAllowAnimation) {
                mAllowAnimation = false;
            } else {
                d.stop(); // skip directly to end state
            }
            return d;
        }
    }

    protected enum UserBoolean {
        USER_TRUE(true, true),
        USER_FALSE(true, false),
        BACKGROUND_TRUE(false, true),
        BACKGROUND_FALSE(false, false);
        public final boolean value;
        public final boolean userInitiated;
        private UserBoolean(boolean userInitiated, boolean value) {
            this.value = value;
            this.userInitiated = userInitiated;
            return context.getDrawable(mResId).getConstantState().newDrawable();
        }
    }

+0 −2
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
    public void handleClick() {
        MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
        setEnabled(!mState.value);
        mEnable.setAllowAnimation(true);
        mDisable.setAllowAnimation(true);
    }

    private void setEnabled(boolean enabled) {
+0 −2
Original line number Diff line number Diff line
@@ -71,8 +71,6 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
    protected void handleClick() {
        MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
        mSetting.setValue(mState.value ? 0 : 1);
        mEnable.setAllowAnimation(true);
        mDisable.setAllowAnimation(true);
    }

    @Override
+0 −2
Original line number Diff line number Diff line
@@ -107,8 +107,6 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
                    Toast.LENGTH_LONG).show();
            return;
        }
        mDisable.setAllowAnimation(true);
        mDisableTotalSilence.setAllowAnimation(true);
        MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
        if (mState.value) {
            mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
Loading