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

Commit 1e119db1 authored by Selim Cinek's avatar Selim Cinek Committed by Dan Sandler
Browse files

Changed the visual appearance of the speedbump view.

The colorfulldots are replaced by a simple line to avoid
catching too much attention.

Bug: 15188625
Change-Id: I41be50dcc61d495f3bc88e4731388f770fda83d0
parent 486ed088
Loading
Loading
Loading
Loading
+7 −42
Original line number Diff line number Diff line
@@ -18,48 +18,13 @@
<com.android.systemui.statusbar.SpeedBumpView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:clickable="true"
    android:layout_height="@dimen/speed_bump_height"
    android:visibility="gone"
    >
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/speed_bump_height_collapsed"
            android:layout_gravity="top"
            android:orientation="horizontal">
        <com.android.systemui.statusbar.AlphaOptimizedView
            android:id="@+id/speedbump_line_left"
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_weight="1"
            android:background="#6fdddddd"
            android:layout_gravity="center_vertical"/>
        <com.android.systemui.statusbar.SpeedBumpDotsLayout
                android:id="@+id/speed_bump_dots_layout"
                android:layout_width="34dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_height="match_parent"
                android:layout_weight="0"/>
    <com.android.systemui.statusbar.AlphaOptimizedView
            android:id="@+id/speedbump_line_right"
            android:layout_width="0dp"
        android:id="@+id/speedbump_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
            android:layout_weight="1"
        android:background="#6fdddddd"
        android:layout_gravity="center_vertical"/>
    </LinearLayout>
    <TextView
            android:id="@+id/speed_bump_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|center_horizontal"
            android:fontFamily="sans-serif-condensed"
            android:textSize="15sp"
            android:singleLine="true"
            android:textColor="#eeeeee"
            android:visibility="invisible"
            android:text="@string/speed_bump_explanation"
            android:paddingTop="4dp" />
</com.android.systemui.statusbar.SpeedBumpView>
+0 −12
Original line number Diff line number Diff line
@@ -45,18 +45,6 @@
    <!-- Tint color for the content on the notification overflow card. -->
    <color name="keyguard_overflow_content_color">#ff686868</color>

    <!-- The color of the red speed bump dot -->
    <color name="speed_bump_dot_red">#ffd50000</color>

    <!-- The color of the blue speed bump dot -->
    <color name="speed_bump_dot_blue">#ff2962ff</color>

    <!-- The color of the yellow speed bump dot -->
    <color name="speed_bump_dot_yellow">#ffffd600</color>

    <!-- The color of the green speed bump dot -->
    <color name="speed_bump_dot_green">#ff00c853</color>

    <!-- The default recents task bar background color. -->
    <color name="recents_task_bar_default_background_color">#e6444444</color>
    <!-- The default recents task bar text color. -->
+2 −8
Original line number Diff line number Diff line
@@ -275,14 +275,8 @@
    <!-- The minimum amount of top overscroll to go to the quick settings. -->
    <dimen name="min_top_overscroll_to_qs">36dp</dimen>

    <!-- The height of the collapsed speed bump view. -->
    <dimen name="speed_bump_height_collapsed">24dp</dimen>

    <!-- The padding inset the explanation text needs compared to the collapsed height -->
    <dimen name="speed_bump_text_padding_inset">10dp</dimen>

    <!-- The height of the speed bump dots. -->
    <dimen name="speed_bump_dots_height">5dp</dimen>
    <!-- The height of the speed bump view. -->
    <dimen name="speed_bump_height">16dp</dimen>

    <!-- The total height of the stack in its collapsed size (i.e. when quick settings is open) -->
    <dimen name="collapsed_stack_height">94dp</dimen>
+0 −52
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.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * An single dot of the {@link com.android.systemui.statusbar.SpeedBumpDotsLayout}
 */
public class SpeedBumpDotView extends View {

    private final Paint mPaint = new Paint();

    public SpeedBumpDotView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mPaint.setAntiAlias(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        float radius = getWidth() / 2.0f;
        canvas.drawCircle(radius, radius, radius, mPaint);
    }

    @Override
    public boolean hasOverlappingRendering() {
        return false;
    }

    public void setColor(int color) {
        mPaint.setColor(color);
    }
}
+0 −80
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;
import com.android.systemui.R;

/**
 * The Algorithm of the {@link com.android.systemui.statusbar.SpeedBumpDotsLayout} which can be
 * queried for {@link * com.android.systemui.statusbar.SpeedBumpDotsState}
 */
public class SpeedBumpDotsAlgorithm {

    private final float mDotRadius;

    public SpeedBumpDotsAlgorithm(Context context) {
        mDotRadius = context.getResources().getDimensionPixelSize(R.dimen.speed_bump_dots_height)
                / 2.0f;
    }

    public void getState(SpeedBumpDotsState resultState) {

        // First reset the current state and ensure that every View has a ViewState
        resultState.resetViewStates();

        SpeedBumpDotsLayout hostView = resultState.getHostView();
        boolean currentlyVisible = hostView.isCurrentlyVisible();
        resultState.setActiveState(currentlyVisible
                ? SpeedBumpDotsState.SHOWN
                : SpeedBumpDotsState.HIDDEN);
        int hostWidth = hostView.getWidth();
        float layoutWidth = hostWidth - 2 * mDotRadius;
        int childCount = hostView.getChildCount();
        float paddingBetween = layoutWidth / (childCount - 1);
        float centerY = hostView.getHeight() / 2.0f;
        for (int i = 0; i < childCount; i++) {
            View child = hostView.getChildAt(i);
            SpeedBumpDotsState.ViewState viewState = resultState.getViewStateForView(child);
            if (currentlyVisible) {
                float xTranslation = i * paddingBetween;
                viewState.xTranslation = xTranslation;
                viewState.yTranslation = calculateYTranslation(hostView, centerY, xTranslation,
                        layoutWidth);
            } else {
                viewState.xTranslation = layoutWidth / 2;
                viewState.yTranslation = centerY - mDotRadius;
            }
            viewState.alpha = currentlyVisible ? 1.0f : 0.0f;
            viewState.scale = currentlyVisible ? 1.0f : 0.5f;
        }
    }

    private float calculateYTranslation(SpeedBumpDotsLayout hostView, float centerY,
            float xTranslation, float layoutWidth) {
        float t = hostView.getAnimationProgress();
        if (t == 0.0f || t == 1.0f) {
            return centerY - mDotRadius;
        }
        float damping = (0.5f -Math.abs(0.5f - t)) * 1.3f;
        float partialOffset = xTranslation / layoutWidth;
        float indentFactor = (float) (Math.sin((t + partialOffset * 1.5f) * - Math.PI) * damping);
        return (1.0f - indentFactor) * centerY - mDotRadius;
    }

}
Loading