Galou Minisini05/04/2023, 6:56 AM
in it I want to now have the word
. Is there an easy way to do it without having to do a if/else statement in front of every string? Like for example having two string file and setup once in the app or maybe once in every screen to take this string file or the other one depending on feature flag value. One way would be for every string having a placeholder instead of
but it will still add quite a bite of complexity within the code
Muhammad Utbah05/04/2023, 7:44 AM
method to retrieve the string resource and substitute the placeholder with the appropriate value depending on the feature flag: val featureFlag = /* retrieve feature flag value */ val textResId = if (featureFlag) R.string.my_feature_text_buzz else R.string.my_feature_text_foo val text = getString(textResId, if (featureFlag) "buzz" else "foo") This way, you only need to define two string resources with different placeholders for each variant of the feature name, and the if/else statement is only needed once to retrieve the appropriate resource ID. Another option is to use a library like Flipper to manage feature flags, which can make it easier to switch between different feature flag configurations and manage the visibility of the new name in your app. With Flipper, you can define feature flags and toggle them on or off from a central dashboard, and use these flags to control the visibility of UI elements or other app behavior.