@@ -30,7 +30,6 @@ import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
3030import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
3131import androidx.biometric.BiometricPrompt
3232import androidx.core.content.ContextCompat
33- import androidx.core.content.res.ResourcesCompat
3433import androidx.core.os.bundleOf
3534import androidx.core.view.children
3635import androidx.fragment.app.Fragment
@@ -81,6 +80,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
8180
8281 private var _binding : FragmentHomeBinding ? = null
8382 private val binding get() = _binding !!
83+
8484 // Instantiate Colors object
8585 private val colors = Colors ()
8686
@@ -135,7 +135,10 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
135135
136136 val timezone = prefs.language.timezone()
137137 val is24HourFormat = DateFormat .is24HourFormat(requireContext())
138- val best12 = DateFormat .getBestDateTimePattern(timezone, if (prefs.showTimeFormat) " hhmma" else " hhmm" ).let {
138+ val best12 = DateFormat .getBestDateTimePattern(
139+ timezone,
140+ if (prefs.showTimeFormat) " hhmma" else " hhmm"
141+ ).let {
139142 if (! prefs.showTimeFormat) it.removeSuffix(" a" ) else it
140143 }
141144 Log .d(" currentDateTime" , best12)
@@ -150,35 +153,26 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
150153
151154 binding.clock.textSize = prefs.clockSize.toFloat()
152155 binding.date.textSize = prefs.dateSize.toFloat()
153- binding.batteryText .textSize = prefs.batterySize.toFloat()
156+ binding.battery .textSize = prefs.batterySize.toFloat()
154157 binding.homeScreenPager.textSize = prefs.appSize.toFloat()
155158
156- if (prefs.showBatteryIcon) {
157- binding.batteryIcon.visibility = View .VISIBLE
158- val typeface = ResourcesCompat .getFont(requireActivity(), R .font.roboto)
159- binding.batteryIcon.typeface = typeface
160- binding.batteryIcon.textSize = prefs.batterySize.toFloat()
161- }
162-
163159 if (prefs.showBattery) {
164- binding.batteryLayout .visibility = View .VISIBLE
160+ binding.battery .visibility = View .VISIBLE
165161 }
166162
167163 binding.mainLayout.setBackgroundColor(colors.background(requireContext(), prefs))
168164 if (prefs.followAccentColors) {
169165 val fontColor = getHexFontColor(requireContext(), prefs)
170166 binding.clock.setTextColor(fontColor)
171167 binding.date.setTextColor(fontColor)
172- binding.batteryIcon.setTextColor(fontColor)
173- binding.batteryText.setTextColor(fontColor)
168+ binding.battery.setTextColor(fontColor)
174169 binding.setTotalScreenTime.setTextColor(fontColor)
175170 binding.setDefaultLauncher.setTextColor(fontColor)
176171 binding.homeScreenPager.setTextColor(fontColor)
177- } else {
172+ } else {
178173 binding.clock.setTextColor(colors.accents(requireContext(), prefs, 1 ))
179174 binding.date.setTextColor(colors.accents(requireContext(), prefs, 1 ))
180- binding.batteryIcon.setTextColor(colors.accents(requireContext(), prefs, 1 ))
181- binding.batteryText.setTextColor(colors.accents(requireContext(), prefs, 1 ))
175+ binding.battery.setTextColor(colors.accents(requireContext(), prefs, 1 ))
182176 binding.setTotalScreenTime.setTextColor(colors.accents(requireContext(), prefs, 2 ))
183177 binding.setDefaultLauncher.setTextColor(colors.accents(requireContext(), prefs, 2 ))
184178 binding.homeScreenPager.setTextColor(colors.accents(requireContext(), prefs, 2 ))
@@ -252,7 +246,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
252246 viewModel.resetDefaultLauncherApp(requireContext())
253247 }
254248
255- R .id.batteryLayout -> {
249+ R .id.battery -> {
256250 openBatteryUsage()
257251 }
258252
@@ -290,7 +284,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
290284 binding.date.setOnClickListener(this )
291285 binding.setTotalScreenTime.setOnClickListener(this )
292286 binding.setDefaultLauncher.setOnClickListener(this )
293- binding.batteryLayout .setOnClickListener(this )
287+ binding.battery .setOnClickListener(this )
294288 }
295289
296290 @RequiresApi(Build .VERSION_CODES .Q )
@@ -355,6 +349,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
355349 }
356350 }
357351 }
352+
358353 @SuppressLint(" WrongConstant" , " PrivateApi" )
359354 private fun expandNotificationDrawer (context : Context ) {
360355 try {
@@ -388,6 +383,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
388383 launchApp(prefs.appShortSwipeUp)
389384 else openDialerApp(requireContext())
390385 }
386+
391387 private fun openSwipeDownApp () {
392388 if (prefs.appShortSwipeDown.activityPackage.isNotEmpty())
393389 launchApp(prefs.appShortSwipeDown)
@@ -411,6 +407,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
411407 launchApp(prefs.appLongSwipeUp)
412408 else openDialerApp(requireContext())
413409 }
410+
414411 private fun openLongSwipeDownApp () {
415412 if (prefs.appLongSwipeDown.activityPackage.isNotEmpty())
416413 launchApp(prefs.appLongSwipeDown)
@@ -521,14 +518,16 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
521518 startTime = System .currentTimeMillis()
522519 longSwipeTriggered = false // Reset the flag
523520 }
521+
524522 MotionEvent .ACTION_UP -> {
525523 val endX = motionEvent.x
526524 val endY = motionEvent.y
527525 val endTime = System .currentTimeMillis()
528526 val duration = endTime - startTime
529527 val deltaX = endX - startX
530528 val deltaY = endY - startY
531- val distance = sqrt((deltaX * deltaX + deltaY * deltaY).toDouble()).toFloat()
529+ val distance =
530+ sqrt((deltaX * deltaX + deltaY * deltaY).toDouble()).toFloat()
532531 val direction: String = if (abs(deltaX) < abs(deltaY)) {
533532 if (deltaY < 0 ) " up" else " down"
534533 } else {
@@ -613,14 +612,16 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
613612 startTime = System .currentTimeMillis()
614613 longSwipeTriggered = false // Reset the flag
615614 }
615+
616616 MotionEvent .ACTION_UP -> {
617617 val endX = motionEvent.x
618618 val endY = motionEvent.y
619619 val endTime = System .currentTimeMillis()
620620 val duration = endTime - startTime
621621 val deltaX = endX - startX
622622 val deltaY = endY - startY
623- val distance = sqrt((deltaX * deltaX + deltaY * deltaY).toDouble()).toFloat()
623+ val distance =
624+ sqrt((deltaX * deltaX + deltaY * deltaY).toDouble()).toFloat()
624625 val direction: String = if (abs(deltaX) < abs(deltaY)) {
625626 if (deltaY < 0 ) " up" else " down"
626627 } else {
@@ -692,14 +693,17 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
692693 Action .OpenApp -> openLongSwipeUpApp()
693694 else -> handleOtherAction(action)
694695 }
696+
695697 " down" -> when (val action = prefs.longSwipeDownAction) {
696698 Action .OpenApp -> openLongSwipeDownApp()
697699 else -> handleOtherAction(action)
698700 }
701+
699702 " left" -> when (val action = prefs.longSwipeLeftAction) {
700703 Action .OpenApp -> openLongSwipeLeftApp()
701704 else -> handleOtherAction(action)
702705 }
706+
703707 " right" -> when (val action = prefs.longSwipeRightAction) {
704708 Action .OpenApp -> openLongSwipeRightApp()
705709 else -> handleOtherAction(action)
@@ -728,7 +732,8 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
728732 }
729733
730734 // Create existingAppView
731- val existingAppView = layoutInflater.inflate(R .layout.home_app_button, null ) as TextView
735+ val existingAppView =
736+ layoutInflater.inflate(R .layout.home_app_button, null ) as TextView
732737 existingAppView.apply {
733738 // Set properties of existingAppView
734739 textSize = prefs.appSize.toFloat()
@@ -758,7 +763,12 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
758763 // Set properties of newAppView
759764 textSize = prefs.appSize.toFloat() / 1.5f
760765 id = i
761- text = formatMillisToHMS(getUsageStats(context, prefs.getHomeAppModel(i).activityPackage))
766+ text = formatMillisToHMS(
767+ getUsageStats(
768+ context,
769+ prefs.getHomeAppModel(i).activityPackage
770+ )
771+ )
762772 setOnTouchListener(getHomeAppsGestureListener(context, this ))
763773 setOnClickListener(this @HomeFragment)
764774 if (! prefs.extendHomeAppsArea) {
@@ -772,7 +782,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
772782 if (prefs.followAccentColors) {
773783 val fontColor = getHexFontColor(requireContext(), prefs)
774784 setTextColor(fontColor)
775- } else {
785+ } else {
776786 setTextColor(colors.accents(requireContext(), prefs, 3 ))
777787 }
778788 }
@@ -895,17 +905,18 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
895905
896906 // Set the text for the page selector corresponding to each page
897907 binding.homeScreenPager.text = pageSelectorTexts.joinToString(" " )
898- if (prefs.homePagesNum > 1 && prefs.homePagerOn) binding.homeScreenPager.visibility = View .VISIBLE
908+ if (prefs.homePagesNum > 1 && prefs.homePagerOn) binding.homeScreenPager.visibility =
909+ View .VISIBLE
899910 }
900911
901- private fun handleSwipeLeft (totalPages : Int ) {
912+ private fun handleSwipeLeft (totalPages : Int ) {
902913 if (currentPage < totalPages - 1 ) {
903914 currentPage++
904915 updateAppsVisibility(totalPages)
905916 }
906917 }
907918
908- private fun handleSwipeRight (totalPages : Int ) {
919+ private fun handleSwipeRight (totalPages : Int ) {
909920 if (currentPage > 0 ) {
910921 currentPage--
911922 updateAppsVisibility(totalPages)
0 commit comments