Sharesheet - add label loading placeholder

When loading DS targets we show an animated icon, also want to
show a label placeholder.

Fixes: 129979593
Test: manual, visual
Change-Id: I2f8fbbad552dd412fd5aed3dfad9ac2a5abed0b0
This commit is contained in:
Mike Digman
2019-04-23 14:52:45 -07:00
parent 5bcdc825ed
commit bd7e0dfc54
4 changed files with 58 additions and 0 deletions

View File

@@ -2115,6 +2115,24 @@ public class ChooserActivity extends ResolverActivity {
com.android.internal.R.layout.resolve_grid_item, parent, false);
}
@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

View File

@@ -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>

View File

@@ -735,4 +735,5 @@
<dimen name="resolver_badge_size">18dp</dimen>
<dimen name="chooser_target_width">90dp</dimen>
<dimen name="chooser_max_collapsed_height">288dp</dimen>
<dimen name="chooser_direct_share_label_placeholder_max_width">72dp</dimen>
</resources>

View File

@@ -3766,4 +3766,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>