Merge "Adds additional pages to Taskbar Edu." into sc-v2-dev am: 7b65460e9a

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15618164

Change-Id: I2c73100dbc9a343fac2d938494fae0875886e4a0
This commit is contained in:
Andy Wickham
2021-08-24 18:49:15 +00:00
committed by Automerger Merge Worker
6 changed files with 260 additions and 31 deletions

View File

@@ -17,6 +17,7 @@
<com.android.launcher3.taskbar.TaskbarEduView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
@@ -33,46 +34,121 @@
android:paddingHorizontal="36dp"
android:paddingTop="64dp">
<TextView
android:id="@+id/edu_header"
<com.android.launcher3.taskbar.TaskbarEduPagedView
android:id="@+id/content"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_height="378dp"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center_horizontal"
style="@style/TextHeadline"
android:text="@string/taskbar_edu_header_1"
android:fontFamily="google-sans"
android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp"
android:maxLines="2"/>
launcher:pageIndicator="@+id/content_page_indicator">
<ImageView
android:id="@+id/edu_illustration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/edu_header"
android:src="@drawable/taskbar_edu_splitscreen"/>
<LinearLayout
android:id="@+id/page_splitscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_horizontal"
style="@style/TextHeadline"
android:text="@string/taskbar_edu_splitscreen"
android:fontFamily="google-sans"
android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp"
android:maxLines="2"/>
<ImageView
android:layout_width="322dp"
android:layout_height="282dp"
android:layout_marginTop="16dp"
android:src="@drawable/taskbar_edu_splitscreen"/>
</LinearLayout>
<LinearLayout
android:id="@+id/page_customize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_horizontal"
style="@style/TextHeadline"
android:text="@string/taskbar_edu_customize"
android:fontFamily="google-sans"
android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp"
android:maxLines="2"/>
<ImageView
android:layout_width="322dp"
android:layout_height="282dp"
android:layout_marginTop="16dp"
android:src="@drawable/taskbar_edu_splitscreen"/>
</LinearLayout>
<LinearLayout
android:id="@+id/page_dock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_horizontal"
style="@style/TextHeadline"
android:text="@string/taskbar_edu_dock"
android:fontFamily="google-sans"
android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp"
android:maxLines="2"/>
<ImageView
android:layout_width="322dp"
android:layout_height="282dp"
android:layout_marginTop="16dp"
android:src="@drawable/taskbar_edu_splitscreen"/>
</LinearLayout>
</com.android.launcher3.taskbar.TaskbarEduPagedView>
<Button
android:id="@+id/edu_close_button"
android:id="@+id/edu_start_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginBottom="92dp"
app:layout_constraintTop_toBottomOf="@id/edu_illustration"
app:layout_constraintTop_toBottomOf="@id/content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="@string/taskbar_edu_close"
style="@style/TaskbarEdu.Button.Close"
android:textColor="?android:attr/textColorPrimary"/>
<com.android.launcher3.pageindicators.PageIndicatorDots
android:id="@+id/content_page_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@id/edu_start_button"
app:layout_constraintBottom_toBottomOf="@id/edu_start_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:elevation="1dp" />
<Button
android:id="@+id/edu_next_button"
android:id="@+id/edu_end_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginBottom="92dp"
app:layout_constraintTop_toBottomOf="@id/edu_illustration"
app:layout_constraintTop_toBottomOf="@id/content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/taskbar_edu_next"

View File

@@ -205,11 +205,25 @@
<string name="gesture_tutorial_action_button_label_skip">Skip</string>
<!-- ******* Taskbar Edu ******* -->
<!-- Text in dialog that lets a user know how they can use the taskbar on their device.
[CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_header_1">Use 2 apps at once and switch apps with the taskbar</string>
<!-- Text on button to go to the next screen of a tutorial [CHAR_LIMIT=30] -->
<!-- Accessibility text spoken when the taskbar education panel appears [CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_opened">Taskbar education appeared</string>
<!-- Accessibility text spoken when the taskbar education panel disappears [CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_closed">Taskbar education closed</string>
<!-- Text in dialog that lets a user know how they can use the taskbar to use multiple apps on their device.
[CHAR_LIMIT=60] -->
<string name="taskbar_edu_splitscreen" translatable="false">Use 2 apps at once and switch apps with the taskbar</string>
<!-- Text in dialog that lets a user know how they can customize the taskbar on their device.
[CHAR_LIMIT=60] -->
<string name="taskbar_edu_customize" translatable="false">Add your favorite apps and get automatic suggestions</string>
<!-- Text in dialog that lets a user know how they can hide the taskbar on their device.
[CHAR_LIMIT=60] -->
<string name="taskbar_edu_dock">Touch &amp; hold to hide the taskbar anytime</string>
<!-- Text on button to go to the next screen of a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_next">Next</string>
<!-- Text on button to exit a tutorial [CHAR_LIMIT=30] -->
<!-- Text on button to go to the previous screen of a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_previous">Back</string>
<!-- Text on button to exit a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_close">Close</string>
<!-- Text on button to finish a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_done">Done</string>
</resources>

View File

@@ -144,11 +144,13 @@
<item name="android:background">@drawable/button_taskbar_edu_bordered</item>
<item name="android:stateListAnimator">@null</item>
<item name="android:textSize">16sp</item>
<item name="android:padding">4dp</item>
</style>
<style name="TaskbarEdu.Button.Next" parent="@android:style/Widget.Material.Button">
<item name="android:background">@drawable/button_taskbar_edu_colored</item>
<item name="android:stateListAnimator">@null</item>
<item name="android:textSize">16sp</item>
<item name="android:padding">4dp</item>
</style>
</resources>

View File

@@ -32,9 +32,8 @@ public class TaskbarEduController {
mActivity.getDragLayer().post(() -> {
mTaskbarEduView = (TaskbarEduView) mActivity.getLayoutInflater().inflate(
R.layout.taskbar_edu, mActivity.getDragLayer(), false);
mTaskbarEduView.addOnCloseListener(() -> {
mTaskbarEduView = null;
});
mTaskbarEduView.init(new TaskbarEduCallbacks());
mTaskbarEduView.addOnCloseListener(() -> mTaskbarEduView = null);
mTaskbarEduView.show();
});
}
@@ -44,4 +43,27 @@ public class TaskbarEduController {
mTaskbarEduView.close(true /* animate */);
}
}
/**
* Callbacks for {@link TaskbarEduView} to interact with its controller.
*/
class TaskbarEduCallbacks {
void onPageChanged(int currentPage, int pageCount) {
if (currentPage == 0) {
mTaskbarEduView.updateStartButton(R.string.taskbar_edu_close,
v -> mTaskbarEduView.close(true /* animate */));
} else {
mTaskbarEduView.updateStartButton(R.string.taskbar_edu_previous,
v -> mTaskbarEduView.snapToPage(currentPage - 1));
}
if (currentPage == pageCount - 1) {
mTaskbarEduView.updateEndButton(R.string.taskbar_edu_done,
v -> mTaskbarEduView.close(true /* animate */));
} else {
mTaskbarEduView.updateEndButton(R.string.taskbar_edu_next,
v -> mTaskbarEduView.snapToPage(currentPage + 1));
}
}
}
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2021 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.launcher3.taskbar;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_EDUCATION_DIALOG;
import android.content.Context;
import android.util.AttributeSet;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.pageindicators.PageIndicatorDots;
import com.android.launcher3.taskbar.TaskbarEduController.TaskbarEduCallbacks;
import com.android.launcher3.views.ActivityContext;
/** Horizontal carousel of tutorial screens for Taskbar Edu. */
public class TaskbarEduPagedView extends PagedView<PageIndicatorDots> {
private TaskbarEduView mTaskbarEduView;
private TaskbarEduCallbacks mControllerCallbacks;
public TaskbarEduPagedView(Context context, AttributeSet attrs) {
super(context, attrs);
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
}
void setTaskbarEduView(TaskbarEduView taskbarEduView) {
mTaskbarEduView = taskbarEduView;
mPageIndicator = taskbarEduView.findViewById(R.id.content_page_indicator);
initParentViews(taskbarEduView);
}
void setControllerCallbacks(TaskbarEduCallbacks controllerCallbacks) {
mControllerCallbacks = controllerCallbacks;
mControllerCallbacks.onPageChanged(getCurrentPage(), getPageCount());
}
@Override
protected int getChildGap() {
return mTaskbarEduView.getPaddingLeft() + mTaskbarEduView.getPaddingRight();
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (mMaxScroll > 0) {
mPageIndicator.setScroll(l, mMaxScroll);
}
}
@Override
protected void notifyPageSwitchListener(int prevPage) {
super.notifyPageSwitchListener(prevPage);
mControllerCallbacks.onPageChanged(getCurrentPage(), getPageCount());
}
@Override
protected boolean canScroll(float absVScroll, float absHScroll) {
return AbstractFloatingView.getTopOpenViewWithType(
ActivityContext.lookupContext(getContext()),
TYPE_ALL & ~TYPE_TASKBAR_EDUCATION_DIALOG) == null;
}
}

View File

@@ -21,6 +21,9 @@ import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.View;
import android.widget.Button;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
@@ -34,6 +37,10 @@ public class TaskbarEduView extends AbstractSlideInView<TaskbarActivityContext>
private final Rect mInsets = new Rect();
private Button mStartButton;
private Button mEndButton;
private TaskbarEduPagedView mPagedView;
public TaskbarEduView(Context context, AttributeSet attr) {
this(context, attr, 0);
}
@@ -43,6 +50,12 @@ public class TaskbarEduView extends AbstractSlideInView<TaskbarActivityContext>
super(context, attrs, defStyleAttr);
}
protected void init(TaskbarEduController.TaskbarEduCallbacks callbacks) {
if (mPagedView != null) {
mPagedView.setControllerCallbacks(callbacks);
}
}
@Override
protected void handleClose(boolean animate) {
handleClose(animate, DEFAULT_CLOSE_DURATION);
@@ -57,7 +70,10 @@ public class TaskbarEduView extends AbstractSlideInView<TaskbarActivityContext>
protected void onFinishInflate() {
super.onFinishInflate();
mContent = findViewById(R.id.edu_view);
findViewById(R.id.edu_close_button).setOnClickListener(v -> close(true /* animate */));
mStartButton = findViewById(R.id.edu_start_button);
mEndButton = findViewById(R.id.edu_end_button);
mPagedView = findViewById(R.id.content);
mPagedView.setTaskbarEduView(this);
}
@Override
@@ -81,6 +97,12 @@ public class TaskbarEduView extends AbstractSlideInView<TaskbarActivityContext>
animateOpen();
}
@Override
protected Pair<View, String> getAccessibilityTarget() {
return Pair.create(mContent, mIsOpen ? getContext().getString(R.string.taskbar_edu_opened)
: getContext().getString(R.string.taskbar_edu_closed));
}
@Override
protected int getScrimColor(Context context) {
return context.getResources().getColor(R.color.widgets_picker_scrim);
@@ -110,4 +132,18 @@ public class TaskbarEduView extends AbstractSlideInView<TaskbarActivityContext>
mOpenCloseAnimator.setInterpolator(FAST_OUT_SLOW_IN);
mOpenCloseAnimator.start();
}
void snapToPage(int page) {
mPagedView.snapToPage(page);
}
void updateStartButton(int textResId, OnClickListener onClickListener) {
mStartButton.setText(textResId);
mStartButton.setOnClickListener(onClickListener);
}
void updateEndButton(int textResId, OnClickListener onClickListener) {
mEndButton.setText(textResId);
mEndButton.setOnClickListener(onClickListener);
}
}