Merge "Adds AllSetActivity in Launcher." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
19a1c4765f
@@ -103,16 +103,40 @@
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:exported="false"/>
|
||||
|
||||
<!--
|
||||
Activity for gesture nav onboarding.
|
||||
It's protected by android.permission.REBOOT to ensure that only system apps can start it
|
||||
(setup wizard already has this permission)
|
||||
-->
|
||||
<activity android:name="com.android.quickstep.interaction.GestureSandboxActivity"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="true">
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:permission="android.permission.REBOOT"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.quickstep.action.GESTURE_SANDBOX"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!--
|
||||
Activity following gesture nav onboarding.
|
||||
It's protected by android.permission.REBOOT to ensure that only system apps can start it
|
||||
(setup wizard already has this permission)
|
||||
-->
|
||||
<activity android:name="com.android.quickstep.interaction.AllSetActivity"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:permission="android.permission.REBOOT"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.quickstep.action.GESTURE_ONBOARDING_ALL_SET"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".hybridhotseat.HotseatEduActivity"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="42dp"
|
||||
android:height="40dp"
|
||||
android:viewportWidth="42"
|
||||
android:viewportHeight="40">
|
||||
<path
|
||||
android:pathData="M38,14H25.38L27.28,4.86L27.34,4.22C27.34,3.4 27,2.64 26.46,2.1L24.34,0C24.34,0 10.16,13.7 10,14H0V40H32C33.66,40 35.08,39 35.68,37.56L41.72,23.46C41.9,23 42,22.52 42,22V18C42,15.8 40.2,14 38,14ZM10,36H4V18H10V36ZM38,22L32,36H14V16L22.68,7.32L20,18H38V22Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="@dimen/allset_page_margin_horizontal"
|
||||
android:paddingEnd="@dimen/allset_page_margin_horizontal"
|
||||
android:layoutDirection="locale"
|
||||
android:textDirection="locale"
|
||||
android:background="?android:attr/colorBackground">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_gravity="start"
|
||||
android:gravity="start"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/allset_title_icon_margin_top"
|
||||
android:src="@drawable/ic_all_set"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.GestureTutorial.Feedback.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/allset_title_margin_top"
|
||||
android:gravity="start"
|
||||
android:text="@string/allset_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtitle"
|
||||
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/allset_subtitle_margin_top"
|
||||
android:gravity="start"
|
||||
android:text="@string/allset_description"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/navigation_settings"
|
||||
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
|
||||
android:textSize="14sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/hint"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginBottom="72dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@id/hint"
|
||||
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
|
||||
android:textSize="14sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/allset_hint_margin_bottom"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/allset_hint"/>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<resources>
|
||||
<declare-styleable name="AllSetLinkSpan">
|
||||
<attr name="android:textSize"/>
|
||||
<attr name="android:fontFamily"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
@@ -99,6 +99,13 @@
|
||||
<dimen name="gesture_tutorial_feedback_margin_start_end">24dp</dimen>
|
||||
<dimen name="gesture_tutorial_button_margin_start_end">18dp</dimen>
|
||||
|
||||
<!-- All Set page -->
|
||||
<dimen name="allset_page_margin_horizontal">40dp</dimen>
|
||||
<dimen name="allset_title_margin_top">28dp</dimen>
|
||||
<dimen name="allset_title_icon_margin_top">80dp</dimen>
|
||||
<dimen name="allset_hint_margin_bottom">52dp</dimen>
|
||||
<dimen name="allset_subtitle_margin_top">24dp</dimen>
|
||||
|
||||
<!-- All Apps Education tutorial -->
|
||||
<dimen name="swipe_edu_padding">8dp</dimen>
|
||||
<dimen name="swipe_edu_circle_size">64dp</dimen>
|
||||
|
||||
@@ -177,6 +177,15 @@
|
||||
<!-- Feedback subtext displaying the current step and the total number of steps for the tutorial. [CHAR LIMIT=30] -->
|
||||
<string name="gesture_tutorial_step">Tutorial <xliff:g id="current">%1$d</xliff:g>/<xliff:g id="total">%2$d</xliff:g></string>
|
||||
|
||||
<!-- Title of "All Set" page [CHAR LIMIT=NONE] -->
|
||||
<string name="allset_title">All set!</string>
|
||||
<!-- Hint string at the bottom of "All Set" page [CHAR LIMIT=NONE] -->
|
||||
<string name="allset_hint">Swipe up to go home</string>
|
||||
<!-- Description of "All Set" page [CHAR LIMIT=NONE] -->
|
||||
<string name="allset_description">You\u2019re ready to start using your phone</string>
|
||||
<!-- String linking to navigation settings on "All Set" page [CHAR LIMIT=NONE] -->
|
||||
<string name="allset_navigation_settings"><annotation id="link">Navigation settings for accessibility</annotation></string>
|
||||
|
||||
<!-- ******* Overview ******* -->
|
||||
<!-- Label for a button that causes the current overview app to be shared. [CHAR_LIMIT=40] -->
|
||||
<string name="action_share">Share</string>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
parent="TextAppearance.GestureTutorial">
|
||||
<item name="android:gravity">start</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:fontFamily">google-sans</item>
|
||||
<item name="android:fontFamily">google-sans-text</item>
|
||||
<item name="android:letterSpacing">0.03</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
<item name="android:lineHeight">24sp</item>
|
||||
@@ -99,6 +99,11 @@
|
||||
<item name="android:textColor">@color/gesture_tutorial_primary_color</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.GestureTutorial.LinkText"
|
||||
parent="TextAppearance.GestureTutorial.Feedback.Subtitle">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Can be applied to views to color things like ripples and list highlights the workspace text
|
||||
color.
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* 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.quickstep.interaction;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextPaint;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
* A page shows after SUW flow to hint users to swipe up from the bottom of the screen to go home
|
||||
* for the gestural system navigation.
|
||||
*/
|
||||
public class AllSetActivity extends Activity {
|
||||
|
||||
private static final String LOG_TAG = "AllSetActivity";
|
||||
private static final String URI_SYSTEM_NAVIGATION_SETTING =
|
||||
"#Intent;action=com.android.settings.SEARCH_RESULT_TRAMPOLINE;S.:settings:fragment_args_key=gesture_system_navigation_input_summary;S.:settings:show_fragment=com.android.settings.gestures.SystemNavigationGestureSettings;end";
|
||||
private static final String EXTRA_ACCENT_COLOR_DARK_MODE = "accent_color_dark_mode";
|
||||
private static final String EXTRA_ACCENT_COLOR_LIGHT_MODE = "accent_color_light_mode";
|
||||
|
||||
private int mAccentColor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_allset);
|
||||
setTitle(R.string.allset_title);
|
||||
|
||||
final int mode =
|
||||
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
mAccentColor = getIntent().getIntExtra(
|
||||
mode == Configuration.UI_MODE_NIGHT_YES
|
||||
? EXTRA_ACCENT_COLOR_DARK_MODE : EXTRA_ACCENT_COLOR_LIGHT_MODE,
|
||||
/* defValue= */ Color.BLACK);
|
||||
|
||||
((ImageView) findViewById(R.id.icon)).getDrawable().mutate().setTint(mAccentColor);
|
||||
|
||||
TextView navigationSettings = findViewById(R.id.navigation_settings);
|
||||
navigationSettings.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
|
||||
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION,
|
||||
new AllSetLinkSpan(
|
||||
/* context= */ this,
|
||||
view -> {
|
||||
try {
|
||||
startActivityForResult(
|
||||
Intent.parseUri(URI_SYSTEM_NAVIGATION_SETTING, 0), 0);
|
||||
} catch (URISyntaxException e) {
|
||||
Log.e(LOG_TAG, "Failed to parse system nav settings intent", e);
|
||||
}
|
||||
finish();
|
||||
}));
|
||||
navigationSettings.setText(
|
||||
AnnotationSpan.linkify(getText(R.string.allset_navigation_settings), linkInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
hideSystemUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideSystemUI() {
|
||||
getWindow().getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||
getWindow().setNavigationBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
private final class AllSetLinkSpan extends AnnotationSpan {
|
||||
|
||||
private final String mFontFamily;
|
||||
private final int mTextSize;
|
||||
|
||||
AllSetLinkSpan(Context context, View.OnClickListener listener) {
|
||||
super(listener);
|
||||
TypedArray typedArray =
|
||||
context.obtainStyledAttributes(R.style.TextAppearance_GestureTutorial_LinkText,
|
||||
R.styleable.AllSetLinkSpan);
|
||||
mFontFamily = typedArray.getString(R.styleable.AllSetLinkSpan_android_fontFamily);
|
||||
mTextSize =
|
||||
typedArray.getDimensionPixelSize(
|
||||
R.styleable.AllSetLinkSpan_android_textSize, /* defValue= */ -1);
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(mAccentColor);
|
||||
ds.setTypeface(Typeface.create(mFontFamily, Typeface.NORMAL));
|
||||
ds.setUnderlineText(false);
|
||||
if (mTextSize != -1) {
|
||||
ds.setTextSize(mTextSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.quickstep.interaction;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.Annotation;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* This class is used to add {@link View.OnClickListener} for the text been wrapped by
|
||||
* annotation.
|
||||
*
|
||||
* Copied from packages/apps/Settings/src/com/android/settings/utils/AnnotationSpan.java.
|
||||
*/
|
||||
public class AnnotationSpan extends URLSpan {
|
||||
|
||||
private final View.OnClickListener mClickListener;
|
||||
|
||||
AnnotationSpan(View.OnClickListener lsn) {
|
||||
super((String) null);
|
||||
mClickListener = lsn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
if (mClickListener != null) {
|
||||
mClickListener.onClick(widget);
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence linkify(CharSequence rawText, LinkInfo... linkInfos) {
|
||||
SpannableString msg = new SpannableString(rawText);
|
||||
Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(msg);
|
||||
for (Annotation annotation : spans) {
|
||||
final String key = annotation.getValue();
|
||||
int start = msg.getSpanStart(annotation);
|
||||
int end = msg.getSpanEnd(annotation);
|
||||
AnnotationSpan link = null;
|
||||
for (LinkInfo linkInfo : linkInfos) {
|
||||
if (linkInfo.mAnnotation.equals(key)) {
|
||||
link = linkInfo.mCustomizedSpan != null ? linkInfo.mCustomizedSpan
|
||||
: new AnnotationSpan(linkInfo.mClickListener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (link != null) {
|
||||
builder.setSpan(link, start, end, msg.getSpanFlags(link));
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the text part without having text for link part
|
||||
*/
|
||||
public static CharSequence textWithoutLink(CharSequence encodedText) {
|
||||
SpannableString msg = new SpannableString(encodedText);
|
||||
Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
|
||||
if (spans == null) {
|
||||
return encodedText;
|
||||
}
|
||||
Arrays.sort(spans, Comparator.comparingInt(span -> -msg.getSpanStart(span)));
|
||||
StringBuilder msgWithoutLink = new StringBuilder(msg.toString());
|
||||
for (Annotation span : spans) {
|
||||
msgWithoutLink.delete(msg.getSpanStart(span), msg.getSpanEnd(span));
|
||||
}
|
||||
return msgWithoutLink.toString();
|
||||
}
|
||||
|
||||
/** Data class to store the annotation and the click action. */
|
||||
public static class LinkInfo {
|
||||
public static final String DEFAULT_ANNOTATION = "link";
|
||||
private static final String TAG = "AnnotationSpan.LinkInfo";
|
||||
private final String mAnnotation;
|
||||
private final Boolean mActionable;
|
||||
private final View.OnClickListener mClickListener;
|
||||
private final AnnotationSpan mCustomizedSpan;
|
||||
|
||||
public LinkInfo(String annotation, View.OnClickListener listener) {
|
||||
mAnnotation = annotation;
|
||||
mClickListener = listener;
|
||||
mActionable = true; // assume actionable
|
||||
mCustomizedSpan = null;
|
||||
}
|
||||
|
||||
public LinkInfo(String annotation, AnnotationSpan customizedSpan) {
|
||||
mAnnotation = annotation;
|
||||
mClickListener = null;
|
||||
mActionable = customizedSpan != null;
|
||||
mCustomizedSpan = customizedSpan;
|
||||
}
|
||||
|
||||
public LinkInfo(Context context, String annotation, Intent intent) {
|
||||
mAnnotation = annotation;
|
||||
mCustomizedSpan = null;
|
||||
if (intent != null) {
|
||||
mActionable = context.getPackageManager().resolveActivity(intent, 0) != null;
|
||||
} else {
|
||||
mActionable = false;
|
||||
}
|
||||
if (mActionable) {
|
||||
mClickListener =
|
||||
view -> {
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.w(TAG, "Activity was not found for intent, " + intent);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
mClickListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActionable() {
|
||||
return mActionable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user