Loading packages/SystemUI/res/layout/priority_onboarding_half_shell.xml 0 → 100644 +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> packages/SystemUI/res/values/strings.xml +12 −0 Original line number Diff line number Diff line Loading @@ -2639,6 +2639,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 Overlay Window [CHAR LIMIT=NONE] --> <string name="magnification_overlay_title">Magnification Overlay Window</string> Loading packages/SystemUI/src/com/android/systemui/Prefs.java +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -109,6 +123,8 @@ public final class Prefs { String HAS_SEEN_BUBBLES_EDUCATION = "HasSeenBubblesOnboarding"; String HAS_SEEN_BUBBLES_MANAGE_EDUCATION = "HasSeenBubblesManageOnboarding"; 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) { Loading packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +13 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import androidx.annotation.Nullable; import com.android.keyguard.KeyguardViewController; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManagerImpl; import com.android.systemui.plugins.qs.QSFactory; Loading @@ -33,6 +34,7 @@ import com.android.systemui.power.EnhancedEstimatesImpl; import com.android.systemui.qs.tileimpl.QSFactoryImpl; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.settings.CurrentUserContextTracker; import com.android.systemui.stackdivider.DividerModule; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; Loading Loading @@ -136,4 +138,15 @@ public abstract class SystemUIDefaultModule { @Binds abstract KeyguardViewController bindKeyguardViewController( StatusBarKeyguardViewManager statusBarKeyguardViewManager); @Singleton @Provides static CurrentUserContextTracker provideCurrentUserContextTracker( Context context, BroadcastDispatcher broadcastDispatcher) { CurrentUserContextTracker tracker = new CurrentUserContextTracker(context, broadcastDispatcher); tracker.initialize(); return tracker; } } packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt 0 → 100644 +60 −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 com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.util.Assert import javax.inject.Inject import javax.inject.Singleton /** * Tracks a reference to the context for the current user */ @Singleton class CurrentUserContextTracker @Inject constructor( private val sysuiContext: Context, broadcastDispatcher: BroadcastDispatcher ) { private val userTracker: CurrentUserTracker var currentUserContext: Context init { userTracker = object : CurrentUserTracker(broadcastDispatcher) { override fun onUserSwitched(newUserId: Int) { handleUserSwitched(newUserId) } } currentUserContext = makeUserContext(userTracker.currentUserId) } fun initialize() { userTracker.startTracking() } private fun handleUserSwitched(newUserId: Int) { currentUserContext = makeUserContext(newUserId) } private fun makeUserContext(uid: Int): Context { Assert.isMainThread() return sysuiContext.createContextAsUser( UserHandle.getUserHandleForUid(userTracker.currentUserId), 0) } } No newline at end of file Loading
packages/SystemUI/res/layout/priority_onboarding_half_shell.xml 0 → 100644 +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>
packages/SystemUI/res/values/strings.xml +12 −0 Original line number Diff line number Diff line Loading @@ -2639,6 +2639,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 Overlay Window [CHAR LIMIT=NONE] --> <string name="magnification_overlay_title">Magnification Overlay Window</string> Loading
packages/SystemUI/src/com/android/systemui/Prefs.java +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -109,6 +123,8 @@ public final class Prefs { String HAS_SEEN_BUBBLES_EDUCATION = "HasSeenBubblesOnboarding"; String HAS_SEEN_BUBBLES_MANAGE_EDUCATION = "HasSeenBubblesManageOnboarding"; 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) { Loading
packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +13 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import androidx.annotation.Nullable; import com.android.keyguard.KeyguardViewController; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManagerImpl; import com.android.systemui.plugins.qs.QSFactory; Loading @@ -33,6 +34,7 @@ import com.android.systemui.power.EnhancedEstimatesImpl; import com.android.systemui.qs.tileimpl.QSFactoryImpl; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImplementation; import com.android.systemui.settings.CurrentUserContextTracker; import com.android.systemui.stackdivider.DividerModule; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationLockscreenUserManager; Loading Loading @@ -136,4 +138,15 @@ public abstract class SystemUIDefaultModule { @Binds abstract KeyguardViewController bindKeyguardViewController( StatusBarKeyguardViewManager statusBarKeyguardViewManager); @Singleton @Provides static CurrentUserContextTracker provideCurrentUserContextTracker( Context context, BroadcastDispatcher broadcastDispatcher) { CurrentUserContextTracker tracker = new CurrentUserContextTracker(context, broadcastDispatcher); tracker.initialize(); return tracker; } }
packages/SystemUI/src/com/android/systemui/settings/CurrentUserContextTracker.kt 0 → 100644 +60 −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 com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.util.Assert import javax.inject.Inject import javax.inject.Singleton /** * Tracks a reference to the context for the current user */ @Singleton class CurrentUserContextTracker @Inject constructor( private val sysuiContext: Context, broadcastDispatcher: BroadcastDispatcher ) { private val userTracker: CurrentUserTracker var currentUserContext: Context init { userTracker = object : CurrentUserTracker(broadcastDispatcher) { override fun onUserSwitched(newUserId: Int) { handleUserSwitched(newUserId) } } currentUserContext = makeUserContext(userTracker.currentUserId) } fun initialize() { userTracker.startTracking() } private fun handleUserSwitched(newUserId: Int) { currentUserContext = makeUserContext(newUserId) } private fun makeUserContext(uid: Int): Context { Assert.isMainThread() return sysuiContext.createContextAsUser( UserHandle.getUserHandleForUid(userTracker.currentUserId), 0) } } No newline at end of file