More Activity : Coming soon card

blogs api adapter and recyclerview

AboutWoka Activity

saving instance of player in home one and two fragment to optimize the theme switching
This commit is contained in:
2024-06-03 20:39:33 +05:30
parent 78f3cd85e6
commit 5946bf414f
33 changed files with 571 additions and 190 deletions

View File

@@ -15,6 +15,10 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Woka" android:theme="@style/Theme.Woka"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".home.sidebar.AboutActivity"
android:screenOrientation="portrait"
android:exported="false" />
<activity <activity
android:name=".home.MoreHomeActivity" android:name=".home.MoreHomeActivity"
android:exported="false" android:exported="false"

View File

@@ -1,21 +1,53 @@
package com.woka.home package com.woka.home
import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncDifferConfig import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.bumptech.glide.Glide
import com.woka.R
import com.woka.databinding.BlogViewHolderBinding import com.woka.databinding.BlogViewHolderBinding
import com.woka.modules.blogs.Blog import com.woka.modules.blogs.Blog
import java.util.concurrent.Executors
class BlogsAdapter(config: AsyncDifferConfig<Blog>) : class BlogsAdapter(config: AsyncDifferConfig<Blog>) :
ListAdapter<Blog, BlogsAdapter.BlogViewHolder>(config) { ListAdapter<Blog, BlogsAdapter.BlogViewHolder>(config) {
inner class BlogViewHolder(binding: BlogViewHolderBinding): ViewHolder(binding.root) inner class BlogViewHolder(val binding: BlogViewHolderBinding): ViewHolder(binding.root)
companion object{
private val DIFF_UTILS = object : DiffUtil.ItemCallback<Blog>(){
override fun areItemsTheSame(oldItem: Blog, newItem: Blog): Boolean =
oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: Blog, newItem: Blog): Boolean =
oldItem == newItem
}
private val ASYNC_DIFF_CONFIG = AsyncDifferConfig.Builder(DIFF_UTILS)
.setBackgroundThreadExecutor(Executors.newSingleThreadExecutor())
.build()
}
constructor(): this(ASYNC_DIFF_CONFIG)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BlogViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BlogViewHolder {
return BlogViewHolder(BlogViewHolderBinding.inflate(LayoutInflater.from(parent.context), parent, false))
} }
override fun onBindViewHolder(holder: BlogViewHolder, position: Int) { override fun onBindViewHolder(holder: BlogViewHolder, position: Int) {
with(getItem(position)){
thumbnail_path?.let {
Glide.with(holder.binding.image)
.load(it)
.placeholder(android.R.color.darker_gray)
.error(R.drawable.woka_logo_half)
.into(holder.binding.image)
}
holder.binding.title.text = title
}
} }
} }

View File

@@ -12,6 +12,7 @@ import android.graphics.Shader
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.HapticFeedbackConstants
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import android.view.WindowManager import android.view.WindowManager
@@ -26,6 +27,7 @@ import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.exoplayer2.ExoPlayer
import com.jwplayer.pub.api.license.LicenseUtil import com.jwplayer.pub.api.license.LicenseUtil
import com.woka.BuildConfig import com.woka.BuildConfig
import com.woka.R import com.woka.R
@@ -37,6 +39,7 @@ import com.woka.home.BottomNavigation.Companion.MY_LIST
import com.woka.home.fragments.Home1Fragment import com.woka.home.fragments.Home1Fragment
import com.woka.home.fragments.Home2Fragment import com.woka.home.fragments.Home2Fragment
import com.woka.home.fragments.MyListFragment import com.woka.home.fragments.MyListFragment
import com.woka.home.sidebar.AboutActivity
import com.woka.mvvm.userDataModels.UserDataResponse import com.woka.mvvm.userDataModels.UserDataResponse
import com.woka.networking.ApiResult import com.woka.networking.ApiResult
import com.woka.onboard.OnboardActivity import com.woka.onboard.OnboardActivity
@@ -131,6 +134,8 @@ class HomeActivity : WokaBaseActivity(),
} }
LicenseUtil().setLicenseKey(this, "LkYoNusv+gSIVJIrXa5Bf59iBNlUMxeg82PM/l8JWk+cD4BE") LicenseUtil().setLicenseKey(this, "LkYoNusv+gSIVJIrXa5Bf59iBNlUMxeg82PM/l8JWk+cD4BE")
viewModel.initPlayer(applicationContext)
} }
override fun onResume() { override fun onResume() {
@@ -256,6 +261,11 @@ class HomeActivity : WokaBaseActivity(),
} }
} }
} }
sbAboutWokaCard.setOnClickListener {
startActivity(Intent(this@HomeActivity, AboutActivity::class.java),
ActivityOptions.makeSceneTransitionAnimation(this@HomeActivity).toBundle())
}
} }
} }
@@ -267,10 +277,16 @@ class HomeActivity : WokaBaseActivity(),
Theme.THEME_ONE -> { Theme.THEME_ONE -> {
sbTheme1Selected.visibility = VISIBLE sbTheme1Selected.visibility = VISIBLE
sbTheme2Selected.visibility = GONE sbTheme2Selected.visibility = GONE
sbTheme1.isPressable = false
sbTheme2.isPressable = true
} }
Theme.THEME_TWO -> { Theme.THEME_TWO -> {
sbTheme2Selected.visibility = VISIBLE sbTheme2Selected.visibility = VISIBLE
sbTheme1Selected.visibility = GONE sbTheme1Selected.visibility = GONE
sbTheme1.isPressable = true
sbTheme2.isPressable = false
} }
} }
} }
@@ -310,6 +326,8 @@ class HomeActivity : WokaBaseActivity(),
if (!init){ if (!init){
binding.homeDrawer.closeDrawer(GravityCompat.END) binding.homeDrawer.closeDrawer(GravityCompat.END)
viewModel.sendLocaleChangeEvent(locale) viewModel.sendLocaleChangeEvent(locale)
binding.root.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
} }
} }
} }

View File

@@ -1,9 +1,13 @@
package com.woka.home package com.woka.home
import android.content.Context
import android.net.Uri
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import com.woka.home.BottomNavigation.Companion.HOME import com.woka.home.BottomNavigation.Companion.HOME
import com.woka.mvvm.UserApiService import com.woka.mvvm.UserApiService
import com.woka.mvvm.UserRepository import com.woka.mvvm.UserRepository
@@ -26,6 +30,20 @@ class HomeViewModel: ViewModel(){
val logoutLiveData: LiveData<ApiResult<Any>?> val logoutLiveData: LiveData<ApiResult<Any>?>
get() = _logoutLiveData get() = _logoutLiveData
var player: ExoPlayer? = null
fun initPlayer(context: Context) {
player = ExoPlayer.Builder(context).build()
player?.volume = 0f
val videoUri = Uri.parse("https://d3volyx7jx7oal.cloudfront.net/master.m3u8")
val mediaItem = MediaItem.fromUri(videoUri)
player?.setMediaItem(mediaItem)
player?.playWhenReady = true
player?.prepare()
}
fun sendLocaleChangeEvent(locale: String){ fun sendLocaleChangeEvent(locale: String){
_localeChangeLiveData.postValue(locale) _localeChangeLiveData.postValue(locale)
} }
@@ -36,4 +54,10 @@ class HomeViewModel: ViewModel(){
_logoutLiveData.postValue(userRepository.logout()) _logoutLiveData.postValue(userRepository.logout())
} }
} }
override fun onCleared() {
super.onCleared()
player?.release()
player = null
}
} }

View File

@@ -2,44 +2,93 @@ package com.woka.home
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.transition.Fade
import android.view.WindowManager import android.view.WindowManager
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.ViewModelProvider
import com.woka.R import com.woka.R
import com.woka.modules.BlogsViewModel import com.woka.databinding.ActivityMoreHomeBinding
import com.woka.modules.BlogsRepository
import com.woka.networking.ApiResult
import com.woka.utils.WokaBaseActivity import com.woka.utils.WokaBaseActivity
import com.woka.utils.hide
import com.woka.utils.lightStatusBar import com.woka.utils.lightStatusBar
import com.woka.utils.show
import com.woka.utils.toast
class MoreHomeActivity : WokaBaseActivity() { class MoreHomeActivity : WokaBaseActivity() {
private lateinit var blogsViewModel: BlogsViewModel private lateinit var binding: ActivityMoreHomeBinding
private lateinit var blogsAdapter: BlogsAdapter
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
with(window){
enterTransition = Fade()
}
enableEdgeToEdge() enableEdgeToEdge()
setContentView(R.layout.activity_more_home) binding = ActivityMoreHomeBinding.inflate(layoutInflater)
setContentView(binding.root)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets insets
} }
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) with(window){
window.statusBarColor = Color.TRANSPARENT addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.navigationBarColor = getColor(R.color.more_bg) statusBarColor = Color.TRANSPARENT
window.lightStatusBar() navigationBarColor = getColor(R.color.more_bg)
lightStatusBar()
}
blogsViewModel = ViewModelProvider(this)[BlogsViewModel::class.java] blogsAdapter = BlogsAdapter()
initViews()
clickEvents()
setObservers() setObservers()
} }
private fun setObservers() { private fun clickEvents() {
blogsViewModel.blogsLiveData.observe(this){ binding.apply {
more.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
}
}
private fun initViews(){
binding.apply {
rvBlogs.adapter = blogsAdapter
}
}
private fun setObservers() {
BlogsRepository.blogsLiveData.observe(this){
when(it){
is ApiResult.Error -> {
toast(it.errorMessage)
binding.blogsTxt.hide()
binding.rvBlogs.hide()
}
is ApiResult.Loading -> {
binding.blogsTxt.hide()
binding.rvBlogs.hide()
}
is ApiResult.Success -> {
it.data?.blogs?.let {blogList ->
binding.blogsTxt.show()
binding.rvBlogs.show()
blogsAdapter.submitList(blogList)
}
}
null -> {}
}
} }
} }
} }

View File

@@ -2,6 +2,7 @@ package com.woka.home.fragments
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.app.ActivityOptions
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@@ -47,8 +48,6 @@ class Home1Fragment : Fragment() {
private var star1Animator: ValueAnimator? = null private var star1Animator: ValueAnimator? = null
private var star2Animator: ValueAnimator? = null private var star2Animator: ValueAnimator? = null
private lateinit var player: ExoPlayer
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
@@ -56,7 +55,6 @@ class Home1Fragment : Fragment() {
binding = FragmentHome1Binding.inflate(inflater, container, false) binding = FragmentHome1Binding.inflate(inflater, container, false)
activity?.let { activity?.let {
viewModel = ViewModelProvider(it)[HomeViewModel::class.java] viewModel = ViewModelProvider(it)[HomeViewModel::class.java]
player = ExoPlayer.Builder(it).build()
} }
initViews() initViews()
@@ -85,8 +83,8 @@ class Home1Fragment : Fragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
handleAnimations() handleAnimations()
if (!player.isPlaying){ if (viewModel.player?.isPlaying == false){
player.play() viewModel.player?.play()
} }
binding.playerView.show() binding.playerView.show()
@@ -100,29 +98,16 @@ class Home1Fragment : Fragment() {
if (star1Animator?.isRunning == true) star1Animator?.pause() if (star1Animator?.isRunning == true) star1Animator?.pause()
if (star2Animator?.isRunning == true) star2Animator?.pause() if (star2Animator?.isRunning == true) star2Animator?.pause()
if (player.isPlaying) player.pause() if (viewModel.player?.isPlaying == true) viewModel.player?.pause()
if (viewModel.isHomeBackgroundBlurred){ if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide() binding.playerView.hide()
} }
} }
override fun onDestroy() {
super.onDestroy()
player.release()
}
private fun initPlayerView() { private fun initPlayerView() {
binding.playerView.player = player binding.playerView.player = viewModel.player
binding.playerView.useController = false binding.playerView.useController = false
player.volume = 0f
val videoUri = Uri.parse("https://d3volyx7jx7oal.cloudfront.net/master.m3u8")
val mediaItem = MediaItem.fromUri(videoUri)
player.setMediaItem(mediaItem)
player.playWhenReady = true
player.prepare()
} }
private fun setObservers() { private fun setObservers() {
@@ -169,7 +154,8 @@ class Home1Fragment : Fragment() {
more.setOnClickListener { more.setOnClickListener {
activity?.let { activity?.let {
startActivity(Intent(it, MoreHomeActivity::class.java)) startActivity(Intent(it, MoreHomeActivity::class.java),
ActivityOptions.makeSceneTransitionAnimation(it).toBundle())
} } } }
} }
} }

View File

@@ -31,8 +31,6 @@ class Home2Fragment : Fragment() {
private lateinit var viewModel: HomeViewModel private lateinit var viewModel: HomeViewModel
private lateinit var player: ExoPlayer
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
@@ -41,7 +39,6 @@ class Home2Fragment : Fragment() {
activity?.let { activity?.let {
viewModel = ViewModelProvider(it)[HomeViewModel::class.java] viewModel = ViewModelProvider(it)[HomeViewModel::class.java]
player = ExoPlayer.Builder(it).build()
} }
iniViews() iniViews()
@@ -65,8 +62,8 @@ class Home2Fragment : Fragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (!player.isPlaying){ if (viewModel.player?.isPlaying == false){
player.play() viewModel.player?.play()
} }
binding.playerView.show() binding.playerView.show()
@@ -74,32 +71,16 @@ class Home2Fragment : Fragment() {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
if (player.isPlaying) { if (viewModel.player?.isPlaying == true) viewModel.player?.pause()
player.pause()
}
if (viewModel.isHomeBackgroundBlurred){ if (viewModel.isHomeBackgroundBlurred){
binding.playerView.hide() binding.playerView.hide()
} }
} }
override fun onDestroy() {
super.onDestroy()
player.release()
}
private fun initPlayerView() { private fun initPlayerView() {
binding.playerView.player = player binding.playerView.player = viewModel.player
binding.playerView.useController = false binding.playerView.useController = false
player.volume = 0f
val videoUri = Uri.parse("https://d3volyx7jx7oal.cloudfront.net/master.m3u8")
val mediaItem = MediaItem.fromUri(videoUri)
player.setMediaItem(mediaItem)
player.playWhenReady = true
player.prepare()
} }
private fun clickEvents(){ private fun clickEvents(){

View File

@@ -0,0 +1,49 @@
package com.woka.home.sidebar
import android.graphics.Color
import android.os.Bundle
import android.transition.Fade
import android.transition.Slide
import android.view.Gravity.END
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.woka.R
import com.woka.databinding.ActivityAboutBinding
import com.woka.utils.WokaBaseActivity
import com.woka.utils.lightStatusBar
class AboutActivity : WokaBaseActivity() {
private lateinit var binding: ActivityAboutBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.enterTransition = Slide().apply {
slideEdge = END
}
enableEdgeToEdge()
binding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(binding.root)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
with(window){
lightStatusBar(true)
}
clickEvents()
}
private fun clickEvents() {
binding.apply {
backBtn.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
}
}
}

View File

@@ -1,17 +1,39 @@
package com.woka.modules package com.woka.modules
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.woka.modules.blogs.BlogsResponse import com.woka.modules.blogs.BlogsResponse
import com.woka.networking.ApiResult import com.woka.networking.ApiResult
import com.woka.networking.RetrofitHelper import com.woka.networking.RetrofitHelper
import com.woka.networking.RetrofitHelper.handleApiCall import com.woka.networking.RetrofitHelper.handleApiCall
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
object BlogsRepository{
class BlogsRepository {
private val apiService = RetrofitHelper.getRetrofit().create(ModuleApiService::class.java) private val apiService = RetrofitHelper.getRetrofit().create(ModuleApiService::class.java)
suspend fun getBlogs(): ApiResult<BlogsResponse>{ private val _blogsLiveData = MutableLiveData<ApiResult<BlogsResponse>>()
val blogsLiveData: LiveData<ApiResult<BlogsResponse>?>
get() = _blogsLiveData
init {
loadBlogs()
}
private suspend fun getBlogs(): ApiResult<BlogsResponse>{
return handleApiCall{ return handleApiCall{
apiService.getBlogs() apiService.getBlogs()
} }
} }
private fun loadBlogs(){
CoroutineScope(Dispatchers.IO).launch {
_blogsLiveData.postValue(ApiResult.Loading())
_blogsLiveData.postValue(getBlogs())
}
}
} }

View File

@@ -1,30 +0,0 @@
package com.woka.modules
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.woka.modules.blogs.BlogsResponse
import com.woka.networking.ApiResult
import kotlinx.coroutines.launch
class BlogsViewModel: ViewModel() {
private val blogsRepository = BlogsRepository()
private val _blogsLiveData = MutableLiveData<ApiResult<BlogsResponse>>()
val blogsLiveData: LiveData<ApiResult<BlogsResponse>?>
get() = _blogsLiveData
init {
loadBlogs()
}
private fun loadBlogs(){
viewModelScope.launch {
_blogsLiveData.postValue(ApiResult.Loading())
_blogsLiveData.postValue(blogsRepository.getBlogs())
}
}
}

View File

@@ -16,8 +16,8 @@ import androidx.fragment.app.Fragment
import com.woka.WokaApp.Companion.userPrefs import com.woka.WokaApp.Companion.userPrefs
import java.util.Locale import java.util.Locale
fun Window.lightStatusBar(){ fun Window.lightStatusBar(lightStatus: Boolean = false){
WindowCompat.getInsetsController(this, decorView).isAppearanceLightStatusBars = false WindowCompat.getInsetsController(this, decorView).isAppearanceLightStatusBars = lightStatus
} }
fun View.scaleAnimate(from: Float = 0.5f, to: Float = 1f, duration: Long = 500){ fun View.scaleAnimate(from: Float = 0.5f, to: Float = 1f, duration: Long = 500){

View File

@@ -1,34 +1,20 @@
package com.woka.utils package com.woka.utils
import android.content.Context import android.content.Context
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log import android.view.HapticFeedbackConstants
import android.view.MotionEvent import android.view.MotionEvent
import android.view.MotionEvent.ACTION_CANCEL import android.view.MotionEvent.ACTION_CANCEL
import android.view.MotionEvent.ACTION_DOWN import android.view.MotionEvent.ACTION_DOWN
import android.view.MotionEvent.ACTION_OUTSIDE import android.view.MotionEvent.ACTION_OUTSIDE
import android.view.MotionEvent.ACTION_SCROLL import android.view.MotionEvent.ACTION_SCROLL
import android.view.MotionEvent.ACTION_UP import android.view.MotionEvent.ACTION_UP
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ScrollView
import androidx.core.view.ScrollingView
import com.woka.R import com.woka.R
import kotlin.math.abs
class PressableCard : FrameLayout { class PressableCard : FrameLayout {
companion object {
private const val DEFAULT_SCALE_WHEN_PRESS = 0.9f
private const val DEFAULT_SCALE = 1f
private const val DEFAULT_ALPHA_WHEN_PRESS = 0.5f
private const val DEFAULT_ALPHA = 1f
private const val MIN_MOMENT_AFTER_TOUCH = 25f
}
enum class PressableType(value: Int){ enum class PressableType(value: Int){
SCALE(0), FADE(1); SCALE(0), FADE(1);
} }
@@ -48,39 +34,65 @@ class PressableCard : FrameLayout {
// attributes // attributes
private var pressType: PressableType? = PressableType.SCALE private var pressType: PressableType? = PressableType.SCALE
private var scaleFrom = 0.9f
private var scaleTo = 1f
private var alphaFrom = 0.5f
private var alphaTo = 1f
private var isHapticEnabled = false
var isPressable = true
private fun setPressType(attrs: AttributeSet?){ private fun setPressType(attrs: AttributeSet?){
val attributes = context.obtainStyledAttributes(attrs, R.styleable.PressableCard) val attributes = context.obtainStyledAttributes(attrs, R.styleable.PressableCard)
val value = attributes.getInt(R.styleable.PressableCard_pressType, 0) val value = attributes.getInt(R.styleable.PressableCard_pressType, 0)
pressType = when(value){ pressType = when(value){
1 -> PressableType.FADE 1 -> PressableType.FADE
else -> PressableType.SCALE else -> PressableType.SCALE
} }
scaleFrom = attributes.getFloat(R.styleable.PressableCard_scaleFrom, 0.9f)
scaleTo = attributes.getFloat(R.styleable.PressableCard_scaleTo, 1f)
alphaFrom = attributes.getFloat(R.styleable.PressableCard_alphaFrom, 0.5f)
alphaTo = attributes.getFloat(R.styleable.PressableCard_alphaTo, 1f)
isHapticEnabled = attributes.getBoolean(R.styleable.PressableCard_isHapticEnabled, false)
attributes.recycle() attributes.recycle()
} }
private fun refresh() { private fun refresh() {
if (isPressed) { if (isPressed) {
if (isHapticEnabled){
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
}
if (pressType == PressableType.SCALE){ if (pressType == PressableType.SCALE){
scaleX = (DEFAULT_SCALE_WHEN_PRESS) scaleX = (scaleFrom)
scaleY = (DEFAULT_SCALE_WHEN_PRESS) scaleY = (scaleFrom)
}else if (pressType == PressableType.FADE){ }else if (pressType == PressableType.FADE){
alpha = DEFAULT_ALPHA_WHEN_PRESS alpha = alphaFrom
} }
invalidate() invalidate()
return return
} }
if (isHapticEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE)
}
if (pressType == PressableType.SCALE){ if (pressType == PressableType.SCALE){
scaleX = (DEFAULT_SCALE) scaleX = (scaleTo)
scaleY = (DEFAULT_SCALE) scaleY = (scaleTo)
}else if (pressType == PressableType.FADE){ }else if (pressType == PressableType.FADE){
alpha = DEFAULT_ALPHA alpha = alphaTo
} }
invalidate() invalidate()
} }
override fun setPressed(pressed: Boolean) { override fun setPressed(pressed: Boolean) {
super.setPressed(pressed) super.setPressed(pressed)
if (!isPressable) return
refresh() refresh()
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="rectangle">
<solid android:color="#AAECFD" />
</shape>
</item>
<item
android:bottom="@dimen/_320sdp"
android:left="-100dp"
android:right="-100dp"
android:top="-280dp">
<shape
android:shape="oval">
<solid android:color="#F9F0CB" />
</shape>
</item>
</layer-list>

View File

@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/about_bg"
tools:context=".home.sidebar.AboutActivity">
<ImageView
android:id="@+id/back_btn"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:contentDescription="@string/back_btn"
android:src="@drawable/ic_arrow_back_full"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:translationZ="1dp"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
app:tint="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:translationZ="1dp"
android:text="@string/about_woka"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/black"
android:textSize="@dimen/_12ssp"
android:layout_marginStart="10dp"
app:layout_constraintStart_toEndOf="@id/back_btn"
app:layout_constraintTop_toTopOf="@id/back_btn"
app:layout_constraintBottom_toBottomOf="@id/back_btn"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:contentDescription="@string/about_woka"
android:src="@drawable/img_about"
android:translationZ="1dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/g1"
/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/g1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum"
android:fontFamily="@font/exo_2"
android:textColor="@color/black"
android:textSize="@dimen/_11ssp"
app:layout_constraintTop_toBottomOf="@id/g1"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="25dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -206,89 +206,108 @@
android:gravity="center" android:gravity="center"
> >
<androidx.cardview.widget.CardView <com.woka.utils.PressableCard
android:id="@+id/sb_theme_1" android:id="@+id/sb_theme_1"
android:layout_width="80dp" android:layout_width="wrap_content"
android:layout_height="120dp" android:layout_height="wrap_content"
app:cardCornerRadius="3dp" app:scaleFrom="0.95"
app:isHapticEnabled="true"
android:layout_marginEnd="12dp"
> >
<ImageView <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="80dp"
android:layout_height="match_parent" android:layout_height="120dp"
android:contentDescription="@string/image" app:cardCornerRadius="3dp"
android:src="@drawable/theme_1"
/>
<RelativeLayout android:layout_marginEnd="12dp"
android:id="@+id/sb_theme_1_selected"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
> >
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:contentDescription="@string/image" android:contentDescription="@string/image"
android:src="@drawable/theme_selected_tint"/> android:src="@drawable/theme_1"
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/image"
android:src="@drawable/ic_green_tick"
/> />
</RelativeLayout> <RelativeLayout
android:id="@+id/sb_theme_1_selected"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</androidx.cardview.widget.CardView> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/image"
android:src="@drawable/theme_selected_tint"/>
<androidx.cardview.widget.CardView <ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/image"
android:src="@drawable/ic_green_tick"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</com.woka.utils.PressableCard>
<com.woka.utils.PressableCard
android:id="@+id/sb_theme_2" android:id="@+id/sb_theme_2"
android:layout_width="80dp" android:layout_width="wrap_content"
android:layout_height="120dp" android:layout_height="wrap_content"
app:strokeWidth="1dp"
app:strokeColor="@color/white"
app:cardCornerRadius="3dp"
android:layout_marginStart="12dp" app:scaleFrom="0.95"
app:isHapticEnabled="true"
> >
<ImageView <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="80dp"
android:layout_height="match_parent" android:layout_height="120dp"
android:contentDescription="@string/image" app:strokeWidth="1dp"
android:src="@drawable/theme_2" app:strokeColor="@color/white"
/> app:cardCornerRadius="3dp"
<RelativeLayout android:layout_marginStart="12dp"
android:id="@+id/sb_theme_2_selected"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
> >
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:contentDescription="@string/image" android:contentDescription="@string/image"
android:src="@drawable/theme_selected_tint"/> android:src="@drawable/theme_2"
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/image"
android:src="@drawable/ic_green_tick"
/> />
</RelativeLayout> <RelativeLayout
android:id="@+id/sb_theme_2_selected"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</androidx.cardview.widget.CardView> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/image"
android:src="@drawable/theme_selected_tint"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/image"
android:src="@drawable/ic_green_tick"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</com.woka.utils.PressableCard>
</LinearLayout> </LinearLayout>
@@ -366,24 +385,28 @@
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
/> />
<TextView <com.woka.utils.PressableCard
android:id="@+id/sb_about_woka" android:id="@+id/sb_about_woka_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:pressType="fade"
>
android:text="@string/about_woka" <TextView
android:fontFamily="@font/exo_2_bold" android:id="@+id/sb_about_woka"
android:textColor="@color/white" android:layout_width="match_parent"
android:textSize="@dimen/_14ssp" android:layout_height="wrap_content"
android:paddingVertical="5dp" android:text="@string/about_woka"
android:paddingHorizontal="5dp" android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
android:clickable="true" android:paddingVertical="5dp"
android:focusable="true" android:paddingHorizontal="5dp"
/>
android:foreground="?android:attr/selectableItemBackground" </com.woka.utils.PressableCard>
/>
<TextView <TextView
android:id="@+id/sb_faq" android:id="@+id/sb_faq"

View File

@@ -26,8 +26,6 @@
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:padding="15dp"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent">
@@ -67,6 +65,8 @@
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_marginHorizontal="15dp"
/> />
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
@@ -77,6 +77,8 @@
app:cardCornerRadius="5dp" app:cardCornerRadius="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginHorizontal="15dp"
> >
<LinearLayout <LinearLayout
@@ -143,6 +145,7 @@
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
android:id="@+id/blogs_txt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -154,6 +157,8 @@
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_marginHorizontal="15dp"
/> />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View File

@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.woka.utils.PressableCard xmlns:android="http://schemas.android.com/apk/res/android" <com.woka.utils.PressableCard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="@dimen/_150sdp"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/round_bg_5" android:background="@drawable/round_bg_5"
android:backgroundTint="@color/white" android:backgroundTint="@color/white"
android:layout_marginEnd="15dp" android:layout_marginStart="15dp"
android:layout_marginEnd="5dp"
app:pressType="scale"
app:scaleFrom="0.95"
app:scaleTo="1"
android:elevation="3dp"> android:elevation="3dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
@@ -21,7 +27,7 @@
android:layout_marginHorizontal="10dp" android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
app:cardElevation="0dp" app:cardElevation="3dp"
app:cardBackgroundColor="@color/white" app:cardBackgroundColor="@color/white"
app:cardCornerRadius="5dp"> app:cardCornerRadius="5dp">
@@ -31,16 +37,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:contentDescription="@string/image" android:contentDescription="@string/image"
android:src="@color/black" android:src="@drawable/woka_logo_half"
android:scaleType="fitXY"
/> />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="Sabak Degi Naani: The Lessons of a Wise Grandmother" tools:text="Sabak Degi Naani: The Lessons of a Wise Grandmother and this is extr"
android:fontFamily="@font/exo_2_bold" android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary" android:textColor="@color/color_primary"
@@ -50,6 +58,9 @@
android:ems="9" android:ems="9"
android:maxLines="3"
android:ellipsize="end"
/> />
</LinearLayout> </LinearLayout>

View File

@@ -556,6 +556,82 @@
/> />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="@dimen/_40sdp"
android:layout_marginHorizontal="15dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:src="@drawable/img_masila_tn_small"
android:contentDescription="@string/masila"
android:scaleType="fitXY"
/>
<com.woka.utils.PressableCard
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_25"
android:backgroundTint="@color/color_primary"
android:layout_centerInParent="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/play_trailer"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
/>
</com.woka.utils.PressableCard>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/masila"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary"
android:textSize="@dimen/_12ssp"
android:layout_marginStart="15dp"
android:layout_marginVertical="10dp"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@@ -6,6 +6,13 @@
<enum name="fade" value="1"/> <enum name="fade" value="1"/>
<enum name="scale" value="0"/> <enum name="scale" value="0"/>
</attr> </attr>
<attr name="scaleFrom" format="float"/>
<attr name="scaleTo" format="float"/>
<attr name="alphaFrom" format="float"/>
<attr name="alphaTo" format="float"/>
<attr name="isHapticEnabled" format="boolean"/>
</declare-styleable> </declare-styleable>
</resources> </resources>

View File

@@ -135,7 +135,7 @@
<string name="games">GAMES</string> <string name="games">GAMES</string>
<string name="coming_soonn_on_woka">Coming soonn on Woka</string> <string name="coming_soonn_on_woka">Coming soonn on Woka</string>
<string name="woka_live_tv">WOKA LIVE TV</string> <string name="woka_live_tv">WOKA LIVE TV</string>
<string name="blogs">BLOGS</string> <string name="blogs">Blogs</string>
<string name="masila">MASILA</string> <string name="masila">MASILA</string>
<string name="play_trailer">PLAY TRAILER</string> <string name="play_trailer">PLAY TRAILER</string>
</resources> </resources>