Skip to content

Commit

Permalink
Tint pending group invites menu icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal authored and greyson-signal committed Jul 21, 2020
1 parent 8e962bf commit 4e55d2d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.thoughtcrime.securesms.groups.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -12,9 +15,13 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;

import org.thoughtcrime.securesms.R;

import java.util.Objects;

public final class PopupMenuView extends View {

@MenuRes private int menu;
Expand All @@ -23,22 +30,34 @@ public final class PopupMenuView extends View {

public PopupMenuView(Context context) {
super(context);
init();
init(null);
}

public PopupMenuView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
init(attrs);
}

public PopupMenuView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
init(attrs);
}

private void init() {
private void init(@Nullable AttributeSet attrs) {
setBackgroundResource(R.drawable.ic_more_vert_24);

if (attrs != null) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.PopupMenuView, 0, 0);
int tint = typedArray.getColor(R.styleable.PopupMenuView_background_tint, Color.BLACK);
Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_more_vert_24);

DrawableCompat.setTint(Objects.requireNonNull(drawable), tint);

setBackground(drawable);

typedArray.recycle();
}

setOnClickListener(v -> {
if (callback != null) {
PopupMenu popup = new PopupMenu(getContext(), v);
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/layout/group_recipient_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars"/>
tools:src="@tools:sample/avatars" />

<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/recipient_selected"
android:background="?attr/contact_selection_checkbox_background"
android:button="@null"
android:layout_width="22dp"
android:layout_height="22dp"
android:focusable="false"
android:background="?attr/contact_selection_checkbox_background"
android:button="@null"
android:clickable="false"
android:focusable="false"
app:layout_constraintBottom_toBottomOf="@+id/recipient_avatar"
app:layout_constraintEnd_toEndOf="@+id/recipient_avatar"
tools:checked="true"/>
tools:checked="true" />

<TextView
android:id="@+id/recipient_name"
Expand Down Expand Up @@ -80,6 +80,7 @@
android:layout_height="24dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
app:background_tint="?title_text_color_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@
<attr name="selectable" format="boolean" />
</declare-styleable>

<declare-styleable name="PopupMenuView">
<attr name="background_tint" format="color" />
</declare-styleable>

<declare-styleable name="WebRtcAudioOutputToggleButtonState">
<attr name="state_speaker_on" format="boolean" />
<attr name="state_speaker_off" format="boolean" />
Expand Down

0 comments on commit 4e55d2d

Please sign in to comment.