Feat: Added app font color to headers of the page.
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
@@ -3,6 +3,9 @@ package com.github.droidworksstudio.launcher.ui.drawer
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.Spannable
|
||||||
|
import android.text.SpannableString
|
||||||
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -98,6 +101,16 @@ class DrawFragment : Fragment(),
|
|||||||
private fun observeDrawerApps() {
|
private fun observeDrawerApps() {
|
||||||
viewModel.compareInstalledAppInfo()
|
viewModel.compareInstalledAppInfo()
|
||||||
|
|
||||||
|
val searchAppsHint = getString(R.string.search)
|
||||||
|
val coloredHint = SpannableString(searchAppsHint)
|
||||||
|
coloredHint.setSpan(
|
||||||
|
ForegroundColorSpan(preferenceHelper.appColor),
|
||||||
|
0,
|
||||||
|
searchAppsHint.length,
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
|
)
|
||||||
|
binding.searchViewText.queryHint = coloredHint
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
viewLifecycleOwner.lifecycleScope.launchWhenCreated {
|
viewLifecycleOwner.lifecycleScope.launchWhenCreated {
|
||||||
viewModel.drawApps.collect {
|
viewModel.drawApps.collect {
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import androidx.recyclerview.widget.ListAdapter
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
import com.github.droidworksstudio.launcher.databinding.ItemFavoriteBinding
|
import com.github.droidworksstudio.launcher.databinding.ItemFavoriteBinding
|
||||||
|
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||||
import com.github.droidworksstudio.launcher.listener.OnItemMoveListener
|
import com.github.droidworksstudio.launcher.listener.OnItemMoveListener
|
||||||
|
|
||||||
class FavoriteAdapter(
|
class FavoriteAdapter(
|
||||||
private val onAppClickedListener:
|
private val onAppClickedListener:
|
||||||
OnItemClickedListener.OnAppsClickedListener,
|
OnItemClickedListener.OnAppsClickedListener,
|
||||||
|
private val preferenceHelperProvider: PreferenceHelper
|
||||||
) : ListAdapter<AppInfo, RecyclerView.ViewHolder>(DiffCallback()),
|
) : ListAdapter<AppInfo, RecyclerView.ViewHolder>(DiffCallback()),
|
||||||
OnItemMoveListener.OnItemActionListener {
|
OnItemMoveListener.OnItemActionListener {
|
||||||
|
|
||||||
@@ -27,7 +29,13 @@ class FavoriteAdapter(
|
|||||||
parent,
|
parent,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
return FavoriteViewHolder(binding, onAppClickedListener, touchHelper)
|
val preferenceHelper = preferenceHelperProvider
|
||||||
|
return FavoriteViewHolder(
|
||||||
|
binding,
|
||||||
|
onAppClickedListener,
|
||||||
|
preferenceHelper,
|
||||||
|
touchHelper
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class FavoriteFragment : Fragment(),
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var appHelper: AppHelper
|
lateinit var appHelper: AppHelper
|
||||||
|
|
||||||
private val favoriteAdapter: FavoriteAdapter by lazy { FavoriteAdapter(this) }
|
private val favoriteAdapter: FavoriteAdapter by lazy { FavoriteAdapter(this, preferenceHelper) }
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
@@ -107,6 +107,8 @@ class FavoriteFragment : Fragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeFavorite() {
|
private fun observeFavorite() {
|
||||||
|
binding.topTextView.setTextColor(preferenceHelper.appColor)
|
||||||
|
|
||||||
viewModel.compareInstalledAppInfo()
|
viewModel.compareInstalledAppInfo()
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
viewModel.favoriteApps.collect {
|
viewModel.favoriteApps.collect {
|
||||||
@@ -180,7 +182,7 @@ class FavoriteFragment : Fragment(),
|
|||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun observeSwipeTouchListener() {
|
private fun observeSwipeTouchListener() {
|
||||||
binding.touchArea.setOnTouchListener(getSwipeGestureListener(context))
|
binding.fragmentContainer.setOnTouchListener(getSwipeGestureListener(context))
|
||||||
binding.favoriteAdapter.setOnTouchListener(getSwipeGestureListener(context))
|
binding.favoriteAdapter.setOnTouchListener(getSwipeGestureListener(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
package com.github.droidworksstudio.launcher.ui.favorite
|
package com.github.droidworksstudio.launcher.ui.favorite
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.graphics.BlendMode
|
||||||
|
import android.graphics.BlendModeColorFilter
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import androidx.appcompat.widget.LinearLayoutCompat
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||||
import com.github.droidworksstudio.launcher.databinding.ItemFavoriteBinding
|
import com.github.droidworksstudio.launcher.databinding.ItemFavoriteBinding
|
||||||
|
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
class FavoriteViewHolder(
|
class FavoriteViewHolder(
|
||||||
private val binding: ItemFavoriteBinding,
|
private val binding: ItemFavoriteBinding,
|
||||||
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
||||||
|
private val preferenceHelper: PreferenceHelper,
|
||||||
private val touchHelper: ItemTouchHelper,
|
private val touchHelper: ItemTouchHelper,
|
||||||
) :
|
) :
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
@@ -27,10 +35,42 @@ class FavoriteViewHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun bind(appInfo: AppInfo) {
|
fun bind(appInfo: AppInfo) {
|
||||||
|
|
||||||
|
|
||||||
binding.apply {
|
binding.apply {
|
||||||
|
// Get the current LayoutParams of appFavoriteName
|
||||||
|
val layoutParams = appFavoriteName.layoutParams as LinearLayoutCompat.LayoutParams
|
||||||
|
|
||||||
|
// Set the margins
|
||||||
|
layoutParams.topMargin = preferenceHelper.homeAppPadding.toInt()
|
||||||
|
layoutParams.bottomMargin = preferenceHelper.homeAppPadding.toInt()
|
||||||
|
|
||||||
|
appFavoriteName.layoutParams = layoutParams
|
||||||
appFavoriteName.text = appInfo.appName
|
appFavoriteName.text = appInfo.appName
|
||||||
//appFavoriteDragIcon.visibility = View.GONE
|
appFavoriteName.setTextColor(preferenceHelper.appColor)
|
||||||
|
appFavoriteName.textSize = preferenceHelper.appTextSize
|
||||||
Log.d("Tag", "Draw Adapter: ${appInfo.appName}")
|
Log.d("Tag", "Draw Adapter: ${appInfo.appName}")
|
||||||
|
|
||||||
|
|
||||||
|
// Create a BlendModeColorFilter with the specified color and blend mode
|
||||||
|
val blendModeColorFilter = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
BlendModeColorFilter(
|
||||||
|
preferenceHelper.appColor,
|
||||||
|
BlendMode.SRC_IN
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PorterDuffColorFilter(
|
||||||
|
preferenceHelper.appColor,
|
||||||
|
PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current drawable set as the background
|
||||||
|
val drawable = appFavoriteDragIcon.background.mutate()
|
||||||
|
// Apply a color filter to change its color
|
||||||
|
drawable.colorFilter = blendModeColorFilter
|
||||||
|
// Set the modified drawable back as the background
|
||||||
|
appFavoriteDragIcon.background = drawable
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnClickListener {
|
itemView.setOnClickListener {
|
||||||
|
|||||||
@@ -7,13 +7,6 @@
|
|||||||
android:id="@+id/favorite_view"
|
android:id="@+id/favorite_view"
|
||||||
tools:context=".ui.favorite.FavoriteFragment">
|
tools:context=".ui.favorite.FavoriteFragment">
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/touchArea"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/fragment_container"
|
android:id="@+id/fragment_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -38,7 +31,7 @@
|
|||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/favoriteAdapter"
|
android:id="@+id/favoriteAdapter"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="20dp"
|
android:layout_marginHorizontal="20dp"
|
||||||
android:layout_marginTop="92dp"
|
android:layout_marginTop="92dp"
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/appListAdapter"
|
android:id="@+id/appListAdapter"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/appFavorite_name"
|
android:id="@+id/appFavorite_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginVertical="10dp"
|
android:layout_marginVertical="10dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:ignore="RtlHardcoded"
|
tools:ignore="RtlHardcoded"
|
||||||
style="@style/TextDefaultStyle"/>
|
style="@style/TextDefaultStyle" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/appFavorite_drag_icon"
|
android:id="@+id/appFavorite_drag_icon"
|
||||||
|
|||||||
Reference in New Issue
Block a user