Merge "AllSet page fixes" into sc-dev
This commit is contained in:
commit
50f43df36e
|
@ -124,6 +124,8 @@
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:permission="android.permission.REBOOT"
|
android:permission="android.permission.REBOOT"
|
||||||
|
android:theme="@style/AllSetTheme"
|
||||||
|
android:label="@string/allset_title"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.android.quickstep.action.GESTURE_ONBOARDING_ALL_SET"/>
|
<action android:name="com.android.quickstep.action.GESTURE_ONBOARDING_ALL_SET"/>
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
android:paddingStart="@dimen/allset_page_margin_horizontal"
|
android:paddingStart="@dimen/allset_page_margin_horizontal"
|
||||||
android:paddingEnd="@dimen/allset_page_margin_horizontal"
|
android:paddingEnd="@dimen/allset_page_margin_horizontal"
|
||||||
android:layoutDirection="locale"
|
android:layoutDirection="locale"
|
||||||
android:textDirection="locale"
|
android:textDirection="locale">
|
||||||
android:background="?android:attr/colorBackground">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -59,13 +58,15 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/navigation_settings"
|
android:id="@+id/navigation_settings"
|
||||||
style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle"
|
style="@style/TextAppearance.GestureTutorial.LinkText"
|
||||||
android:textSize="14sp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_above="@+id/hint"
|
android:layout_above="@+id/hint"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center"
|
||||||
android:layout_marginBottom="72dp"/>
|
android:layout_marginBottom="72dp"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:text="@string/allset_navigation_settings" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@id/hint"
|
android:id="@id/hint"
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?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>
|
||||||
|
|
||||||
|
<style name="AllSetTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
|
||||||
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:enforceNavigationBarContrast">false</item>
|
||||||
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
|
<item name="android:windowBackground">#FF000000</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -110,6 +110,14 @@
|
||||||
<item name="android:textSize">14sp</item>
|
<item name="android:textSize">14sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AllSetTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||||
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:enforceNavigationBarContrast">false</item>
|
||||||
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
|
<item name="android:windowBackground">#FFFFFFFF</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Can be applied to views to color things like ripples and list highlights the workspace text
|
Can be applied to views to color things like ripples and list highlights the workspace text
|
||||||
color.
|
color.
|
||||||
|
|
|
@ -16,23 +16,22 @@
|
||||||
package com.android.quickstep.interaction;
|
package com.android.quickstep.interaction;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextPaint;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.AccessibilityDelegate;
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
|
import com.android.launcher3.Utilities;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
@ -48,86 +47,56 @@ public class AllSetActivity extends Activity {
|
||||||
private static final String EXTRA_ACCENT_COLOR_DARK_MODE = "suwColorAccentDark";
|
private static final String EXTRA_ACCENT_COLOR_DARK_MODE = "suwColorAccentDark";
|
||||||
private static final String EXTRA_ACCENT_COLOR_LIGHT_MODE = "suwColorAccentLight";
|
private static final String EXTRA_ACCENT_COLOR_LIGHT_MODE = "suwColorAccentLight";
|
||||||
|
|
||||||
private int mAccentColor;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_allset);
|
setContentView(R.layout.activity_allset);
|
||||||
setTitle(R.string.allset_title);
|
|
||||||
|
|
||||||
final int mode =
|
int mode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||||
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
boolean isDarkTheme = mode == Configuration.UI_MODE_NIGHT_YES;
|
||||||
mAccentColor = getIntent().getIntExtra(
|
int accentColor = getIntent().getIntExtra(
|
||||||
mode == Configuration.UI_MODE_NIGHT_YES
|
isDarkTheme ? EXTRA_ACCENT_COLOR_DARK_MODE : EXTRA_ACCENT_COLOR_LIGHT_MODE,
|
||||||
? EXTRA_ACCENT_COLOR_DARK_MODE : EXTRA_ACCENT_COLOR_LIGHT_MODE,
|
isDarkTheme ? Color.WHITE : Color.BLACK);
|
||||||
/* defValue= */ Color.BLACK);
|
|
||||||
|
|
||||||
((ImageView) findViewById(R.id.icon)).getDrawable().mutate().setTint(mAccentColor);
|
((ImageView) findViewById(R.id.icon)).getDrawable().mutate().setTint(accentColor);
|
||||||
|
|
||||||
TextView navigationSettings = findViewById(R.id.navigation_settings);
|
TextView tv = findViewById(R.id.navigation_settings);
|
||||||
navigationSettings.setMovementMethod(LinkMovementMethod.getInstance());
|
tv.setTextColor(accentColor);
|
||||||
AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
|
tv.setOnClickListener(v -> {
|
||||||
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION,
|
try {
|
||||||
new AllSetLinkSpan(
|
startActivityForResult(
|
||||||
/* context= */ this,
|
Intent.parseUri(URI_SYSTEM_NAVIGATION_SETTING, 0), 0);
|
||||||
view -> {
|
} catch (URISyntaxException e) {
|
||||||
try {
|
Log.e(LOG_TAG, "Failed to parse system nav settings intent", e);
|
||||||
startActivityForResult(
|
}
|
||||||
Intent.parseUri(URI_SYSTEM_NAVIGATION_SETTING, 0), 0);
|
finish();
|
||||||
} catch (URISyntaxException e) {
|
});
|
||||||
Log.e(LOG_TAG, "Failed to parse system nav settings intent", e);
|
|
||||||
}
|
findViewById(R.id.hint).setAccessibilityDelegate(new SkipButtonAccessibilityDelegate());
|
||||||
finish();
|
|
||||||
}));
|
|
||||||
navigationSettings.setText(
|
|
||||||
AnnotationSpan.linkify(getText(R.string.allset_navigation_settings), linkInfo));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
* Accessibility delegate which exposes a click event without making the view
|
||||||
super.onWindowFocusChanged(hasFocus);
|
* clickable in touch mode
|
||||||
if (hasFocus) {
|
*/
|
||||||
hideSystemUI();
|
private class SkipButtonAccessibilityDelegate extends AccessibilityDelegate {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideSystemUI() {
|
@Override
|
||||||
getWindow().getDecorView().setSystemUiVisibility(
|
public AccessibilityNodeInfo createAccessibilityNodeInfo(View host) {
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
AccessibilityNodeInfo info = super.createAccessibilityNodeInfo(host);
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
info.addAction(AccessibilityAction.ACTION_CLICK);
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
info.setClickable(true);
|
||||||
| View.SYSTEM_UI_FLAG_FULLSCREEN);
|
return info;
|
||||||
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
|
@Override
|
||||||
public void updateDrawState(TextPaint ds) {
|
public boolean performAccessibilityAction(View host, int action, Bundle args) {
|
||||||
super.updateDrawState(ds);
|
if (action == AccessibilityAction.ACTION_CLICK.getId()) {
|
||||||
ds.setColor(mAccentColor);
|
startActivity(Utilities.createHomeIntent());
|
||||||
ds.setTypeface(Typeface.create(mFontFamily, Typeface.NORMAL));
|
finish();
|
||||||
ds.setUnderlineText(false);
|
return true;
|
||||||
if (mTextSize != -1) {
|
|
||||||
ds.setTextSize(mTextSize);
|
|
||||||
}
|
}
|
||||||
|
return super.performAccessibilityAction(host, action, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue