@@ -30,28 +30,28 @@ import androidx.lifecycle.ViewModelProvider
3030import com.github.droidworksstudio.mlauncher.MainViewModel
3131import com.github.droidworksstudio.mlauncher.R
3232import com.github.droidworksstudio.mlauncher.data.Prefs
33- import com.github.droidworksstudio.mlauncher.databinding.FragmentReorderHomeAppsBinding
33+ import com.github.droidworksstudio.mlauncher.databinding.FragmentFavoriteBinding
3434import com.github.droidworksstudio.mlauncher.helper.getHexFontColor
3535import com.github.droidworksstudio.mlauncher.helper.getHexForOpacity
3636import com.github.droidworksstudio.mlauncher.helper.hideStatusBar
3737import com.github.droidworksstudio.mlauncher.helper.showStatusBar
3838
39- class ReorderHomeAppsFragment : Fragment () {
39+ class FavoriteFragment : Fragment () {
4040
4141 private lateinit var prefs: Prefs
4242 private lateinit var viewModel: MainViewModel
4343 private lateinit var deviceManager: DevicePolicyManager
4444 private lateinit var vibrator: Vibrator
4545
46- private var _binding : FragmentReorderHomeAppsBinding ? = null
46+ private var _binding : FragmentFavoriteBinding ? = null
4747 private val binding get() = _binding !!
4848
4949 override fun onCreateView (
5050 inflater : LayoutInflater ,
5151 container : ViewGroup ? ,
5252 savedInstanceState : Bundle ?
5353 ): View {
54- _binding = FragmentReorderHomeAppsBinding .inflate(inflater, container, false )
54+ _binding = FragmentFavoriteBinding .inflate(inflater, container, false )
5555
5656 val view = binding.root
5757 prefs = Prefs (requireContext())
@@ -110,35 +110,41 @@ class ReorderHomeAppsFragment : Fragment() {
110110 // Indicate that we accept drag events
111111 return true
112112 }
113+
113114 DragEvent .ACTION_DRAG_ENTERED -> {
114115 // Highlight the target view as the drag enters
115116 targetView.setBackgroundResource(R .drawable.reorder_apps_background)
116117 return true
117118 }
119+
118120 DragEvent .ACTION_DRAG_EXITED -> {
119121 // Remove highlighting when the drag exits
120122 targetView.background = null
121123 return true
122124 }
125+
123126 DragEvent .ACTION_DROP -> {
124127 // Remove highlighting
125128 targetView.background = null
126-
129+
127130 // Extract the dragged TextView
128131 val draggedTextView = event.localState as TextView
129132
130133 // Reorder apps based on the drop position
131- val draggedIndex = (draggedTextView.parent as ViewGroup ).indexOfChild(draggedTextView)
134+ val draggedIndex =
135+ (draggedTextView.parent as ViewGroup ).indexOfChild(draggedTextView)
132136 val targetIndex = (targetView.parent as ViewGroup ).indexOfChild(targetView)
133137 reorderApps(draggedIndex, targetIndex)
134138
135139 return true
136140 }
141+
137142 DragEvent .ACTION_DRAG_ENDED -> {
138143 // Remove highlighting when the drag ends
139144 targetView.background = null
140145 return true
141146 }
147+
142148 else -> return false
143149 }
144150 }
@@ -149,7 +155,10 @@ class ReorderHomeAppsFragment : Fragment() {
149155 targetIndex < 0 || targetIndex >= binding.homeAppsLayout.childCount
150156 ) {
151157 // Handle out of bounds indices gracefully, or log an error
152- Log .e(" ReorderApps" , " Invalid indices: draggedIndex=$draggedIndex , targetIndex=$targetIndex " )
158+ Log .e(
159+ " ReorderApps" ,
160+ " Invalid indices: draggedIndex=$draggedIndex , targetIndex=$targetIndex "
161+ )
153162 return
154163 }
155164
@@ -182,12 +191,14 @@ class ReorderHomeAppsFragment : Fragment() {
182191 if (diff in 1 until oldAppsNum) { // 1 <= diff <= oldNumApps
183192 binding.homeAppsLayout.children.drop(diff)
184193 } else if (diff < 0 ) {
185- val prefixDrawable: Drawable ? = context?.let { ContextCompat .getDrawable(it, R .drawable.ic_prefix_drawable) }
194+ val prefixDrawable: Drawable ? =
195+ context?.let { ContextCompat .getDrawable(it, R .drawable.ic_prefix_drawable) }
186196 // add all missing apps to list
187197 for (i in oldAppsNum until newAppsNum) {
188198 val view = layoutInflater.inflate(R .layout.home_app_button, null ) as TextView
189199 view.apply {
190- val appLabel = prefs.getHomeAppModel(i).activityLabel.ifEmpty { getString(R .string.app) }
200+ val appLabel =
201+ prefs.getHomeAppModel(i).activityLabel.ifEmpty { getString(R .string.app) }
191202 textSize = prefs.appSize.toFloat()
192203 id = i
193204 text = " $appLabel "
@@ -201,7 +212,7 @@ class ReorderHomeAppsFragment : Fragment() {
201212 }
202213 val padding: Int = prefs.textPaddingSize
203214 view.setPadding(0 , padding, 0 , padding)
204- binding.pageName.text = getString(R .string.reorder_apps )
215+ binding.pageName.text = getString(R .string.favorite_apps )
205216 binding.pageName.textSize = prefs.appSize * 1.5f
206217
207218 if (prefs.followAccentColors) {
0 commit comments