mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 16:19:33 +01:00
Implement new Material3 spec.
This commit is contained in:
committed by
Greyson Parrelli
parent
556e480b06
commit
1b471e163d
@@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.messagerequests
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
||||
enum class MessageRequestBarColorTheme(
|
||||
private val containerBackgroundColor: Int,
|
||||
private val buttonBackgroundColor: Int,
|
||||
private val buttonForegroundDenyColor: Int,
|
||||
private val buttonForegroundAcceptColor: Int
|
||||
) {
|
||||
WALLPAPER(
|
||||
R.color.message_request_bar_container_background_wallpaper,
|
||||
R.color.message_request_bar_background_wallpaper,
|
||||
R.color.message_request_bar_denyForeground_wallpaper,
|
||||
R.color.message_request_bar_acceptForeground_wallpaper
|
||||
),
|
||||
NORMAL(
|
||||
R.color.message_request_bar_container_background_normal,
|
||||
R.color.message_request_bar_background_normal,
|
||||
R.color.message_request_bar_denyForeground_normal,
|
||||
R.color.message_request_bar_acceptForeground_normal
|
||||
);
|
||||
|
||||
@ColorInt
|
||||
fun getContainerButtonBackgroundColor(context: Context): Int = ContextCompat.getColor(context, containerBackgroundColor)
|
||||
|
||||
@ColorInt
|
||||
fun getButtonBackgroundColor(context: Context): Int = ContextCompat.getColor(context, buttonBackgroundColor)
|
||||
|
||||
@ColorInt
|
||||
fun getButtonForegroundDenyColor(context: Context): Int = ContextCompat.getColor(context, buttonForegroundDenyColor)
|
||||
|
||||
@ColorInt
|
||||
fun getButtonForegroundAcceptColor(context: Context): Int = ContextCompat.getColor(context, buttonForegroundAcceptColor)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun resolveTheme(hasWallpaper: Boolean): MessageRequestBarColorTheme {
|
||||
return if (hasWallpaper) WALLPAPER else NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.messagerequests;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@@ -10,6 +11,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
@@ -18,17 +21,19 @@ import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.HtmlUtil;
|
||||
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class MessageRequestsBottomView extends ConstraintLayout {
|
||||
|
||||
private final Debouncer showProgressDebouncer = new Debouncer(250);
|
||||
|
||||
private LearnMoreTextView question;
|
||||
private Button accept;
|
||||
private Button gv1Continue;
|
||||
private View block;
|
||||
private View delete;
|
||||
private View bigDelete;
|
||||
private View bigUnblock;
|
||||
private MaterialButton accept;
|
||||
private MaterialButton gv1Continue;
|
||||
private MaterialButton block;
|
||||
private MaterialButton delete;
|
||||
private MaterialButton bigDelete;
|
||||
private MaterialButton bigUnblock;
|
||||
private View busyIndicator;
|
||||
|
||||
private Group normalButtons;
|
||||
@@ -65,6 +70,8 @@ public class MessageRequestsBottomView extends ConstraintLayout {
|
||||
blockedButtons = findViewById(R.id.message_request_blocked_buttons);
|
||||
gv1MigrationButtons = findViewById(R.id.message_request_gv1_migration_buttons);
|
||||
busyIndicator = findViewById(R.id.message_request_busy_indicator);
|
||||
|
||||
setWallpaperEnabled(false);
|
||||
}
|
||||
|
||||
public void setMessageData(@NonNull MessageRequestViewModel.MessageData messageData) {
|
||||
@@ -162,6 +169,24 @@ public class MessageRequestsBottomView extends ConstraintLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void setWallpaperEnabled(boolean isEnabled) {
|
||||
MessageRequestBarColorTheme theme = MessageRequestBarColorTheme.resolveTheme(isEnabled);
|
||||
|
||||
Stream.of(delete, bigDelete, block, bigUnblock, accept, gv1Continue).forEach(button -> {
|
||||
button.setBackgroundTintList(ColorStateList.valueOf(theme.getButtonBackgroundColor(getContext())));
|
||||
});
|
||||
|
||||
Stream.of(delete, bigDelete, block).forEach(button -> {
|
||||
button.setTextColor(theme.getButtonForegroundDenyColor(getContext()));
|
||||
});
|
||||
|
||||
Stream.of(accept, bigUnblock, gv1Continue).forEach(button -> {
|
||||
button.setTextColor(theme.getButtonForegroundAcceptColor(getContext()));
|
||||
});
|
||||
|
||||
setBackgroundColor(theme.getContainerButtonBackgroundColor(getContext()));
|
||||
}
|
||||
|
||||
public void setAcceptOnClickListener(OnClickListener acceptOnClickListener) {
|
||||
accept.setOnClickListener(acceptOnClickListener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user