Home Fragment theme 1:

PressableImageView class setup
icons setup: made dynamic with screen size changes
tv view
moving tv view
other ui: more button, woka fm, user details
This commit is contained in:
2024-05-24 20:54:42 +05:30
parent 144425adf8
commit 9522c9ab16
43 changed files with 489 additions and 80 deletions

View File

@@ -1,35 +0,0 @@
package com.woka.home
import android.content.Context
import android.graphics.Bitmap
import android.renderscript.Allocation
import android.renderscript.Element
import android.renderscript.RenderScript
import android.renderscript.ScriptIntrinsicBlur
class BlurBackground {
companion object {
private const val BITMAP_SCALE = 0.4f
private const val BLUR_RADIUS = 7.5f
fun blur(context: Context, image: Bitmap): Bitmap {
val width = (image.width * BITMAP_SCALE).toInt()
val height = (image.height * BITMAP_SCALE).toInt()
val inputBitmap = Bitmap.createScaledBitmap(image, width, height, false)
val outputBitmap = Bitmap.createBitmap(inputBitmap)
val rs = RenderScript.create(context)
val script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs))
val tmpIn = Allocation.createFromBitmap(rs, inputBitmap)
val tmpOut = Allocation.createFromBitmap(rs, outputBitmap)
script.setRadius(BLUR_RADIUS)
script.setInput(tmpIn)
script.forEach(tmpOut)
tmpOut.copyTo(outputBitmap)
return outputBitmap
}
}
}

View File

@@ -0,0 +1,56 @@
package com.woka.home
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatImageView
class PressableImageView : AppCompatImageView {
constructor(context: Context?) : super(context!!)
constructor(context: Context?, attrs: AttributeSet?) : super(
context!!, attrs
)
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
context!!, attrs, defStyle
)
private fun refresh() {
if (isPressed) {
setAlpha(DEFAULT_ALPHA_WHEN_PRESS)
invalidate()
return
}
setAlpha(DEFAULT_ALPHA)
invalidate()
}
override fun setPressed(pressed: Boolean) {
super.setPressed(pressed)
refresh()
}
override fun onTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_DOWN) {
setPressed(true)
} else if (event.action == MotionEvent.ACTION_UP) {
setPressed(false)
val x = event.x
val y = event.y
val isInside = x > 0 && x < width && y > 0 && y < height
if (isInside) {
performClick()
}
}
return true
}
override fun performClick(): Boolean {
return super.performClick()
}
companion object {
private const val DEFAULT_ALPHA_WHEN_PRESS = 0.5f
private const val DEFAULT_ALPHA = 1f
}
}

View File

@@ -1,11 +1,14 @@
package com.woka.home.fragments
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
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.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -44,6 +47,8 @@ class Home1Fragment : Fragment() {
private var currentBackground: TimePeriod? = null
private var minuteReceiver: BroadcastReceiver? = null
private var valueAnimator: ValueAnimator? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -55,15 +60,47 @@ class Home1Fragment : Fragment() {
minuteReceiver = object : BroadcastReceiver(){
override fun onReceive(context: Context?, intent: Intent?) {
// this function is called every minute
updateBackground()
if (intent?.action == ACTION_TIME_TICK){
updateBackground()
}
}
}
activity?.registerReceiver(minuteReceiver, IntentFilter(ACTION_TIME_TICK))
clickEvents()
return binding.root
}
override fun onResume() {
super.onResume()
if (valueAnimator == null) {
binding.tvView.post {
val endMargin: Float = 25f * (resources.displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)
valueAnimator = ObjectAnimator.ofFloat(binding.tvView, "translationX", resources.displayMetrics.widthPixels - binding.tvView.width - (2 * endMargin)).apply {
duration = 12000
repeatCount = ValueAnimator.INFINITE
repeatMode = ValueAnimator.REVERSE
start()
}
}
} else {
valueAnimator?.resume()
}
}
override fun onPause() {
super.onPause()
valueAnimator?.pause()
}
private fun clickEvents() {
binding.apply {
}
}
override fun onDestroyView() {
super.onDestroyView()
activity?.unregisterReceiver(minuteReceiver)
@@ -89,6 +126,10 @@ class Home1Fragment : Fragment() {
ContextCompat.getDrawable(it, R.drawable.evening_bg)
}
TimePeriod.NIGHT -> {
// text colors
binding.userName.setTextColor(ContextCompat.getColor(it, R.color.white))
binding.welcomeText.setTextColor(ContextCompat.getColor(it, R.color.white))
it.window.statusBarColor = ContextCompat.getColor(it, R.color.night_status)
ContextCompat.getDrawable(it, R.drawable.night_bg)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

View File

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

View File

Before

Width:  |  Height:  |  Size: 287 KiB

After

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M12.5,0C5.602,0 0,5.602 0,12.5C0,19.397 5.602,25 12.5,25C19.397,25 25,19.397 25,12.5C25,5.602 19.397,0 12.5,0ZM12.5,1.087C18.809,1.087 23.913,6.191 23.913,12.5C23.913,18.809 18.809,23.913 12.5,23.913C6.191,23.913 1.087,18.809 1.087,12.5C1.087,6.191 6.191,1.087 12.5,1.087ZM6.946,10.326C6.968,10.32 6.991,10.313 7.014,10.309C7.18,10.296 7.343,10.358 7.456,10.479L12.5,15.523L17.544,10.479C17.761,10.262 18.109,10.262 18.325,10.479C18.542,10.696 18.542,11.044 18.325,11.26L12.891,16.695C12.789,16.801 12.646,16.861 12.5,16.861C12.354,16.861 12.211,16.801 12.109,16.695L6.675,11.26C6.524,11.12 6.464,10.908 6.522,10.708C6.579,10.511 6.743,10.362 6.946,10.326Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>

View File

@@ -14,31 +14,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
<com.woka.home.PressableImageView
android:id="@+id/side_menu"
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_40sdp"
android:layout_width="@dimen/_35sdp"
android:layout_height="@dimen/_35sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:cardCornerRadius="@dimen/_20sdp"
app:cardElevation="3dp"
android:layout_margin="15dp"
android:layout_margin="20dp"
android:elevation="5dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/image"
android:src="@drawable/ic_menu"
/>
</androidx.cardview.widget.CardView>
android:contentDescription="@string/image"
android:src="@drawable/ic_menu"
/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fc_home"

View File

@@ -7,41 +7,379 @@
android:background="@drawable/morning_bg"
tools:context=".home.fragments.Home1Fragment">
<androidx.cardview.widget.CardView
<com.woka.home.PressableImageView
android:id="@+id/pressableImageView"
android:layout_width="@dimen/_70sdp"
android:layout_height="@dimen/_70sdp"
android:layout_margin="10dp"
android:contentDescription="@string/image"
android:scaleType="fitXY"
android:src="@drawable/img_woka_fm"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_marginTop="25dp"
android:contentDescription="@string/image"
android:src="@drawable/profile_placeholder"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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">
<LinearLayout
android:layout_marginTop="3dp"
android:fontFamily="@font/exo_2_bold"
android:text="Hello, Aditya"
android:textAlignment="center"
android:textColor="@color/color_primary"
android:textSize="@dimen/_14ssp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/profile_image"
/>
<TextView
android:id="@+id/welcome_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2"
android:text="@string/welcome_to_wokaland"
android:textAlignment="center"
android:textColor="@color/color_primary"
android:textSize="@dimen/_12ssp"
app:layout_constraintBottom_toTopOf="@id/tv_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/user_name"
app:layout_constraintVertical_bias="0" />
<RelativeLayout
android:id="@+id/tv_view"
android:layout_width="@dimen/_170sdp"
android:layout_height="@dimen/_140sdp"
android:layout_marginStart="25dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.25">
<ImageView
android:id="@+id/balloon"
android:layout_width="@dimen/_70sdp"
android:layout_height="@dimen/_40sdp"
android:layout_centerHorizontal="true"
android:contentDescription="@string/live_tv"
android:scaleType="fitXY"
android:src="@drawable/img_live_tv_balloon" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="@dimen/_15sdp"
android:layout_marginTop="@dimen/_15sdp"
android:contentDescription="@string/live_tv"
android:src="@drawable/img_tv_border"
android:translationZ="1dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/_28sdp"
android:layout_marginTop="@dimen/_50sdp"
android:layout_marginBottom="@dimen/_14sdp"
android:background="@color/white"
android:contentDescription="@string/image"
android:paddingHorizontal="@dimen/_15sdp"
android:src="@drawable/woka_logo_full"
android:visibility="visible"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.63">
<com.woka.home.PressableImageView
android:id="@+id/web_series"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/web_series"
android:scaleType="fitXY"
android:src="@drawable/img_web_series_t1" />
<TextView
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" />
android:fontFamily="@font/exo_2_bold"
android:text="@string/web_series"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
</LinearLayout>
android:fontFamily="@font/exo_2_bold"
android:text="@string/paint"
android:textAlignment="center"
android:textColor="@color/white" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
</LinearLayout>
android:orientation="vertical"
android:visibility="visible"
</androidx.cardview.widget.CardView>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.59">
<com.woka.home.PressableImageView
android:id="@+id/live_tv"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/live_tv"
android:scaleType="fitXY"
android:src="@drawable/img_live_tv_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/live_tv"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.51">
<com.woka.home.PressableImageView
android:id="@+id/shop"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/shop"
android:scaleType="fitXY"
android:src="@drawable/img_shop_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/shop"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.05"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.82">
<com.woka.home.PressableImageView
android:id="@+id/karaoke"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/karaoke"
android:scaleType="fitXY"
android:src="@drawable/img_karaoke_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/karaoke"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.52"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.83">
<com.woka.home.PressableImageView
android:id="@+id/audio_books"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/audio_books"
android:scaleType="fitXY"
android:src="@drawable/img_listen_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/audio_books"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.98"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.72">
<com.woka.home.PressableImageView
android:id="@+id/play"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_70sdp"
android:contentDescription="@string/play"
android:scaleType="fitXY"
android:src="@drawable/img_play_t1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:text="@string/play"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_20sdp"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.woka.home.PressableImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:contentDescription="@string/more"
android:scaleType="fitXY"
android:src="@drawable/ic_more_down" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="@font/exo_2_bold"
android:text="@string/more"
android:textAlignment="center"
android:textColor="@color/white"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -97,6 +97,7 @@
android:textColor="@color/black"
android:textColorHint="@android:color/darker_gray"
android:textSize="@dimen/_13sdp"
android:textAlignment="center"
android:digits="@string/alphanumeric"
android:maxLength="16"
@@ -154,6 +155,7 @@
android:textColorHint="@android:color/darker_gray"
android:inputType="textPassword"
android:textSize="@dimen/_13sdp"
android:textAlignment="center"
android:maxLength="16"

View File

@@ -118,5 +118,12 @@
<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>
<string name="web_series">WEB SERIES</string>
<string name="audio_books">AUDIO-BOOKS</string>
<string name="play">PLAY</string>
<string name="karaoke">KARAOKE</string>
<string name="shop">SHOP</string>
<string name="more">MORE</string>
<string name="live_tv">LIVE TV</string>
<string name="welcome_to_wokaland">Welcome to WOKALAND</string>
</resources>