Replace internal setting for CIV2 TextOnly with a FeatureFlag.

This commit is contained in:
Alex Hart 2023-08-31 16:50:05 -03:00 committed by Nicholas Tinsley
parent 305d7485c1
commit 1f2bfe8245
9 changed files with 20 additions and 33 deletions

View file

@ -616,14 +616,6 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
} }
) )
switchPref(
title = DSLSettingsText.from("Use V2 ConversationItem"),
isChecked = state.useConversationItemV2,
onClick = {
viewModel.setUseConversationItemV2(!state.useConversationItemV2)
}
)
switchPref( switchPref(
title = DSLSettingsText.from("Use V2 ConversationItem for Media"), title = DSLSettingsText.from("Use V2 ConversationItem for Media"),
isChecked = state.useConversationItemV2ForMedia, isChecked = state.useConversationItemV2ForMedia,

View file

@ -22,6 +22,5 @@ data class InternalSettingsState(
val disableStorageService: Boolean, val disableStorageService: Boolean,
val canClearOnboardingState: Boolean, val canClearOnboardingState: Boolean,
val pnpInitialized: Boolean, val pnpInitialized: Boolean,
val useConversationItemV2: Boolean,
val useConversationItemV2ForMedia: Boolean val useConversationItemV2ForMedia: Boolean
) )

View file

@ -104,11 +104,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
refresh() refresh()
} }
fun setUseConversationItemV2(enabled: Boolean) {
SignalStore.internalValues().setUseConversationItemV2(enabled)
refresh()
}
fun setUseConversationItemV2Media(enabled: Boolean) { fun setUseConversationItemV2Media(enabled: Boolean) {
SignalStore.internalValues().setUseConversationItemV2Media(enabled) SignalStore.internalValues().setUseConversationItemV2Media(enabled)
refresh() refresh()
@ -141,7 +136,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
disableStorageService = SignalStore.internalValues().storageServiceDisabled(), disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled(), canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
pnpInitialized = SignalStore.misc().hasPniInitializedDevices(), pnpInitialized = SignalStore.misc().hasPniInitializedDevices(),
useConversationItemV2 = SignalStore.internalValues().useConversationItemV2(),
useConversationItemV2ForMedia = SignalStore.internalValues().useConversationItemV2Media() useConversationItemV2ForMedia = SignalStore.internalValues().useConversationItemV2Media()
) )

View file

@ -35,7 +35,7 @@ import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge
import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge.PulseRequest import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge.PulseRequest
import org.thoughtcrime.securesms.conversation.v2.items.InteractiveConversationElement import org.thoughtcrime.securesms.conversation.v2.items.InteractiveConversationElement
import org.thoughtcrime.securesms.keyvalue.SignalStore import org.thoughtcrime.securesms.util.FeatureFlags
import org.thoughtcrime.securesms.util.ThemeUtil import org.thoughtcrime.securesms.util.ThemeUtil
import org.thoughtcrime.securesms.util.ViewUtil import org.thoughtcrime.securesms.util.ViewUtil
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
@ -558,7 +558,7 @@ class MultiselectItemDecoration(
} }
private fun RecyclerView.getMultiselectableChildren(): Sequence<Multiselectable> { private fun RecyclerView.getMultiselectableChildren(): Sequence<Multiselectable> {
return if (SignalStore.internalValues().useConversationItemV2()) { return if (FeatureFlags.useTextOnlyConversationItemV2()) {
children.map { getChildViewHolder(it) }.filterIsInstance<Multiselectable>() children.map { getChildViewHolder(it) }.filterIsInstance<Multiselectable>()
} else { } else {
children.filterIsInstance<Multiselectable>() children.filterIsInstance<Multiselectable>()
@ -566,7 +566,7 @@ class MultiselectItemDecoration(
} }
private fun RecyclerView.getInteractableChildren(): Sequence<InteractiveConversationElement> { private fun RecyclerView.getInteractableChildren(): Sequence<InteractiveConversationElement> {
return if (SignalStore.internalValues().useConversationItemV2()) { return if (FeatureFlags.useTextOnlyConversationItemV2()) {
children.map { getChildViewHolder(it) }.filterIsInstance<InteractiveConversationElement>() children.map { getChildViewHolder(it) }.filterIsInstance<InteractiveConversationElement>()
} else { } else {
children.filterIsInstance<InteractiveConversationElement>() children.filterIsInstance<InteractiveConversationElement>()
@ -574,7 +574,7 @@ class MultiselectItemDecoration(
} }
private fun resolveMultiselectable(parent: RecyclerView, child: View): Multiselectable? { private fun resolveMultiselectable(parent: RecyclerView, child: View): Multiselectable? {
return if (SignalStore.internalValues().useConversationItemV2()) { return if (FeatureFlags.useTextOnlyConversationItemV2()) {
parent.getChildViewHolder(child) as? Multiselectable parent.getChildViewHolder(child) as? Multiselectable
} else { } else {
child as? Multiselectable child as? Multiselectable

View file

@ -53,6 +53,7 @@ import org.thoughtcrime.securesms.mms.GlideRequests
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.CachedInflater import org.thoughtcrime.securesms.util.CachedInflater
import org.thoughtcrime.securesms.util.FeatureFlags
import org.thoughtcrime.securesms.util.HtmlUtil import org.thoughtcrime.securesms.util.HtmlUtil
import org.thoughtcrime.securesms.util.Projection import org.thoughtcrime.securesms.util.Projection
import org.thoughtcrime.securesms.util.ProjectionList import org.thoughtcrime.securesms.util.ProjectionList
@ -119,7 +120,7 @@ class ConversationAdapterV2(
} }
} }
if (SignalStore.internalValues().useConversationItemV2()) { if (FeatureFlags.useTextOnlyConversationItemV2()) {
registerFactory(OutgoingTextOnly::class.java) { parent -> registerFactory(OutgoingTextOnly::class.java) { parent ->
val view = CachedInflater.from(parent.context).inflate<View>(R.layout.v2_conversation_item_text_only_outgoing, parent, false) val view = CachedInflater.from(parent.context).inflate<View>(R.layout.v2_conversation_item_text_only_outgoing, parent, false)
V2ConversationItemTextOnlyViewHolder(V2ConversationItemTextOnlyOutgoingBinding.bind(view).bridge(), this) V2ConversationItemTextOnlyViewHolder(V2ConversationItemTextOnlyOutgoingBinding.bind(view).bridge(), this)

View file

@ -164,7 +164,7 @@ open class V2ConversationItemTextOnlyViewHolder<Model : MappingModel<Model>>(
var hasProcessedSupportedPayload = false var hasProcessedSupportedPayload = false
if (ConversationAdapterBridge.PAYLOAD_TIMESTAMP in payload) { if (ConversationAdapterBridge.PAYLOAD_TIMESTAMP in payload) {
presentDate(shape) presentDate()
hasProcessedSupportedPayload = true hasProcessedSupportedPayload = true
} }

View file

@ -175,7 +175,6 @@ import org.thoughtcrime.securesms.util.SignalLocalMetrics;
import org.thoughtcrime.securesms.util.SignalProxyUtil; import org.thoughtcrime.securesms.util.SignalProxyUtil;
import org.thoughtcrime.securesms.util.SnapToTopDataObserver; import org.thoughtcrime.securesms.util.SnapToTopDataObserver;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.WindowUtil; import org.thoughtcrime.securesms.util.WindowUtil;
import org.thoughtcrime.securesms.util.adapter.mapping.PagingMappingAdapter; import org.thoughtcrime.securesms.util.adapter.mapping.PagingMappingAdapter;
@ -984,7 +983,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
FrameLayout parent = new FrameLayout(context); FrameLayout parent = new FrameLayout(context);
parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
if (SignalStore.internalValues().useConversationItemV2()) { if (FeatureFlags.useTextOnlyConversationItemV2()) {
CachedInflater.from(context).cacheUntilLimit(R.layout.v2_conversation_item_text_only_incoming, parent, 25); CachedInflater.from(context).cacheUntilLimit(R.layout.v2_conversation_item_text_only_incoming, parent, 25);
CachedInflater.from(context).cacheUntilLimit(R.layout.v2_conversation_item_text_only_outgoing, parent, 25); CachedInflater.from(context).cacheUntilLimit(R.layout.v2_conversation_item_text_only_outgoing, parent, 25);
} else { } else {

View file

@ -29,7 +29,6 @@ public final class InternalValues extends SignalStoreValues {
public static final String DISABLE_STORAGE_SERVICE = "internal.disable_storage_service"; public static final String DISABLE_STORAGE_SERVICE = "internal.disable_storage_service";
public static final String FORCE_WEBSOCKET_MODE = "internal.force_websocket_mode"; public static final String FORCE_WEBSOCKET_MODE = "internal.force_websocket_mode";
public static final String LAST_SCROLL_POSITION = "internal.last_scroll_position"; public static final String LAST_SCROLL_POSITION = "internal.last_scroll_position";
public static final String CONVERSATION_ITEM_V2 = "internal.conversation_item_v2";
public static final String CONVERSATION_ITEM_V2_MEDIA = "internal.conversation_item_v2_media"; public static final String CONVERSATION_ITEM_V2_MEDIA = "internal.conversation_item_v2_media";
InternalValues(KeyValueStore store) { InternalValues(KeyValueStore store) {
@ -192,14 +191,6 @@ public final class InternalValues extends SignalStoreValues {
return getInteger(LAST_SCROLL_POSITION, 0); return getInteger(LAST_SCROLL_POSITION, 0);
} }
public void setUseConversationItemV2(boolean useConversationFragmentV2) {
putBoolean(CONVERSATION_ITEM_V2, useConversationFragmentV2);
}
public boolean useConversationItemV2() {
return FeatureFlags.internalUser() && getBoolean(CONVERSATION_ITEM_V2, false);
}
public void setUseConversationItemV2Media(boolean useConversationFragmentV2Media) { public void setUseConversationItemV2Media(boolean useConversationFragmentV2Media) {
putBoolean(CONVERSATION_ITEM_V2_MEDIA, useConversationFragmentV2Media); putBoolean(CONVERSATION_ITEM_V2_MEDIA, useConversationFragmentV2Media);
} }

View file

@ -114,6 +114,7 @@ public final class FeatureFlags {
public static final String PROMPT_BATTERY_SAVER = "android.promptBatterySaver"; public static final String PROMPT_BATTERY_SAVER = "android.promptBatterySaver";
public static final String USERNAMES = "android.usernames"; public static final String USERNAMES = "android.usernames";
public static final String INSTANT_VIDEO_PLAYBACK = "android.instantVideoPlayback"; public static final String INSTANT_VIDEO_PLAYBACK = "android.instantVideoPlayback";
private static final String CONVERSATION_ITEM_V2_TEXT = "android.conversationItemV2.text";
/** /**
* We will only store remote values for flags in this set. If you want a flag to be controllable * We will only store remote values for flags in this set. If you want a flag to be controllable
@ -179,7 +180,8 @@ public final class FeatureFlags {
PROMPT_FOR_NOTIFICATION_CONFIG, PROMPT_FOR_NOTIFICATION_CONFIG,
PROMPT_BATTERY_SAVER, PROMPT_BATTERY_SAVER,
USERNAMES, USERNAMES,
INSTANT_VIDEO_PLAYBACK INSTANT_VIDEO_PLAYBACK,
CONVERSATION_ITEM_V2_TEXT
); );
@VisibleForTesting @VisibleForTesting
@ -639,6 +641,15 @@ public final class FeatureFlags {
return getBoolean(INSTANT_VIDEO_PLAYBACK, false); return getBoolean(INSTANT_VIDEO_PLAYBACK, false);
} }
/**
* Note: this setting is currently
*
* @return Whether to use TextOnly V2 Conversation Items.
*/
public static boolean useTextOnlyConversationItemV2() {
return getBoolean(CONVERSATION_ITEM_V2_TEXT, false);
}
public static String promptForDelayedNotificationLogs() { public static String promptForDelayedNotificationLogs() {
return getString(PROMPT_FOR_NOTIFICATION_LOGS, "*"); return getString(PROMPT_FOR_NOTIFICATION_LOGS, "*");
} }