Fix intent resolver height calculation
This CL makes the following changes: - We update ResolverViewPager to wrap around the tallest of its children. We can do that now thanks to recent changes that load the inactive tab. - Place empty state screens at the top of the tab content and update padding and text sizes - Use layout_alwaysShow=true instead of trying to calculate the proper height for the different layout cases (with/without tabs, with/without default app layout). Test: manual Bug: 149823158 Bug: 149822719 Bug: 149823253 Bug: 149817311 Bug: 148156663 Bug: 149824092 Change-Id: I81f9e8600e59b74c64584723054d309becf34f12
This commit is contained in:
@@ -396,13 +396,6 @@ public class ResolverActivity extends Activity implements
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets);
|
||||
|
||||
if (shouldShowTabs()) {
|
||||
rdl.setMaxCollapsedHeight(getResources().getDimensionPixelSize(
|
||||
R.dimen.resolver_empty_state_height_with_tabs));
|
||||
findViewById(R.id.profile_pager).setMinimumHeight(
|
||||
getResources().getDimensionPixelSize(R.dimen.resolver_empty_state_height));
|
||||
}
|
||||
|
||||
mResolverDrawerLayout = rdl;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@ package com.android.internal.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* A {@link ViewPager} which wraps around its first child's height.
|
||||
* A {@link ViewPager} which wraps around its tallest child's height.
|
||||
* <p>Normally {@link ViewPager} instances expand their height to cover all remaining space in
|
||||
* the layout.
|
||||
* <p>This class is used for the intent resolver's tabbed view.
|
||||
@@ -56,16 +55,17 @@ public class ResolverViewPager extends ViewPager {
|
||||
}
|
||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
|
||||
int height = getMeasuredHeight();
|
||||
if (getChildCount() > 0) {
|
||||
View child = getChildAt(0);
|
||||
int maxHeight = 0;
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
child.measure(widthMeasureSpec,
|
||||
MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
if (height > child.getMeasuredHeight()) {
|
||||
height = child.getMeasuredHeight();
|
||||
if (maxHeight < child.getMeasuredHeight()) {
|
||||
maxHeight = child.getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
if (height < getMinimumHeight()) {
|
||||
height = getMinimumHeight();
|
||||
if (maxHeight > 0) {
|
||||
height = maxHeight;
|
||||
}
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp">
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
<com.android.internal.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -20,34 +20,34 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/resolver_empty_state_height"
|
||||
android:orientation="vertical"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:visibility="gone"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp">
|
||||
<ImageView
|
||||
android:id="@+id/resolver_empty_state_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"/>
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"/>
|
||||
<TextView
|
||||
android:id="@+id/resolver_empty_state_title"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@string/config_headlineFontFamilyMedium"
|
||||
android:textColor="@color/resolver_empty_state_text"
|
||||
android:textSize="18sp"/>
|
||||
android:textSize="14sp"/>
|
||||
<TextView
|
||||
android:id="@+id/resolver_empty_state_subtitle"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/resolver_empty_state_text"
|
||||
android:textSize="14sp"
|
||||
android:textSize="12sp"
|
||||
android:gravity="center_horizontal" />
|
||||
<Button
|
||||
android:id="@+id/resolver_empty_state_button"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/resolver_switch_on_work"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -108,8 +108,7 @@
|
||||
<com.android.internal.app.ResolverViewPager
|
||||
android:id="@+id/profile_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/resolver_empty_state_height" />
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp">
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
<ListView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -153,12 +153,14 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/stub"
|
||||
android:layout_alwaysShow="true"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorBackgroundFloating"/>
|
||||
|
||||
<TabHost
|
||||
android:layout_alwaysShow="true"
|
||||
android:id="@+id/profile_tabhost"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -178,7 +180,6 @@
|
||||
<View
|
||||
android:id="@+id/resolver_tab_divider"
|
||||
android:visibility="gone"
|
||||
android:layout_alwaysShow="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/colorBackgroundFloating"
|
||||
@@ -190,8 +191,7 @@
|
||||
<com.android.internal.app.ResolverViewPager
|
||||
android:id="@+id/profile_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/resolver_empty_state_height" />
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
|
||||
Reference in New Issue
Block a user