diff --git a/README-CHANGES.xml b/README-CHANGES.xml index edbc3a7fb..730922b04 100644 --- a/README-CHANGES.xml +++ b/README-CHANGES.xml @@ -337,15 +337,16 @@ - + - + + diff --git a/org.thepalaceproject.android.platform b/org.thepalaceproject.android.platform index 362a330dc..57380b0ee 160000 --- a/org.thepalaceproject.android.platform +++ b/org.thepalaceproject.android.platform @@ -1 +1 @@ -Subproject commit 362a330dcf1c0fe74fe67a7a1953d711adec4c0c +Subproject commit 57380b0ee62bb24e73b435b11c66c3291958538b diff --git a/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLoginTask.kt b/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLoginTask.kt index 2e0463b05..79ba77b20 100644 --- a/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLoginTask.kt +++ b/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLoginTask.kt @@ -244,8 +244,7 @@ class ProfileAccountLoginTask( this.runDeviceActivation() this.account.setLoginState(AccountLoggedIn(this.credentials)) notificationTokenHttpCalls.registerFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) this.steps.finishSuccess(Unit) } @@ -318,8 +317,7 @@ class ProfileAccountLoginTask( this.runDeviceActivation() this.account.setLoginState(AccountLoggedIn(this.credentials)) notificationTokenHttpCalls.registerFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) this.steps.finishSuccess(Unit) } @@ -365,8 +363,7 @@ class ProfileAccountLoginTask( this.runDeviceActivation() this.account.setLoginState(AccountLoggedIn(this.credentials)) notificationTokenHttpCalls.registerFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) return this.steps.finishSuccess(Unit) } @@ -407,8 +404,7 @@ class ProfileAccountLoginTask( this.runDeviceActivation() this.account.setLoginState(AccountLoggedIn(this.credentials)) notificationTokenHttpCalls.registerFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) return this.steps.finishSuccess(Unit) } diff --git a/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLogoutTask.kt b/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLogoutTask.kt index fd29a91ff..14f462345 100644 --- a/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLogoutTask.kt +++ b/simplified-books-controller/src/main/java/org/nypl/simplified/books/controller/ProfileAccountLogoutTask.kt @@ -145,8 +145,7 @@ class ProfileAccountLogoutTask( this.debug("running fcm token deletion") notificationTokenHttpCalls.deleteFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) } diff --git a/simplified-main/src/main/java/org/librarysimplified/main/MainActivity.kt b/simplified-main/src/main/java/org/librarysimplified/main/MainActivity.kt index 1baa24ba0..870fda95b 100644 --- a/simplified-main/src/main/java/org/librarysimplified/main/MainActivity.kt +++ b/simplified-main/src/main/java/org/librarysimplified/main/MainActivity.kt @@ -162,16 +162,6 @@ class MainActivity : AppCompatActivity(R.layout.main_host) { private fun askForNotificationsPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - val services = - Services.serviceDirectory() - val profiles = - services.requireService(ProfilesControllerType::class.java) - - if (!profiles.profileCurrent().preferences().areNotificationsEnabled) { - logger.debug("Notifications are currently disabled, so we won't be asking for permissions") - return - } - ActivityCompat.requestPermissions( this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), diff --git a/simplified-notifications/src/main/java/NotificationTokenHTTPCalls.kt b/simplified-notifications/src/main/java/NotificationTokenHTTPCalls.kt index dee1924d6..05270c47e 100644 --- a/simplified-notifications/src/main/java/NotificationTokenHTTPCalls.kt +++ b/simplified-notifications/src/main/java/NotificationTokenHTTPCalls.kt @@ -27,21 +27,14 @@ class NotificationTokenHTTPCalls( override fun registerFCMTokenForProfileAccounts(profile: ProfileReadableType) { profile.accounts().values.forEach { account -> registerFCMTokenForProfileAccount( - account = account, - areNotificationsEnabled = profile.preferences().areNotificationsEnabled + account = account ) } } override fun registerFCMTokenForProfileAccount( - account: AccountType, - areNotificationsEnabled: Boolean + account: AccountType ) { - if (!areNotificationsEnabled) { - logger.debug("Notifications are currently disabled, so we won't be registering a token") - return - } - firebaseInstance.token .addOnSuccessListener { token -> logger.debug("Success fetching FCM Token: {}", token) @@ -105,14 +98,8 @@ class NotificationTokenHTTPCalls( } override fun deleteFCMTokenForProfileAccount( - account: AccountType, - areNotificationsEnabled: Boolean + account: AccountType ) { - if (!areNotificationsEnabled) { - logger.debug("Notifications are currently disabled, so we won't be deleting the token") - return - } - firebaseInstance.token .addOnSuccessListener { token -> logger.debug("Success fetching FCM Token: {}", token) diff --git a/simplified-notifications/src/main/java/NotificationTokenHTTPCallsType.kt b/simplified-notifications/src/main/java/NotificationTokenHTTPCallsType.kt index 3bbd169ca..5107e163f 100644 --- a/simplified-notifications/src/main/java/NotificationTokenHTTPCallsType.kt +++ b/simplified-notifications/src/main/java/NotificationTokenHTTPCallsType.kt @@ -6,7 +6,7 @@ import org.nypl.simplified.profiles.api.ProfileReadableType interface NotificationTokenHTTPCallsType { fun registerFCMTokenForProfileAccounts(profile: ProfileReadableType) - fun registerFCMTokenForProfileAccount(account: AccountType, areNotificationsEnabled: Boolean) + fun registerFCMTokenForProfileAccount(account: AccountType) - fun deleteFCMTokenForProfileAccount(account: AccountType, areNotificationsEnabled: Boolean) + fun deleteFCMTokenForProfileAccount(account: AccountType) } diff --git a/simplified-profiles-api/src/main/java/org/nypl/simplified/profiles/api/ProfilePreferences.kt b/simplified-profiles-api/src/main/java/org/nypl/simplified/profiles/api/ProfilePreferences.kt index 667f2633a..bffda14a2 100644 --- a/simplified-profiles-api/src/main/java/org/nypl/simplified/profiles/api/ProfilePreferences.kt +++ b/simplified-profiles-api/src/main/java/org/nypl/simplified/profiles/api/ProfilePreferences.kt @@ -50,10 +50,6 @@ data class ProfilePreferences( val isManualLCPPassphraseEnabled: Boolean = false, - /** @return `true` if the push notifications are enabled. */ - - val areNotificationsEnabled: Boolean = false, - /** @return `true` if the debug settings should be visible. */ val showDebugSettings: Boolean = false diff --git a/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfileDescriptionJSON.kt b/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfileDescriptionJSON.kt index e4b44e85c..a1e196014 100644 --- a/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfileDescriptionJSON.kt +++ b/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfileDescriptionJSON.kt @@ -207,9 +207,6 @@ object ProfileDescriptionJSON { val isManualLCPPassphraseEnabled = JSONParserUtilities.getBooleanDefault(objectNode, "isManualLCPPassphraseEnabled", false) - val areNotificationsEnabled = - JSONParserUtilities.getBooleanDefault(objectNode, "areNotificationsEnabled", false) - val mostRecentAccount = JSONParserUtilities.getStringOrNull(objectNode, "mostRecentAccount") ?.let { AccountID(UUID.fromString(it)) } @@ -224,7 +221,6 @@ object ProfileDescriptionJSON { showDebugSettings = showDebugSettings, playbackRates = playbackRates, sleepTimers = sleepTimers, - areNotificationsEnabled = areNotificationsEnabled, isManualLCPPassphraseEnabled = isManualLCPPassphraseEnabled ) } @@ -261,9 +257,6 @@ object ProfileDescriptionJSON { val isManualLCPPassphraseEnabled = JSONParserUtilities.getBooleanDefault(objectNode, "isManualLCPPassphraseEnabled", false) - val areNotificationsEnabled = - JSONParserUtilities.getBooleanDefault(objectNode, "areNotificationsEnabled", false) - val mostRecentAccount = JSONParserUtilities.getStringOrNull(objectNode, "mostRecentAccount") ?.let { AccountID(UUID.fromString(it)) } @@ -277,7 +270,6 @@ object ProfileDescriptionJSON { hasSeenLibrarySelectionScreen = true, playbackRates = playbackRates, sleepTimers = sleepTimers, - areNotificationsEnabled = areNotificationsEnabled, isManualLCPPassphraseEnabled = isManualLCPPassphraseEnabled ) } @@ -338,9 +330,6 @@ object ProfileDescriptionJSON { val isManualLCPPassphraseEnabled = JSONParserUtilities.getBooleanDefault(preferencesNode, "isManualLCPPassphraseEnabled", false) - val areNotificationsEnabled = - JSONParserUtilities.getBooleanDefault(preferencesNode, "areNotificationsEnabled", false) - val preferences = ProfilePreferences( dateOfBirth = this.someOrNull(dateOfBirth), @@ -350,7 +339,6 @@ object ProfileDescriptionJSON { hasSeenLibrarySelectionScreen = true, playbackRates = playbackRates, sleepTimers = sleepTimers, - areNotificationsEnabled = areNotificationsEnabled, isManualLCPPassphraseEnabled = isManualLCPPassphraseEnabled ) @@ -496,7 +484,6 @@ object ProfileDescriptionJSON { ): ObjectNode { val output = objectMapper.createObjectNode() output.put("showTestingLibraries", preferences.showTestingLibraries) - output.put("areNotificationsEnabled", preferences.areNotificationsEnabled) output.put("isManualLCPPassphraseEnabled", preferences.isManualLCPPassphraseEnabled) output.put("hasSeenLibrarySelectionScreen", preferences.hasSeenLibrarySelectionScreen) output.put("showDebugSettings", preferences.showDebugSettings) diff --git a/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfilesDatabases.kt b/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfilesDatabases.kt index 729881707..4f32954ce 100644 --- a/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfilesDatabases.kt +++ b/simplified-profiles/src/main/java/org/nypl/simplified/profiles/ProfilesDatabases.kt @@ -502,7 +502,6 @@ object ProfilesDatabases { hasSeenLibrarySelectionScreen = false, playbackRates = hashMapOf(), sleepTimers = hashMapOf(), - areNotificationsEnabled = false, isManualLCPPassphraseEnabled = false ), attributes = ProfileAttributes(sortedMapOf()) diff --git a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLoginTaskContract.kt b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLoginTaskContract.kt index 709482d12..766d78ef8 100644 --- a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLoginTaskContract.kt +++ b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLoginTaskContract.kt @@ -114,10 +114,6 @@ abstract class ProfileAccountLoginTaskContract { this.server = MockWebServer() this.server.start() - val preferences = Mockito.mock(ProfilePreferences::class.java) - Mockito.`when`(this.profile.preferences()).thenReturn(preferences) - Mockito.`when`(preferences.areNotificationsEnabled).thenReturn(true) - this.profileWithoutDRM = """ { "simplified:authorization_identifier": "6120696828384", @@ -724,7 +720,7 @@ abstract class ProfileAccountLoginTaskContract { assertEquals(1, this.server.requestCount) Mockito.verify(tokenHttp, Mockito.times(1)) - .registerFCMTokenForProfileAccount(account, true) + .registerFCMTokenForProfileAccount(account) } /** diff --git a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLogoutTaskContract.kt b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLogoutTaskContract.kt index 603e41bac..81303acd2 100644 --- a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLogoutTaskContract.kt +++ b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileAccountLogoutTaskContract.kt @@ -153,10 +153,6 @@ abstract class ProfileAccountLogoutTaskContract { this.server = MockWebServer() this.server.start() - - val preferences = Mockito.mock(ProfilePreferences::class.java) - Mockito.`when`(this.profile.preferences()).thenReturn(preferences) - Mockito.`when`(preferences.areNotificationsEnabled).thenReturn(true) } @AfterEach @@ -288,7 +284,7 @@ abstract class ProfileAccountLogoutTaskContract { this.bookRegistry.books().values.all { it.status is BookStatus.Loaned.LoanedNotDownloaded } ) - Mockito.verify(tokenHttp, Mockito.times(1)).deleteFCMTokenForProfileAccount(account, true) + Mockito.verify(tokenHttp, Mockito.times(1)).deleteFCMTokenForProfileAccount(account) } /** diff --git a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileDescriptionJSONTest.kt b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileDescriptionJSONTest.kt index da886fb60..e16b99184 100644 --- a/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileDescriptionJSONTest.kt +++ b/simplified-tests/src/test/java/org/nypl/simplified/tests/books/profiles/ProfileDescriptionJSONTest.kt @@ -56,7 +56,6 @@ class ProfileDescriptionJSONTest { mostRecentAccount = AccountID.generate(), playbackRates = hashMapOf(), sleepTimers = hashMapOf(), - areNotificationsEnabled = false, isManualLCPPassphraseEnabled = false ), attributes = ProfileAttributes( diff --git a/simplified-tests/src/test/java/org/nypl/simplified/tests/mocking/MockProfile.kt b/simplified-tests/src/test/java/org/nypl/simplified/tests/mocking/MockProfile.kt index 9a8545128..4a2fa39a2 100644 --- a/simplified-tests/src/test/java/org/nypl/simplified/tests/mocking/MockProfile.kt +++ b/simplified-tests/src/test/java/org/nypl/simplified/tests/mocking/MockProfile.kt @@ -37,7 +37,6 @@ class MockProfile( mostRecentAccount = this.accounts.firstKey(), playbackRates = hashMapOf(), sleepTimers = hashMapOf(), - areNotificationsEnabled = false, isManualLCPPassphraseEnabled = false ), attributes = ProfileAttributes(sortedMapOf()) diff --git a/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugFragment.kt b/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugFragment.kt index f60f19442..b7ee73d2f 100644 --- a/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugFragment.kt +++ b/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugFragment.kt @@ -65,7 +65,6 @@ class SettingsDebugFragment : Fragment(R.layout.settings_debug) { private lateinit var syncAccountsButton: Button private lateinit var enableOpenEBooksQA: Button private lateinit var toolbar: PalaceToolbar - private lateinit var areNotificationsEnabled: SwitchCompat private lateinit var isManualLCPPassphraseEnabled: SwitchCompat override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -99,8 +98,6 @@ class SettingsDebugFragment : Fragment(R.layout.settings_debug) { view.findViewById(R.id.settingsVersionDevSeenLibrarySelectionScreen) this.isManualLCPPassphraseEnabled = view.findViewById(R.id.settingsVersionDevIsManualLCPPassphraseEnabled) - this.areNotificationsEnabled = - view.findViewById(R.id.settingsVersionDevAreNotificationsEnabled) this.cardCreatorFakeLocation = view.findViewById(R.id.settingsVersionDevCardCreatorLocationSwitch) this.showOnlySupportedBooks = @@ -141,8 +138,6 @@ class SettingsDebugFragment : Fragment(R.layout.settings_debug) { this.viewModel.cardCreatorFakeLocation this.isManualLCPPassphraseEnabled.isChecked = this.viewModel.isManualLCPPassphraseEnabled - this.areNotificationsEnabled.isChecked = - this.viewModel.areNotificationsEnabled this.showOnlySupportedBooks.isChecked = this.viewModel.showOnlySupportedBooks this.crashlyticsId.text = @@ -246,9 +241,6 @@ class SettingsDebugFragment : Fragment(R.layout.settings_debug) { this.isManualLCPPassphraseEnabled.setOnCheckedChangeListener { _, isChecked -> this.viewModel.isManualLCPPassphraseEnabled = isChecked } - this.areNotificationsEnabled.setOnCheckedChangeListener { _, isChecked -> - this.viewModel.areNotificationsEnabled = isChecked - } /* * Configure the custom OPDS button. diff --git a/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugViewModel.kt b/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugViewModel.kt index 743820484..4dc1a2953 100644 --- a/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugViewModel.kt +++ b/simplified-ui-settings/src/main/java/org/nypl/simplified/ui/settings/SettingsDebugViewModel.kt @@ -141,18 +141,6 @@ class SettingsDebugViewModel(application: Application) : AndroidViewModel(applic } } - var areNotificationsEnabled: Boolean - get() = - this.profilesController - .profileCurrent() - .preferences() - .areNotificationsEnabled - set(value) { - this.profilesController.profileUpdate { description -> - description.copy(preferences = description.preferences.copy(areNotificationsEnabled = value)) - } - } - var isBootFailureEnabled: Boolean get() = BootFailureTesting.isBootFailureEnabled(getApplication()) diff --git a/simplified-ui-settings/src/main/res/layout/settings_debug.xml b/simplified-ui-settings/src/main/res/layout/settings_debug.xml index bfcbb478a..49ecebd27 100644 --- a/simplified-ui-settings/src/main/res/layout/settings_debug.xml +++ b/simplified-ui-settings/src/main/res/layout/settings_debug.xml @@ -166,15 +166,6 @@ android:enabled="true" android:text="@string/settingsDevEnableManualLCPPassphrase" /> - - DRM Support Enable Hidden Libraries Enable Manual LCP Passphrase - Enable Push Notifications Enable Time Tracking Cause the next application startup to fail Forget All Announcements