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

Commit 07e23a0e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove obsolete lock screen UI"

parents 43f887ae ed002624
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.util;

import android.annotation.UnsupportedAppUsage;
import android.graphics.Rect;

/**
 * A class that contains utility methods related to numbers.
@@ -227,4 +228,18 @@ public final class MathUtils {
        }
        throw new IllegalArgumentException("Addition overflow: " + a + " + " + b);
    }

    /**
     * Resize a {@link Rect} so one size would be {@param largestSide}.
     *
     * @param outToResize Rectangle that will be resized.
     * @param largestSide Size of the largest side.
     */
    public static void fitRect(Rect outToResize, int largestSide) {
        if (outToResize.isEmpty()) {
            return;
        }
        float maxSize = Math.max(outToResize.width(), outToResize.height());
        outToResize.scale(largestSide / maxSize);
    }
}
+0 −11
Original line number Diff line number Diff line
@@ -28,17 +28,6 @@
    android:clipToPadding="false"
    android:orientation="vertical"
    android:layout_centerHorizontal="true">
    <view class="com.android.keyguard.KeyguardSliceView$TitleView"
              android:id="@+id/title"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="@dimen/widget_title_bottom_margin"
              android:paddingStart="64dp"
              android:paddingEnd="64dp"
              android:visibility="gone"
              android:textColor="?attr/wallpaperTextColor"
              android:theme="@style/TextAppearance.Keyguard"
    />
    <view class="com.android.keyguard.KeyguardSliceView$Row"
              android:id="@+id/row"
              android:layout_width="match_parent"
+17 −90
Original line number Diff line number Diff line
@@ -23,15 +23,12 @@ import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.ColorInt;
import android.app.PendingIntent;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Trace;
import android.provider.Settings;
import android.text.Layout;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
@@ -41,16 +38,24 @@ import android.view.ViewGroup;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.slice.Slice;
import androidx.slice.SliceItem;
import androidx.slice.SliceViewManager;
import androidx.slice.core.SliceQuery;
import androidx.slice.widget.ListContent;
import androidx.slice.widget.RowContent;
import androidx.slice.widget.SliceContent;
import androidx.slice.widget.SliceLiveData;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.statusbar.AlphaOptimizedTextView;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.wakelock.KeepAwakeAnimationListener;
@@ -58,16 +63,6 @@ import com.android.systemui.util.wakelock.KeepAwakeAnimationListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Consumer;

import androidx.slice.Slice;
import androidx.slice.SliceItem;
import androidx.slice.SliceViewManager;
import androidx.slice.core.SliceQuery;
import androidx.slice.widget.ListContent;
import androidx.slice.widget.RowContent;
import androidx.slice.widget.SliceContent;
import androidx.slice.widget.SliceLiveData;

/**
 * View visible under the clock on the lock screen and AoD.
@@ -80,8 +75,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe

    private final HashMap<View, PendingIntent> mClickActions;
    private Uri mKeyguardSliceUri;
    @VisibleForTesting
    TextView mTitle;
    private Row mRow;
    private int mTextColor;
    private float mDarkAmount = 0;
@@ -92,7 +85,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
     * Runnable called whenever the view contents change.
     */
    private Runnable mContentChangeListener;
    private boolean mHasHeader;
    private Slice mSlice;
    private boolean mPulsing;

@@ -128,7 +120,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mTitle = findViewById(R.id.title);
        mRow = findViewById(R.id.row);
        mTextColor = Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor);
        mIconSize = (int) mContext.getResources().getDimension(R.dimen.widget_icon_size);
@@ -154,7 +145,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
    private void showSlice() {
        Trace.beginSection("KeyguardSliceView#showSlice");
        if (mPulsing || mSlice == null) {
            mTitle.setVisibility(GONE);
            mRow.setVisibility(GONE);
            if (mContentChangeListener != null) {
                mContentChangeListener.run();
@@ -164,8 +154,9 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe

        ListContent lc = new ListContent(getContext(), mSlice);
        SliceContent headerContent = lc.getHeader();
        mHasHeader = headerContent != null && !headerContent.getSliceItem().hasHint(HINT_LIST_ITEM);
        List<SliceContent> subItems = new ArrayList<SliceContent>();
        boolean hasHeader = headerContent != null
                && !headerContent.getSliceItem().hasHint(HINT_LIST_ITEM);
        List<SliceContent> subItems = new ArrayList<>();
        for (int i = 0; i < lc.getRowItems().size(); i++) {
            SliceContent subItem = lc.getRowItems().get(i);
            String itemUri = subItem.getSliceItem().getSlice().getUri().toString();
@@ -174,21 +165,11 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
                subItems.add(subItem);
            }
        }
        if (!mHasHeader) {
            mTitle.setVisibility(GONE);
        } else {
            mTitle.setVisibility(VISIBLE);

            RowContent header = lc.getHeader();
            SliceItem mainTitle = header.getTitleItem();
            CharSequence title = mainTitle != null ? mainTitle.getText() : null;
            mTitle.setText(title);
        }

        mClickActions.clear();
        final int subItemsCount = subItems.size();
        final int blendedColor = getTextColor();
        final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it
        final int startIndex = hasHeader ? 1 : 0; // First item is header; skip it
        mRow.setVisibility(subItemsCount > 0 ? VISIBLE : GONE);
        for (int i = startIndex; i < subItemsCount; i++) {
            RowContent rc = (RowContent) subItems.get(i);
@@ -200,7 +181,7 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
                button = new KeyguardSliceButton(mContext);
                button.setTextColor(blendedColor);
                button.setTag(itemTag);
                final int viewIndex = i - (mHasHeader ? 1 : 0);
                final int viewIndex = i - (hasHeader ? 1 : 0);
                mRow.addView(button, viewIndex);
            }

@@ -303,7 +284,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe

    private void updateTextColors() {
        final int blendedColor = getTextColor();
        mTitle.setTextColor(blendedColor);
        int childCount = mRow.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View v = mRow.getChildAt(i);
@@ -333,10 +313,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
        mContentChangeListener = contentChangeListener;
    }

    public boolean hasHeader() {
        return mHasHeader;
    }

    /**
     * LiveData observer lifecycle.
     * @param slice the new slice content.
@@ -352,7 +328,7 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
        setupUri(newValue);
    }

    public void setupUri(String uriString) {
    private void setupUri(String uriString) {
        if (uriString == null) {
            uriString = KeyguardSliceProvider.KEYGUARD_SLICE_URI;
        }
@@ -564,46 +540,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
        }
    }

    /**
     * A text view that will split its contents in 2 lines when possible.
     */
    static class TitleView extends AlphaOptimizedTextView {

        public TitleView(Context context) {
            super(context);
        }

        public TitleView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public TitleView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }

        public TitleView(Context context, AttributeSet attrs, int defStyleAttr,
                int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);

            Layout layout = getLayout();
            int lineCount = layout.getLineCount();
            boolean ellipsizing = layout.getEllipsisCount(lineCount - 1) != 0;
            if (lineCount > 0 && !ellipsizing) {
                CharSequence title = getText();
                CharSequence bestLineBreak = findBestLineBreak(title);
                if (!TextUtils.equals(title, bestLineBreak)) {
                    setText(bestLineBreak);
                    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                }
            }
        }
    }

    private class SliceViewTransitionListener implements LayoutTransition.TransitionListener {
        @Override
        public void startTransition(LayoutTransition transition, ViewGroup container, View view,
@@ -619,15 +555,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
                            .setInterpolator(Interpolators.ALPHA_IN)
                            .start();
                    break;
                case LayoutTransition.DISAPPEARING:
                    if (view == mTitle) {
                        // Translate the view to the inverse of its height, so the layout event
                        // won't misposition it.
                        LayoutParams params = (LayoutParams) mTitle.getLayoutParams();
                        int margin = params.topMargin + params.bottomMargin;
                        mTitle.setTranslationY(-mTitle.getHeight() - margin);
                    }
                    break;
            }
        }

+4 −12
Original line number Diff line number Diff line
@@ -200,10 +200,9 @@ public class KeyguardStatusView extends GridLayout implements
     * Moves clock, adjusting margins when slice content changes.
     */
    private void onSliceContentChanged() {
        boolean smallClock = mKeyguardSlice.hasHeader() || mPulsing;
        RelativeLayout.LayoutParams layoutParams =
                (RelativeLayout.LayoutParams) mClockView.getLayoutParams();
        layoutParams.bottomMargin = smallClock ? mSmallClockPadding : 0;
        layoutParams.bottomMargin = mPulsing ? mSmallClockPadding : 0;
        mClockView.setLayoutParams(layoutParams);
    }

@@ -214,17 +213,15 @@ public class KeyguardStatusView extends GridLayout implements
    public void onLayoutChange(View view, int left, int top, int right, int bottom,
            int oldLeft, int oldTop, int oldRight, int oldBottom) {
        int heightOffset = mPulsing || mWasPulsing ? 0 : getHeight() - mLastLayoutHeight;
        boolean hasHeader = mKeyguardSlice.hasHeader();
        boolean smallClock = hasHeader || mPulsing;
        long duration = KeyguardSliceView.DEFAULT_ANIM_DURATION;
        long delay = smallClock || mWasPulsing ? 0 : duration / 4;
        long delay = mPulsing || mWasPulsing ? 0 : duration / 4;
        mWasPulsing = false;

        boolean shouldAnimate = mKeyguardSlice.getLayoutTransition() != null
                && mKeyguardSlice.getLayoutTransition().isRunning();
        if (view == mClockView) {
            float clockScale = smallClock ? mSmallClockScale : 1;
            Paint.Style style = smallClock ? Paint.Style.FILL_AND_STROKE : Paint.Style.FILL;
            float clockScale = mPulsing ? mSmallClockScale : 1;
            Paint.Style style = mPulsing ? Paint.Style.FILL_AND_STROKE : Paint.Style.FILL;
            mClockView.animate().cancel();
            if (shouldAnimate) {
                mClockView.setY(oldTop + heightOffset);
@@ -431,11 +428,6 @@ public class KeyguardStatusView extends GridLayout implements
            mWasPulsing = true;
        }
        mPulsing = pulsing;
        // Animation can look really weird when the slice has a header, let's hide the views
        // immediately instead of fading them away.
        if (mKeyguardSlice.hasHeader()) {
            animate = false;
        }
        mKeyguardSlice.setPulsing(pulsing, animate);
        updateDozeVisibleViews();
    }
+14 −0
Original line number Diff line number Diff line
@@ -20,5 +20,19 @@ package com.android.systemui.doze;
 * Interface for class that cares about doze states.
 */
public interface DozeReceiver {

    /**
     * If device enters or leaves doze mode
     */
    void setDozing(boolean dozing);

    /**
     * Invoked every time a minute is elapsed in doze mode
     */
    void dozeTimeTick();

    /**
     * When view is double tapped in doze mode.
     */
    void onDozeDoubleTap();
}
Loading