Overflow labels: higher contrast

Fixes: 155495912
Test: manual
Change-Id: Ie23d5918700cd51388accf9fb5236c3d8b42dd19
This commit is contained in:
Lyn Han
2020-05-06 13:37:31 -07:00
parent 98b14f98fa
commit 6e6a52dd3a
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;
@@ -241,6 +242,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(
@@ -249,6 +252,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);
}