Merge "Sharesheet - Edge to edge support" into qt-dev

am: 31b6820f42

Change-Id: I1f706125aa44a303f979cce07a07389d3c59054d
This commit is contained in:
Matt Pietal
2019-05-22 09:44:26 -07:00
committed by android-build-merger
5 changed files with 62 additions and 18 deletions

View File

@@ -237,7 +237,6 @@ public class ChooserActivity extends ResolverActivity {
private boolean mListViewDataChanged = false; private boolean mListViewDataChanged = false;
@Retention(SOURCE) @Retention(SOURCE)
@IntDef({CONTENT_PREVIEW_FILE, CONTENT_PREVIEW_IMAGE, CONTENT_PREVIEW_TEXT}) @IntDef({CONTENT_PREVIEW_FILE, CONTENT_PREVIEW_IMAGE, CONTENT_PREVIEW_TEXT})
private @interface ContentPreviewType { private @interface ContentPreviewType {
@@ -2036,7 +2035,8 @@ public class ChooserActivity extends ResolverActivity {
return; return;
} }
if (mChooserRowAdapter.calculateChooserTargetWidth(right - left) int availableWidth = right - left - v.getPaddingLeft() - v.getPaddingRight();
if (mChooserRowAdapter.calculateChooserTargetWidth(availableWidth)
|| mAdapterView.getAdapter() == null) { || mAdapterView.getAdapter() == null) {
mAdapterView.setAdapter(mChooserRowAdapter); mAdapterView.setAdapter(mChooserRowAdapter);
@@ -2045,7 +2045,9 @@ public class ChooserActivity extends ResolverActivity {
return; return;
} }
int offset = 0; final int bottomInset = mSystemWindowInsets != null
? mSystemWindowInsets.bottom : 0;
int offset = bottomInset;
int rowsToShow = mChooserRowAdapter.getContentPreviewRowCount() int rowsToShow = mChooserRowAdapter.getContentPreviewRowCount()
+ mChooserRowAdapter.getProfileRowCount() + mChooserRowAdapter.getProfileRowCount()
+ mChooserRowAdapter.getServiceTargetRowCount() + mChooserRowAdapter.getServiceTargetRowCount()
@@ -2060,7 +2062,7 @@ public class ChooserActivity extends ResolverActivity {
// still zero? then use a default height and leave, which // still zero? then use a default height and leave, which
// can happen when there are no targets to show // can happen when there are no targets to show
if (rowsToShow == 0) { if (rowsToShow == 0) {
offset = getResources().getDimensionPixelSize( offset += getResources().getDimensionPixelSize(
R.dimen.chooser_max_collapsed_height); R.dimen.chooser_max_collapsed_height);
mResolverDrawerLayout.setCollapsibleHeightReserved(offset); mResolverDrawerLayout.setCollapsibleHeightReserved(offset);
return; return;
@@ -2085,8 +2087,9 @@ public class ChooserActivity extends ResolverActivity {
// make sure to leave room for direct share 4->8 expansion // make sure to leave room for direct share 4->8 expansion
int requiredExpansionHeight = int requiredExpansionHeight =
(int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE); (int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE);
int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0;
int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight() int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight()
- requiredExpansionHeight; - requiredExpansionHeight - topInset - bottomInset;
offset = Math.min(offset, minHeight); offset = Math.min(offset, minHeight);
} }

View File

@@ -46,6 +46,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.ColorMatrix; import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.Insets;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
@@ -67,12 +68,15 @@ import android.util.Slog;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowInsets;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Space;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@@ -136,6 +140,9 @@ public class ResolverActivity extends Activity {
private ColorMatrixColorFilter mSuspendedMatrixColorFilter; private ColorMatrixColorFilter mSuspendedMatrixColorFilter;
protected Insets mSystemWindowInsets = null;
private Space mFooterSpacer = null;
/** See {@link #setRetainInOnStop}. */ /** See {@link #setRetainInOnStop}. */
private boolean mRetainInOnStop; private boolean mRetainInOnStop;
@@ -329,6 +336,11 @@ public class ResolverActivity extends Activity {
if (isVoiceInteraction()) { if (isVoiceInteraction()) {
rdl.setCollapsed(false); rdl.setCollapsed(false);
} }
rdl.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets);
mResolverDrawerLayout = rdl; mResolverDrawerLayout = rdl;
} }
@@ -364,10 +376,38 @@ public class ResolverActivity extends Activity {
finish(); finish();
} }
protected WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
mSystemWindowInsets = insets.getSystemWindowInsets();
mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top,
mSystemWindowInsets.right, 0);
View emptyView = findViewById(R.id.empty);
emptyView.setPadding(0, 0, 0, mSystemWindowInsets.bottom
+ getResources().getDimensionPixelSize(
R.dimen.chooser_edge_margin_normal) * 2);
if (mFooterSpacer == null) {
mFooterSpacer = new Space(getApplicationContext());
} else {
((ListView) mAdapterView).removeFooterView(mFooterSpacer);
}
mFooterSpacer.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
mSystemWindowInsets.bottom));
((ListView) mAdapterView).addFooterView(mFooterSpacer);
return insets.consumeSystemWindowInsets();
}
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
mAdapter.handlePackagesChanged(); mAdapter.handlePackagesChanged();
if (mSystemWindowInsets != null) {
mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top,
mSystemWindowInsets.right, 0);
}
} }
private void initSuspendedColorMatrix() { private void initSuspendedColorMatrix() {
@@ -1277,6 +1317,10 @@ public class ResolverActivity extends Activity {
final ViewGroup buttonLayout = findViewById(R.id.button_bar); final ViewGroup buttonLayout = findViewById(R.id.button_bar);
if (buttonLayout != null) { if (buttonLayout != null) {
buttonLayout.setVisibility(View.VISIBLE); buttonLayout.setVisibility(View.VISIBLE);
int inset = mSystemWindowInsets != null ? mSystemWindowInsets.bottom : 0;
buttonLayout.setPadding(buttonLayout.getPaddingLeft(), buttonLayout.getPaddingTop(),
buttonLayout.getPaddingRight(), buttonLayout.getPaddingBottom() + inset);
mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once); mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
mSettingsButton = (Button) buttonLayout.findViewById(R.id.button_app_settings); mSettingsButton = (Button) buttonLayout.findViewById(R.id.button_app_settings);
mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always); mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);

View File

@@ -854,12 +854,11 @@ public class ResolverDrawerLayout extends ViewGroup {
final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY); final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
final int heightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY); final int heightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
final int widthPadding = getPaddingLeft() + getPaddingRight();
// Currently we allot more height than is really needed so that the entirety of the // Currently we allot more height than is really needed so that the entirety of the
// sheet may be pulled up. // sheet may be pulled up.
// TODO: Restrict the height here to be the right value. // TODO: Restrict the height here to be the right value.
int heightUsed = getPaddingTop() + getPaddingBottom(); int heightUsed = 0;
// Measure always-show children first. // Measure always-show children first.
final int childCount = getChildCount(); final int childCount = getChildCount();
@@ -869,11 +868,11 @@ public class ResolverDrawerLayout extends ViewGroup {
if (lp.alwaysShow && child.getVisibility() != GONE) { if (lp.alwaysShow && child.getVisibility() != GONE) {
if (lp.maxHeight != -1) { if (lp.maxHeight != -1) {
final int remainingHeight = heightSize - heightUsed; final int remainingHeight = heightSize - heightUsed;
measureChildWithMargins(child, widthSpec, widthPadding, measureChildWithMargins(child, widthSpec, 0,
MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST),
lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0); lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0);
} else { } else {
measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed); measureChildWithMargins(child, widthSpec, 0, heightSpec, heightUsed);
} }
heightUsed += child.getMeasuredHeight(); heightUsed += child.getMeasuredHeight();
} }
@@ -889,11 +888,11 @@ public class ResolverDrawerLayout extends ViewGroup {
if (!lp.alwaysShow && child.getVisibility() != GONE) { if (!lp.alwaysShow && child.getVisibility() != GONE) {
if (lp.maxHeight != -1) { if (lp.maxHeight != -1) {
final int remainingHeight = heightSize - heightUsed; final int remainingHeight = heightSize - heightUsed;
measureChildWithMargins(child, widthSpec, widthPadding, measureChildWithMargins(child, widthSpec, 0,
MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST),
lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0); lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0);
} else { } else {
measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed); measureChildWithMargins(child, widthSpec, 0, heightSpec, heightUsed);
} }
heightUsed += child.getMeasuredHeight(); heightUsed += child.getMeasuredHeight();
} }

View File

@@ -88,5 +88,4 @@ easier.
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon"> <style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
<item name="windowLightNavigationBar">false</item> <item name="windowLightNavigationBar">false</item>
</style> </style>
</resources> </resources>

View File

@@ -1678,8 +1678,11 @@ easier.
<item name="colorControlActivated">?attr/colorControlHighlight</item> <item name="colorControlActivated">?attr/colorControlHighlight</item>
<item name="listPreferredItemPaddingStart">?attr/dialogPreferredPadding</item> <item name="listPreferredItemPaddingStart">?attr/dialogPreferredPadding</item>
<item name="listPreferredItemPaddingEnd">?attr/dialogPreferredPadding</item> <item name="listPreferredItemPaddingEnd">?attr/dialogPreferredPadding</item>
<item name="navigationBarColor">?attr/colorBackgroundFloating</item> <item name="navigationBarColor">@android:color/transparent</item>
<item name="navigationBarDividerColor">@color/chooser_row_divider</item> </style>
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
<item name="windowLightNavigationBar">true</item>
</style> </style>
<style name="Animation.DeviceDefault.Activity.Resolver" parent="Animation.DeviceDefault.Activity"> <style name="Animation.DeviceDefault.Activity.Resolver" parent="Animation.DeviceDefault.Activity">
@@ -1690,10 +1693,6 @@ easier.
<item name="taskOpenExitAnimation">@anim/resolver_close_anim</item> <item name="taskOpenExitAnimation">@anim/resolver_close_anim</item>
</style> </style>
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
<item name="windowLightNavigationBar">true</item>
</style>
<!-- @hide DeviceDefault themes for the autofill FillUi --> <!-- @hide DeviceDefault themes for the autofill FillUi -->
<style name="Theme.DeviceDefault.Autofill" /> <style name="Theme.DeviceDefault.Autofill" />
<style name="Theme.DeviceDefault.Light.Autofill" /> <style name="Theme.DeviceDefault.Light.Autofill" />