Add transparency to the compose bar when wallpaper is present.

fork-5.53.8
Greyson Parrelli 2021-02-05 16:18:21 -05:00 zatwierdzone przez GitHub
rodzic 133a7d2576
commit 8f86de1764
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
13 zmienionych plików z 140 dodań i 6 usunięć

Wyświetl plik

@ -74,6 +74,7 @@ public class InputPanel extends LinearLayout
private View buttonToggle; private View buttonToggle;
private View recordingContainer; private View recordingContainer;
private View recordLockCancel; private View recordLockCancel;
private View composeContainer;
private MicrophoneRecorderView microphoneRecorderView; private MicrophoneRecorderView microphoneRecorderView;
private SlideToCancel slideToCancel; private SlideToCancel slideToCancel;
@ -103,6 +104,7 @@ public class InputPanel extends LinearLayout
View quoteDismiss = findViewById(R.id.quote_dismiss); View quoteDismiss = findViewById(R.id.quote_dismiss);
this.composeContainer = findViewById(R.id.compose_bubble);
this.stickerSuggestion = findViewById(R.id.input_panel_sticker_suggestion); this.stickerSuggestion = findViewById(R.id.input_panel_sticker_suggestion);
this.quoteView = findViewById(R.id.quote_view); this.quoteView = findViewById(R.id.quote_view);
this.linkPreview = findViewById(R.id.link_preview); this.linkPreview = findViewById(R.id.link_preview);
@ -286,6 +288,16 @@ public class InputPanel extends LinearLayout
return mediaKeyboard; return mediaKeyboard;
} }
public void setWallpaperEnabled(boolean enabled) {
if (enabled) {
setBackgroundColor(getContext().getResources().getColor(R.color.wallpaper_compose_background));
composeContainer.setBackgroundResource(R.drawable.compose_background_wallpaper);
} else {
setBackgroundColor(getResources().getColor(R.color.signal_background_primary));
composeContainer.setBackgroundResource(R.drawable.compose_background);
}
}
@Override @Override
public void onRecordPermissionRequired() { public void onRecordPermissionRequired() {
if (listener != null) listener.onRecorderPermissionRequired(); if (listener != null) listener.onRecorderPermissionRequired();

Wyświetl plik

@ -6,6 +6,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
@ -23,6 +24,7 @@ import java.util.List;
public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.InputView { public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.InputView {
private View container;
private AttachmentKeyboardMediaAdapter mediaAdapter; private AttachmentKeyboardMediaAdapter mediaAdapter;
private AttachmentKeyboardButtonAdapter buttonAdapter; private AttachmentKeyboardButtonAdapter buttonAdapter;
private Callback callback; private Callback callback;
@ -44,8 +46,9 @@ public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.
private void init(@NonNull Context context) { private void init(@NonNull Context context) {
inflate(context, R.layout.attachment_keyboard, this); inflate(context, R.layout.attachment_keyboard, this);
this.mediaList = findViewById(R.id.attachment_keyboard_media_list ); this.container = findViewById(R.id.attachment_keyboard_container);
this.permissionText = findViewById(R.id.attachment_keyboard_permission_text ); this.mediaList = findViewById(R.id.attachment_keyboard_media_list);
this.permissionText = findViewById(R.id.attachment_keyboard_permission_text);
this.permissionButton = findViewById(R.id.attachment_keyboard_permission_button); this.permissionButton = findViewById(R.id.attachment_keyboard_permission_button);
RecyclerView buttonList = findViewById(R.id.attachment_keyboard_button_list); RecyclerView buttonList = findViewById(R.id.attachment_keyboard_button_list);
@ -98,6 +101,16 @@ public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.
} }
} }
public void setWallpaperEnabled(boolean wallpaperEnabled) {
if (wallpaperEnabled) {
container.setBackgroundColor(getContext().getResources().getColor(R.color.wallpaper_compose_background));
} else {
container.setBackgroundColor(getContext().getResources().getColor(R.color.signal_background_primary));
}
buttonAdapter.setWallpaperEnabled(wallpaperEnabled);
}
@Override @Override
public void show(int height, boolean immediate) { public void show(int height, boolean immediate) {
ViewGroup.LayoutParams params = getLayoutParams(); ViewGroup.LayoutParams params = getLayoutParams();

Wyświetl plik

@ -19,6 +19,8 @@ class AttachmentKeyboardButtonAdapter extends RecyclerView.Adapter<AttachmentKey
private final List<AttachmentKeyboardButton> buttons; private final List<AttachmentKeyboardButton> buttons;
private final Listener listener; private final Listener listener;
private boolean wallpaperEnabled;
AttachmentKeyboardButtonAdapter(@NonNull Listener listener) { AttachmentKeyboardButtonAdapter(@NonNull Listener listener) {
this.buttons = new ArrayList<>(); this.buttons = new ArrayList<>();
this.listener = listener; this.listener = listener;
@ -39,7 +41,7 @@ class AttachmentKeyboardButtonAdapter extends RecyclerView.Adapter<AttachmentKey
@Override @Override
public void onBindViewHolder(@NonNull ButtonViewHolder holder, int position) { public void onBindViewHolder(@NonNull ButtonViewHolder holder, int position) {
holder.bind(buttons.get(position), listener); holder.bind(buttons.get(position), wallpaperEnabled, listener);
} }
@Override @Override
@ -52,13 +54,19 @@ class AttachmentKeyboardButtonAdapter extends RecyclerView.Adapter<AttachmentKey
return buttons.size(); return buttons.size();
} }
public void setButtons(@NonNull List<AttachmentKeyboardButton> buttons) { public void setButtons(@NonNull List<AttachmentKeyboardButton> buttons) {
this.buttons.clear(); this.buttons.clear();
this.buttons.addAll(buttons); this.buttons.addAll(buttons);
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setWallpaperEnabled(boolean enabled) {
if (wallpaperEnabled != enabled) {
wallpaperEnabled = enabled;
notifyDataSetChanged();
}
}
interface Listener { interface Listener {
void onClick(@NonNull AttachmentKeyboardButton button); void onClick(@NonNull AttachmentKeyboardButton button);
} }
@ -75,11 +83,17 @@ class AttachmentKeyboardButtonAdapter extends RecyclerView.Adapter<AttachmentKey
this.title = itemView.findViewById(R.id.attachment_button_title); this.title = itemView.findViewById(R.id.attachment_button_title);
} }
void bind(@NonNull AttachmentKeyboardButton button, @NonNull Listener listener) { void bind(@NonNull AttachmentKeyboardButton button,boolean wallpaperEnabled, @NonNull Listener listener) {
image.setImageResource(button.getIconRes()); image.setImageResource(button.getIconRes());
title.setText(button.getTitleRes()); title.setText(button.getTitleRes());
itemView.setOnClickListener(v -> listener.onClick(button)); itemView.setOnClickListener(v -> listener.onClick(button));
if (wallpaperEnabled) {
itemView.setBackgroundResource(R.drawable.attachment_keyboard_button_wallpaper_background);
} else {
itemView.setBackgroundResource(R.drawable.attachment_keyboard_button_background);
}
} }
void recycle() { void recycle() {

Wyświetl plik

@ -1403,6 +1403,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
} else { } else {
viewModel.getRecentMedia().observe(this, media -> attachmentKeyboardStub.get().onMediaChanged(media)); viewModel.getRecentMedia().observe(this, media -> attachmentKeyboardStub.get().onMediaChanged(media));
attachmentKeyboardStub.get().setCallback(this); attachmentKeyboardStub.get().setCallback(this);
attachmentKeyboardStub.get().setWallpaperEnabled(recipient.get().hasWallpaper());
container.show(composeText, attachmentKeyboardStub.get()); container.show(composeText, attachmentKeyboardStub.get());
viewModel.onAttachmentKeyboardOpen(); viewModel.onAttachmentKeyboardOpen();
@ -1996,9 +1997,17 @@ public class ConversationActivity extends PassphraseRequiredActivity
if (chatWallpaper != null) { if (chatWallpaper != null) {
chatWallpaper.loadInto(wallpaper); chatWallpaper.loadInto(wallpaper);
ChatWallpaperDimLevelUtil.applyDimLevelForNightMode(wallpaperDim, chatWallpaper); ChatWallpaperDimLevelUtil.applyDimLevelForNightMode(wallpaperDim, chatWallpaper);
inputPanel.setWallpaperEnabled(true);
if (attachmentKeyboardStub.resolved()) {
attachmentKeyboardStub.get().setWallpaperEnabled(true);
}
} else { } else {
wallpaper.setImageDrawable(null); wallpaper.setImageDrawable(null);
wallpaperDim.setVisibility(View.GONE); wallpaperDim.setVisibility(View.GONE);
inputPanel.setWallpaperEnabled(false);
if (attachmentKeyboardStub.resolved()) {
attachmentKeyboardStub.get().setWallpaperEnabled(false);
}
} }
fragment.onWallpaperChanged(chatWallpaper); fragment.onWallpaperChanged(chatWallpaper);
} }
@ -2503,7 +2512,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
if (supportActionBar == null) throw new AssertionError(); if (supportActionBar == null) throw new AssertionError();
int actionBarColor = color.toActionBarColor(this); int actionBarColor = color.toActionBarColor(this);
supportActionBar.setBackgroundDrawable(new ColorDrawable(actionBarColor)); supportActionBar.setBackgroundDrawable(new ColorDrawable(actionBarColor));
WindowUtil.setStatusBarColor(getWindow(), color.toStatusBarColor(this)); WindowUtil.setStatusBarColor(getWindow(), actionBarColor);
joinGroupCallButton.setTextColor(actionBarColor); joinGroupCallButton.setTextColor(actionBarColor);
joinGroupCallButton.setIconTint(ColorStateList.valueOf(actionBarColor)); joinGroupCallButton.setIconTint(ColorStateList.valueOf(actionBarColor));

Wyświetl plik

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/transparent_white_20">
<item android:id="@+id/mask">
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/transparent_black" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<corners android:radius="4dp" />
<solid android:color="@color/core_grey_95"/>
</shape>
</item>
</ripple>

Wyświetl plik

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners android:radius="4dp" />
<solid android:color="@color/core_grey_95"/>
</shape>

Wyświetl plik

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/core_grey_75" />
<solid
android:color="@color/conversation_item_wallpaper_bubble_color" />
<corners
android:radius="20dp" />
</shape>

Wyświetl plik

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/transparent_black_10">
<item android:id="@+id/mask">
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/transparent_black" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<corners android:radius="4dp" />
<solid android:color="@color/core_white"/>
</shape>
</item>
</ripple>

Wyświetl plik

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners android:radius="4dp" />
<solid android:color="@color/core_white"/>
</shape>

Wyświetl plik

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/core_grey_05" />
<solid
android:color="@color/conversation_item_wallpaper_bubble_color" />
<corners
android:radius="20dp" />
</shape>

Wyświetl plik

@ -7,6 +7,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/attachment_keyboard_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/signal_background_primary" android:background="@color/signal_background_primary"
@ -29,6 +30,7 @@
android:id="@+id/attachment_keyboard_button_list" android:id="@+id/attachment_keyboard_button_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
android:layout_marginBottom="8dp"
android:paddingStart="8dp" android:paddingStart="8dp"
android:clipToPadding="false" android:clipToPadding="false"
android:clipChildren="false" android:clipChildren="false"

Wyświetl plik

@ -120,4 +120,6 @@
<color name="tooltip_default_color">@color/core_grey_75</color> <color name="tooltip_default_color">@color/core_grey_75</color>
<color name="wallpaper_preview_background">@color/transparent_black_60</color> <color name="wallpaper_preview_background">@color/transparent_black_60</color>
<color name="wallpaper_compose_background">@color/transparent_black_80</color>
<color name="wallpaper_toolbar_background">@color/core_black</color>
</resources> </resources>

Wyświetl plik

@ -120,4 +120,6 @@
<color name="tooltip_default_color">@color/core_white</color> <color name="tooltip_default_color">@color/core_white</color>
<color name="wallpaper_preview_background">@color/transparent_white_30</color> <color name="wallpaper_preview_background">@color/transparent_white_30</color>
<color name="wallpaper_compose_background">@color/transparent_white_80</color>
<color name="wallpaper_toolbar_background">@color/core_white</color>
</resources> </resources>