Issue related to animations on home theme 1 fragment
Scaling animation on press of view Hindi texts for sidebar Differentiating side bar between signed in and guest user logout api integration guest api integration on login page completed flow of login and logout from inside screens
@@ -32,19 +32,30 @@ import com.woka.home.fragments.Home2Fragment
|
||||
import com.woka.home.fragments.MyListFragment
|
||||
import com.woka.mvvm.userDataModels.UserDataResponse
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.onboard.OnboardActivity
|
||||
import com.woka.onboard.OnboardActivity.Companion.LOG_IN_INTENT
|
||||
import com.woka.onboard.OnboardActivity.Companion.ONBOARD_ACTIVITY_INTENT
|
||||
import com.woka.utils.DecisionDialog
|
||||
import com.woka.utils.LOCALE_ENGLISH
|
||||
import com.woka.utils.LOCALE_HINDI
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.TAG
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.changeLocale
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.toast
|
||||
|
||||
class HomeActivity : WokaBaseActivity(),
|
||||
Observer<ApiResult<UserDataResponse>>,
|
||||
Observer<ApiResult<UserDataResponse>?>,
|
||||
BottomNavigation.OnBottomTabSelectListener {
|
||||
|
||||
private lateinit var binding: ActivityHomeBinding
|
||||
|
||||
private lateinit var viewModel: HomeViewModel
|
||||
private lateinit var progressView: ProgressView
|
||||
private lateinit var decisionDialog: DecisionDialog
|
||||
|
||||
private var minuteReceiver: BroadcastReceiver? = null
|
||||
private var currentBackground: TimePeriod? = null
|
||||
@@ -66,9 +77,32 @@ class HomeActivity : WokaBaseActivity(),
|
||||
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = false
|
||||
|
||||
viewModel = ViewModelProvider(this)[HomeViewModel::class.java]
|
||||
progressView = ProgressView(this)
|
||||
decisionDialog = DecisionDialog(this)
|
||||
|
||||
userPrefs?.userLiveData?.observe(this, this)
|
||||
|
||||
viewModel.logoutLiveData.observe(this){
|
||||
when(it){
|
||||
is ApiResult.Error -> {
|
||||
progressView.hide()
|
||||
toast(it.errorMessage)
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
progressView.show(getString(R.string.logging_you_out))
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
startActivity(Intent(this, OnboardActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
finish()
|
||||
|
||||
userPrefs?.logout()
|
||||
}
|
||||
null -> {}
|
||||
}
|
||||
}
|
||||
|
||||
minuteReceiver = object : BroadcastReceiver(){
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
// this function is called every minute
|
||||
@@ -83,6 +117,10 @@ class HomeActivity : WokaBaseActivity(),
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
if (userPrefs?.userLiveData?.isInitialized == false){
|
||||
userPrefs?.loadUserData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
@@ -105,11 +143,43 @@ class HomeActivity : WokaBaseActivity(),
|
||||
|
||||
bottomNav.setOnBottomTabSelectListener(this@HomeActivity)
|
||||
bottomNav.selectTab(viewModel.selectedBottomTab)
|
||||
|
||||
sbBtn.text = if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE){
|
||||
|
||||
// hiding menu options
|
||||
sbDeActivateAccount.hide()
|
||||
sbMyOrders.hide()
|
||||
sbMyProfile.hide()
|
||||
|
||||
notifications.hide()
|
||||
|
||||
getString(R.string.login_register)
|
||||
}else{
|
||||
// hiding menu options
|
||||
sbDeActivateAccount.show()
|
||||
sbMyOrders.show()
|
||||
sbMyProfile.show()
|
||||
|
||||
notifications.show()
|
||||
|
||||
getString(R.string.logout)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.localeChangeLiveData.observe(this){
|
||||
// locale has changed
|
||||
binding.bottomNav.initTitles()
|
||||
binding.apply {
|
||||
bottomNav.initTitles()
|
||||
themeTxt.text = getString(R.string.theme)
|
||||
helloTxt.text = getString(R.string.hello)
|
||||
sbBtn.text = getString(R.string.logout)
|
||||
|
||||
sbBtn.text = if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE){
|
||||
getString(R.string.login_register)
|
||||
}else{
|
||||
getString(R.string.logout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectTheme(userPrefs?.appTheme?: Theme.THEME_ONE, true)
|
||||
@@ -142,6 +212,26 @@ class HomeActivity : WokaBaseActivity(),
|
||||
sbHindi.setOnClickListener {
|
||||
selectLanguage(LOCALE_HINDI)
|
||||
}
|
||||
|
||||
sbBtn.setOnClickListener {
|
||||
if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE){
|
||||
// guest or none user
|
||||
startActivity(Intent(this@HomeActivity, OnboardActivity::class.java).apply {
|
||||
putExtra(ONBOARD_ACTIVITY_INTENT, LOG_IN_INTENT)
|
||||
})
|
||||
}else{
|
||||
// signing out user
|
||||
decisionDialog.apply {
|
||||
title = getString(R.string.woka)
|
||||
message = getString(R.string.do_you_want_to_log_out)
|
||||
setPositiveButton(getString(R.string.yes)){
|
||||
viewModel.logout()
|
||||
}
|
||||
setNegativeButton(getString(R.string.no))
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +324,8 @@ class HomeActivity : WokaBaseActivity(),
|
||||
when(binding.bottomNav.getSelectedTab()){
|
||||
HOME -> {
|
||||
if (userPrefs?.appTheme == Theme.THEME_ONE){
|
||||
binding.root.backgroundTintList = null
|
||||
|
||||
val timePeriod = TimePeriod.getCurrentTimePeriod()
|
||||
if (currentBackground != timePeriod){
|
||||
// time period has changed
|
||||
@@ -262,7 +354,7 @@ class HomeActivity : WokaBaseActivity(),
|
||||
}
|
||||
|
||||
// observer for userdata changes
|
||||
override fun onChanged(value: ApiResult<UserDataResponse>) {
|
||||
override fun onChanged(value: ApiResult<UserDataResponse>?) {
|
||||
when(value){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
@@ -279,11 +371,20 @@ class HomeActivity : WokaBaseActivity(),
|
||||
.into(sbUserImage)
|
||||
}
|
||||
|
||||
sbUserName.text = it.fullname
|
||||
val name = if (userPrefs?.userType == UserType.GUEST) userPrefs?.guestUserName
|
||||
else it.fullname
|
||||
|
||||
if (!name.isNullOrEmpty()) {
|
||||
val text = ", ${name.split(" ")[0]}"
|
||||
sbUserName.text = text
|
||||
}
|
||||
|
||||
sbBtn.text = getString(R.string.logout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
null -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,36 @@ package com.woka.home
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.woka.home.BottomNavigation.Companion.HOME
|
||||
import com.woka.mvvm.UserApiService
|
||||
import com.woka.mvvm.UserRepository
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.networking.RetrofitHelper
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class HomeViewModel: ViewModel(){
|
||||
|
||||
private val userRepository = UserRepository(RetrofitHelper.getRetrofit().create(UserApiService::class.java))
|
||||
|
||||
var selectedBottomTab: Int = HOME
|
||||
|
||||
private val _localeChangeLiveData = MutableLiveData<String>()
|
||||
val localeChangeLiveData: LiveData<String>
|
||||
get() = _localeChangeLiveData
|
||||
|
||||
private val _logoutLiveData = MutableLiveData<ApiResult<Any>?>()
|
||||
val logoutLiveData: LiveData<ApiResult<Any>?>
|
||||
get() = _logoutLiveData
|
||||
|
||||
fun sendLocaleChangeEvent(locale: String){
|
||||
_localeChangeLiveData.postValue(locale)
|
||||
}
|
||||
|
||||
fun logout(){
|
||||
viewModelScope.launch {
|
||||
_logoutLiveData.postValue(ApiResult.Loading())
|
||||
_logoutLiveData.postValue(userRepository.logout())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,13 @@ class PressableImageView : AppCompatImageView {
|
||||
|
||||
private fun refresh() {
|
||||
if (isPressed) {
|
||||
setAlpha(DEFAULT_ALPHA_WHEN_PRESS)
|
||||
scaleX = (DEFAULT_SCALE_WHEN_PRESS)
|
||||
scaleY = (DEFAULT_SCALE_WHEN_PRESS)
|
||||
invalidate()
|
||||
return
|
||||
}
|
||||
setAlpha(DEFAULT_ALPHA)
|
||||
scaleX = (DEFAULT_SCALE)
|
||||
scaleY = (DEFAULT_SCALE)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ class PressableImageView : AppCompatImageView {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_ALPHA_WHEN_PRESS = 0.5f
|
||||
private const val DEFAULT_ALPHA = 1f
|
||||
private const val DEFAULT_SCALE_WHEN_PRESS = 0.9f
|
||||
private const val DEFAULT_SCALE = 1f
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.woka.home.fragments
|
||||
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.BroadcastReceiver
|
||||
@@ -22,10 +23,12 @@ import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.FragmentHome1Binding
|
||||
import com.woka.home.HomeViewModel
|
||||
import com.woka.home.TimePeriod
|
||||
import com.woka.mvvm.userDataModels.UserData
|
||||
import com.woka.mvvm.userDataModels.UserDataResponse
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.scaleAnimate
|
||||
import com.woka.utils.show
|
||||
|
||||
class Home1Fragment : Fragment() {
|
||||
|
||||
@@ -44,12 +47,14 @@ class Home1Fragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
binding = FragmentHome1Binding.inflate(inflater, container, false)
|
||||
activity?.let {
|
||||
viewModel = ViewModelProvider(it)[HomeViewModel::class.java]
|
||||
}
|
||||
|
||||
handleScaleAnimations()
|
||||
|
||||
updateBackground()
|
||||
|
||||
minuteReceiver = object : BroadcastReceiver() {
|
||||
@@ -76,11 +81,11 @@ class Home1Fragment : Fragment() {
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
tvAnimator?.pause()
|
||||
cloud1Animator?.pause()
|
||||
cloud2Animator?.pause()
|
||||
star1Animator?.pause()
|
||||
star2Animator?.pause()
|
||||
if (tvAnimator?.isRunning == true) tvAnimator?.pause()
|
||||
if (cloud1Animator?.isRunning == true) cloud1Animator?.pause()
|
||||
if (cloud2Animator?.isRunning == true) cloud2Animator?.pause()
|
||||
if (star1Animator?.isRunning == true) star1Animator?.pause()
|
||||
if (star2Animator?.isRunning == true) star2Animator?.pause()
|
||||
}
|
||||
|
||||
private fun setObservers() {
|
||||
@@ -122,9 +127,39 @@ class Home1Fragment : Fragment() {
|
||||
binding.apply {
|
||||
val name = if (userPrefs?.userType == UserType.GUEST) userPrefs?.guestUserName
|
||||
else data?.result?.fullname
|
||||
val text = ", $name"
|
||||
|
||||
userName.text = text
|
||||
if (!name.isNullOrEmpty()) {
|
||||
val text = ", ${name.split(" ")[0]}"
|
||||
userName.text = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleScaleAnimations(){
|
||||
binding.apply {
|
||||
webSeriesLl.post {
|
||||
webSeriesLl.scaleAnimate()
|
||||
}
|
||||
|
||||
liveTvLl.post {
|
||||
liveTvLl.scaleAnimate()
|
||||
}
|
||||
|
||||
shopLl.post {
|
||||
shopLl.scaleAnimate()
|
||||
}
|
||||
|
||||
karaokeLl.post {
|
||||
karaokeLl.scaleAnimate()
|
||||
}
|
||||
|
||||
audioBooksLl.post {
|
||||
audioBooksLl.scaleAnimate()
|
||||
}
|
||||
|
||||
playLl.post {
|
||||
playLl.scaleAnimate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +179,7 @@ class Home1Fragment : Fragment() {
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (tvAnimator?.isPaused == true){
|
||||
tvAnimator?.resume()
|
||||
}
|
||||
|
||||
@@ -163,7 +198,7 @@ class Home1Fragment : Fragment() {
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (cloud1Animator?.isPaused == true){
|
||||
cloud1Animator?.resume()
|
||||
}
|
||||
|
||||
@@ -182,10 +217,14 @@ class Home1Fragment : Fragment() {
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (cloud2Animator?.isPaused == true) {
|
||||
cloud2Animator?.resume()
|
||||
}
|
||||
|
||||
handleNightAnimations()
|
||||
}
|
||||
|
||||
private fun handleNightAnimations(){
|
||||
if (currentBackground == TimePeriod.NIGHT && star1Animator == null) {
|
||||
binding.star1.post {
|
||||
star1Animator = ObjectAnimator.ofFloat(binding.star1, "alpha", 0.3f, 1f).apply {
|
||||
@@ -195,7 +234,7 @@ class Home1Fragment : Fragment() {
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (star1Animator?.isPaused == true){
|
||||
star1Animator?.resume()
|
||||
}
|
||||
|
||||
@@ -208,7 +247,7 @@ class Home1Fragment : Fragment() {
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (star2Animator?.isPaused == true) {
|
||||
star2Animator?.resume()
|
||||
}
|
||||
}
|
||||
@@ -240,9 +279,9 @@ class Home1Fragment : Fragment() {
|
||||
)
|
||||
)
|
||||
|
||||
binding.star1.visibility = GONE
|
||||
binding.star2.visibility = GONE
|
||||
binding.moon.visibility = GONE
|
||||
binding.star1.hide()
|
||||
binding.star2.hide()
|
||||
binding.moon.hide()
|
||||
|
||||
binding.grass.setImageResource(R.drawable.img_grass_d)
|
||||
}
|
||||
@@ -268,9 +307,9 @@ class Home1Fragment : Fragment() {
|
||||
)
|
||||
)
|
||||
|
||||
binding.star1.visibility = GONE
|
||||
binding.star2.visibility = GONE
|
||||
binding.moon.visibility = GONE
|
||||
binding.star1.hide()
|
||||
binding.star2.hide()
|
||||
binding.moon.hide()
|
||||
|
||||
binding.grass.setImageResource(R.drawable.img_grass_d)
|
||||
}
|
||||
@@ -281,9 +320,9 @@ class Home1Fragment : Fragment() {
|
||||
binding.welcomeText.setTextColor(ContextCompat.getColor(it, R.color.white))
|
||||
binding.helloTxt.setTextColor(ContextCompat.getColor(it, R.color.white))
|
||||
|
||||
binding.star1.visibility = GONE
|
||||
binding.star2.visibility = GONE
|
||||
binding.moon.visibility = GONE
|
||||
binding.star1.hide()
|
||||
binding.star2.hide()
|
||||
binding.moon.hide()
|
||||
|
||||
binding.grass.setImageResource(R.drawable.img_grass_d)
|
||||
}
|
||||
@@ -294,12 +333,12 @@ class Home1Fragment : Fragment() {
|
||||
binding.welcomeText.setTextColor(ContextCompat.getColor(it, R.color.white))
|
||||
binding.helloTxt.setTextColor(ContextCompat.getColor(it, R.color.white))
|
||||
|
||||
binding.star1.visibility = VISIBLE
|
||||
binding.star2.visibility = VISIBLE
|
||||
binding.moon.visibility = VISIBLE
|
||||
binding.star1.show()
|
||||
binding.star2.show()
|
||||
binding.moon.show()
|
||||
|
||||
currentBackground = timePeriod
|
||||
handleAnimations()
|
||||
handleNightAnimations()
|
||||
|
||||
binding.grass.setImageResource(R.drawable.img_grass_n)
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ interface UserApiService {
|
||||
|
||||
@GET("get_user_data")
|
||||
suspend fun getUserData(): Response<ApiResponse<UserDataResponse>>
|
||||
|
||||
@GET("user_logout")
|
||||
suspend fun logout(): Response<ApiResponse<Any>>
|
||||
}
|
||||
@@ -11,4 +11,10 @@ class UserRepository(private val userApiService: UserApiService) {
|
||||
userApiService.getUserData()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun logout(): ApiResult<Any>{
|
||||
return handleApiCall {
|
||||
userApiService.logout()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ data class UserData(
|
||||
val child_detail: ChildDetail?,
|
||||
val email: String?,
|
||||
val fullname: String?,
|
||||
val gender: String?,
|
||||
// val gender: Gender?,
|
||||
val id: Int?,
|
||||
val is_active: String?,
|
||||
val language: Language?,
|
||||
|
||||
@@ -2,6 +2,6 @@ package com.woka.mvvm.userDataModels
|
||||
|
||||
data class UserDataResponse(
|
||||
val result: UserData?,
|
||||
val userNotificationData: UserNotificationData?,
|
||||
// val userNotificationData: UserNotificationData?,
|
||||
val userNotificationsCount: Int?
|
||||
)
|
||||
@@ -12,6 +12,12 @@ import com.woka.utils.WokaBaseActivity
|
||||
|
||||
class OnboardActivity : WokaBaseActivity() {
|
||||
|
||||
companion object {
|
||||
const val ONBOARD_ACTIVITY_INTENT = "onboard_act_intent"
|
||||
|
||||
const val LOG_IN_INTENT = "login_intent"
|
||||
}
|
||||
|
||||
private var player: MediaPlayer? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -24,12 +30,17 @@ class OnboardActivity : WokaBaseActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
// val hostFragment = supportFragmentManager.findFragmentById(R.id.fc_onboard) as NavHostFragment
|
||||
// hostFragment.navController.navigate(R.id.action_onboardFragment_to_signInFragment,
|
||||
// null,
|
||||
// NavOptions.Builder()
|
||||
// .setPopUpTo(R.id.onboardFragment, true)
|
||||
// .build())
|
||||
if (intent.getStringExtra(ONBOARD_ACTIVITY_INTENT) == LOG_IN_INTENT) {
|
||||
val hostFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.fc_onboard) as NavHostFragment
|
||||
hostFragment.navController.navigate(
|
||||
R.id.action_onboardFragment_to_signInFragment,
|
||||
null,
|
||||
NavOptions.Builder()
|
||||
.setPopUpTo(R.id.onboardFragment, true)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
player = MediaPlayer.create(this, R.raw.audiotwo)
|
||||
player?.isLooping = true
|
||||
|
||||
@@ -143,6 +143,8 @@ class SelectAvatarFragment : Fragment() {
|
||||
userPrefs?.accessToken = result.remember_token?:"no_token_received"
|
||||
userPrefs?.userType = UserType.createUserType(result.user_type)
|
||||
|
||||
userPrefs?.loadUserData()
|
||||
|
||||
startActivity(Intent(activity, HomeActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
|
||||
@@ -109,8 +109,44 @@ class SignInFragment : Fragment() {
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
progressView.hide()
|
||||
toast(it.message)
|
||||
gotoHomeActivity()
|
||||
it.data?.result?.let {data->
|
||||
toast(it.message)
|
||||
|
||||
// saving to user prefs
|
||||
userPrefs?.accessToken = data.remember_token?:"no_value_received"
|
||||
userPrefs?.userType = UserType.createUserType(data.user_type)
|
||||
|
||||
gotoHomeActivity()
|
||||
}
|
||||
}
|
||||
null -> {}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.guestLogin.observe(viewLifecycleOwner){
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
progressView.hide()
|
||||
toast(it.errorMessage)
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
progressView.show()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
progressView.hide()
|
||||
it.data?.let {data ->
|
||||
toast(it.message)
|
||||
|
||||
userPrefs?.userType = UserType.GUEST
|
||||
userPrefs?.guestUserName = data.fullname
|
||||
|
||||
activity?.let { activity->
|
||||
startActivity(Intent(activity, HomeActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
activity.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
null -> {}
|
||||
}
|
||||
@@ -120,6 +156,7 @@ class SignInFragment : Fragment() {
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
viewModel.clearLoginLiveData()
|
||||
viewModel.clearGuestLoginData()
|
||||
}
|
||||
|
||||
private fun clickEvents() {
|
||||
@@ -135,6 +172,18 @@ class SignInFragment : Fragment() {
|
||||
activity?.onBackPressedDispatcher?.onBackPressed()
|
||||
}
|
||||
|
||||
continueAsGuest.setOnClickListener {
|
||||
if (userPrefs?.guestUserName == null){
|
||||
// no guest available
|
||||
viewModel.guestLogin()
|
||||
}else{
|
||||
startActivity(Intent(activity, HomeActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
})
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
createAccount.setOnClickListener {
|
||||
findNavController().navigate(R.id.action_signInFragment_to_age_select_fragment)
|
||||
}
|
||||
@@ -158,6 +207,9 @@ class SignInFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun gotoHomeActivity(){
|
||||
|
||||
userPrefs?.loadUserData()
|
||||
|
||||
activity?.let { activity->
|
||||
startActivity(Intent(activity, HomeActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
|
||||
@@ -30,7 +30,7 @@ import kotlinx.coroutines.launch
|
||||
/*
|
||||
Root fragment to the launcher activity i.e. WelcomeActivity
|
||||
*/
|
||||
class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
|
||||
class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>?> {
|
||||
|
||||
private lateinit var binding: FragmentSplashBinding
|
||||
|
||||
@@ -113,7 +113,7 @@ class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChanged(value: ApiResult<UserDataResponse>) {
|
||||
override fun onChanged(value: ApiResult<UserDataResponse>?) {
|
||||
// on user data loaded
|
||||
when (value){
|
||||
is ApiResult.Error -> {
|
||||
@@ -123,6 +123,8 @@ class SplashFragment : Fragment(), Observer<ApiResult<UserDataResponse>> {
|
||||
is ApiResult.Success -> {
|
||||
goForward()
|
||||
}
|
||||
|
||||
null -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,8 +59,8 @@ class UserPreference(context: Context) {
|
||||
private val userRepository =
|
||||
UserRepository(RetrofitHelper.getRetrofit().create(UserApiService::class.java))
|
||||
|
||||
private val _userLiveData = MutableLiveData<ApiResult<UserDataResponse>>()
|
||||
val userLiveData: LiveData<ApiResult<UserDataResponse>>
|
||||
private val _userLiveData = MutableLiveData<ApiResult<UserDataResponse>?>()
|
||||
val userLiveData: LiveData<ApiResult<UserDataResponse>?>
|
||||
get() = _userLiveData
|
||||
|
||||
fun loadUserData() {
|
||||
@@ -69,4 +69,10 @@ class UserPreference(context: Context) {
|
||||
_userLiveData.postValue(userRepository.getUserData())
|
||||
}
|
||||
}
|
||||
|
||||
fun logout(){
|
||||
accessToken = null
|
||||
userType = if (guestUserName == null) UserType.NONE else UserType.GUEST
|
||||
_userLiveData.postValue(null)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.woka.utils
|
||||
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
@@ -12,6 +14,18 @@ import androidx.fragment.app.Fragment
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import java.util.Locale
|
||||
|
||||
fun View.scaleAnimate(from: Float = 0.5f, to: Float = 1f, duration: Long = 500){
|
||||
val animationSet = AnimatorSet()
|
||||
|
||||
val scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", from, to)
|
||||
val scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", from, to)
|
||||
|
||||
animationSet.apply {
|
||||
playTogether(scaleXAnimator, scaleYAnimator)
|
||||
setDuration(duration)
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
fun View.show(){
|
||||
this.visibility = VISIBLE
|
||||
|
||||
|
Before Width: | Height: | Size: 8.2 KiB |
BIN
app/src/main/res/drawable-hdpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
app/src/main/res/drawable-hdpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/drawable-ldpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/main/res/drawable-ldpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/drawable-mdpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
app/src/main/res/drawable-mdpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
BIN
app/src/main/res/drawable-xhdpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
app/src/main/res/drawable-xhdpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 23 KiB |
BIN
app/src/main/res/drawable-xxhdpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable-xxhdpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 37 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/img_notification.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/img_woka_w.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
@@ -16,6 +16,25 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.woka.home.PressableImageView
|
||||
android:id="@+id/notifications"
|
||||
android:visibility="visible"
|
||||
android:layout_width="@dimen/_35sdp"
|
||||
android:layout_height="@dimen/_35sdp"
|
||||
|
||||
app:layout_constraintEnd_toStartOf="@id/side_menu"
|
||||
app:layout_constraintBottom_toBottomOf="@id/side_menu"
|
||||
app:layout_constraintTop_toTopOf="@id/side_menu"
|
||||
|
||||
android:layout_margin="15dp"
|
||||
|
||||
android:elevation="5dp"
|
||||
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/img_notification"
|
||||
android:scaleType="fitXY"
|
||||
/>
|
||||
|
||||
<com.woka.home.PressableImageView
|
||||
android:id="@+id/side_menu"
|
||||
android:layout_width="@dimen/_35sdp"
|
||||
@@ -30,6 +49,7 @@
|
||||
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_menu"
|
||||
android:scaleType="fitXY"
|
||||
/>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
@@ -37,6 +57,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
android:layout_marginBottom="-15dp"
|
||||
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_nav"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
@@ -95,25 +117,49 @@
|
||||
android:layout_marginTop="15dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_user_name"
|
||||
<LinearLayout
|
||||
android:id="@+id/user_name_LL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="Aditya Gaikwad"
|
||||
android:textColor="@color/white"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
android:textAlignment="center"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
<TextView
|
||||
android:id="@+id/hello_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/hello"
|
||||
android:layout_marginTop="3dp"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
|
||||
/>
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_user_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text=", Aditya"
|
||||
android:layout_marginTop="3dp"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/sb_btn"
|
||||
@@ -135,6 +181,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/theme_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -319,6 +366,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_about_woka"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -337,6 +385,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_faq"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -355,6 +404,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_woka_support"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -373,6 +423,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_my_profile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -393,6 +444,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_my_orders"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -413,6 +465,7 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb_de_activate_account"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
|
||||
@@ -261,11 +261,14 @@
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:id="@+id/web_series_ll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
@@ -301,11 +304,13 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout2"
|
||||
android:id="@+id/live_tv_ll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleY="0.5"
|
||||
android:scaleX="0.5"
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
@@ -342,11 +347,13 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout3"
|
||||
android:id="@+id/shop_ll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleY="0.5"
|
||||
android:scaleX="0.5"
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
@@ -388,6 +395,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleY="0.5"
|
||||
android:scaleX="0.5"
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
@@ -424,11 +433,13 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout5"
|
||||
android:id="@+id/audio_books_ll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleY="0.5"
|
||||
android:scaleX="0.5"
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
@@ -470,6 +481,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:scaleY="0.5"
|
||||
android:scaleX="0.5"
|
||||
android:translationZ="2dp"
|
||||
|
||||
android:orientation="vertical"
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
android:layout_width="@dimen/_25sdp"
|
||||
android:layout_height="@dimen/_15sdp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_woka"
|
||||
android:src="@drawable/img_woka_w"
|
||||
android:scaleType="fitXY"
|
||||
/>
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
android:textColor="@color/color_primary"
|
||||
tools:text="This is message that will be shown as subtitle"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@
|
||||
<string name="home">घर</string>
|
||||
<string name="explore_woka">वोका का अन्वेषण करें</string>
|
||||
<string name="my_list">मेरी सूची</string>
|
||||
<string name="logout">लॉग आउट</string>
|
||||
<string name="theme">थीम</string>
|
||||
<string name="hello">नमस्ते</string>
|
||||
<string name="web_series">वेब सीरीज</string>
|
||||
<string name="audio_books">ऑडियो-किताबें</string>
|
||||
@@ -108,4 +110,7 @@
|
||||
<string name="more">और</string>
|
||||
<string name="live_tv">लाइव टीवी</string>
|
||||
<string name="welcome_to_wokaland">वोकलैंड में आपका स्वागत है</string>
|
||||
<string name="login_register">लॉगइन / रजिस्टर करें</string>
|
||||
<string name="logging_you_out">लॉग आउट कर रहे हैं</string>
|
||||
<string name="do_you_want_to_log_out">क्या आप Woka ऐप से लॉग आउट करना चाहते हैं?</string>
|
||||
</resources>
|
||||
@@ -106,8 +106,8 @@
|
||||
<string name="home">Home</string>
|
||||
<string name="explore_woka">Explore Woka</string>
|
||||
<string name="my_list">My List</string>
|
||||
<string name="logout" translatable="false">Logout</string>
|
||||
<string name="theme" translatable="false">THEME</string>
|
||||
<string name="logout">Logout</string>
|
||||
<string name="theme">THEME</string>
|
||||
<string name="about_woka" translatable="false">About WOKA</string>
|
||||
<string name="faqs" translatable="false">FAQs</string>
|
||||
<string name="woka_support" translatable="false">WOKA Support</string>
|
||||
@@ -127,4 +127,8 @@
|
||||
<string name="more">MORE</string>
|
||||
<string name="live_tv">LIVE TV</string>
|
||||
<string name="welcome_to_wokaland">Welcome to WOKALAND</string>
|
||||
<string name="login_register">Login / Register</string>
|
||||
<string name="logging_you_out">Logging you out</string>
|
||||
<string name="woka" translatable="false">Woka</string>
|
||||
<string name="do_you_want_to_log_out">Do you want to log out of Woka app?</string>
|
||||
</resources>
|
||||