Skip to content

Commit

Permalink
Refactor: Added a better icon for reorder apps.
Browse files Browse the repository at this point in the history
  • Loading branch information
HeCodes2Much committed May 27, 2024
1 parent 57fa78f commit 3b090dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.admin.DevicePolicyManager
import android.content.ClipData
import android.content.Context
import android.content.Context.VIBRATOR_SERVICE
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.os.Vibrator
Expand All @@ -16,6 +17,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.children
import androidx.core.view.size
Expand All @@ -33,7 +35,6 @@ import com.github.droidworksstudio.mlauncher.helper.showStatusBar
class ReorderHomeAppsFragment : Fragment() {

private lateinit var prefs: Prefs
private lateinit var prefix: String
private lateinit var viewModel: MainViewModel
private lateinit var deviceManager: DevicePolicyManager
private lateinit var vibrator: Vibrator
Expand All @@ -50,7 +51,6 @@ class ReorderHomeAppsFragment : Fragment() {

val view = binding.root
prefs = Prefs(requireContext())
prefix = "\uEB22 "

return view
}
Expand Down Expand Up @@ -173,13 +173,16 @@ class ReorderHomeAppsFragment : Fragment() {
if (diff in 1 until oldAppsNum) { // 1 <= diff <= oldNumApps
binding.homeAppsLayout.children.drop(diff)
} else if (diff < 0) {
val prefixDrawable: Drawable? = context?.let { ContextCompat.getDrawable(it, R.drawable.ic_prefix_drawable) }
// add all missing apps to list
for (i in oldAppsNum until newAppsNum) {
val view = layoutInflater.inflate(R.layout.home_app_button, null) as TextView
view.apply {
val appLabel = prefs.getHomeAppModel(i).appLabel.ifEmpty { getString(R.string.app) }
textSize = prefs.appSize.toFloat()
id = i
text = "$prefix${prefs.getHomeAppModel(i).appLabel}"
text = " $appLabel"
setCompoundDrawablesWithIntrinsicBounds(prefixDrawable, null, null, null)
if (!prefs.extendHomeAppsArea) {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_prefix_drawable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="16dp" android:tint="@android:color/darker_gray"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>

0 comments on commit 3b090dc

Please sign in to comment.