Skip to content

Commit 17b1ed9

Browse files
feat: added config flag for enabling/disabling dates screen
1 parent 1abd340 commit 17b1ed9

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

app/src/main/java/org/openedx/app/MainFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class MainFragment : Fragment(R.layout.fragment_main) {
4242
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
4343
super.onViewCreated(view, savedInstanceState)
4444

45+
if (!viewModel.isDatesFragmentEnabled) {
46+
binding.bottomNavView.menu.removeItem(R.id.fragmentDates)
47+
}
48+
4549
initViewPager()
4650

4751
binding.bottomNavView.setOnItemSelectedListener {

app/src/main/java/org/openedx/app/MainViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class MainViewModel(
3333
val isDiscoveryTypeWebView get() = config.getDiscoveryConfig().isViewTypeWebView()
3434
val getDiscoveryFragment get() = DiscoveryNavigator(isDiscoveryTypeWebView).getDiscoveryFragment()
3535

36+
val isDatesFragmentEnabled get() = config.getDatesConfig().isEnabled
37+
3638
override fun onCreate(owner: LifecycleOwner) {
3739
super.onCreate(owner)
3840
notifier.notifier

core/src/main/java/org/openedx/core/config/Config.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class Config(context: Context) {
9292
return getObjectOrNewInstance(DASHBOARD, DashboardConfig::class.java)
9393
}
9494

95+
fun getDatesConfig(): DatesConfig {
96+
return getObjectOrNewInstance(DATES, DatesConfig::class.java)
97+
}
98+
9599
fun getBranchConfig(): BranchConfig {
96100
return getObjectOrNewInstance(BRANCH, BranchConfig::class.java)
97101
}
@@ -179,6 +183,7 @@ class Config(context: Context) {
179183
private const val DISCOVERY = "DISCOVERY"
180184
private const val PROGRAM = "PROGRAM"
181185
private const val DASHBOARD = "DASHBOARD"
186+
private const val DATES = "DATES"
182187
private const val BRANCH = "BRANCH"
183188
private const val UI_COMPONENTS = "UI_COMPONENTS"
184189
private const val PLATFORM_NAME = "PLATFORM_NAME"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.openedx.core.config
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
data class DatesConfig(
6+
@SerializedName("ENABLED")
7+
val isEnabled: Boolean = true,
8+
)

default_config/dev/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ PROGRAM:
3131
DASHBOARD:
3232
TYPE: 'gallery'
3333

34+
DATES:
35+
ENABLED: true
36+
3437
FIREBASE:
3538
ENABLED: false
3639
CLOUD_MESSAGING_ENABLED: false

default_config/prod/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ PROGRAM:
3131
DASHBOARD:
3232
TYPE: 'gallery'
3333

34+
DATES:
35+
ENABLED: true
36+
3437
FIREBASE:
3538
ENABLED: false
3639
CLOUD_MESSAGING_ENABLED: false

default_config/stage/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ PROGRAM:
3131
DASHBOARD:
3232
TYPE: 'gallery'
3333

34+
DATES:
35+
ENABLED: true
36+
3437
FIREBASE:
3538
ENABLED: false
3639
CLOUD_MESSAGING_ENABLED: false

0 commit comments

Comments
 (0)