Merge "Fix intent resolver height calculation" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-02 19:06:26 +00:00
committed by Android (Google) Code Review
7 changed files with 25 additions and 31 deletions

View File

@@ -396,13 +396,6 @@ public class ResolverActivity extends Activity implements
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE); | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets); 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; mResolverDrawerLayout = rdl;
} }

View File

@@ -18,13 +18,12 @@ package com.android.internal.app;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import com.android.internal.widget.ViewPager; 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 * <p>Normally {@link ViewPager} instances expand their height to cover all remaining space in
* the layout. * the layout.
* <p>This class is used for the intent resolver's tabbed view. * <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); widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
int height = getMeasuredHeight(); int height = getMeasuredHeight();
if (getChildCount() > 0) { int maxHeight = 0;
View child = getChildAt(0); for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, child.measure(widthMeasureSpec,
MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
if (height > child.getMeasuredHeight()) { if (maxHeight < child.getMeasuredHeight()) {
height = child.getMeasuredHeight(); maxHeight = child.getMeasuredHeight();
} }
} }
if (height < getMinimumHeight()) { if (maxHeight > 0) {
height = getMinimumHeight(); height = maxHeight;
} }
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);

View File

@@ -17,7 +17,8 @@
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_marginTop="8dp"> android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.android.internal.widget.RecyclerView <com.android.internal.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@@ -20,34 +20,34 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/resolver_empty_state_height" android:layout_height="@dimen/resolver_empty_state_height"
android:orientation="vertical" android:orientation="vertical"
android:layout_centerInParent="true" android:gravity="center_horizontal"
android:gravity="center"
android:visibility="gone" android:visibility="gone"
android:paddingStart="24dp" android:paddingStart="24dp"
android:paddingEnd="24dp"> android:paddingEnd="24dp">
<ImageView <ImageView
android:id="@+id/resolver_empty_state_icon" android:id="@+id/resolver_empty_state_icon"
android:layout_width="32dp" android:layout_marginTop="48dp"
android:layout_height="32dp"/> android:layout_width="24dp"
android:layout_height="24dp"/>
<TextView <TextView
android:id="@+id/resolver_empty_state_title" android:id="@+id/resolver_empty_state_title"
android:layout_marginTop="16dp" android:layout_marginTop="8dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="@string/config_headlineFontFamilyMedium" android:fontFamily="@string/config_headlineFontFamilyMedium"
android:textColor="@color/resolver_empty_state_text" android:textColor="@color/resolver_empty_state_text"
android:textSize="18sp"/> android:textSize="14sp"/>
<TextView <TextView
android:id="@+id/resolver_empty_state_subtitle" android:id="@+id/resolver_empty_state_subtitle"
android:layout_marginTop="8dp" android:layout_marginTop="4dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/resolver_empty_state_text" android:textColor="@color/resolver_empty_state_text"
android:textSize="14sp" android:textSize="12sp"
android:gravity="center_horizontal" /> android:gravity="center_horizontal" />
<Button <Button
android:id="@+id/resolver_empty_state_button" android:id="@+id/resolver_empty_state_button"
android:layout_marginTop="24dp" android:layout_marginTop="16dp"
android:text="@string/resolver_switch_on_work" android:text="@string/resolver_switch_on_work"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -108,8 +108,7 @@
<com.android.internal.app.ResolverViewPager <com.android.internal.app.ResolverViewPager
android:id="@+id/profile_pager" android:id="@+id/profile_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:minHeight="@dimen/resolver_empty_state_height" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</TabHost> </TabHost>

View File

@@ -18,7 +18,8 @@
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_marginTop="8dp"> android:paddingTop="8dp"
android:paddingBottom="8dp">
<ListView <ListView
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"

View File

@@ -153,12 +153,14 @@
<FrameLayout <FrameLayout
android:id="@+id/stub" android:id="@+id/stub"
android:layout_alwaysShow="true"
android:visibility="gone" android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorBackgroundFloating"/> android:background="?attr/colorBackgroundFloating"/>
<TabHost <TabHost
android:layout_alwaysShow="true"
android:id="@+id/profile_tabhost" android:id="@+id/profile_tabhost"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -178,7 +180,6 @@
<View <View
android:id="@+id/resolver_tab_divider" android:id="@+id/resolver_tab_divider"
android:visibility="gone" android:visibility="gone"
android:layout_alwaysShow="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/colorBackgroundFloating" android:background="?attr/colorBackgroundFloating"
@@ -190,8 +191,7 @@
<com.android.internal.app.ResolverViewPager <com.android.internal.app.ResolverViewPager
android:id="@+id/profile_pager" android:id="@+id/profile_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:minHeight="@dimen/resolver_empty_state_height" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</TabHost> </TabHost>