Update sharesheet for large devices
Switches to a wrapped sharesheet (instead of filling the screen) and 6 columns instead of 8 for large screens. Also fixes some small details with the appearance (see https://docs.google.com/presentation/d/1WDbmWx6uXaFi8jos7Sp6ZUmBh24Y5Bj5G7dW78LxE40/edit#slide=id.gb836e06a0c_0_0) Bug: 195102471 Test: manual (visual changes) Merged-In: I5d84dce0aea7657a50dc3376be9d8b5e41b907db Change-Id: I5d84dce0aea7657a50dc3376be9d8b5e41b907db
This commit is contained in:
committed by
Matt Casey
parent
e7c2ac3d12
commit
c5e145c3bf
@@ -163,9 +163,6 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
private AppPredictor mWorkAppPredictor;
|
private AppPredictor mWorkAppPredictor;
|
||||||
private boolean mShouldDisplayLandscape;
|
private boolean mShouldDisplayLandscape;
|
||||||
|
|
||||||
private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4;
|
|
||||||
private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8;
|
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public ChooserActivity() {
|
public ChooserActivity() {
|
||||||
}
|
}
|
||||||
@@ -275,6 +272,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
private int mCurrAvailableWidth = 0;
|
private int mCurrAvailableWidth = 0;
|
||||||
private int mLastNumberOfChildren = -1;
|
private int mLastNumberOfChildren = -1;
|
||||||
|
private int mMaxTargetsPerRow = 1;
|
||||||
|
|
||||||
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
|
private static final String TARGET_DETAILS_FRAGMENT_TAG = "targetDetailsFragment";
|
||||||
|
|
||||||
@@ -741,8 +739,9 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
mCallerChooserTargets = targets;
|
mCallerChooserTargets = targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
mShouldDisplayLandscape = shouldDisplayLandscape(
|
mMaxTargetsPerRow = getResources().getInteger(R.integer.config_chooser_max_targets_per_row);
|
||||||
getResources().getConfiguration().orientation);
|
mShouldDisplayLandscape =
|
||||||
|
shouldDisplayLandscape(getResources().getConfiguration().orientation);
|
||||||
setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
|
setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
|
||||||
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
|
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
|
||||||
null, false);
|
null, false);
|
||||||
@@ -916,7 +915,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
adapter,
|
adapter,
|
||||||
getPersonalProfileUserHandle(),
|
getPersonalProfileUserHandle(),
|
||||||
/* workProfileUserHandle= */ null,
|
/* workProfileUserHandle= */ null,
|
||||||
isSendAction(getTargetIntent()), getMaxTargetsPerRow());
|
isSendAction(getTargetIntent()), mMaxTargetsPerRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles(
|
private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles(
|
||||||
@@ -945,7 +944,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
selectedProfile,
|
selectedProfile,
|
||||||
getPersonalProfileUserHandle(),
|
getPersonalProfileUserHandle(),
|
||||||
getWorkProfileUserHandle(),
|
getWorkProfileUserHandle(),
|
||||||
isSendAction(getTargetIntent()), getMaxTargetsPerRow());
|
isSendAction(getTargetIntent()), mMaxTargetsPerRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findSelectedProfile() {
|
private int findSelectedProfile() {
|
||||||
@@ -1107,6 +1106,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
mShouldDisplayLandscape = shouldDisplayLandscape(newConfig.orientation);
|
mShouldDisplayLandscape = shouldDisplayLandscape(newConfig.orientation);
|
||||||
|
mMaxTargetsPerRow = getResources().getInteger(R.integer.config_chooser_max_targets_per_row);
|
||||||
adjustPreviewWidth(newConfig.orientation, null);
|
adjustPreviewWidth(newConfig.orientation, null);
|
||||||
updateStickyContentPreview();
|
updateStickyContentPreview();
|
||||||
}
|
}
|
||||||
@@ -2690,7 +2690,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
// and b/150936654
|
// and b/150936654
|
||||||
recyclerView.setAdapter(gridAdapter);
|
recyclerView.setAdapter(gridAdapter);
|
||||||
((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount(
|
((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount(
|
||||||
getMaxTargetsPerRow());
|
mMaxTargetsPerRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle();
|
UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle();
|
||||||
@@ -2855,7 +2855,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|
|
||||||
@Override // ChooserListCommunicator
|
@Override // ChooserListCommunicator
|
||||||
public int getMaxRankedTargets() {
|
public int getMaxRankedTargets() {
|
||||||
return getMaxTargetsPerRow();
|
return mMaxTargetsPerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // ChooserListCommunicator
|
@Override // ChooserListCommunicator
|
||||||
@@ -3203,13 +3203,6 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getMaxTargetsPerRow() {
|
|
||||||
int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT;
|
|
||||||
if (mShouldDisplayLandscape) {
|
|
||||||
maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
|
|
||||||
}
|
|
||||||
return maxTargets;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Adapter for all types of items and targets in ShareSheet.
|
* Adapter for all types of items and targets in ShareSheet.
|
||||||
* Note that ranked sections like Direct Share - while appearing grid-like - are handled on the
|
* Note that ranked sections like Direct Share - while appearing grid-like - are handled on the
|
||||||
@@ -3277,7 +3270,11 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int newWidth = width / getMaxTargetsPerRow();
|
// Limit width to the maximum width of the chooser activity
|
||||||
|
int maxWidth = getResources().getDimensionPixelSize(R.dimen.chooser_width);
|
||||||
|
width = Math.min(maxWidth, width);
|
||||||
|
|
||||||
|
int newWidth = width / mMaxTargetsPerRow;
|
||||||
if (newWidth != mChooserTargetWidth) {
|
if (newWidth != mChooserTargetWidth) {
|
||||||
mChooserTargetWidth = newWidth;
|
mChooserTargetWidth = newWidth;
|
||||||
return true;
|
return true;
|
||||||
@@ -3312,7 +3309,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
+ getAzLabelRowCount()
|
+ getAzLabelRowCount()
|
||||||
+ Math.ceil(
|
+ Math.ceil(
|
||||||
(float) mChooserListAdapter.getAlphaTargetCount()
|
(float) mChooserListAdapter.getAlphaTargetCount()
|
||||||
/ getMaxTargetsPerRow())
|
/ mMaxTargetsPerRow)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3352,7 +3349,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
public int getCallerAndRankedTargetRowCount() {
|
public int getCallerAndRankedTargetRowCount() {
|
||||||
return (int) Math.ceil(
|
return (int) Math.ceil(
|
||||||
((float) mChooserListAdapter.getCallerTargetCount()
|
((float) mChooserListAdapter.getCallerTargetCount()
|
||||||
+ mChooserListAdapter.getRankedTargetCount()) / getMaxTargetsPerRow());
|
+ mChooserListAdapter.getRankedTargetCount()) / mMaxTargetsPerRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There can be at most one row in the listview, that is internally
|
// There can be at most one row in the listview, that is internally
|
||||||
@@ -3551,7 +3548,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
parentGroup.addView(row2);
|
parentGroup.addView(row2);
|
||||||
|
|
||||||
mDirectShareViewHolder = new DirectShareViewHolder(parentGroup,
|
mDirectShareViewHolder = new DirectShareViewHolder(parentGroup,
|
||||||
Lists.newArrayList(row1, row2), getMaxTargetsPerRow(), viewType);
|
Lists.newArrayList(row1, row2), mMaxTargetsPerRow, viewType);
|
||||||
loadViewsIntoGroup(mDirectShareViewHolder);
|
loadViewsIntoGroup(mDirectShareViewHolder);
|
||||||
|
|
||||||
return mDirectShareViewHolder;
|
return mDirectShareViewHolder;
|
||||||
@@ -3559,7 +3556,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
ViewGroup row = (ViewGroup) mLayoutInflater.inflate(R.layout.chooser_row, parent,
|
ViewGroup row = (ViewGroup) mLayoutInflater.inflate(R.layout.chooser_row, parent,
|
||||||
false);
|
false);
|
||||||
ItemGroupViewHolder holder =
|
ItemGroupViewHolder holder =
|
||||||
new SingleRowViewHolder(row, getMaxTargetsPerRow(), viewType);
|
new SingleRowViewHolder(row, mMaxTargetsPerRow, viewType);
|
||||||
loadViewsIntoGroup(holder);
|
loadViewsIntoGroup(holder);
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
@@ -3651,7 +3648,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
|
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
|
||||||
final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets());
|
final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets());
|
||||||
if (position < serviceRows) {
|
if (position < serviceRows) {
|
||||||
return position * getMaxTargetsPerRow();
|
return position * mMaxTargetsPerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
position -= serviceRows;
|
position -= serviceRows;
|
||||||
@@ -3660,7 +3657,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
+ mChooserListAdapter.getRankedTargetCount();
|
+ mChooserListAdapter.getRankedTargetCount();
|
||||||
final int callerAndRankedRows = getCallerAndRankedTargetRowCount();
|
final int callerAndRankedRows = getCallerAndRankedTargetRowCount();
|
||||||
if (position < callerAndRankedRows) {
|
if (position < callerAndRankedRows) {
|
||||||
return serviceCount + position * getMaxTargetsPerRow();
|
return serviceCount + position * mMaxTargetsPerRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
position -= getAzLabelRowCount() + callerAndRankedRows;
|
position -= getAzLabelRowCount() + callerAndRankedRows;
|
||||||
@@ -3673,7 +3670,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
if (mDirectShareViewHolder != null && canExpandDirectShare) {
|
if (mDirectShareViewHolder != null && canExpandDirectShare) {
|
||||||
mDirectShareViewHolder.handleScroll(
|
mDirectShareViewHolder.handleScroll(
|
||||||
mChooserMultiProfilePagerAdapter.getActiveAdapterView(), y, oldy,
|
mChooserMultiProfilePagerAdapter.getActiveAdapterView(), y, oldy,
|
||||||
getMaxTargetsPerRow());
|
mMaxTargetsPerRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,10 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:maxCollapsedHeight="0dp"
|
android:maxCollapsedHeight="0dp"
|
||||||
android:maxCollapsedHeightSmall="56dp"
|
android:maxCollapsedHeightSmall="56dp"
|
||||||
|
android:maxWidth="@dimen/chooser_width"
|
||||||
android:id="@id/contentPanel">
|
android:id="@id/contentPanel">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<view class="com.android.internal.app.ChooserActivity$RoundedRectImageView"
|
<view class="com.android.internal.app.ChooserActivity$RoundedRectImageView"
|
||||||
android:id="@+id/content_preview_image_1_large"
|
android:id="@+id/content_preview_image_1_large"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="104dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
android:id="@+id/content_preview_image_2_large"
|
android:id="@+id/content_preview_image_2_large"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="120dp"
|
android:layout_width="120dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="104dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_toRightOf="@id/content_preview_image_1_large"
|
android:layout_toRightOf="@id/content_preview_image_1_large"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
|
|||||||
@@ -56,5 +56,7 @@
|
|||||||
to be aligned to one side of the screen when in landscape mode. -->
|
to be aligned to one side of the screen when in landscape mode. -->
|
||||||
<bool name="config_enableDynamicKeyguardPositioning">true</bool>
|
<bool name="config_enableDynamicKeyguardPositioning">true</bool>
|
||||||
|
|
||||||
|
<integer name="config_chooser_max_targets_per_row">6</integer>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|||||||
@@ -110,4 +110,7 @@
|
|||||||
<dimen name="immersive_mode_cling_width">380dp</dimen>
|
<dimen name="immersive_mode_cling_width">380dp</dimen>
|
||||||
|
|
||||||
<dimen name="floating_toolbar_preferred_width">544dp</dimen>
|
<dimen name="floating_toolbar_preferred_width">544dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="chooser_width">624dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -5290,6 +5290,8 @@
|
|||||||
M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM14,6h-4L10,4h4v2z
|
M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM14,6h-4L10,4h4v2z
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<integer name="config_chooser_max_targets_per_row">4</integer>
|
||||||
|
|
||||||
<!-- Whether this device should support taking app snapshots on closure -->
|
<!-- Whether this device should support taking app snapshots on closure -->
|
||||||
<bool name="config_disableTaskSnapshots">false</bool>
|
<bool name="config_disableTaskSnapshots">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -900,7 +900,8 @@
|
|||||||
<dimen name="seekbar_thumb_exclusion_max_size">48dp</dimen>
|
<dimen name="seekbar_thumb_exclusion_max_size">48dp</dimen>
|
||||||
|
|
||||||
<!-- chooser/resolver (sharesheet) spacing -->
|
<!-- chooser/resolver (sharesheet) spacing -->
|
||||||
<dimen name="chooser_corner_radius">16dp</dimen>
|
<dimen name="chooser_width">412dp</dimen>
|
||||||
|
<dimen name="chooser_corner_radius">28dp</dimen>
|
||||||
<dimen name="chooser_row_text_option_translate">25dp</dimen>
|
<dimen name="chooser_row_text_option_translate">25dp</dimen>
|
||||||
<dimen name="chooser_view_spacing">18dp</dimen>
|
<dimen name="chooser_view_spacing">18dp</dimen>
|
||||||
<dimen name="chooser_edge_margin_thin">16dp</dimen>
|
<dimen name="chooser_edge_margin_thin">16dp</dimen>
|
||||||
@@ -917,7 +918,7 @@
|
|||||||
<dimen name="resolver_icon_size">32dp</dimen>
|
<dimen name="resolver_icon_size">32dp</dimen>
|
||||||
<dimen name="resolver_button_bar_spacing">0dp</dimen>
|
<dimen name="resolver_button_bar_spacing">0dp</dimen>
|
||||||
<dimen name="resolver_badge_size">18dp</dimen>
|
<dimen name="resolver_badge_size">18dp</dimen>
|
||||||
<dimen name="resolver_icon_margin">16dp</dimen>
|
<dimen name="resolver_icon_margin">8dp</dimen>
|
||||||
<dimen name="resolver_small_margin">18dp</dimen>
|
<dimen name="resolver_small_margin">18dp</dimen>
|
||||||
<dimen name="resolver_edge_margin">24dp</dimen>
|
<dimen name="resolver_edge_margin">24dp</dimen>
|
||||||
<dimen name="resolver_elevation">1dp</dimen>
|
<dimen name="resolver_elevation">1dp</dimen>
|
||||||
|
|||||||
@@ -275,6 +275,7 @@
|
|||||||
<java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
|
<java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
|
||||||
<java-symbol type="bool" name="config_avoidGfxAccel" />
|
<java-symbol type="bool" name="config_avoidGfxAccel" />
|
||||||
<java-symbol type="bool" name="config_bluetooth_address_validation" />
|
<java-symbol type="bool" name="config_bluetooth_address_validation" />
|
||||||
|
<java-symbol type="integer" name="config_chooser_max_targets_per_row" />
|
||||||
<java-symbol type="bool" name="config_flipToScreenOffEnabled" />
|
<java-symbol type="bool" name="config_flipToScreenOffEnabled" />
|
||||||
<java-symbol type="integer" name="config_flipToScreenOffMaxLatencyMicros" />
|
<java-symbol type="integer" name="config_flipToScreenOffMaxLatencyMicros" />
|
||||||
<java-symbol type="bool" name="config_bluetooth_sco_off_call" />
|
<java-symbol type="bool" name="config_bluetooth_sco_off_call" />
|
||||||
@@ -2844,6 +2845,7 @@
|
|||||||
<java-symbol type="layout" name="date_picker_month_item_material" />
|
<java-symbol type="layout" name="date_picker_month_item_material" />
|
||||||
<java-symbol type="id" name="month_view" />
|
<java-symbol type="id" name="month_view" />
|
||||||
<java-symbol type="integer" name="config_zen_repeat_callers_threshold" />
|
<java-symbol type="integer" name="config_zen_repeat_callers_threshold" />
|
||||||
|
<java-symbol type="dimen" name="chooser_width" />
|
||||||
<java-symbol type="dimen" name="chooser_corner_radius" />
|
<java-symbol type="dimen" name="chooser_corner_radius" />
|
||||||
<java-symbol type="string" name="chooser_no_direct_share_targets" />
|
<java-symbol type="string" name="chooser_no_direct_share_targets" />
|
||||||
<java-symbol type="drawable" name="chooser_row_layer_list" />
|
<java-symbol type="drawable" name="chooser_row_layer_list" />
|
||||||
|
|||||||
Reference in New Issue
Block a user