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

Commit 5ecac7a9 authored by arangelov's avatar arangelov
Browse files

Hide "Always" and "Just once" buttons for empty state screens

This change does the following things:
- Groups the button bar and divider in a view with the system
background, so that when they get invisible, the background is not
transparent
- Sets the invisibility of the button bar and divider to invisible
so that the height of the intent resolver is preserved
- Removes the bottom padding for the empty state screen for
the intent resolver to reduce the blank space under it caused
by the now blank button bar

Fixes: 154326163
Test: manual
Change-Id: Iaea4da3f2250f51f9d1d627c1965f42014914084
parent 4ae27323
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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()));
+25 −14
Original line number Diff line number Diff line
@@ -1745,7 +1745,21 @@ public class ResolverActivity extends Activity implements
            return;
        }
        final ViewGroup buttonLayout = findViewById(R.id.button_bar);
        if (buttonLayout != null) {
        if (buttonLayout == null) {
            Log.e(TAG, "Layout unexpectedly does not have a button bar");
            return;
        }
        ResolverListAdapter activeListAdapter =
                mMultiProfilePagerAdapter.getActiveListAdapter();
        View buttonBarDivider = findViewById(R.id.resolver_button_bar_divider);
        if (activeListAdapter.isTabLoaded()
                && mMultiProfilePagerAdapter.shouldShowEmptyStateScreen(activeListAdapter)) {
            buttonLayout.setVisibility(View.INVISIBLE);
            buttonBarDivider.setVisibility(View.INVISIBLE);
            return;
        }

        buttonBarDivider.setVisibility(View.VISIBLE);
        buttonLayout.setVisibility(View.VISIBLE);

        if (!useLayoutWithDefault()) {
@@ -1758,9 +1772,6 @@ public class ResolverActivity extends Activity implements
        mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);

        resetAlwaysOrOnceButtonBar();
        } else {
            Log.e(TAG, "Layout unexpectedly does not have a button bar");
        }
    }

    private void resetAlwaysOrOnceButtonBar() {
+6 −0
Original line number Diff line number Diff line
@@ -213,6 +213,12 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
                /* subtitleRes */ 0);
    }

    @Override
    protected void setupContainerPadding(View container) {
        container.setPadding(container.getPaddingLeft(), container.getPaddingTop(),
                container.getPaddingRight(), /* bottom */ 0);
    }

    class ResolverProfileDescriptor extends ProfileDescriptor {
        private ResolverListAdapter resolverListAdapter;
        final ListView listView;
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
    android:paddingStart="24dp"
    android:paddingEnd="24dp">
    <RelativeLayout
        android:id="@+id/resolver_empty_state_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="48dp"
+50 −48
Original line number Diff line number Diff line
@@ -112,14 +112,18 @@
            </FrameLayout>
        </LinearLayout>
    </TabHost>

    <View
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alwaysShow="true"
        android:orientation="vertical"
        android:background="?attr/colorBackgroundFloating">
        <View
            android:id="@+id/resolver_button_bar_divider"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="?attr/colorBackgroundFloating"
            android:foreground="?attr/dividerVertical" />

        <LinearLayout
            android:id="@+id/button_bar"
            android:visibility="gone"
@@ -127,13 +131,11 @@
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_ignoreOffset="true"
        android:layout_alwaysShow="true"
            android:layout_hasNestedScrollIndicator="true"
            android:gravity="end|center_vertical"
            android:orientation="horizontal"
            android:layoutDirection="locale"
            android:measureWithLargestChild="true"
        android:background="?attr/colorBackgroundFloating"
            android:paddingTop="@dimen/resolver_button_bar_spacing"
            android:paddingBottom="@dimen/resolver_button_bar_spacing"
            android:paddingStart="@dimen/resolver_edge_margin"
@@ -166,5 +168,5 @@
                android:text="@string/activity_resolver_use_always"
                android:onClick="onButtonClick" />
        </LinearLayout>

    </LinearLayout>
</com.android.internal.widget.ResolverDrawerLayout>
Loading