kopia lustrzana https://github.com/ryukoposting/Signal-Android
Various wallpaper UX fixes.
rodzic
e1c6311a18
commit
e460973957
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.thoughtcrime.securesms.conversation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -23,11 +25,13 @@ import android.widget.FrameLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
|
@ -43,6 +47,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||
import org.thoughtcrime.securesms.util.CachedInflater;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
@ -302,7 +307,9 @@ public class ConversationAdapter
|
|||
|
||||
@Override
|
||||
public void onBindHeaderViewHolder(StickyHeaderViewHolder viewHolder, int position, int type) {
|
||||
Context context = viewHolder.itemView.getContext();
|
||||
ConversationMessage conversationMessage = Objects.requireNonNull(getItem(position));
|
||||
|
||||
viewHolder.setText(DateUtils.getRelativeDate(viewHolder.itemView.getContext(), locale, conversationMessage.getMessageRecord().getDateReceived()));
|
||||
|
||||
if (type == HEADER_TYPE_POPOVER_DATE) {
|
||||
|
@ -318,6 +325,12 @@ public class ConversationAdapter
|
|||
viewHolder.clearBackground();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasWallpaper && ThemeUtil.isDarkTheme(context)) {
|
||||
viewHolder.setTextColor(ContextCompat.getColor(context, R.color.core_grey_15));
|
||||
} else {
|
||||
viewHolder.setTextColor(ContextCompat.getColor(context, R.color.signal_text_secondary));
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ConversationMessage getItem(int position) {
|
||||
|
@ -451,12 +464,16 @@ public class ConversationAdapter
|
|||
|
||||
/**
|
||||
* Lets the adapter know that the wallpaper state has changed.
|
||||
* @return True if the internal wallpaper state changed, otherwise false.
|
||||
*/
|
||||
void onHasWallpaperChanged(boolean hasWallpaper) {
|
||||
boolean onHasWallpaperChanged(boolean hasWallpaper) {
|
||||
if (this.hasWallpaper != hasWallpaper) {
|
||||
Log.d(TAG, "Resetting adapter due to wallpaper change.");
|
||||
this.hasWallpaper = hasWallpaper;
|
||||
notifyDataSetChanged();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -603,6 +620,10 @@ public class ConversationAdapter
|
|||
textView.setText(text);
|
||||
}
|
||||
|
||||
public void setTextColor(@ColorInt int color) {
|
||||
textView.setTextColor(color);
|
||||
}
|
||||
|
||||
public void setBackgroundRes(@DrawableRes int resId) {
|
||||
textView.setBackgroundResource(resId);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import android.widget.RelativeLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DimenRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -185,6 +186,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
private @Nullable EventListener eventListener;
|
||||
|
||||
private int defaultBubbleColor;
|
||||
private int defaultBubbleColorForWallpaper;
|
||||
private int measureCalls;
|
||||
|
||||
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
||||
|
@ -276,7 +278,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
|
||||
setGutterSizes(messageRecord, groupThread);
|
||||
setMessageShape(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
|
||||
setMediaAttributes(messageRecord, previousMessageRecord, nextMessageRecord, conversationRecipient, groupThread);
|
||||
setMediaAttributes(messageRecord, previousMessageRecord, nextMessageRecord, conversationRecipient, groupThread, hasWallpaper);
|
||||
setBodyText(messageRecord, searchQuery);
|
||||
setBubbleState(messageRecord, hasWallpaper);
|
||||
setInteractionState(conversationMessage, pulse);
|
||||
|
@ -390,7 +392,12 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
}
|
||||
|
||||
private void initializeAttributes() {
|
||||
defaultBubbleColor = ContextCompat.getColor(context, R.color.signal_background_secondary);
|
||||
defaultBubbleColor = ContextCompat.getColor(context, R.color.signal_background_secondary);
|
||||
defaultBubbleColorForWallpaper = ContextCompat.getColor(context, R.color.conversation_item_wallpaper_bubble_color);
|
||||
}
|
||||
|
||||
private @ColorInt int getDefaultBubbleColor(boolean hasWallpaper) {
|
||||
return hasWallpaper ? defaultBubbleColorForWallpaper : defaultBubbleColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -412,7 +419,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
|
||||
private void setBubbleState(MessageRecord messageRecord, boolean hasWallpaper) {
|
||||
if (messageRecord.isOutgoing() && !messageRecord.isRemoteDelete()) {
|
||||
bodyBubble.getBackground().setColorFilter(defaultBubbleColor, PorterDuff.Mode.MULTIPLY);
|
||||
bodyBubble.getBackground().setColorFilter(getDefaultBubbleColor(hasWallpaper), PorterDuff.Mode.MULTIPLY);
|
||||
footer.setTextColor(ContextCompat.getColor(context, R.color.signal_text_secondary));
|
||||
footer.setIconColor(ContextCompat.getColor(context, R.color.signal_icon_tint_secondary));
|
||||
footer.setOnlyShowSendingStatus(false, messageRecord);
|
||||
|
@ -659,7 +666,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
@NonNull Optional<MessageRecord> previousRecord,
|
||||
@NonNull Optional<MessageRecord> nextRecord,
|
||||
@NonNull Recipient conversationRecipient,
|
||||
boolean isGroupThread)
|
||||
boolean isGroupThread,
|
||||
boolean hasWallpaper)
|
||||
{
|
||||
boolean showControls = !messageRecord.isFailed();
|
||||
|
||||
|
@ -834,7 +842,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
mediaThumbnailStub.get().setOnLongClickListener(passthroughClickListener);
|
||||
mediaThumbnailStub.get().setOnClickListener(passthroughClickListener);
|
||||
mediaThumbnailStub.get().showShade(TextUtils.isEmpty(messageRecord.getDisplayBody(getContext())) && !hasExtraText(messageRecord));
|
||||
mediaThumbnailStub.get().setConversationColor(messageRecord.isOutgoing() ? defaultBubbleColor
|
||||
mediaThumbnailStub.get().setConversationColor(messageRecord.isOutgoing() ? getDefaultBubbleColor(hasWallpaper)
|
||||
: messageRecord.getRecipient().getColor().toConversationColor(context));
|
||||
mediaThumbnailStub.get().setBorderless(false);
|
||||
|
||||
|
@ -1106,7 +1114,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
|
||||
if (hasWallpaper && hasNoBubble((messageRecord))) {
|
||||
if (messageRecord.isOutgoing()) {
|
||||
activeFooter.enableBubbleBackground(R.drawable.wallpaper_bubble_background_tintable_11, defaultBubbleColor);
|
||||
activeFooter.enableBubbleBackground(R.drawable.wallpaper_bubble_background_tintable_11, getDefaultBubbleColor(hasWallpaper));
|
||||
} else {
|
||||
activeFooter.enableBubbleBackground(R.drawable.wallpaper_bubble_background_tintable_11, messageRecord.getRecipient().getColor().toConversationColor(context));
|
||||
activeFooter.setTextColor(ContextCompat.getColor(context, R.color.conversation_item_received_text_secondary_color));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.thoughtcrime.securesms.conversation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.util.AttributeSet;
|
||||
|
@ -15,6 +16,8 @@ import androidx.lifecycle.LifecycleOwner;
|
|||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.BindableConversationItem;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
@ -29,6 +32,7 @@ import org.thoughtcrime.securesms.recipients.LiveRecipient;
|
|||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
|
||||
|
@ -49,7 +53,7 @@ public final class ConversationUpdateItem extends FrameLayout
|
|||
private Set<ConversationMessage> batchSelected;
|
||||
|
||||
private TextView body;
|
||||
private TextView actionButton;
|
||||
private MaterialButton actionButton;
|
||||
private View background;
|
||||
private ConversationMessage conversationMessage;
|
||||
private Recipient conversationRecipient;
|
||||
|
@ -135,8 +139,21 @@ public final class ConversationUpdateItem extends FrameLayout
|
|||
background.setBackground(null);
|
||||
}
|
||||
|
||||
int textColor = ContextCompat.getColor(getContext(), R.color.conversation_item_update_text_color);
|
||||
if (ThemeUtil.isDarkTheme(getContext()) && hasWallpaper) {
|
||||
textColor = ContextCompat.getColor(getContext(), R.color.core_grey_15);
|
||||
}
|
||||
|
||||
if (!ThemeUtil.isDarkTheme(getContext())) {
|
||||
if (hasWallpaper) {
|
||||
actionButton.setStrokeColor(ColorStateList.valueOf(getResources().getColor(R.color.core_grey_45)));
|
||||
} else {
|
||||
actionButton.setStrokeColor(ColorStateList.valueOf(getResources().getColor(R.color.signal_button_secondary_stroke)));
|
||||
}
|
||||
}
|
||||
|
||||
UpdateDescription updateDescription = Objects.requireNonNull(messageRecord.getUpdateDisplayBody(getContext()));
|
||||
LiveData<Spannable> liveUpdateMessage = LiveUpdateMessage.fromMessageDescription(getContext(), updateDescription, ContextCompat.getColor(getContext(), R.color.conversation_item_update_text_color));
|
||||
LiveData<Spannable> liveUpdateMessage = LiveUpdateMessage.fromMessageDescription(getContext(), updateDescription, textColor);
|
||||
LiveData<Spannable> spannableMessage = loading(liveUpdateMessage);
|
||||
|
||||
observeDisplayBody(lifecycleOwner, spannableMessage);
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -23,10 +24,10 @@ import org.thoughtcrime.securesms.util.ThemeUtil;
|
|||
|
||||
public class ChatWallpaperFragment extends Fragment {
|
||||
|
||||
private boolean isSettingDimFromViewModel;
|
||||
private View clearWallpaper;
|
||||
private View resetAllWallpaper;
|
||||
private View divider;
|
||||
private boolean isSettingDimFromViewModel;
|
||||
private TextView clearWallpaper;
|
||||
private View resetAllWallpaper;
|
||||
private View divider;
|
||||
|
||||
@Override
|
||||
public @NonNull View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -69,8 +70,9 @@ public class ChatWallpaperFragment extends Fragment {
|
|||
|
||||
viewModel.getEnableWallpaperControls().observe(getViewLifecycleOwner(), enableWallpaperControls -> {
|
||||
dimInNightMode.setEnabled(enableWallpaperControls);
|
||||
clearWallpaper.setVisibility(enableWallpaperControls ? View.VISIBLE : View.GONE);
|
||||
updateDividerVisibility();
|
||||
dimInNightMode.setAlpha(enableWallpaperControls ? 1 : 0.5f);
|
||||
clearWallpaper.setEnabled(enableWallpaperControls);
|
||||
clearWallpaper.setAlpha(enableWallpaperControls ? 1 : 0.5f);
|
||||
});
|
||||
|
||||
chatWallpaperPreview.setOnClickListener(unused -> setWallpaper.performClick());
|
||||
|
@ -78,7 +80,6 @@ public class ChatWallpaperFragment extends Fragment {
|
|||
.navigate(R.id.action_chatWallpaperFragment_to_chatWallpaperSelectionFragment));
|
||||
|
||||
resetAllWallpaper.setVisibility(viewModel.isGlobal() ? View.VISIBLE : View.GONE);
|
||||
updateDividerVisibility();
|
||||
|
||||
clearWallpaper.setOnClickListener(unused -> {
|
||||
confirmAction(viewModel.isGlobal() ? R.string.ChatWallpaperFragment__clear_wallpaper_this_will_not
|
||||
|
@ -108,14 +109,6 @@ public class ChatWallpaperFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
private void updateDividerVisibility() {
|
||||
if (clearWallpaper.getVisibility() == View.VISIBLE || resetAllWallpaper.getVisibility() == View.VISIBLE) {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
divider.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void confirmAction(@StringRes int title, @StringRes int positiveActionLabel, @NonNull Runnable onPositiveAction) {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setMessage(title)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/wallpaper_preview_background" />
|
||||
<corners android:radius="100dp" />
|
||||
</shape>
|
|
@ -137,12 +137,18 @@
|
|||
android:id="@+id/preview_blur"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@string/WallpaperCropActivity__blur"
|
||||
android:layout_marginBottom="17dp"
|
||||
android:text="@string/WallpaperCropActivity__blur_photo"
|
||||
android:textColor="@color/signal_button_primary"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/preview_set_wallpaper"
|
||||
android:background="@drawable/wallpaper_crop_bubble_background"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
app:switchPadding="4dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/preview_guideline"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/preview_set_wallpaper" />
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/preview_set_wallpaper"
|
||||
|
@ -155,4 +161,11 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/preview_guideline" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="@color/wallpaper_preview_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/navigation_bar_guideline"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</org.thoughtcrime.securesms.components.InsetAwareConstraintLayout>
|
|
@ -236,11 +236,10 @@
|
|||
android:layout_height="1dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@color/signal_inverse_transparent_15"
|
||||
android:visibility="gone"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chat_wallpaper_dark_theme_dims_wallpaper"
|
||||
tools:visibility="visible" />
|
||||
app:layout_constraintTop_toBottomOf="@id/chat_wallpaper_dark_theme_dims_wallpaper" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chat_wallpaper_clear_wallpaper"
|
||||
|
@ -254,11 +253,10 @@
|
|||
android:text="@string/ChatWallpaperFragment__clear_wallpaper"
|
||||
android:textAppearance="@style/Signal.Text.Body"
|
||||
android:textColor="@color/signal_text_primary"
|
||||
android:visibility="gone"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/chat_wallpaper_divider"
|
||||
tools:visibility="visible" />
|
||||
app:layout_constraintTop_toBottomOf="@id/chat_wallpaper_divider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chat_wallpaper_reset_all_wallpapers"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
android:paddingEnd="10dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:layout_gravity="center"
|
||||
tools:text="March 1, 2015" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
android:id="@+id/rbs_about"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/signal_text_secondary"
|
||||
style="@style/Signal.Text.Body"
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<color name="conversation_item_update_text_color">@color/core_grey_45</color>
|
||||
<color name="conversation_item_sent_icon_color">@color/core_grey_25</color>
|
||||
<color name="conversation_item_quote_text_color">@color/core_grey_05</color>
|
||||
<color name="conversation_item_wallpaper_bubble_color">@color/core_black</color>
|
||||
|
||||
<color name="wallpaper_bubble_color">@color/transparent_black_80</color>
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<color name="conversation_item_update_text_color">@color/core_grey_60</color>
|
||||
<color name="conversation_item_sent_icon_color">@color/core_grey_60</color>
|
||||
<color name="conversation_item_quote_text_color">@color/core_grey_90</color>
|
||||
<color name="conversation_item_wallpaper_bubble_color">@color/core_white</color>
|
||||
|
||||
<color name="wallpaper_bubble_color">@color/transparent_white_80</color>
|
||||
|
||||
|
|
|
@ -2871,7 +2871,7 @@
|
|||
<string name="WallpaperCropActivity__set_wallpaper_for_all_chats">Set wallpaper for all chats.</string>
|
||||
<string name="WallpaperCropActivity__set_wallpaper_for_s">Set wallpaper for %s.</string>
|
||||
<string name="WallpaperCropActivity__error_setting_wallpaper">Error setting wallpaper.</string>
|
||||
<string name="WallpaperCropActivity__blur">Blur</string>
|
||||
<string name="WallpaperCropActivity__blur_photo">Blur photo</string>
|
||||
|
||||
<!-- EOF -->
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue