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

Commit 2ebbd51d authored by Joel Galenson's avatar Joel Galenson
Browse files

Separate the header description and link.

We use the text under SettingsWithLargeHeader for both text (e.g.,
permission descriptions on PermissionAppsFragment) and links (e.g.,
"See all in Dashboard" in a filtered PermissionUsageFragment).  Split
them out into two separate entries (only one of which is visible at a
time) so we can apply separate styles.

Fixes: 130182794
Test: View the above screens.
Change-Id: Ifcc553a69da9a9de73b4102b162eeb09a83d8a60
parent 3d908f2f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@

    <include layout="@layout/settings_entity_header" />

    <TextView
        android:id="@+id/header_text"
        style="@style/LargeHeaderText"/>

    <TextView
        android:id="@+id/header_link"
        android:clickable="true"
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@
            <item type="style" name="AppPermission" />

            <item type="style" name="LargeHeader" />
            <item type="style" name="LargeHeaderText" />
            <item type="style" name="LargeHeaderLink" />
            <item type="style" name="LargeHeaderDivider" />

+10 −0
Original line number Diff line number Diff line
@@ -243,6 +243,16 @@
        <item name="android:gravity">center</item>
    </style>

    <style name="LargeHeaderText">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginBottom">16dp</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:textColor">?android:attr/textColorSecondary</item>
        <item name="android:paddingStart">48dp</item>
        <item name="android:paddingEnd">48dp</item>
    </style>

    <style name="LargeHeaderLink"
           parent="@android:style/Widget.DeviceDefault.Button.Borderless.Colored">
        <item name="android:layout_width">wrap_content</item>
+9 −10
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.packageinstaller.permission.ui.handheld;

import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -121,17 +120,17 @@ public abstract class SettingsWithLargeHeader extends PermissionsFrameFragment
     * @param listener the click listener if the summary should be clickable
     */
    public void setSummary(@NonNull CharSequence summary, @Nullable View.OnClickListener listener) {
        TextView summaryView = mHeader.requireViewById(R.id.header_link);
        summaryView.setVisibility(View.VISIBLE);
        summaryView.setText(summary);
        TextView textView = mHeader.requireViewById(R.id.header_text);
        TextView linkView = mHeader.requireViewById(R.id.header_link);
        if (listener != null) {
            summaryView.setOnClickListener(listener);
            linkView.setOnClickListener(listener);
            linkView.setVisibility(View.VISIBLE);
            linkView.setText(summary);
            textView.setVisibility(View.GONE);
        } else {
            TypedArray a = getContext().obtainStyledAttributes(
                    new int[] { android.R.attr.textColorSecondary });
            int color = a.getColor(0, 0);
            a.recycle();
            summaryView.setTextColor(color);
            textView.setVisibility(View.VISIBLE);
            textView.setText(summary);
            linkView.setVisibility(View.GONE);
        }
    }
}