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

Commit 1321736e authored by Paul Soulos's avatar Paul Soulos
Browse files

Adds extra padding to top entry if no title

Bug: 16679107
Change-Id: Id5bff96d419acd27b179f7f2913b08b61afe09c5
parent b6f3a94d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@
    <dimen name="expanding_entry_card_title_text_size">16sp</dimen>
    <!-- Padding for the title text for a ExpandingEntryCardView -->
    <dimen name="expanding_entry_card_title_padding">16dp</dimen>
    <!-- Extra top padding if the title is set to null -->
    <dimen name="expanding_entry_card_null_title_top_extra_padding">2dp</dimen>

    <!-- Height of the separator between entries in an ExpandingEntryCardView -->
    <dimen name="expanding_entry_card_item_separator_height">1dp</dimen>
+32 −6
Original line number Diff line number Diff line
@@ -353,6 +353,15 @@ public class ExpandingEntryCardView extends CardView {
    }

    private void addEntry(View entry) {
        // If no title and the first entry in the group, add extra padding
        if (TextUtils.isEmpty(mTitleTextView.getText()) &&
                mEntriesViewGroup.getChildCount() == 0) {
            entry.setPadding(entry.getPaddingLeft(),
                    entry.getPaddingTop() + getResources().getDimensionPixelSize(
                            R.dimen.expanding_entry_card_null_title_top_extra_padding),
                    entry.getPaddingRight(),
                    entry.getPaddingBottom());
        }
        mEntriesViewGroup.addView(entry);
    }

@@ -786,13 +795,30 @@ public class ExpandingEntryCardView extends CardView {
        if (mTitleTextView == null) {
            Log.e(TAG, "mTitleTextView is null");
        }
        if (title == null) {
            mTitleTextView.setVisibility(View.GONE);
            findViewById(R.id.title_separator).setVisibility(View.GONE);
        }
        mTitleTextView.setText(title);
        mTitleTextView.setVisibility(View.VISIBLE);
        findViewById(R.id.title_separator).setVisibility(View.VISIBLE);
        mTitleTextView.setVisibility(TextUtils.isEmpty(title) ? View.GONE : View.VISIBLE);
        findViewById(R.id.title_separator).setVisibility(TextUtils.isEmpty(title) ?
                View.GONE : View.VISIBLE);
        // If the title is set after children have been added, reset the top entry's padding to
        // the default. Else if the title is cleared after children have been added, set
        // the extra top padding
        if (!TextUtils.isEmpty(title) && mEntriesViewGroup.getChildCount() > 0) {
            View firstEntry = mEntriesViewGroup.getChildAt(0);
            firstEntry.setPadding(firstEntry.getPaddingLeft(),
                    getResources().getDimensionPixelSize(
                            R.dimen.expanding_entry_card_item_padding_top),
                    firstEntry.getPaddingRight(),
                    firstEntry.getPaddingBottom());
        } else if (!TextUtils.isEmpty(title) && mEntriesViewGroup.getChildCount() > 0) {
            View firstEntry = mEntriesViewGroup.getChildAt(0);
            firstEntry.setPadding(firstEntry.getPaddingLeft(),
                    getResources().getDimensionPixelSize(
                            R.dimen.expanding_entry_card_item_padding_top) +
                            getResources().getDimensionPixelSize(
                                    R.dimen.expanding_entry_card_null_title_top_extra_padding),
                    firstEntry.getPaddingRight(),
                    firstEntry.getPaddingBottom());
        }
    }

    public boolean shouldShow() {