Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide some menu options #343

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions app/src/main/java/org/openedx/app/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import org.openedx.core.config.Config
import org.openedx.core.presentation.global.app_upgrade.UpgradeRequiredFragment
import org.openedx.core.presentation.global.viewBinding
import org.openedx.dashboard.presentation.DashboardFragment
import org.openedx.discovery.presentation.DiscoveryNavigator
import org.openedx.discovery.presentation.DiscoveryRouter
import org.openedx.discovery.presentation.program.ProgramFragment
import org.openedx.profile.presentation.profile.ProfileFragment

class MainFragment : Fragment(R.layout.fragment_main) {
Expand Down Expand Up @@ -47,24 +45,14 @@ class MainFragment : Fragment(R.layout.fragment_main) {

binding.bottomNavView.setOnItemSelectedListener {
when (it.itemId) {
R.id.fragmentHome -> {
viewModel.logDiscoveryTabClickedEvent()
binding.viewPager.setCurrentItem(0, false)
}

R.id.fragmentDashboard -> {
viewModel.logMyCoursesTabClickedEvent()
binding.viewPager.setCurrentItem(1, false)
}

R.id.fragmentPrograms -> {
viewModel.logMyProgramsTabClickedEvent()
binding.viewPager.setCurrentItem(2, false)
binding.viewPager.setCurrentItem(0, false)
}

R.id.fragmentProfile -> {
viewModel.logProfileTabClickedEvent()
binding.viewPager.setCurrentItem(3, false)
binding.viewPager.setCurrentItem(1, false)
}
}
true
Expand All @@ -77,9 +65,9 @@ class MainFragment : Fragment(R.layout.fragment_main) {
}

viewLifecycleOwner.lifecycleScope.launch {
viewModel.navigateToDiscovery.collect { shouldNavigateToDiscovery ->
if (shouldNavigateToDiscovery) {
binding.bottomNavView.selectedItemId = R.id.fragmentHome
viewModel.navigateToHome.collect { shouldNavigateToHome ->
if (shouldNavigateToHome) {
binding.bottomNavView.selectedItemId = R.id.fragmentDashboard
}
}
}
Expand All @@ -105,18 +93,8 @@ class MainFragment : Fragment(R.layout.fragment_main) {
binding.viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
binding.viewPager.offscreenPageLimit = 4

val discoveryFragment = DiscoveryNavigator(viewModel.isDiscoveryTypeWebView)
.getDiscoveryFragment()
val programFragment = if (viewModel.isProgramTypeWebView) {
ProgramFragment(true)
} else {
InDevelopmentFragment()
}

adapter = MainNavigationFragmentAdapter(this).apply {
addFragment(discoveryFragment)
addFragment(DashboardFragment())
addFragment(programFragment)
addFragment(ProfileFragment())
}
binding.viewPager.adapter = adapter
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/openedx/app/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class MainViewModel(
val isBottomBarEnabled: LiveData<Boolean>
get() = _isBottomBarEnabled

private val _navigateToDiscovery = MutableSharedFlow<Boolean>()
val navigateToDiscovery: SharedFlow<Boolean>
get() = _navigateToDiscovery.asSharedFlow()
private val _navigateToHome = MutableSharedFlow<Boolean>()
val navigateToHome: SharedFlow<Boolean>
get() = _navigateToHome.asSharedFlow()

val isDiscoveryTypeWebView get() = config.getDiscoveryConfig().isViewTypeWebView()

Expand All @@ -37,7 +37,7 @@ class MainViewModel(
super.onCreate(owner)
notifier.notifier.onEach {
if (it is NavigationToDiscovery) {
_navigateToDiscovery.emit(true)
_navigateToHome.emit(true)
}
}.distinctUntilChanged().launchIn(viewModelScope)
}
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/menu/bottom_view_menu.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/fragmentHome"
android:title="@string/app_navigation_discovery"
android:enabled="true"
android:icon="@drawable/app_ic_home"/>

<item
android:id="@+id/fragmentDashboard"
android:title="@string/app_navigation_dashboard"
android:enabled="true"
android:icon="@drawable/app_ic_rows"/>

<item
android:id="@+id/fragmentPrograms"
android:title="@string/app_navigation_programs"
android:enabled="true"
android:icon="@drawable/app_ic_book"/>

<item
android:id="@+id/fragmentProfile"
android:title="@string/app_navigation_profile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ internal data class AgreementUrlsConfig(
private val dataSellConsentUrl: String = "",
@SerializedName("TOS_URL")
private val tosUrl: String = "",
@SerializedName("CONTACT_SUPPORT_URL")
private val contactSupportUrl: String = "",
@SerializedName("EULA_URL")
private val eulaUrl: String = "",
@SerializedName("SUPPORTED_LANGUAGES")
Expand All @@ -25,6 +27,7 @@ internal data class AgreementUrlsConfig(
cookiePolicyUrl = cookiePolicyUrl,
dataSellConsentUrl = dataSellConsentUrl,
tosUrl = tosUrl,
contactSupportUrl = contactSupportUrl,
eulaUrl = eulaUrl,
supportedLanguages = supportedLanguages,
)
Expand All @@ -35,6 +38,7 @@ internal data class AgreementUrlsConfig(
cookiePolicyUrl = cookiePolicyUrl.appendLocale(it),
dataSellConsentUrl = dataSellConsentUrl.appendLocale(it),
tosUrl = tosUrl.appendLocale(it),
contactSupportUrl = contactSupportUrl.appendLocale(it),
eulaUrl = eulaUrl.appendLocale(it),
supportedLanguages = supportedLanguages,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal data class Agreement(

data class AgreementUrls(
val privacyPolicyUrl: String = "",
val contactSupportUrl: String = "",
val cookiePolicyUrl: String = "",
val dataSellConsentUrl: String = "",
val tosUrl: String = "",
Expand Down
1 change: 1 addition & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<string name="core_data_sell" translatable="false">Do not sell my personal information</string>
<string name="core_faq" translatable="false">View FAQ</string>
<string name="core_terms_of_use">Terms of Use</string>
<string name="core_contact_support">Contact Support</string>
<string name="core_profile">Profile</string>
<string name="core_cancel">Cancel</string>
<string name="core_search">Search</string>
Expand Down
9 changes: 5 additions & 4 deletions default_config/dev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
API_HOST_URL: 'http://localhost:8000'
API_HOST_URL: 'https://lms.quince-sandbox.eshe.opencraft.hosting'
APPLICATION_ID: 'org.openedx.app'
ENVIRONMENT_DISPLAY_NAME: 'Localhost'
ENVIRONMENT_DISPLAY_NAME: 'Eshe dev'
URI_SCHEME: ''
FEEDBACK_EMAIL_ADDRESS: '[email protected]'
FAQ_URL: ''
OAUTH_CLIENT_ID: 'OAUTH_CLIENT_ID'
OAUTH_CLIENT_ID: 'android-app-client-id'

# Keep empty to hide setting
AGREEMENT_URLS:
PRIVACY_POLICY_URL: ''
COOKIE_POLICY_URL: ''
DATA_SELL_CONSENT_URL: ''
TOS_URL: ''
CONTACT_SUPPORT_URL: 'https://eshemoeasu.my.site.com/help/s/'
TOS_URL: 'https://courses.ethernet.edu.et/terms'
EULA_URL: ''
SUPPORTED_LANGUAGES: [ ] #en is default language

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import androidx.compose.ui.unit.dp
import org.openedx.core.R
import org.openedx.core.UIMessage
import org.openedx.core.ui.HandleUIMessage
import org.openedx.core.ui.OpenEdXOutlinedButton
import org.openedx.core.ui.Toolbar
import org.openedx.core.ui.WindowSize
import org.openedx.core.ui.WindowType
Expand Down Expand Up @@ -142,17 +141,6 @@ internal fun ProfileView(
subtitle = "@${uiState.account.username}"
)
ProfileInfoSection(uiState.account)
OpenEdXOutlinedButton(
modifier = Modifier
.fillMaxWidth(),
text = stringResource(id = org.openedx.profile.R.string.profile_edit_profile),
onClick = {
onAction(ProfileViewAction.EditAccountClick)
},
borderColor = MaterialTheme.appColors.buttonBackground,
textColor = MaterialTheme.appColors.textAccent
)
Spacer(modifier = Modifier.height(12.dp))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class SettingsFragment : Fragment() {
SettingsScreenAction.FaqClick -> viewModel.faqClicked()

SettingsScreenAction.SupportClick -> {
viewModel.emailSupportClicked(requireContext())
viewModel.emailSupportClicked(
requireActivity().supportFragmentManager
)
}

SettingsScreenAction.TermsClick -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ internal fun SettingsScreen(
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(Modifier.height(30.dp))

ManageAccountSection(onManageAccountClick = {
onAction(SettingsScreenAction.ManageAccount)
})

Spacer(modifier = Modifier.height(24.dp))

SettingsSection(onVideoSettingsClick = {
Expand Down Expand Up @@ -269,7 +263,7 @@ private fun SupportInfoSection(
backgroundColor = MaterialTheme.appColors.cardViewBackground
) {
Column(Modifier.fillMaxWidth()) {
if (uiState.configuration.supportEmail.isNotBlank()) {
if (uiState.configuration.agreementUrls.contactSupportUrl.isNotBlank()) {
SettingsItem(text = stringResource(id = profileR.string.profile_contact_support)) {
onAction(SettingsScreenAction.SupportClick)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.openedx.core.system.AppCookieManager
import org.openedx.core.system.ResourceManager
import org.openedx.core.system.notifier.AppUpgradeEvent
import org.openedx.core.system.notifier.AppUpgradeNotifier
import org.openedx.core.utils.EmailUtil
import org.openedx.profile.domain.interactor.ProfileInteractor
import org.openedx.profile.domain.model.Configuration
import org.openedx.profile.presentation.ProfileAnalytics
Expand Down Expand Up @@ -168,11 +167,11 @@ class SettingsViewModel(
logProfileEvent(ProfileAnalyticsEvent.TERMS_OF_USE_CLICKED)
}

fun emailSupportClicked(context: Context) {
EmailUtil.showFeedbackScreen(
context = context,
feedbackEmailAddress = config.getFeedbackEmailAddress(),
appVersion = appData.versionName
fun emailSupportClicked(fragmentManager: FragmentManager) {
router.navigateToWebContent(
fm = fragmentManager,
title = resourceManager.getString(R.string.core_contact_support),
url = configuration.agreementUrls.contactSupportUrl,
)
logProfileEvent(ProfileAnalyticsEvent.CONTACT_SUPPORT_CLICKED)
}
Expand Down
Loading