Merge "Overflow labels: higher contrast" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-05-14 00:07:53 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 3 deletions

View File

@@ -30,9 +30,8 @@
<TextView
android:id="@+id/bubble_view_name"
android:fontFamily="@*android:string/config_bodyFontFamily"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textSize="13sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"

View File

@@ -41,6 +41,7 @@ import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import java.util.ArrayList;
@@ -214,6 +215,8 @@ class BubbleOverflowAdapter extends RecyclerView.Adapter<BubbleOverflowAdapter.V
@Override
public BubbleOverflowAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// Set layout for overflow bubble view.
LinearLayout overflowView = (LinearLayout) LayoutInflater.from(parent.getContext())
.inflate(R.layout.bubble_overflow_view, parent, false);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
@@ -222,6 +225,18 @@ class BubbleOverflowAdapter extends RecyclerView.Adapter<BubbleOverflowAdapter.V
params.width = mWidth;
params.height = mHeight;
overflowView.setLayoutParams(params);
// Ensure name has enough contrast.
final TypedArray ta = mContext.obtainStyledAttributes(
new int[]{android.R.attr.colorBackgroundFloating, android.R.attr.textColorPrimary});
final int bgColor = ta.getColor(0, Color.WHITE);
int textColor = ta.getColor(1, Color.BLACK);
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
ta.recycle();
TextView viewName = overflowView.findViewById(R.id.bubble_view_name);
viewName.setTextColor(textColor);
return new ViewHolder(overflowView);
}