Merge "Sharesheet - Edge to edge support" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
31b6820f42
@@ -237,7 +237,6 @@ public class ChooserActivity extends ResolverActivity {
|
||||
|
||||
private boolean mListViewDataChanged = false;
|
||||
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({CONTENT_PREVIEW_FILE, CONTENT_PREVIEW_IMAGE, CONTENT_PREVIEW_TEXT})
|
||||
private @interface ContentPreviewType {
|
||||
@@ -2036,7 +2035,8 @@ public class ChooserActivity extends ResolverActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mChooserRowAdapter.calculateChooserTargetWidth(right - left)
|
||||
int availableWidth = right - left - v.getPaddingLeft() - v.getPaddingRight();
|
||||
if (mChooserRowAdapter.calculateChooserTargetWidth(availableWidth)
|
||||
|| mAdapterView.getAdapter() == null) {
|
||||
mAdapterView.setAdapter(mChooserRowAdapter);
|
||||
|
||||
@@ -2045,7 +2045,9 @@ public class ChooserActivity extends ResolverActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
final int bottomInset = mSystemWindowInsets != null
|
||||
? mSystemWindowInsets.bottom : 0;
|
||||
int offset = bottomInset;
|
||||
int rowsToShow = mChooserRowAdapter.getContentPreviewRowCount()
|
||||
+ mChooserRowAdapter.getProfileRowCount()
|
||||
+ mChooserRowAdapter.getServiceTargetRowCount()
|
||||
@@ -2060,7 +2062,7 @@ public class ChooserActivity extends ResolverActivity {
|
||||
// still zero? then use a default height and leave, which
|
||||
// can happen when there are no targets to show
|
||||
if (rowsToShow == 0) {
|
||||
offset = getResources().getDimensionPixelSize(
|
||||
offset += getResources().getDimensionPixelSize(
|
||||
R.dimen.chooser_max_collapsed_height);
|
||||
mResolverDrawerLayout.setCollapsibleHeightReserved(offset);
|
||||
return;
|
||||
@@ -2085,8 +2087,9 @@ public class ChooserActivity extends ResolverActivity {
|
||||
// make sure to leave room for direct share 4->8 expansion
|
||||
int requiredExpansionHeight =
|
||||
(int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE);
|
||||
int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0;
|
||||
int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight()
|
||||
- requiredExpansionHeight;
|
||||
- requiredExpansionHeight - topInset - bottomInset;
|
||||
|
||||
offset = Math.min(offset, minHeight);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
@@ -67,12 +68,15 @@ import android.util.Slog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Space;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -136,6 +140,9 @@ public class ResolverActivity extends Activity {
|
||||
|
||||
private ColorMatrixColorFilter mSuspendedMatrixColorFilter;
|
||||
|
||||
protected Insets mSystemWindowInsets = null;
|
||||
private Space mFooterSpacer = null;
|
||||
|
||||
/** See {@link #setRetainInOnStop}. */
|
||||
private boolean mRetainInOnStop;
|
||||
|
||||
@@ -329,6 +336,11 @@ public class ResolverActivity extends Activity {
|
||||
if (isVoiceInteraction()) {
|
||||
rdl.setCollapsed(false);
|
||||
}
|
||||
|
||||
rdl.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets);
|
||||
|
||||
mResolverDrawerLayout = rdl;
|
||||
}
|
||||
|
||||
@@ -364,10 +376,38 @@ public class ResolverActivity extends Activity {
|
||||
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
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mAdapter.handlePackagesChanged();
|
||||
|
||||
if (mSystemWindowInsets != null) {
|
||||
mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top,
|
||||
mSystemWindowInsets.right, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void initSuspendedColorMatrix() {
|
||||
@@ -1277,6 +1317,10 @@ public class ResolverActivity extends Activity {
|
||||
final ViewGroup buttonLayout = findViewById(R.id.button_bar);
|
||||
if (buttonLayout != null) {
|
||||
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);
|
||||
mSettingsButton = (Button) buttonLayout.findViewById(R.id.button_app_settings);
|
||||
mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
|
||||
|
||||
@@ -854,12 +854,11 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
|
||||
final int widthSpec = MeasureSpec.makeMeasureSpec(widthSize, 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
|
||||
// sheet may be pulled up.
|
||||
// TODO: Restrict the height here to be the right value.
|
||||
int heightUsed = getPaddingTop() + getPaddingBottom();
|
||||
int heightUsed = 0;
|
||||
|
||||
// Measure always-show children first.
|
||||
final int childCount = getChildCount();
|
||||
@@ -869,11 +868,11 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
if (lp.alwaysShow && child.getVisibility() != GONE) {
|
||||
if (lp.maxHeight != -1) {
|
||||
final int remainingHeight = heightSize - heightUsed;
|
||||
measureChildWithMargins(child, widthSpec, widthPadding,
|
||||
measureChildWithMargins(child, widthSpec, 0,
|
||||
MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST),
|
||||
lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0);
|
||||
} else {
|
||||
measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed);
|
||||
measureChildWithMargins(child, widthSpec, 0, heightSpec, heightUsed);
|
||||
}
|
||||
heightUsed += child.getMeasuredHeight();
|
||||
}
|
||||
@@ -889,11 +888,11 @@ public class ResolverDrawerLayout extends ViewGroup {
|
||||
if (!lp.alwaysShow && child.getVisibility() != GONE) {
|
||||
if (lp.maxHeight != -1) {
|
||||
final int remainingHeight = heightSize - heightUsed;
|
||||
measureChildWithMargins(child, widthSpec, widthPadding,
|
||||
measureChildWithMargins(child, widthSpec, 0,
|
||||
MeasureSpec.makeMeasureSpec(lp.maxHeight, MeasureSpec.AT_MOST),
|
||||
lp.maxHeight > remainingHeight ? lp.maxHeight - remainingHeight : 0);
|
||||
} else {
|
||||
measureChildWithMargins(child, widthSpec, widthPadding, heightSpec, heightUsed);
|
||||
measureChildWithMargins(child, widthSpec, 0, heightSpec, heightUsed);
|
||||
}
|
||||
heightUsed += child.getMeasuredHeight();
|
||||
}
|
||||
|
||||
@@ -88,5 +88,4 @@ easier.
|
||||
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
|
||||
<item name="windowLightNavigationBar">false</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1678,8 +1678,11 @@ easier.
|
||||
<item name="colorControlActivated">?attr/colorControlHighlight</item>
|
||||
<item name="listPreferredItemPaddingStart">?attr/dialogPreferredPadding</item>
|
||||
<item name="listPreferredItemPaddingEnd">?attr/dialogPreferredPadding</item>
|
||||
<item name="navigationBarColor">?attr/colorBackgroundFloating</item>
|
||||
<item name="navigationBarDividerColor">@color/chooser_row_divider</item>
|
||||
<item name="navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
|
||||
<item name="windowLightNavigationBar">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Animation.DeviceDefault.Activity.Resolver" parent="Animation.DeviceDefault.Activity">
|
||||
@@ -1690,10 +1693,6 @@ easier.
|
||||
<item name="taskOpenExitAnimation">@anim/resolver_close_anim</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.DeviceDefault.Resolver" parent="Theme.DeviceDefault.ResolverCommon">
|
||||
<item name="windowLightNavigationBar">true</item>
|
||||
</style>
|
||||
|
||||
<!-- @hide DeviceDefault themes for the autofill FillUi -->
|
||||
<style name="Theme.DeviceDefault.Autofill" />
|
||||
<style name="Theme.DeviceDefault.Light.Autofill" />
|
||||
|
||||
Reference in New Issue
Block a user