Merge "Sharesheet - add label loading placeholder" into qt-dev
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 5930f8f..7c4a171 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -2137,6 +2137,24 @@
         }
 
         @Override
+        protected void onBindView(View view, TargetInfo info) {
+            super.onBindView(view, info);
+
+            // If target is loading, show a special placeholder shape in the label
+            final ViewHolder holder = (ViewHolder) view.getTag();
+            if (info instanceof PlaceHolderTargetInfo) {
+                final int maxWidth = getResources().getDimensionPixelSize(
+                        R.dimen.chooser_direct_share_label_placeholder_max_width);
+                holder.text.setMaxWidth(maxWidth);
+                holder.text.setBackground(getResources().getDrawable(
+                        R.drawable.chooser_direct_share_label_placeholder, getTheme()));
+            } else {
+                holder.text.setMaxWidth(Integer.MAX_VALUE);
+                holder.text.setBackground(null);
+            }
+        }
+
+        @Override
         public void onListRebuilt() {
             // don't support direct share on low ram devices
             if (ActivityManager.isLowRamDeviceStatic()) {
diff --git a/core/res/res/drawable/chooser_direct_share_label_placeholder.xml b/core/res/res/drawable/chooser_direct_share_label_placeholder.xml
new file mode 100644
index 0000000..b21444b
--- /dev/null
+++ b/core/res/res/drawable/chooser_direct_share_label_placeholder.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2019 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
+  -->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!-- This drawable is intended to be used as the background of a two line TextView. We only
+         want the height to be ~1 line. Do this cheaply by applying padding to the bottom. -->
+    <item android:bottom="18dp">
+        <shape android:shape="rectangle" >
+
+            <!-- Size used for scaling should the container be different dimensions -->
+            <size android:width="@dimen/chooser_direct_share_label_placeholder_max_width"
+                  android:height="18dp"/>
+
+            <!-- Absurd corner radius to ensure pill shape -->
+            <corners android:bottomLeftRadius="100dp"
+                     android:bottomRightRadius="100dp"
+                     android:topLeftRadius="100dp"
+                     android:topRightRadius="100dp" />
+
+            <solid android:color="@color/chooser_gradient_background "/>
+        </shape>
+    </item>
+</layer-list>
\ No newline at end of file
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index f2ac755..167e672 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -731,4 +731,5 @@
     <dimen name="chooser_target_width">90dp</dimen>
     <dimen name="chooser_header_scroll_elevation">4dp</dimen>
     <dimen name="chooser_max_collapsed_height">288dp</dimen>
+    <dimen name="chooser_direct_share_label_placeholder_max_width">72dp</dimen>
 </resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 61e57e2..7cf03fea 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3769,4 +3769,6 @@
   <java-symbol type="drawable" name="chooser_direct_share_icon_placeholder" />
   <java-symbol type="color" name="chooser_gradient_background" />
   <java-symbol type="color" name="chooser_gradient_highlight" />
+  <java-symbol type="drawable" name="chooser_direct_share_label_placeholder" />
+  <java-symbol type="dimen" name="chooser_direct_share_label_placeholder_max_width" />
 </resources>