Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b052cfaf authored by tmfang's avatar tmfang
Browse files

Fix janky on permission bar chart

In old design, the height of bar view is wrap_content.
So, it may have additional space after we normalized the
height for each bar view.
As a result, the button moves down when permission chart
gets filled.

For now, we fix the height which is max normalized height
for bar view. So, it won't have additional space while widget
is rendering the chart.

Test: See bar chart in privacy settings and permission dashboard.
Fixes: 123539793
Change-Id: Idb2619e21606248079715e055cb26ff366c71ad3
parent b953577b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -25,8 +25,7 @@
    <View
        android:id="@+id/bar_view"
        android:layout_width="8dp"
        android:layout_height="wrap_content"
        android:background="?android:attr/colorAccent"/>
        android:layout_height="wrap_content"/>

    <ImageView
        android:id="@+id/icon_view"
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
<resources>
    <style name="BarViewStyle">
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_height">226dp</item>
        <item name="android:layout_weight">1</item>
        <item name="android:layout_marginStart">8dp</item>
        <item name="android:layout_marginEnd">8dp</item>
+3 −0
Original line number Diff line number Diff line
@@ -160,8 +160,11 @@ public class BarChartPreference extends Preference {

        // If the state is loading, we just show a blank view.
        if (mIsLoading) {
            holder.itemView.setVisibility(View.INVISIBLE);
            return;
        }
        holder.itemView.setVisibility(View.VISIBLE);

        // We must show title of bar chart.
        bindChartTitleView(holder);

+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public class BarView extends LinearLayout {
    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.settings_bar_view, this);
        setOrientation(LinearLayout.VERTICAL);
        setGravity(Gravity.CENTER);
        setGravity(Gravity.CENTER | Gravity.BOTTOM);

        mBarView = findViewById(R.id.bar_view);
        mIcon = findViewById(R.id.icon_view);
+3 −3
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public class BarChartPreferenceTest {
    }

    @Test
    public void onBindViewHolder_loadingStateIsTrue_shouldNotInitAnyView() {
    public void onBindViewHolder_loadingStateIsTrue_shouldHideAllViews() {
        final BarViewInfo viewInfo = new BarViewInfo(mIcon, 30 /* barNumber */, R.string.debug_app);
        viewInfo.setClickListener(v -> {
        });
@@ -317,8 +317,7 @@ public class BarChartPreferenceTest {

        mPreference.onBindViewHolder(mHolder);

        assertThat(TextUtils.isEmpty(mTitleView.getText())).isTrue();
        assertThat(TextUtils.isEmpty(mDetailsView.getText())).isTrue();
        assertThat(mHolder.itemView.getVisibility()).isEqualTo(View.INVISIBLE);
    }

    @Test
@@ -334,6 +333,7 @@ public class BarChartPreferenceTest {

        mPreference.onBindViewHolder(mHolder);

        assertThat(mHolder.itemView.getVisibility()).isEqualTo(View.VISIBLE);
        assertThat(TextUtils.isEmpty(mTitleView.getText())).isFalse();
        assertThat(TextUtils.isEmpty(mDetailsView.getText())).isFalse();
    }