Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Feat: Added the ability to hide battery icon.
Browse files Browse the repository at this point in the history
Closes: #497
  • Loading branch information
CreativeCodeCat committed May 5, 2024
1 parent b87387f commit e177b18
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private const val DRAWER_ALIGNMENT = "DRAWER_ALIGNMENT"
private const val TIME_ALIGNMENT = "TIME_ALIGNMENT"
private const val STATUS_BAR = "STATUS_BAR"
private const val SHOW_BATTERY = "SHOW_BATTERY"
private const val SHOW_BATTERY_ICON = "SHOW_BATTERY_ICON"
private const val SHOW_DATE = "SHOW_DATE"
private const val HOME_LOCKED = "HOME_LOCKED"
private const val SETTINGS_LOCKED = "SETTINGS_LOCKED"
Expand Down Expand Up @@ -226,6 +227,10 @@ class Prefs(val context: Context) {
get() = prefs.getBoolean(SHOW_BATTERY, true)
set(value) = prefs.edit().putBoolean(SHOW_BATTERY, value).apply()

var showBatteryIcon: Boolean
get() = prefs.getBoolean(SHOW_BATTERY_ICON, true)
set(value) = prefs.edit().putBoolean(SHOW_BATTERY_ICON, value).apply()

var homeLocked: Boolean
get() = prefs.getBoolean(HOME_LOCKED, false)
set(value) = prefs.edit().putBoolean(HOME_LOCKED, value).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener

binding.clock.textSize = prefs.clockSize.toFloat()
binding.date.textSize = prefs.textSizeLauncher.toFloat()
binding.batteryIcon.textSize = prefs.textSizeLauncher.toFloat() / 1.5f
binding.batteryText.textSize = prefs.textSizeLauncher.toFloat() / 1.5f
binding.homeScreenPager.textSize = prefs.textSizeLauncher.toFloat()

if(prefs.showBatteryIcon) {
binding.batteryIcon.visibility = View.VISIBLE
binding.batteryIcon.typeface = typeface
binding.batteryIcon.textSize = prefs.textSizeLauncher.toFloat() / 1.5f
}

if (prefs.useCustomIconFont) {
binding.clock.typeface = typeface
binding.date.typeface = typeface
Expand All @@ -157,7 +162,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
binding.setDefaultLauncher.typeface = typeface
}
binding.homeScreenPager.typeface = typeface
binding.batteryIcon.typeface = typeface
binding.mainLayout.setBackgroundColor(colors.background(requireContext(), prefs))
if (prefs.followAccentColors) {
val fontColor = getHexFontColor(requireContext(), prefs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@ class SettingsFragment : Fragment() {
state = remember { mutableStateOf(prefs.showBattery) }
) { toggleShowBattery() }
},
{ _, onChange ->
if(prefs.showBattery) {
SettingsToggle(
title = stringResource(R.string.show_battery_icon),
fontSize = iconFs,
onChange = onChange,
state = remember { mutableStateOf(prefs.showBatteryIcon) }
) { toggleShowBatteryIcon() }
}
},
{ _, onChange ->
SettingsToggle(
title = stringResource(R.string.lock_home_apps),
Expand Down Expand Up @@ -801,6 +811,10 @@ class SettingsFragment : Fragment() {
prefs.showBattery = !prefs.showBattery
}

private fun toggleShowBatteryIcon() {
prefs.showBatteryIcon = !prefs.showBatteryIcon
}

private fun toggleHomeLocked() {
prefs.homeLocked = !prefs.homeLocked
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="2dp"
android:textSize="@dimen/date_size" />
android:textSize="@dimen/date_size"
android:visibility="gone" />

<TextView
android:id="@+id/batteryText"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<string name="show_time">Show Time</string>
<string name="show_date">Show Date</string>
<string name="show_battery">Show Battery</string>
<string name="show_battery_icon">Show Battery Icon</string>
<string name="lock_home_apps">Lock Apps</string>
<string name="extend_home_apps_area">Extend Clickable Area</string>
<string name="home_alignment_bottom">Home Screen Align Bottom</string>
Expand Down

0 comments on commit e177b18

Please sign in to comment.