Merge "Keep the intent resolver button bar stuck to the bottom." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1ef9f259c4
@@ -437,6 +437,9 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
|
||||
resetViewVisibilitiesForWorkProfileEmptyState(emptyStateView);
|
||||
emptyStateView.setVisibility(View.VISIBLE);
|
||||
|
||||
View container = emptyStateView.findViewById(R.id.resolver_empty_state_container);
|
||||
setupContainerPadding(container);
|
||||
|
||||
TextView title = emptyStateView.findViewById(R.id.resolver_empty_state_title);
|
||||
title.setText(titleRes);
|
||||
|
||||
@@ -463,6 +466,12 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
|
||||
activeListAdapter.markTabLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the padding of the view containing the empty state screens.
|
||||
* <p>This method is meant to be overridden so that subclasses can customize the padding.
|
||||
*/
|
||||
protected void setupContainerPadding(View container) {}
|
||||
|
||||
private void showConsumerUserNoAppsAvailableEmptyState(ResolverListAdapter activeListAdapter) {
|
||||
ProfileDescriptor descriptor = getItem(
|
||||
userHandleToPageIndex(activeListAdapter.getUserHandle()));
|
||||
@@ -555,12 +564,6 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback called when the button layout has been hidden.
|
||||
* <p>This method is meant to be overridden by subclasses.
|
||||
*/
|
||||
protected void onButtonLayoutHidden() { }
|
||||
|
||||
public interface OnProfileSelectedListener {
|
||||
/**
|
||||
* Callback for when the user changes the active tab from personal to work or vice versa.
|
||||
|
||||
@@ -1030,6 +1030,10 @@ public class ResolverActivity extends Activity implements
|
||||
if (isAutolaunching()) {
|
||||
return;
|
||||
}
|
||||
if (isIntentPicker()) {
|
||||
((ResolverMultiProfilePagerAdapter) mMultiProfilePagerAdapter)
|
||||
.setUseLayoutWithDefault(useLayoutWithDefault());
|
||||
}
|
||||
if (mMultiProfilePagerAdapter.shouldShowEmptyStateScreen(listAdapter)) {
|
||||
mMultiProfilePagerAdapter.showEmptyResolverListEmptyState(listAdapter);
|
||||
} else {
|
||||
@@ -1782,13 +1786,14 @@ public class ResolverActivity extends Activity implements
|
||||
if (buttonBarDivider != null) {
|
||||
buttonBarDivider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mMultiProfilePagerAdapter.onButtonLayoutHidden();
|
||||
setButtonBarIgnoreOffset(/* ignoreOffset */ false);
|
||||
return;
|
||||
}
|
||||
if (buttonBarDivider != null) {
|
||||
buttonBarDivider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
buttonLayout.setVisibility(View.VISIBLE);
|
||||
setButtonBarIgnoreOffset(/* ignoreOffset */ true);
|
||||
|
||||
if (!useLayoutWithDefault()) {
|
||||
int inset = mSystemWindowInsets != null ? mSystemWindowInsets.bottom : 0;
|
||||
@@ -1802,6 +1807,21 @@ public class ResolverActivity extends Activity implements
|
||||
resetAlwaysOrOnceButtonBar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the button bar container {@code ignoreOffset} layout param.
|
||||
* <p>Setting this to {@code true} means that the button bar will be glued to the bottom of
|
||||
* the screen.
|
||||
*/
|
||||
private void setButtonBarIgnoreOffset(boolean ignoreOffset) {
|
||||
View buttonBarContainer = findViewById(R.id.button_bar_container);
|
||||
if (buttonBarContainer != null) {
|
||||
ResolverDrawerLayout.LayoutParams layoutParams =
|
||||
(ResolverDrawerLayout.LayoutParams) buttonBarContainer.getLayoutParams();
|
||||
layoutParams.ignoreOffset = ignoreOffset;
|
||||
buttonBarContainer.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAlwaysOrOnceButtonBar() {
|
||||
// Disable both buttons initially
|
||||
setAlwaysButtonEnabled(false, ListView.INVALID_POSITION, false);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
|
||||
|
||||
private final ResolverProfileDescriptor[] mItems;
|
||||
private final boolean mShouldShowNoCrossProfileIntentsEmptyState;
|
||||
private boolean mUseLayoutWithDefault;
|
||||
|
||||
ResolverMultiProfilePagerAdapter(Context context,
|
||||
ResolverListAdapter adapter,
|
||||
@@ -213,13 +214,15 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
|
||||
/* subtitleRes */ 0);
|
||||
}
|
||||
|
||||
void setUseLayoutWithDefault(boolean useLayoutWithDefault) {
|
||||
mUseLayoutWithDefault = useLayoutWithDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onButtonLayoutHidden() {
|
||||
View emptyStateContainer = getItem(getCurrentPage()).getEmptyStateView()
|
||||
.findViewById(R.id.resolver_empty_state_container);
|
||||
emptyStateContainer.setPadding(emptyStateContainer.getPaddingLeft(),
|
||||
emptyStateContainer.getPaddingTop(), emptyStateContainer.getPaddingRight(),
|
||||
/* bottom */ 0);
|
||||
protected void setupContainerPadding(View container) {
|
||||
int bottom = mUseLayoutWithDefault ? container.getPaddingBottom() : 0;
|
||||
container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
|
||||
container.getPaddingRight(), bottom);
|
||||
}
|
||||
|
||||
class ResolverProfileDescriptor extends ProfileDescriptor {
|
||||
|
||||
@@ -113,11 +113,13 @@
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<LinearLayout
|
||||
android:id="@+id/button_bar_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alwaysShow="true"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/colorBackgroundFloating">
|
||||
android:background="?attr/colorBackgroundFloating"
|
||||
android:layout_ignoreOffset="true">
|
||||
<View
|
||||
android:id="@+id/resolver_button_bar_divider"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -3940,6 +3940,7 @@
|
||||
<java-symbol type="id" name="resolver_tab_divider" />
|
||||
<java-symbol type="id" name="resolver_button_bar_divider" />
|
||||
<java-symbol type="id" name="resolver_empty_state_container" />
|
||||
<java-symbol type="id" name="button_bar_container" />
|
||||
<java-symbol type="string" name="resolver_cant_share_with_work_apps" />
|
||||
<java-symbol type="string" name="resolver_cant_share_with_work_apps_explanation" />
|
||||
<java-symbol type="string" name="resolver_cant_share_with_personal_apps" />
|
||||
|
||||
Reference in New Issue
Block a user