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

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

Merge "Priority conversations onbaording screen"

parents 181faec0 02339a32
Loading
Loading
Loading
Loading
+194 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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
  -->

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/onboarding_half_shell_container"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|bottom"
    android:paddingStart="4dp"
    android:paddingEnd="4dp"
    >

    <LinearLayout
        android:id="@+id/half_shell"
        android:layout_width="@dimen/qs_panel_width"
        android:layout_height="wrap_content"
        android:paddingTop="16dp"
        android:paddingBottom="16dp"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:orientation="vertical"
        android:gravity="bottom"
        android:layout_gravity="center_horizontal|bottom"
        android:background="@drawable/rounded_bg_full"
        >

        <!--  We have a known number of rows that can be shown; just design them all here -->
        <LinearLayout
            android:id="@+id/show_at_top_tip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:orientation="horizontal"
            >
            <ImageView
                android:id="@+id/bell_icon"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical"
                android:src="@drawable/ic_notifications_alert"
                android:tint="?android:attr/colorControlNormal" />

            <TextView
                android:id="@+id/show_at_top_text"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:gravity="center_vertical|start"
                android:textSize="15sp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/priority_onboarding_show_at_top_text"
                style="@style/TextAppearance.NotificationInfo"
                />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/show_avatar_tip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:orientation="horizontal"
            >
            <ImageView
                android:id="@+id/avatar_icon"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical"
                android:src="@drawable/ic_person"
                android:tint="?android:attr/colorControlNormal" />

            <TextView
                android:id="@+id/avatar_text"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:gravity="center_vertical|start"
                android:textSize="15sp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/priority_onboarding_show_avatar_text"
                style="@style/TextAppearance.NotificationInfo"
                />

        </LinearLayout>

        <!-- These rows show optionally -->

        <LinearLayout
            android:id="@+id/floating_bubble_tip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:orientation="horizontal"
            >

            <ImageView
                android:id="@+id/bubble_icon"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical"
                android:src="@drawable/ic_create_bubble"
                android:tint="?android:attr/colorControlNormal" />

            <TextView
                android:id="@+id/bubble_text"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:gravity="center_vertical|start"
                android:textSize="15sp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/priority_onboarding_appear_as_bubble_text"
                style="@style/TextAppearance.NotificationInfo"
                />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/ignore_dnd_tip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:orientation="horizontal"
            >

            <ImageView
                android:id="@+id/dnd_icon"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical"
                android:src="@drawable/moon"
                android:tint="?android:attr/colorControlNormal" />

            <TextView
                android:id="@+id/dnd_text"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:paddingStart="16dp"
                android:paddingEnd="16dp"
                android:gravity="center_vertical|start"
                android:textSize="15sp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/priority_onboarding_ignores_dnd_text"
                style="@style/TextAppearance.NotificationInfo"
                />

        </LinearLayout>

        <!-- Bottom button container -->
        <RelativeLayout
            android:id="@+id/button_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/done_button"
                android:text="@string/priority_onboarding_done_button_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:gravity="end|center_vertical"
                android:minWidth="@dimen/notification_importance_toggle_size"
                android:minHeight="@dimen/notification_importance_toggle_size"
                android:maxWidth="125dp"
                style="@style/TextAppearance.NotificationInfo.Button"/>

        </RelativeLayout>

    </LinearLayout>
</FrameLayout>
+12 −0
Original line number Diff line number Diff line
@@ -2647,6 +2647,18 @@
    <!-- Title of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=25] -->
    <string name="inattentive_sleep_warning_title">Standby</string>

    <!-- Priority conversation onboarding screen -->
    <!--  Text explaining that priority conversations show at the top of the conversation section [CHAR LIMIT=50]  -->
    <string name="priority_onboarding_show_at_top_text">Show at top of conversation section</string>
    <!--  Text explaining that priority conversations show an avatar on the lock screen [CHAR LIMIT=50]  -->
    <string name="priority_onboarding_show_avatar_text">Show profile picture on lock screen</string>
    <!--  Text explaining that priority conversations will appear as a bubble [CHAR LIMIT=50]  -->
    <string name="priority_onboarding_appear_as_bubble_text">Appear as a floating bubble on top of apps</string>
    <!--  Text explaining that priority conversations can interrupt DnD settings [CHAR LIMIT=50]  -->
    <string name="priority_onboarding_ignores_dnd_text">Interrupt Do Not Disturb</string>
    <!--  Title for the affirmative button [CHAR LIMIT=50]  -->
    <string name="priority_onboarding_done_button_title">Got it</string>

    <!-- Window Magnification strings -->
    <!-- Title for Magnification Window [CHAR LIMIT=NONE] -->
    <string name="magnification_window_title">Magnification Window</string>
+16 −0
Original line number Diff line number Diff line
@@ -21,11 +21,25 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;

import com.android.systemui.settings.CurrentUserContextTracker;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;
import java.util.Set;

/**
 * A helper class to store simple preferences for SystemUI. Its main use case is things such as
 * feature education, e.g. "has the user seen this tooltip".
 *
 * As of this writing, feature education settings are *intentionally exempted* from backup and
 * restore because there is not a great way to know which subset of features the user _should_ see
 * again if, for instance, they are coming from multiple OSes back or switching OEMs.
 *
 * NOTE: Clients of this class should take care to pass in the correct user context when querying
 * settings, otherwise you will always read/write for user 0 which is almost never what you want.
 * See {@link CurrentUserContextTracker} for a simple way to get the current context
 */
public final class Prefs {
    private Prefs() {} // no instantation

@@ -111,6 +125,8 @@ public final class Prefs {
        String HAS_SEEN_BUBBLES_MANAGE_EDUCATION = "HasSeenBubblesManageOnboarding";
        String HAS_SEEN_REVERSE_BOTTOM_SHEET = "HasSeenReverseBottomSheet";
        String CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT = "ControlsStructureSwipeTooltipCount";
        /** Tracks whether the user has seen the onboarding screen for priority conversations */
        String HAS_SEEN_PRIORITY_ONBOARDING = "HasSeenPriorityOnboarding";
    }

    public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.Recents;
import com.android.systemui.settings.dagger.SettingsModule;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
@@ -63,6 +64,7 @@ import dagger.Provides;
            LogModule.class,
            PeopleHubModule.class,
            SensorModule.class,
            SettingsModule.class
        },
        subcomponents = {StatusBarComponent.class,
                NotificationRowComponent.class,
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.settings

import android.content.Context
import android.os.UserHandle
import androidx.annotation.VisibleForTesting
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.util.Assert
import java.lang.IllegalStateException

/**
 * Tracks a reference to the context for the current user
 *
 * Constructor is injected at SettingsModule
 */
class CurrentUserContextTracker internal constructor(
    private val sysuiContext: Context,
    broadcastDispatcher: BroadcastDispatcher
) {
    private val userTracker: CurrentUserTracker
    private var initialized = false

    private var _curUserContext: Context? = null
    val currentUserContext: Context
        get() {
            if (!initialized) {
                throw IllegalStateException("Must initialize before getting context")
            }
            return _curUserContext!!
        }

    init {
        userTracker = object : CurrentUserTracker(broadcastDispatcher) {
            override fun onUserSwitched(newUserId: Int) {
                handleUserSwitched(newUserId)
            }
        }
    }

    fun initialize() {
        initialized = true
        _curUserContext = makeUserContext(userTracker.currentUserId)
        userTracker.startTracking()
    }

    @VisibleForTesting
    fun handleUserSwitched(newUserId: Int) {
        _curUserContext = makeUserContext(newUserId)
    }

    private fun makeUserContext(uid: Int): Context {
        Assert.isMainThread()
        return sysuiContext.createContextAsUser(UserHandle.of(uid), 0)
    }
}
 No newline at end of file
Loading