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

Commit

Permalink
Fix for notification actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RichyHBM committed Jan 7, 2019
1 parent 5bbdbd3 commit 801d1cf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "uk.co.richyhbm.monochromatic"
minSdkVersion 21
targetSdkVersion 28
versionCode 9
versionName "0.6.0"
versionCode 10
versionName "0.6.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ import uk.co.richyhbm.monochromatic.Utilities.Settings
class MainActivity : AppCompatActivity() {
val settings by lazy { Settings(this) }

private val preferencesChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
if (settings.isEnabled()) {
MonochromeService.startService(this)
SecureSettings.toggleFilters(settings.isAllowed(), contentResolver, settings)
} else {
MonochromeService.stopService(this)
private val preferencesChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
when(key) {
getString(R.string.settings_key_disable_screen) -> {}
getString(R.string.settings_key_disable_session) -> {}
else -> {
if (settings.isEnabled()) {
MonochromeService.startService(this)
SecureSettings.toggleFilters(settings.isAllowed(), contentResolver, settings)
} else {
MonochromeService.stopService(this)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DisableMonochromeForScreenReceiver: BroadcastReceiver() {
val settings = Settings(context)
if(settings.isEnabled()) {
settings.screenDisabled()
SecureSettings.toggleMonochrome(settings.isAllowed(), context.contentResolver)
SecureSettings.toggleFilters(settings.isAllowed(), context.contentResolver, settings)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DisableMonochromeForSessionReceiver: BroadcastReceiver() {
val settings = Settings(context)
if(settings.isEnabled()) {
settings.sessionDisabled()
SecureSettings.toggleMonochrome(settings.isAllowed(), context.contentResolver)
SecureSettings.toggleFilters(settings.isAllowed(), context.contentResolver, settings)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object SecureSettings {
}
}

fun toggleMonochrome(enabled: Boolean, contentResolver: ContentResolver) {
private fun toggleMonochrome(enabled: Boolean, contentResolver: ContentResolver) {
Settings.Secure.putInt(contentResolver, Constants.secureSetting_displayDaltonizerEnabled, enabled.int)
if (enabled) {
Settings.Secure.putInt(contentResolver, Constants.secureSetting_displayDaltonizer, Constants.secureSettingValue_daltonizerSimulateMonochrome)
Expand Down

0 comments on commit 801d1cf

Please sign in to comment.