diff --git a/common/design/src/main/res/drawable/ic_close.xml b/common/design/src/main/res/drawable/ic_close.xml new file mode 100644 index 000000000..d5183d7fa --- /dev/null +++ b/common/design/src/main/res/drawable/ic_close.xml @@ -0,0 +1,9 @@ + + + diff --git a/common/design/src/main/res/values/colors.xml b/common/design/src/main/res/values/colors.xml index 779ab270c..1a3152165 100644 --- a/common/design/src/main/res/values/colors.xml +++ b/common/design/src/main/res/values/colors.xml @@ -30,7 +30,7 @@ #5b000000 #f2dec3 #484848 - #005EC7 + #2E5797 #27407d #FF5C44 #E51A19 diff --git a/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesActivity.kt b/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesActivity.kt index d0e7d8ee8..a4f17cae6 100644 --- a/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesActivity.kt +++ b/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesActivity.kt @@ -26,9 +26,7 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import android.view.View import androidx.activity.viewModels -import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat import androidx.core.view.isVisible import app.ss.lessons.data.model.SSQuarterly @@ -45,6 +43,7 @@ import com.cryart.sabbathschool.core.navigation.AppNavigator import com.cryart.sabbathschool.core.navigation.Destination import com.cryart.sabbathschool.lessons.R import com.cryart.sabbathschool.lessons.databinding.SsActivityQuarterliesBinding +import com.cryart.sabbathschool.lessons.databinding.SsPromptAppReBrandingBinding import com.cryart.sabbathschool.lessons.ui.base.SSBaseActivity import com.cryart.sabbathschool.lessons.ui.languages.LanguagesListFragment import com.cryart.sabbathschool.lessons.ui.lessons.SSLessonsActivity @@ -67,8 +66,6 @@ class QuarterliesActivity : SSBaseActivity() { private val quarterliesAdapter: SSQuarterliesAdapter = SSQuarterliesAdapter() - private var brandingAlertDialog: AlertDialog? = null - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) @@ -161,18 +158,17 @@ class QuarterliesActivity : SSBaseActivity() { } private fun showAppReBrandingPrompt() { - val view = layoutInflater.inflate(R.layout.ss_prompt_app_re_branding, null) - view.findViewById(R.id.btn_ok).setOnClickListener { - brandingAlertDialog?.dismiss() - brandingAlertDialog = null - viewModel.reBrandingPromptSeen() - } + val binding = SsPromptAppReBrandingBinding.inflate(layoutInflater) - brandingAlertDialog = MaterialAlertDialogBuilder(this) - .setView(view) - .setCancelable(false) + val alertDialog = MaterialAlertDialogBuilder(this) + .setView(binding.root) .create() - brandingAlertDialog?.show() + + binding.btnClose.setOnClickListener { + alertDialog.dismiss() + } + + alertDialog.show() } override fun onCreateOptionsMenu(menu: Menu?): Boolean { diff --git a/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModel.kt b/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModel.kt index 7de728b27..5d4617522 100644 --- a/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModel.kt +++ b/features/lessons/src/main/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModel.kt @@ -102,7 +102,7 @@ class QuarterliesViewModel @Inject constructor( mutableShowLanguagePrompt.call() } } else { - _appReBranding.emit(!ssPrefs.isAppReBrandingPromptShown()) + handleBrandingPrompt() } } else { mutableViewState.postValue(ViewState.Error()) @@ -120,7 +120,10 @@ class QuarterliesViewModel @Inject constructor( ssPrefs.setLanguagePromptSeen() } - fun reBrandingPromptSeen() { - ssPrefs.setAppReBrandingShown() + private suspend fun handleBrandingPrompt() { + if (!ssPrefs.isAppReBrandingPromptShown()) { + ssPrefs.setAppReBrandingShown() + _appReBranding.emit(true) + } } } diff --git a/features/lessons/src/main/res/layout/ss_prompt_app_re_branding.xml b/features/lessons/src/main/res/layout/ss_prompt_app_re_branding.xml index c06ad3150..b8c87043c 100644 --- a/features/lessons/src/main/res/layout/ss_prompt_app_re_branding.xml +++ b/features/lessons/src/main/res/layout/ss_prompt_app_re_branding.xml @@ -1,65 +1,71 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:fillViewport="true"> - - - + android:layout_height="match_parent"> + + + + - + - + + - - + + diff --git a/features/lessons/src/test/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModelTest.kt b/features/lessons/src/test/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModelTest.kt index 893ae5c93..e75ecfb6d 100644 --- a/features/lessons/src/test/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModelTest.kt +++ b/features/lessons/src/test/java/com/cryart/sabbathschool/lessons/ui/quarterlies/QuarterliesViewModelTest.kt @@ -42,7 +42,6 @@ import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.test.runBlockingTest import org.amshove.kluent.shouldBe import org.amshove.kluent.shouldBeEqualTo -import org.amshove.kluent.shouldBeFalse import org.amshove.kluent.shouldBeNull import org.amshove.kluent.shouldBeTrue import org.junit.Before @@ -172,42 +171,15 @@ class QuarterliesViewModelTest { every { mockSSPrefs.getLastQuarterlyIndex() }.returns(null) every { mockSSPrefs.isLanguagePromptSeen() }.returns(true) every { mockSSPrefs.isAppReBrandingPromptShown() }.returns(false) + every { mockSSPrefs.setAppReBrandingShown() }.returns(Unit) viewModel.appReBrandingFlow.test { viewModel.viewCreated() expectItem().shouldBeTrue() - } - } - @Test - fun `should emit false for branding prompt flow when prompt was seen`() = coroutinesTestRule.runBlockingTest { - val language = "de" - val flow: Flow>> = callbackFlow { - sendBlocking(Resource.success(emptyList())) - awaitClose { } + verify { mockSSPrefs.setAppReBrandingShown() } } - every { mockRepository.getQuarterlies(language) }.returns(flow) - every { mockSSPrefs.getLanguageCode() }.returns(language) - every { mockSSPrefs.setLanguageCode(language) }.returns(Unit) - every { mockSSPrefs.getLastQuarterlyIndex() }.returns(null) - every { mockSSPrefs.isLanguagePromptSeen() }.returns(true) - every { mockSSPrefs.isAppReBrandingPromptShown() }.returns(true) - - viewModel.appReBrandingFlow.test { - viewModel.viewCreated() - - expectItem().shouldBeFalse() - } - } - - @Test - fun `should set branding prompt as seen`() { - every { mockSSPrefs.setAppReBrandingShown() }.returns(Unit) - - viewModel.reBrandingPromptSeen() - - verify { mockSSPrefs.setAppReBrandingShown() } } @Test