From ee4f6ff445ed846c6af478492ccded9c05260432 Mon Sep 17 00:00:00 2001 From: Hamza Israr Date: Wed, 6 Dec 2023 04:45:47 +0500 Subject: [PATCH] fix: Minor bugs in default config due to missing feature flags - Fix the API version problem on the register screen - Manage the "My Courses" screen title when programs are absent - Address the functionality of the "View all dates" button on sync dates when the dates tab is absent - Remove unused code from the config Fixes: LEARNER-9732 --- .../main/java/org/edx/mobile/util/Config.java | 27 +++--------- .../view/CourseTabsDashboardFragment.kt | 6 ++- .../java/org/edx/mobile/view/LearnFragment.kt | 44 +++++++++---------- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java b/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java index c8bc3684bb..77a3f78810 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/util/Config.java @@ -2,7 +2,6 @@ import android.content.Context; import android.net.Uri; -import android.os.Build; import android.text.TextUtils; import androidx.annotation.NonNull; @@ -159,8 +158,7 @@ public static class ProgramConfig { private String detailUrlTemplate; public boolean isEnabled() { - // TODO Disable program feature for kitkat users, See Jira story LEARNER-6625 for more details. - return enabled && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT; + return enabled; } public String getUrl() { @@ -277,22 +275,6 @@ public String getSegmentWriteKey() { } } - public static class DomainWhiteListConfig { - @SerializedName("ENABLED") - private boolean mEnabled; - - @SerializedName("DOMAINS") - private List mDomains; - - public boolean isEnabled() { - return mEnabled; - } - - public List getDomains() { - return mDomains != null ? mDomains : new ArrayList(); - } - } - public static class FirebaseConfig { @SerializedName("ENABLED") private boolean mEnabled; @@ -363,6 +345,9 @@ public static class ApiUrlVersionConfig { @SerializedName("ENROLLMENTS") private String enrollmentsApiVersion; + public ApiUrlVersionConfig() { + } + public ApiUrlVersionConfig(String blocksApiVersion, String registrationApiVersion, String enrollmentsApiVersion) { this.blocksApiVersion = blocksApiVersion; this.registrationApiVersion = registrationApiVersion; @@ -713,9 +698,7 @@ private T getObjectOrNewInstance(@NonNull String key, @NonNull Class cls) } else { try { return cls.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt index f70cee1fc6..1b6b3c890a 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt @@ -653,7 +653,7 @@ class CourseTabsDashboardFragment : BaseFragment() { var actionListener: View.OnClickListener? = null var actionResId = 0 - if (binding.pager.currentItem != 3) { + if (environment.config.isCourseDatesEnabled && binding.pager.currentItem != 3) { actionListener = View.OnClickListener { binding.pager.currentItem = 3 } actionResId = R.string.assessment_view_all_dates } @@ -799,7 +799,9 @@ class CourseTabsDashboardFragment : BaseFragment() { items.add(createDatesItem()) } items.add(createHandoutsItem()) - items.add(createAnnouncementsItem()) + if (environment.config.isAnnouncementEnabled) { + items.add(createAnnouncementsItem()) + } return items } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LearnFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LearnFragment.kt index e603ac44c1..4cf61257ee 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LearnFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LearnFragment.kt @@ -30,7 +30,6 @@ class LearnFragment : OfflineSupportBaseFragment() { private var items: ArrayList = arrayListOf() private var selectedItemPosition = -1 private var lastPopupWindowDismissTime = 0L - private var isTitleCollapsed = false override fun onCreateView( inflater: LayoutInflater, @@ -70,29 +69,30 @@ class LearnFragment : OfflineSupportBaseFragment() { binding.ivSelectorIcon.setImageDrawable(R.drawable.ic_drop_up) } } - - binding.appbar.setTitleStateListener( - binding.collapsingToolbar, - object : CollapsingToolbarStatListener { - override fun onExpanded() { - ViewAnimationUtil.animateTitleSize( - binding.tvSelectedItem, - resources.getDimension(R.dimen.edx_x_large) - ) - ImageUtils.animateIconSize(binding.ivSelectorIcon, 1f) - } - - override fun onCollapsed() { - ViewAnimationUtil.animateTitleSize( - binding.tvSelectedItem, - resources.getDimension(R.dimen.edx_large) - ) - ImageUtils.animateIconSize(binding.ivSelectorIcon, 0.75f) - } - }) } else { - binding.llLearnSelection.setVisibility(false) + binding.ivSelectorIcon.setVisibility(false) } + + binding.appbar.setTitleStateListener( + binding.collapsingToolbar, + object : CollapsingToolbarStatListener { + override fun onExpanded() { + ViewAnimationUtil.animateTitleSize( + binding.tvSelectedItem, + resources.getDimension(R.dimen.edx_x_large) + ) + ImageUtils.animateIconSize(binding.ivSelectorIcon, 1f) + } + + override fun onCollapsed() { + ViewAnimationUtil.animateTitleSize( + binding.tvSelectedItem, + resources.getDimension(R.dimen.edx_large) + ) + ImageUtils.animateIconSize(binding.ivSelectorIcon, 0.75f) + } + }) + selectedItemPosition = arguments?.getInt(SELECTED_POSITION) ?: items.first().ordinal // no need to track event cuz handle event through event bus on tab selection. updateScreen(items[selectedItemPosition], false)