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

Commit ab8467e8 authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where not all views are getting disabled alpha applied." into tm-dev

parents 65c610c2 f7a95e4b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@

<selector xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
    <item android:state_enabled="false" android:color="?androidprv:attr/colorSurface"
          android:alpha="?android:attr/disabledAlpha"/>
    <item android:state_selected="true" android:color="?androidprv:attr/colorAccentPrimary"/>
    <item android:color="?androidprv:attr/colorSurface"/>
</selector>
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@

<selector xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
    <item android:state_enabled="false" android:color="?android:attr/textColorPrimary"
          android:alpha="?android:attr/disabledAlpha"/>
    <item android:state_selected="true" android:color="?androidprv:attr/textColorOnAccent"/>
    <item android:color="?android:attr/textColorPrimary"/>
</selector>
 No newline at end of file
+4 −9
Original line number Diff line number Diff line
@@ -50,14 +50,13 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
     * View holder for each {@link IDreamItem}.
     */
    private class DreamViewHolder extends RecyclerView.ViewHolder {
        private static final int VALUE_ENABLED_ALPHA = 255;
        private final TextView mTitleView;
        private final TextView mSummaryView;
        private final ImageView mPreviewView;
        private final ImageView mPreviewPlaceholderView;
        private final Button mCustomizeButton;
        private final Context mContext;
        private final int mDisabledAlphaValue;
        private final float mDisabledAlphaValue;

        DreamViewHolder(View view, Context context) {
            super(view);
@@ -67,7 +66,7 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            mTitleView = view.findViewById(R.id.title_text);
            mSummaryView = view.findViewById(R.id.summary_text);
            mCustomizeButton = view.findViewById(R.id.customize_button);
            mDisabledAlphaValue = (int) (ColorUtil.getDisabledAlpha(context) * VALUE_ENABLED_ALPHA);
            mDisabledAlphaValue = ColorUtil.getDisabledAlpha(context);
        }

        /**
@@ -93,7 +92,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                mPreviewView.setImageDrawable(null);
                mPreviewPlaceholderView.setVisibility(View.VISIBLE);
            }
            mPreviewView.setImageAlpha(getAlpha());

            final Drawable icon = item.isActive()
                    ? mContext.getDrawable(R.drawable.ic_dream_check_circle)
@@ -105,7 +103,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            final int iconSize = mContext.getResources().getDimensionPixelSize(
                    R.dimen.dream_item_icon_size);
            icon.setBounds(0, 0, iconSize, iconSize);
            icon.setAlpha(getAlpha());
            mTitleView.setCompoundDrawablesRelative(icon, null, null, null);

            if (item.isActive()) {
@@ -130,10 +127,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            setEnabledStateOnViews(itemView, mEnabled);
        }

        private int getAlpha() {
            return mEnabled ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue;
        }

        /**
         * Makes sure the view (and any children) get the enabled state changed.
         */
@@ -145,6 +138,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                for (int i = vg.getChildCount() - 1; i >= 0; i--) {
                    setEnabledStateOnViews(vg.getChildAt(i), enabled);
                }
            } else {
                v.setAlpha(enabled ? 1 : mDisabledAlphaValue);
            }
        }
    }