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

Commit 75fe38c5 authored by Selim Cinek's avatar Selim Cinek
Browse files

Added the dozemode for the new notification templates

Previously things were not correctly inverted when dozing,
because of the new template design.

Change-Id: I05211a463c4c7aa3bcba669506975844c389097b
parent 4fb12d3f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@
    <color name="assist_orb_color">#ffffff</color>

    <color name="keyguard_user_switcher_background_gradient_color">#77000000</color>
    <color name="doze_small_icon_background_color">#ff434343</color>

    <!-- The color of the navigation bar icons. Need to be in sync with ic_sysbar_* -->
    <color name="navigation_bar_icon_color">#E5FFFFFF</color>
+27 −11
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;

import java.util.ArrayList;

/**
 * Helper to invert the colors of views and fade between the states.
 */
@@ -33,14 +35,24 @@ public class ViewInvertHelper {

    private final Paint mDarkPaint = new Paint();
    private final Interpolator mLinearOutSlowInInterpolator;
    private final View mTarget;
    private final ArrayList<View> mTargets;
    private final ColorMatrix mMatrix = new ColorMatrix();
    private final ColorMatrix mGrayscaleMatrix = new ColorMatrix();
    private final long mFadeDuration;

    public ViewInvertHelper(View target, long fadeDuration) {
        mTarget = target;
        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(mTarget.getContext(),
        this(constructArray(target), fadeDuration);
    }

    private static ArrayList<View> constructArray(View target) {
        final ArrayList<View> views = new ArrayList<>();
        views.add(target);
        return views;
    }

    public ViewInvertHelper(ArrayList<View> targets, long fadeDuration) {
        mTargets = targets;
        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(mTargets.get(0).getContext(),
                android.R.interpolator.linear_out_slow_in);
        mFadeDuration = fadeDuration;
    }
@@ -53,14 +65,18 @@ public class ViewInvertHelper {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                updateInvertPaint((Float) animation.getAnimatedValue());
                mTarget.setLayerType(View.LAYER_TYPE_HARDWARE, mDarkPaint);
                for (int i = 0; i < mTargets.size(); i++) {
                    mTargets.get(i).setLayerType(View.LAYER_TYPE_HARDWARE, mDarkPaint);
                }
            }
        });
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (!invert) {
                    mTarget.setLayerType(View.LAYER_TYPE_NONE, null);
                    for (int i = 0; i < mTargets.size(); i++) {
                        mTargets.get(i).setLayerType(View.LAYER_TYPE_NONE, null);
                    }
                }
            }
        });
@@ -73,14 +89,14 @@ public class ViewInvertHelper {
    public void update(boolean invert) {
        if (invert) {
            updateInvertPaint(1f);
            mTarget.setLayerType(View.LAYER_TYPE_HARDWARE, mDarkPaint);
            for (int i = 0; i < mTargets.size(); i++) {
                mTargets.get(i).setLayerType(View.LAYER_TYPE_HARDWARE, mDarkPaint);
            }
        } else {
            mTarget.setLayerType(View.LAYER_TYPE_NONE, null);
            for (int i = 0; i < mTargets.size(); i++) {
                mTargets.get(i).setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }

    public View getTarget() {
        return mTarget;
    }

    private void updateInvertPaint(float intensity) {
+0 −36
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar;

import android.content.Context;
import android.view.View;

/**
 * Wraps a big media narrow notification template layout.
 */
public class NotificationBigMediaNarrowViewWrapper extends NotificationMediaViewWrapper {

    protected NotificationBigMediaNarrowViewWrapper(Context ctx,
            View view) {
        super(ctx, view);
    }

    @Override
    public boolean needsRoundRectClipping() {
        return true;
    }
}
+0 −35
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar;

import android.content.Context;
import android.view.View;

/**
 * Wraps a notification view inflated from a big picture style template.
 */
public class NotificationBigPictureViewWrapper extends NotificationTemplateViewWrapper {

    protected NotificationBigPictureViewWrapper(Context ctx, View view) {
        super(ctx, view);
    }

    @Override
    public boolean needsRoundRectClipping() {
        return true;
    }
}
+0 −37
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar;

import android.content.Context;
import android.view.View;

/**
 * Wraps a media notification.
 */
public class NotificationMediaViewWrapper extends NotificationTemplateViewWrapper {

    protected NotificationMediaViewWrapper(Context ctx, View view) {
        super(ctx, view);
    }

    @Override
    public void setDark(boolean dark, boolean fade, long delay) {

        // Only update the large icon, because the rest is already inverted.
        setPictureGrayscale(dark, fade, delay);
    }
}
Loading