Add CFv2 feature flag.
This commit is contained in:
parent
6a443d0074
commit
fe509838f4
9 changed files with 27 additions and 42 deletions
|
@ -616,14 +616,6 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
|||
}
|
||||
)
|
||||
|
||||
switchPref(
|
||||
title = DSLSettingsText.from("Use V2 ConversationFragment"),
|
||||
isChecked = state.useConversationFragmentV2,
|
||||
onClick = {
|
||||
viewModel.setUseConversationFragmentV2(!state.useConversationFragmentV2)
|
||||
}
|
||||
)
|
||||
|
||||
switchPref(
|
||||
title = DSLSettingsText.from("Use V2 ConversationItem"),
|
||||
isChecked = state.useConversationItemV2,
|
||||
|
|
|
@ -22,6 +22,5 @@ data class InternalSettingsState(
|
|||
val disableStorageService: Boolean,
|
||||
val canClearOnboardingState: Boolean,
|
||||
val pnpInitialized: Boolean,
|
||||
val useConversationFragmentV2: Boolean,
|
||||
val useConversationItemV2: Boolean
|
||||
)
|
||||
|
|
|
@ -104,11 +104,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
|||
refresh()
|
||||
}
|
||||
|
||||
fun setUseConversationFragmentV2(enabled: Boolean) {
|
||||
SignalStore.internalValues().setUseConversationFragmentV2(enabled)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun setUseConversationItemV2(enabled: Boolean) {
|
||||
SignalStore.internalValues().setUseConversationItemV2(enabled)
|
||||
refresh()
|
||||
|
@ -141,7 +136,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
|||
disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
|
||||
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
|
||||
pnpInitialized = SignalStore.misc().hasPniInitializedDevices(),
|
||||
useConversationFragmentV2 = SignalStore.internalValues().useConversationFragmentV2(),
|
||||
useConversationItemV2 = SignalStore.internalValues().useConversationItemV2()
|
||||
)
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
|||
FrameLayout parent = new FrameLayout(context);
|
||||
parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
if (SignalStore.internalValues().useConversationFragmentV2() && SignalStore.internalValues().useConversationItemV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2() && SignalStore.internalValues().useConversationItemV2()) {
|
||||
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);
|
||||
} else {
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.mms.SlideFactory;
|
|||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -458,7 +459,7 @@ public class ConversationIntents {
|
|||
intent.setType(dataType);
|
||||
}
|
||||
|
||||
if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2()) {
|
||||
Bundle args = ConversationIntents.createParentFragmentArguments(intent);
|
||||
|
||||
return intent.putExtras(args);
|
||||
|
@ -513,7 +514,7 @@ public class ConversationIntents {
|
|||
}
|
||||
|
||||
private static long checkThreadId(long threadId) {
|
||||
if (threadId < 0 && SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (threadId < 0 && FeatureFlags.useConversationFragmentV2()) {
|
||||
throw new IllegalArgumentException("ThreadId is a required field in CFV2");
|
||||
} else {
|
||||
return threadId;
|
||||
|
@ -521,7 +522,7 @@ public class ConversationIntents {
|
|||
}
|
||||
|
||||
private static Class<? extends Activity> getBaseConversationActivity() {
|
||||
if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2()) {
|
||||
return ConversationActivity.class;
|
||||
} else {
|
||||
return org.thoughtcrime.securesms.conversation.ConversationActivity.class;
|
||||
|
|
|
@ -178,7 +178,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
bottomNavigationBarHeight = 0;
|
||||
}
|
||||
|
||||
if (!SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (!FeatureFlags.useConversationFragmentV2()) {
|
||||
toolbarShade.setVisibility(VISIBLE);
|
||||
toolbarShade.setAlpha(1f);
|
||||
|
||||
|
@ -395,7 +395,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
}
|
||||
|
||||
private void updateToolbarShade(@NonNull Activity activity) {
|
||||
if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2()) {
|
||||
LayoutParams layoutParams = (LayoutParams) toolbarShade.getLayoutParams();
|
||||
layoutParams.height = 0;
|
||||
toolbarShade.setLayoutParams(layoutParams);
|
||||
|
@ -403,7 +403,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
}
|
||||
|
||||
View toolbar = activity.findViewById(R.id.toolbar);
|
||||
View bannerContainer = activity.findViewById(SignalStore.internalValues().useConversationFragmentV2() ? R.id.conversation_banner
|
||||
View bannerContainer = activity.findViewById(FeatureFlags.useConversationFragmentV2() ? R.id.conversation_banner
|
||||
: R.id.conversation_banner_container);
|
||||
|
||||
LayoutParams layoutParams = (LayoutParams) toolbarShade.getLayoutParams();
|
||||
|
@ -412,7 +412,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
}
|
||||
|
||||
private void updateInputShade(@NonNull Activity activity) {
|
||||
if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2()) {
|
||||
LayoutParams layoutParams = (LayoutParams) inputShade.getLayoutParams();
|
||||
layoutParams.height = 0;
|
||||
inputShade.setLayoutParams(layoutParams);
|
||||
|
@ -426,7 +426,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
}
|
||||
|
||||
private int getInputPanelHeight(@NonNull Activity activity) {
|
||||
if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (FeatureFlags.useConversationFragmentV2()) {
|
||||
View bottomPanel = activity.findViewById(R.id.conversation_input_panel);
|
||||
|
||||
return bottomPanel.getHeight();
|
||||
|
@ -915,7 +915,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||
itemYAnim.setDuration(duration);
|
||||
animators.add(itemYAnim);
|
||||
|
||||
if (!SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (!FeatureFlags.useConversationFragmentV2()) {
|
||||
ObjectAnimator toolbarShadeAnim = new ObjectAnimator();
|
||||
toolbarShadeAnim.setProperty(View.ALPHA);
|
||||
toolbarShadeAnim.setFloatValues(0f);
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.thoughtcrime.securesms.R
|
|||
import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge
|
||||
import org.thoughtcrime.securesms.conversation.ConversationAdapterBridge.PulseRequest
|
||||
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.ViewUtil
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
|
||||
|
@ -402,7 +402,7 @@ class MultiselectItemDecoration(
|
|||
}
|
||||
}
|
||||
|
||||
if (!SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (!FeatureFlags.useConversationFragmentV2()) {
|
||||
canvas.clipPath(path)
|
||||
canvas.drawShade()
|
||||
canvas.restore()
|
||||
|
@ -422,7 +422,7 @@ class MultiselectItemDecoration(
|
|||
}
|
||||
}
|
||||
|
||||
if (!SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
if (!FeatureFlags.useConversationFragmentV2()) {
|
||||
canvas.clipPath(path, Region.Op.DIFFERENCE)
|
||||
canvas.drawShade()
|
||||
canvas.restore()
|
||||
|
@ -570,7 +570,7 @@ class MultiselectItemDecoration(
|
|||
}
|
||||
|
||||
private fun RecyclerView.getMultiselectableChildren(): Sequence<Multiselectable> {
|
||||
return if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
return if (FeatureFlags.useConversationFragmentV2()) {
|
||||
children.map { getChildViewHolder(it) }.filterIsInstance<Multiselectable>()
|
||||
} else {
|
||||
children.filterIsInstance<Multiselectable>()
|
||||
|
@ -578,7 +578,7 @@ class MultiselectItemDecoration(
|
|||
}
|
||||
|
||||
private fun RecyclerView.getInteractableChildren(): Sequence<InteractiveConversationElement> {
|
||||
return if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
return if (FeatureFlags.useConversationFragmentV2()) {
|
||||
children.map { getChildViewHolder(it) }.filterIsInstance<InteractiveConversationElement>()
|
||||
} else {
|
||||
children.filterIsInstance<InteractiveConversationElement>()
|
||||
|
@ -586,7 +586,7 @@ class MultiselectItemDecoration(
|
|||
}
|
||||
|
||||
private fun resolveMultiselectable(parent: RecyclerView, child: View): Multiselectable? {
|
||||
return if (SignalStore.internalValues().useConversationFragmentV2()) {
|
||||
return if (FeatureFlags.useConversationFragmentV2()) {
|
||||
parent.getChildViewHolder(child) as? Multiselectable
|
||||
} else {
|
||||
child as? Multiselectable
|
||||
|
|
|
@ -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 FORCE_WEBSOCKET_MODE = "internal.force_websocket_mode";
|
||||
public static final String LAST_SCROLL_POSITION = "internal.last_scroll_position";
|
||||
public static final String CONVERSATION_FRAGMENT_V2 = "internal.conversation_fragment_v2";
|
||||
public static final String CONVERSATION_ITEM_V2 = "internal.conversation_item_v2";
|
||||
|
||||
InternalValues(KeyValueStore store) {
|
||||
|
@ -192,14 +191,6 @@ public final class InternalValues extends SignalStoreValues {
|
|||
return getInteger(LAST_SCROLL_POSITION, 0);
|
||||
}
|
||||
|
||||
public void setUseConversationFragmentV2(boolean useConversationFragmentV2) {
|
||||
putBoolean(CONVERSATION_FRAGMENT_V2, useConversationFragmentV2);
|
||||
}
|
||||
|
||||
public boolean useConversationFragmentV2() {
|
||||
return FeatureFlags.internalUser() && getBoolean(CONVERSATION_FRAGMENT_V2, false);
|
||||
}
|
||||
|
||||
public void setUseConversationItemV2(boolean useConversationFragmentV2) {
|
||||
putBoolean(CONVERSATION_ITEM_V2, useConversationFragmentV2);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ public final class FeatureFlags {
|
|||
private static final String MAX_ATTACHMENT_SIZE_BYTES = "global.attachments.maxBytes";
|
||||
private static final String SVR2_KILLSWITCH = "android.svr2.killSwitch";
|
||||
private static final String CDS_COMPAT_MODE = "global.cds.return_acis_without_uaks";
|
||||
private static final String CONVERSATION_FRAGMENT_V2 = "android.conversationFragmentV2";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
|
@ -165,7 +166,8 @@ public final class FeatureFlags {
|
|||
MAX_ATTACHMENT_SIZE_BYTES,
|
||||
AD_HOC_CALLING,
|
||||
SVR2_KILLSWITCH,
|
||||
CDS_COMPAT_MODE
|
||||
CDS_COMPAT_MODE,
|
||||
CONVERSATION_FRAGMENT_V2
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -230,7 +232,8 @@ public final class FeatureFlags {
|
|||
MAX_ATTACHMENT_RECEIVE_SIZE_BYTES,
|
||||
MAX_ATTACHMENT_SIZE_BYTES,
|
||||
SVR2_KILLSWITCH,
|
||||
CDS_COMPAT_MODE
|
||||
CDS_COMPAT_MODE,
|
||||
CONVERSATION_FRAGMENT_V2
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -592,6 +595,11 @@ public final class FeatureFlags {
|
|||
return getBoolean(CDS_COMPAT_MODE, true);
|
||||
}
|
||||
|
||||
/** True if the new conversation fragment should be used. */
|
||||
public static boolean useConversationFragmentV2() {
|
||||
return getBoolean(CONVERSATION_FRAGMENT_V2, false);
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
return new TreeMap<>(REMOTE_VALUES);
|
||||
|
|
Loading…
Add table
Reference in a new issue