Feat: Display app icons in more places if enabled.
also closes #46 Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
@@ -60,6 +60,17 @@ class DrawViewHolder(
|
||||
appDrawName.setCompoundDrawables(null, null, null, null)
|
||||
appDrawName.compoundDrawablePadding = 0
|
||||
}
|
||||
|
||||
if (preferenceHelper.showAppIcon) {
|
||||
val appIcon =
|
||||
binding.root.context.packageManager.getApplicationIcon(appInfo.packageName)
|
||||
appDrawLeftIcon.setImageDrawable(appIcon)
|
||||
appDrawLeftIcon.layoutParams.width =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appDrawLeftIcon.layoutParams.height =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appDrawLeftIcon.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
itemView.setOnClickListener {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.graphics.PorterDuffColorFilter
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -51,6 +52,17 @@ class FavoriteViewHolder(
|
||||
appFavoriteName.textSize = preferenceHelper.appTextSize
|
||||
Log.d("Tag", "Draw Adapter: ${appInfo.appName}")
|
||||
|
||||
if (preferenceHelper.showAppIcon) {
|
||||
val appIcon =
|
||||
binding.root.context.packageManager.getApplicationIcon(appInfo.packageName)
|
||||
appFavoriteLeftIcon.setImageDrawable(appIcon)
|
||||
appFavoriteLeftIcon.layoutParams.width =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appFavoriteLeftIcon.layoutParams.height =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appFavoriteLeftIcon.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
|
||||
// Create a BlendModeColorFilter with the specified color and blend mode
|
||||
val blendModeColorFilter = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
|
||||
@@ -7,11 +7,13 @@ import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||
import com.github.droidworksstudio.launcher.databinding.ItemHiddenBinding
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||
|
||||
class HiddenAdapter(
|
||||
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
||||
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener
|
||||
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener,
|
||||
private val preferenceHelperProvider: PreferenceHelper
|
||||
) : ListAdapter<AppInfo, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
@@ -23,7 +25,12 @@ class HiddenAdapter(
|
||||
parent,
|
||||
false
|
||||
)
|
||||
return HiddenViewHolder(binding, onAppClickedListener, onAppLongClickedListener)
|
||||
return HiddenViewHolder(
|
||||
binding,
|
||||
onAppClickedListener,
|
||||
onAppLongClickedListener,
|
||||
preferenceHelperProvider
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||
import com.github.droidworksstudio.launcher.databinding.FragmentHiddenBinding
|
||||
import com.github.droidworksstudio.launcher.helper.AppHelper
|
||||
import com.github.droidworksstudio.launcher.helper.FingerprintHelper
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||
import com.github.droidworksstudio.launcher.listener.OnSwipeTouchListener
|
||||
import com.github.droidworksstudio.launcher.ui.bottomsheetdialog.AppInfoBottomSheetFragment
|
||||
@@ -38,8 +39,6 @@ class HiddenFragment : Fragment(),
|
||||
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val hiddenAdapter: HiddenAdapter by lazy { HiddenAdapter(this, this) }
|
||||
|
||||
private val viewModel: AppViewModel by viewModels()
|
||||
|
||||
private lateinit var context: Context
|
||||
@@ -50,6 +49,11 @@ class HiddenFragment : Fragment(),
|
||||
@Inject
|
||||
lateinit var appHelper: AppHelper
|
||||
|
||||
@Inject
|
||||
lateinit var preferenceHelper: PreferenceHelper
|
||||
|
||||
private val hiddenAdapter: HiddenAdapter by lazy { HiddenAdapter(this, this, preferenceHelper) }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
@@ -81,6 +85,7 @@ class HiddenFragment : Fragment(),
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun observeHiddenApps() {
|
||||
viewModel.compareInstalledAppInfo()
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -137,6 +142,7 @@ class HiddenFragment : Fragment(),
|
||||
binding.hiddenAdapter.scrollToPosition(0)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
package com.github.droidworksstudio.launcher.ui.hidden
|
||||
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||
import com.github.droidworksstudio.launcher.databinding.ItemHiddenBinding
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||
|
||||
class HiddenViewHolder(
|
||||
private val binding: ItemHiddenBinding,
|
||||
private val onAppClickedListener: OnItemClickedListener.OnAppsClickedListener,
|
||||
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener
|
||||
private val onAppLongClickedListener: OnItemClickedListener.OnAppLongClickedListener,
|
||||
private val preferenceHelper: PreferenceHelper,
|
||||
) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(appInfo: AppInfo) {
|
||||
binding.apply {
|
||||
appHiddenName.text = appInfo.appName
|
||||
Log.d("Tag", "Draw Adapter: ${appInfo.appName}")
|
||||
|
||||
if (preferenceHelper.showAppIcon) {
|
||||
val appIcon =
|
||||
binding.root.context.packageManager.getApplicationIcon(appInfo.packageName)
|
||||
appHiddenLeftIcon.setImageDrawable(appIcon)
|
||||
appHiddenLeftIcon.layoutParams.width =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appHiddenLeftIcon.layoutParams.height =
|
||||
preferenceHelper.appTextSize.toInt() * 3
|
||||
appHiddenLeftIcon.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
itemView.setOnClickListener {
|
||||
|
||||
@@ -130,17 +130,17 @@ class HomeFragment : Fragment(),
|
||||
val batteryLevel = level * 100 / scale.toFloat()
|
||||
|
||||
val batteryDrawable = when {
|
||||
batteryLevel >= 95 -> ContextCompat.getDrawable(
|
||||
batteryLevel >= 76 -> ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.app_battery100
|
||||
)
|
||||
|
||||
batteryLevel >= 70 -> ContextCompat.getDrawable(
|
||||
batteryLevel >= 51 -> ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.app_battery75
|
||||
)
|
||||
|
||||
batteryLevel >= 45 -> ContextCompat.getDrawable(
|
||||
batteryLevel >= 26 -> ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.app_battery50
|
||||
)
|
||||
|
||||
@@ -2,26 +2,41 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appDraw_name"
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/appDrawLeft_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/linear_layout" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:textSize="@dimen/text_super_large"
|
||||
android:textStyle="normal"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_gravity="start"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appDraw_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24sp"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:gravity="center" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -6,12 +6,22 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/appFavoriteLeft_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/linear_layout" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appFavorite_name"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -1,30 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appHidden_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:textSize="24sp"
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/appHiddenLeft_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle"/>
|
||||
app:layout_constraintTop_toTopOf="@id/linear_layout" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appHidden_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24sp"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:gravity="center" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
Reference in New Issue
Block a user