diff --git a/app/src/main/assets/VID_20190615_173334.mp4 b/app/src/main/assets/VID_20190615_173334.mp4 deleted file mode 100644 index 182865b..0000000 Binary files a/app/src/main/assets/VID_20190615_173334.mp4 and /dev/null differ diff --git a/app/src/main/assets/VID_20190831_213015.mp4 b/app/src/main/assets/VID_20190831_213015.mp4 new file mode 100644 index 0000000..8d3899e Binary files /dev/null and b/app/src/main/assets/VID_20190831_213015.mp4 differ diff --git a/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingFragment.kt b/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingFragment.kt index 71c0704..b916316 100644 --- a/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingFragment.kt +++ b/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingFragment.kt @@ -2,7 +2,9 @@ package com.example.android_curse.ui.onbording import android.os.Bundle import android.view.View -import android.widget.Toast +import androidx.core.content.res.ResourcesCompat +import androidx.fragment.app.viewModels +import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController import androidx.viewpager2.widget.ViewPager2 import by.kirich1409.viewbindingdelegate.viewBinding @@ -17,22 +19,16 @@ import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import com.hannesdorfmann.adapterdelegates4.ListDelegationAdapter import dev.chrisbanes.insetter.applyInsetter +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.launch class OnbordingFragment : BaseFragment(R.layout.fragment_onbording) { - private val viewBinding by viewBinding(FragmentOnbordingBinding::bind) -// private lateinit var binding: FragmentOnbordingBinding - - private var player: ExoPlayer? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) + private val viewModel: OnbordingViewModel by viewModels() -// binding = FragmentOnbordingBinding.inflate(layoutInflater) + private val viewBinding by viewBinding(FragmentOnbordingBinding::bind) - //TODO() -// viewBinding.playerView.player = player!! //TODO() - } + private fun player(): ExoPlayer = viewBinding.playerView.player as ExoPlayer override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -45,44 +41,60 @@ class OnbordingFragment : BaseFragment(R.layout.fragment_onbording) { type(navigationBars = true) { margin() } } - player = SimpleExoPlayer.Builder(requireContext()).build().apply { - addMediaItem(MediaItem.fromUri("asset:///VID_20190615_173334.mp4")) + viewBinding.playerView.player = SimpleExoPlayer.Builder(requireContext()).build().apply { + addMediaItem(MediaItem.fromUri("asset:///VID_20190831_213015.mp4")) repeatMode = Player.REPEAT_MODE_ALL prepare() } - viewBinding.playerView.player = player!! - viewBinding.viewPager.setTextPages() viewBinding.viewPager.attachDots(viewBinding.onboardingTextTabLayout) viewBinding.signInButton.setOnClickListener { -// TODO() findNavController().navigate(R.id.action_onbordingFragment_to_signInFragment) - Toast.makeText(requireContext(), "нажата текста войти", Toast.LENGTH_SHORT).show() } viewBinding.signUpButton.setOnClickListener { findNavController().navigate(R.id.action_onbordingFragment_to_signUpFragment) - -// TODO() - Toast.makeText(requireContext(), "нажата текста регистрации", Toast.LENGTH_SHORT).show() } - + viewBinding.volumeControlButton.setOnClickListener { viewModel.change() } + lifecycleScope.launch { + viewModel.isOffVolumeControlStateFlow().collect { value: Boolean -> + if (value) { + player().volume = 0f + viewBinding.volumeControlButton.setImageDrawable( + ResourcesCompat.getDrawable( + resources, + R.drawable.ic_volume_off_white_24dp, + requireContext().theme + ) + ) + } else { + player().volume = 100f + viewBinding.volumeControlButton.setImageDrawable( + ResourcesCompat.getDrawable( + resources, + R.drawable.ic_volume_on_white_24dp, + requireContext().theme + ) + ) + } + } + } } override fun onResume() { super.onResume() - player?.play() + viewBinding.playerView.player?.play() } override fun onPause() { super.onPause() - player?.pause() + viewBinding.playerView.player?.pause() } override fun onDestroy() { super.onDestroy() - player?.release() + viewBinding.playerView.player?.release() } diff --git a/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingViewModel.kt b/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingViewModel.kt new file mode 100644 index 0000000..18cf270 --- /dev/null +++ b/app/src/main/java/com/example/android_curse/ui/onbording/OnbordingViewModel.kt @@ -0,0 +1,21 @@ +package com.example.android_curse.ui.onbording + + +import com.example.android_curse.ui.base.BaseViewModel +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow + +class OnbordingViewModel : BaseViewModel() { + + private val _isOffVolumeControlStateFlow = MutableStateFlow(true) + + fun isOffVolumeControlStateFlow(): Flow = _isOffVolumeControlStateFlow + + fun change() { + val compareAndSet : Boolean = _isOffVolumeControlStateFlow.compareAndSet(true, false) + if (!compareAndSet){ + _isOffVolumeControlStateFlow.compareAndSet(false, true) + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/color/brand_blue.xml b/app/src/main/res/color/brand_blue.xml deleted file mode 100644 index a8b409b..0000000 --- a/app/src/main/res/color/brand_blue.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_volume_up_white_24dp.xml b/app/src/main/res/drawable/ic_volume_on_white_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_volume_up_white_24dp.xml rename to app/src/main/res/drawable/ic_volume_on_white_24dp.xml diff --git a/app/src/main/res/layout/fragment_onbording.xml b/app/src/main/res/layout/fragment_onbording.xml index e14ee1b..abfb0d9 100644 --- a/app/src/main/res/layout/fragment_onbording.xml +++ b/app/src/main/res/layout/fragment_onbording.xml @@ -81,6 +81,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="24dp" + android:backgroundTint="@color/green_blue" android:text="@string/onboarding_sign_Up_button" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/fragment_sign_in.xml b/app/src/main/res/layout/fragment_sign_in.xml index 7648162..e7dc5a9 100644 --- a/app/src/main/res/layout/fragment_sign_in.xml +++ b/app/src/main/res/layout/fragment_sign_in.xml @@ -65,12 +65,7 @@ diff --git a/app/src/main/res/layout/fragment_sign_up.xml b/app/src/main/res/layout/fragment_sign_up.xml index 09aad75..fe209ef 100644 --- a/app/src/main/res/layout/fragment_sign_up.xml +++ b/app/src/main/res/layout/fragment_sign_up.xml @@ -6,12 +6,7 @@ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index abbc779..ae8b8b6 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -8,6 +8,6 @@ #FF000000 #FFFFFFFF #CCCCCC - #FF9800 - todo + #FF9800 + #1ECECA \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index abf3b68..0675dba 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -11,6 +11,17 @@ 16dp bold @style/TextAppearance.MaterialComponents.Body1 - @color/brand_blue + @color/green_blue + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index c929416..294500a 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,11 +2,11 @@