Skip to content

Commit

Permalink
Add a condition to 'if' statement for new option
Browse files Browse the repository at this point in the history
  • Loading branch information
rlees85 committed May 17, 2024
1 parent cebd834 commit 06df97f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class Rules(context: Context) {
false,
)

fun hideWhenNoNotifications(context: Context): Boolean =
P.getPreferences(context).getBoolean(
"rules_hide_no_notifications",
false
)

fun matchesBatteryPercentage(context: Context): Boolean =
(
getBatteryStatus(context)?.getIntExtra(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class NotificationService : NotificationListenerService() {
if (
CombinedServiceReceiver.isAlwaysOnRunning &&
Rules.isAmbientMode(this) &&
Rules.hideWhenNoNotifications(this) &&
count < 1

Check warning

Code scanning / detekt

Complex conditions should be simplified and extracted into well-named methods if necessary. Warning

This condition is too complex (4). Defined complexity threshold for conditions is set to '4'
) {
AlwaysOn.finish()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/pref_laf_rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_notification"
android:key="pref_hide_no_notifications"
android:key="rules_hide_no_notifications"
android:summary="@string/pref_look_and_feel_hide_no_notifications_summary"
android:title="@string/pref_look_and_feel_hide_no_notifications"
android:dependency="rules_ambient_mode" />
Expand Down

0 comments on commit 06df97f

Please sign in to comment.