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

Commit fb2b6bc6 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Add text view for double-tap and unlock hint on Keyguard."

parents d80cb24a e70d31f4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -31,4 +31,14 @@
        android:scaleType="center"
        android:contentDescription="@string/accessibility_camera_button"
        systemui:glowBackground="@drawable/ic_sysbar_highlight_land" />

    <com.android.systemui.statusbar.phone.KeyguardIndicationTextView
        android:id="@+id/keyguard_indication_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="100dp"
        android:layout_gravity="bottom|center_horizontal"
        android:textStyle="italic"
        android:textAppearance="?android:attr/textAppearanceMedium"/>

</com.android.systemui.statusbar.phone.KeyguardBottomAreaView>
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -546,4 +546,10 @@
    <plurals name="keyguard_more_overflow_text">
        <item quantity="other">%d more</item>
    </plurals>

    <!-- Shows to explain the double tap interaction with notifications: After tapping a notification on Keyguard, this will explain users to tap again to launch a notification. [CHAR LIMIT=60] -->
    <string name="notification_tap_again">Tap again to open</string>

    <!-- Shows when people have pressed the unlock icon to explain how to unlock. [CHAR LIMIT=60] -->
    <string name="keyguard_unlock">Swipe up to unlock</string>
</resources>
+62 −0
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.phone;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * A view to show hints on Keyguard ("Swipe up to unlock", "Tap again to open").
 */
public class KeyguardIndicationTextView extends TextView {

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

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

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

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

    /**
     * Changes the text with an animation and makes sure a single indication is shown long enough.
     *
     * @param text The text to show.
     */
    public void switchIndication(CharSequence text) {

        // TODO: Animation, make sure that we will show one indication long enough.
        setText(text);
    }

    /**
     * See {@link #switchIndication}.
     */
    public void switchIndication(int textResId) {
        switchIndication(getResources().getText(textResId));
    }
}
+28 −1
Original line number Diff line number Diff line
@@ -232,6 +232,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
    View mNotificationPanelHeader;
    View mKeyguardStatusView;
    View mKeyguardBottomArea;
    KeyguardIndicationTextView mKeyguardIndicationTextView;

    // TODO: Fetch phrase from search/hotword provider.
    String mKeyguardHotwordPhrase = "";
    int mKeyguardMaxNotificationCount;
    View mDateTimeView;
    View mClearButton;
@@ -618,7 +622,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        mNotificationPanelHeader = mStatusBarWindow.findViewById(R.id.header);
        mKeyguardStatusView = mStatusBarWindow.findViewById(R.id.keyguard_status_view);
        mKeyguardBottomArea = mStatusBarWindow.findViewById(R.id.keyguard_bottom_area);

        mKeyguardIndicationTextView = (KeyguardIndicationTextView) mStatusBarWindow.findViewById(
                R.id.keyguard_indication_text);
        mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button);
        mClearButton.setOnClickListener(mClearButtonListener);
        mClearButton.setAlpha(0f);
@@ -2942,6 +2947,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
            }
            mKeyguardStatusView.setVisibility(View.VISIBLE);
            mKeyguardBottomArea.setVisibility(View.VISIBLE);
            mKeyguardIndicationTextView.setVisibility(View.VISIBLE);
            mKeyguardIndicationTextView.switchIndication(mKeyguardHotwordPhrase);
            mNotificationPanelHeader.setVisibility(View.GONE);

            mKeyguardFlipper.setVisibility(View.VISIBLE);
@@ -2949,6 +2956,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        } else {
            mKeyguardStatusView.setVisibility(View.GONE);
            mKeyguardBottomArea.setVisibility(View.GONE);
            mKeyguardIndicationTextView.setVisibility(View.GONE);
            mNotificationPanelHeader.setVisibility(View.VISIBLE);

            mKeyguardFlipper.setVisibility(View.GONE);
@@ -3004,9 +3012,28 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
    @Override
    public void onActivated(View view) {
        userActivity();
        mKeyguardIndicationTextView.switchIndication(R.string.notification_tap_again);
        super.onActivated(view);
    }

    @Override
    public void onReset(View view) {
        super.onReset(view);
        mKeyguardIndicationTextView.switchIndication(mKeyguardHotwordPhrase);
    }

    public void onTrackingStarted() {
        if (mOnKeyguard) {
            mKeyguardIndicationTextView.switchIndication(R.string.keyguard_unlock);
        }
    }

    public void onTrackingStopped() {
        if (mOnKeyguard) {
            mKeyguardIndicationTextView.switchIndication(mKeyguardHotwordPhrase);
        }
    }

    @Override
    protected int getMaxKeyguardNotifications() {
        return mKeyguardMaxNotificationCount;
+12 −0
Original line number Diff line number Diff line
@@ -159,6 +159,18 @@ public class PhoneStatusBarView extends PanelBar {
        return barConsumedEvent || super.onTouchEvent(event);
    }

    @Override
    public void onTrackingStarted(PanelView panel) {
        super.onTrackingStarted(panel);
        mBar.onTrackingStarted();
    }

    @Override
    public void onTrackingStopped(PanelView panel) {
        super.onTrackingStopped(panel);
        mBar.onTrackingStopped();
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return mBar.interceptTouchEvent(event) || super.onInterceptTouchEvent(event);