Skip to content

Commit

Permalink
Changes in battery %
Browse files Browse the repository at this point in the history
  • Loading branch information
tanujnotes committed Feb 7, 2023
1 parent 9afa930 commit 47f1da8
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions app/src/main/java/app/olauncher/ui/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
binding.dateTimeLayout.isVisible = prefs.dateTimeVisibility != Constants.DateTime.OFF
binding.clock.isVisible = Constants.DateTime.isTimeVisible(prefs.dateTimeVisibility)
binding.date.isVisible = Constants.DateTime.isDateVisible(prefs.dateTimeVisibility)
val day = SimpleDateFormat("EEE, dd MMM", Locale.getDefault()).format(Date())
if (prefs.showStatusBar)
binding.date.text = day
else {

var dateText = SimpleDateFormat("EEE, dd MMM", Locale.getDefault()).format(Date())
if (!prefs.showStatusBar) {
val battery = (requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager)
.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
binding.date.text = getString(R.string.day_battery, day, battery)
dateText = getString(R.string.day_battery, dateText, battery)
}
binding.date.text = dateText.replace(".,", ",")
}

private fun populateHomeScreen(appCountUpdated: Boolean) {
Expand Down Expand Up @@ -266,11 +266,13 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener

private fun launchApp(appName: String, packageName: String, activityClassName: String?, userString: String) {
viewModel.selectedApp(
AppModel(appName,
AppModel(
appName,
null,
packageName,
activityClassName,
getUserHandleFromString(requireContext(), userString)),
getUserHandleFromString(requireContext(), userString)
),
Constants.FLAG_LAUNCH_APP
)
}
Expand Down Expand Up @@ -307,20 +309,24 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
private fun openSwipeRightApp() {
if (!prefs.swipeRightEnabled) return
if (prefs.appPackageSwipeRight.isNotEmpty())
launchApp(prefs.appNameSwipeRight,
launchApp(
prefs.appNameSwipeRight,
prefs.appPackageSwipeRight,
prefs.appActivityClassNameRight,
android.os.Process.myUserHandle().toString())
android.os.Process.myUserHandle().toString()
)
else openDialerApp(requireContext())
}

private fun openSwipeLeftApp() {
if (!prefs.swipeLeftEnabled) return
if (prefs.appPackageSwipeLeft.isNotEmpty())
launchApp(prefs.appNameSwipeLeft,
launchApp(
prefs.appNameSwipeLeft,
prefs.appPackageSwipeLeft,
prefs.appActivityClassNameSwipeLeft,
android.os.Process.myUserHandle().toString())
android.os.Process.myUserHandle().toString()
)
else openCameraApp(requireContext())
}

Expand Down

0 comments on commit 47f1da8

Please sign in to comment.