Api call time out setting

Completed switching between fragments on home with theme switching and language switching

Language switch live data

Home fragment background switching w.r.t. to time.

Icon settings on home fragment
This commit is contained in:
2024-05-17 20:46:40 +05:30
parent f940abe837
commit 144425adf8
72 changed files with 199 additions and 38 deletions

View File

@@ -4,18 +4,6 @@
<value>
<entry key="app">
<State>
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$PROJECT_DIR$/../.android/avd/6.7_Horizontal_Fold-in_API_34.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-05-03T09:15:20.379362Z" />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />

View File

@@ -9,6 +9,7 @@ import android.widget.TextView
import androidx.cardview.widget.CardView
import com.woka.R
import com.woka.utils.toast
import org.w3c.dom.Text
class BottomNavigation: FrameLayout {
@@ -25,7 +26,6 @@ class BottomNavigation: FrameLayout {
}
private var selectedItem = HOME
fun getSelectedTab() = selectedItem
// colors
@@ -43,6 +43,8 @@ class BottomNavigation: FrameLayout {
private var myListImg: ImageView? = null
private var myListTxt: TextView? = null
private var exploreWokaTxt: TextView? = null
init {
val view = inflate(context, R.layout.layout_bottom_nav, this)
@@ -56,6 +58,10 @@ class BottomNavigation: FrameLayout {
myListImg = view.findViewById(R.id.my_list_img_bn)
myListTxt = view.findViewById(R.id.my_list_txt_bn)
exploreWokaTxt = view.findViewById(R.id.explore_woka_txt_bn)
initTitles()
clickEvents()
}
@@ -106,6 +112,12 @@ class BottomNavigation: FrameLayout {
selectedItem = tab
}
fun initTitles(){
homeTxt?.text = context.getString(R.string.home)
myListTxt?.text = context.getString(R.string.my_list)
exploreWokaTxt?.text = context.getString(R.string.explore_woka)
}
interface OnBottomTabSelectListener{
fun onBottomTabSelected(tab: Int)
}

View File

@@ -1,10 +1,12 @@
package com.woka.home
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.WindowManager
import androidx.activity.enableEdgeToEdge
import androidx.core.content.ContextCompat
import androidx.core.view.GravityCompat
@@ -29,8 +31,11 @@ import com.woka.utils.LOCALE_ENGLISH
import com.woka.utils.LOCALE_HINDI
import com.woka.utils.TAG
import com.woka.utils.WokaBaseActivity
import com.woka.utils.changeLocale
class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>, BottomNavigation.OnBottomTabSelectListener {
class HomeActivity : WokaBaseActivity(),
Observer<ApiResult<UserDataResponse>>,
BottomNavigation.OnBottomTabSelectListener {
private lateinit var binding: ActivityHomeBinding
@@ -47,6 +52,9 @@ class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>,
insets
}
window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window?.statusBarColor = Color.parseColor("#55cffe")
viewModel = ViewModelProvider(this)[HomeViewModel::class.java]
userPrefs?.userLiveData?.observe(this, this)
@@ -70,6 +78,12 @@ class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>,
sbVersion.text = versionName
bottomNav.setOnBottomTabSelectListener(this@HomeActivity)
bottomNav.selectTab(viewModel.selectedBottomTab)
}
viewModel.localeChangeLiveData.observe(this){
// locale has changed
binding.bottomNav.initTitles()
}
selectTheme(userPrefs?.appTheme?: Theme.THEME_ONE, true)
@@ -123,8 +137,10 @@ class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>,
userPrefs?.appTheme = theme
binding.homeDrawer.closeDrawer(GravityCompat.END)
binding.bottomNav.selectTab(HOME)
if (!init) {
binding.homeDrawer.closeDrawer(GravityCompat.END)
binding.bottomNav.selectTab(HOME)
}
}
}
@@ -149,6 +165,12 @@ class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>,
}
userPrefs?.appLanguage = locale
changeLocale(locale)
if (!init){
binding.homeDrawer.closeDrawer(GravityCompat.END)
viewModel.sendLocaleChangeEvent(locale)
}
}
}
}
@@ -176,6 +198,8 @@ class HomeActivity : WokaBaseActivity(), Observer<ApiResult<UserDataResponse>>,
.commit()
}
}
viewModel.selectedBottomTab = tab
}
// observer for userdata changes

View File

@@ -1,5 +1,19 @@
package com.woka.home
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.woka.home.BottomNavigation.Companion.HOME
class HomeViewModel: ViewModel()
class HomeViewModel: ViewModel(){
var selectedBottomTab: Int = HOME
private val _localeChangeLiveData = MutableLiveData<String>()
val localeChangeLiveData: LiveData<String>
get() = _localeChangeLiveData
fun sendLocaleChangeEvent(locale: String){
_localeChangeLiveData.postValue(locale)
}
}

View File

@@ -1,24 +1,104 @@
package com.woka.home.fragments
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_TIME_TICK
import android.content.IntentFilter
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.woka.R
import com.woka.databinding.FragmentHome1Binding
import com.woka.utils.toast
import java.util.Calendar
class Home1Fragment : Fragment() {
enum class TimePeriod{
MORNING,
AFTERNOON,
EVENING,
NIGHT;
companion object{
fun getCurrentTimePeriod(): TimePeriod{
val cal = Calendar.getInstance()
val hrs = cal.get(Calendar.HOUR_OF_DAY)
return when (hrs) {
in 6..10 -> MORNING
in 11..15 -> AFTERNOON
in 16..19 -> EVENING
else -> NIGHT
}
}
}
}
private lateinit var binding: FragmentHome1Binding
private var currentBackground: TimePeriod? = null
private var minuteReceiver: BroadcastReceiver? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentHome1Binding.inflate(inflater, container, false)
updateBackground()
minuteReceiver = object : BroadcastReceiver(){
override fun onReceive(context: Context?, intent: Intent?) {
// this function is called every minute
updateBackground()
}
}
activity?.registerReceiver(minuteReceiver, IntentFilter(ACTION_TIME_TICK))
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
activity?.unregisterReceiver(minuteReceiver)
}
private fun updateBackground(){
toast("Background updated")
val timePeriod = TimePeriod.getCurrentTimePeriod()
if (currentBackground != timePeriod){
// time period has changed
activity?.let {
binding.root.background = when(timePeriod){
TimePeriod.MORNING -> {
it.window.statusBarColor = ContextCompat.getColor(it, R.color.morning_status)
ContextCompat.getDrawable(it, R.drawable.morning_bg)
}
TimePeriod.AFTERNOON -> {
it.window.statusBarColor = ContextCompat.getColor(it, R.color.afternoon_status)
ContextCompat.getDrawable(it, R.drawable.afternoon_bg)
}
TimePeriod.EVENING -> {
it.window.statusBarColor = ContextCompat.getColor(it, R.color.evening_status)
ContextCompat.getDrawable(it, R.drawable.evening_bg)
}
TimePeriod.NIGHT -> {
it.window.statusBarColor = ContextCompat.getColor(it, R.color.night_status)
ContextCompat.getDrawable(it, R.drawable.night_bg)
}
}
}
currentBackground = timePeriod
}
}
companion object {
fun newInstance() = Home1Fragment()
}

View File

@@ -18,6 +18,7 @@ import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.net.UnknownHostException
import java.util.concurrent.TimeUnit
object RetrofitHelper {
@@ -51,6 +52,8 @@ object RetrofitHelper {
chain.proceed(request.build())
})
clientBuilder.callTimeout(10, TimeUnit.SECONDS)
retrofit = Retrofit.Builder()
.baseUrl(BuildConfig.WOKA_STAGINNG_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 MiB

View File

@@ -64,14 +64,13 @@
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/color_primary"
android:fitsSystemWindows="true"
>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:layout_marginTop="40dp"
android:layout_marginTop="45dp"
android:scrollbars="none"
>

View File

@@ -1,16 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:background="@drawable/morning_bg"
tools:context=".home.fragments.Home1Fragment">
<TextView
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:layout_centerInParent="true"
/>
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp"
android:layout_marginBottom="@dimen/_100sdp"
android:layout_marginStart="@dimen/_50sdp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent">
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="128dp"
android:layout_height="105dp"
android:scaleType="fitXY"
android:src="@drawable/img_paint_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/paint"
android:textAlignment="center"
android:textColor="@color/white" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -87,6 +87,7 @@
/>
<TextView
android:id="@+id/explore_woka_txt_bn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -96,4 +96,7 @@
<string name="required">कृपया दर्ज करें</string>
<string name="boy">लड़का</string>
<string name="girl">लड़की</string>
<string name="home">घर</string>
<string name="explore_woka">वोका का अन्वेषण करें</string>
<string name="my_list">मेरी सूची</string>
</resources>

View File

@@ -9,4 +9,9 @@
<color name="age_box_color">#9909005D</color>
<color name="white_60">#99FFFFFF</color>
<color name="evening_status">#cf5278</color>
<color name="morning_status">#a3e1d3</color>
<color name="afternoon_status">#11b3fe</color>
<color name="night_status">#443682</color>
</resources>

View File

@@ -106,16 +106,17 @@
<string name="home">Home</string>
<string name="explore_woka">Explore Woka</string>
<string name="my_list">My List</string>
<string name="logout">Logout</string>
<string name="theme">THEME</string>
<string name="about_woka">About WOKA</string>
<string name="faqs">FAQs</string>
<string name="woka_support">WOKA Support</string>
<string name="my_profile">My Profile</string>
<string name="my_orders">My Orders</string>
<string name="de_activate_account">De-activate Account</string>
<string name="terms_conditions"><![CDATA[Terms & Conditions]]></string>
<string name="privacy_policy"><![CDATA[Privacy & Policy]]></string>
<string name="disclaimer">Disclaimer</string>
<string name="woka_creations_private_ltd">WOKA CREATIONS PVT LTD</string>
<string name="logout" translatable="false">Logout</string>
<string name="theme" translatable="false">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>
<string name="my_profile" translatable="false">My Profile</string>
<string name="my_orders" translatable="false">My Orders</string>
<string name="de_activate_account" translatable="false">De-activate Account</string>
<string name="terms_conditions" translatable="false"><![CDATA[Terms & Conditions]]></string>
<string name="privacy_policy" translatable="false"><![CDATA[Privacy & Policy]]></string>
<string name="disclaimer" translatable="false">Disclaimer</string>
<string name="woka_creations_private_ltd" translatable="false">WOKA CREATIONS PVT LTD</string>
<string name="paint">PAINT</string>
</resources>