Merge "P2P App Sharing: Gray out disabled SystemShortcut"
diff --git a/go/quickstep/res/values/strings.xml b/go/quickstep/res/values/strings.xml
index 8429f6a..42f4702 100644
--- a/go/quickstep/res/values/strings.xml
+++ b/go/quickstep/res/values/strings.xml
@@ -41,4 +41,8 @@
<string name="tooltip_listen">Tap here to listen to text on this screen</string>
<!-- Tooltip to highlight and explain the Translate button -->
<string name="tooltip_translate">Tap here to translate text on this screen</string>
+
+ <!-- ******* Toast Messages ******* -->
+ <!-- Toast to indicate that an app cannot be shared -->
+ <string name="toast_p2p_app_not_shareable">This app can’t be shared</string>
</resources>
diff --git a/go/quickstep/src/com/android/launcher3/AppSharing.java b/go/quickstep/src/com/android/launcher3/AppSharing.java
index fd5456c..7c66f6e 100644
--- a/go/quickstep/src/com/android/launcher3/AppSharing.java
+++ b/go/quickstep/src/com/android/launcher3/AppSharing.java
@@ -25,6 +25,7 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
+import android.widget.Toast;
import androidx.core.content.FileProvider;
@@ -53,7 +54,7 @@
* With this flag enabled, the Share App button will be dynamically enabled/disabled based
* on each app's shareability status.
*/
- public static final boolean ENABLE_SHAREABILITY_CHECK = false;
+ public static final boolean ENABLE_SHAREABILITY_CHECK = true;
private static final String TAG = "AppSharing";
private static final String FILE_PROVIDER_SUFFIX = ".overview.fileprovider";
@@ -111,6 +112,11 @@
@Override
public void onClick(View view) {
+ if (!isEnabled()) {
+ showCannotShareToast(view.getContext());
+ return;
+ }
+
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
@@ -163,6 +169,12 @@
mShareabilityMgr.requestAppStatusUpdate(packageName, this::onStatusUpdated);
}
}
+
+ private void showCannotShareToast(Context context) {
+ CharSequence text = context.getText(R.string.toast_p2p_app_not_shareable);
+ int duration = Toast.LENGTH_SHORT;
+ Toast.makeText(context, text, duration).show();
+ }
}
/**
diff --git a/res/color/system_shortcut_text.xml b/res/color/system_shortcut_text.xml
new file mode 100644
index 0000000..f9f8239
--- /dev/null
+++ b/res/color/system_shortcut_text.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="?android:attr/textColorTertiary" android:state_enabled="false"/>
+ <item android:color="?android:attr/textColorPrimary"/>
+</selector>
\ No newline at end of file
diff --git a/res/layout/system_shortcut_content.xml b/res/layout/system_shortcut_content.xml
index e693dbd..ddcef09 100644
--- a/res/layout/system_shortcut_content.xml
+++ b/res/layout/system_shortcut_content.xml
@@ -33,7 +33,7 @@
android:maxLines="2"
android:ellipsize="end"
android:hyphenationFrequency="full"
- android:textColor="?android:attr/textColorPrimary"
+ android:textColor="@color/system_shortcut_text"
launcher:iconDisplay="shortcut_popup"
launcher:layoutHorizontal="true"
android:focusable="false" />
@@ -44,5 +44,5 @@
android:layout_height="@dimen/system_shortcut_icon_size"
android:layout_marginStart="@dimen/system_shortcut_margin_start"
android:layout_gravity="start|center_vertical"
- android:backgroundTint="?android:attr/textColorPrimary"/>
+ android:backgroundTint="@color/system_shortcut_text"/>
</merge>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 35c257f..413882e 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -148,6 +148,8 @@
@ViewDebug.ExportedProperty(category = "launcher")
private int mTextColor;
@ViewDebug.ExportedProperty(category = "launcher")
+ private ColorStateList mTextColorStateList;
+ @ViewDebug.ExportedProperty(category = "launcher")
private float mTextAlpha = 1;
@ViewDebug.ExportedProperty(category = "launcher")
@@ -617,12 +619,14 @@
@Override
public void setTextColor(int color) {
mTextColor = color;
+ mTextColorStateList = null;
super.setTextColor(getModifiedColor());
}
@Override
public void setTextColor(ColorStateList colors) {
mTextColor = colors.getDefaultColor();
+ mTextColorStateList = colors;
if (Float.compare(mTextAlpha, 1) == 0) {
super.setTextColor(colors);
} else {
@@ -644,7 +648,11 @@
private void setTextAlpha(float alpha) {
mTextAlpha = alpha;
- super.setTextColor(getModifiedColor());
+ if (mTextColorStateList != null) {
+ setTextColor(mTextColorStateList);
+ } else {
+ super.setTextColor(getModifiedColor());
+ }
}
private int getModifiedColor() {
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index cfde143..278f57d 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -364,11 +364,6 @@
}
private void initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) {
- if (!info.isEnabled()) {
- // If the shortcut is disabled, do not display it
- return;
- }
-
View view = inflateAndAdd(
resId, container, getInsertIndexForSystemShortcut(container, info));
if (view instanceof DeepShortcutView) {
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 826c79b..5ebbc67 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -77,12 +77,15 @@
public void setIconAndLabelFor(View iconView, TextView labelView) {
iconView.setBackgroundResource(mIconResId);
+ iconView.setEnabled(isEnabled);
labelView.setText(mLabelResId);
+ labelView.setEnabled(isEnabled);
}
public void setIconAndContentDescriptionFor(ImageView view) {
view.setImageResource(mIconResId);
view.setContentDescription(view.getContext().getText(mLabelResId));
+ view.setEnabled(isEnabled);
}
public AccessibilityNodeInfo.AccessibilityAction createAccessibilityAction(Context context) {