Skip to content

Ms 720 add audio notification for finger removal after scanning#913

Merged
meladRaouf merged 5 commits into
mainfrom
MS-720-Add-Audio-Notification-for-Finger-Removal-After-Scanning
Oct 1, 2024
Merged

Ms 720 add audio notification for finger removal after scanning#913
meladRaouf merged 5 commits into
mainfrom
MS-720-Add-Audio-Notification-for-Finger-Removal-After-Scanning

Conversation

@meladRaouf
Copy link
Copy Markdown
Collaborator

No description provided.

@cla-bot cla-bot Bot added the ... label Sep 24, 2024
@meladRaouf meladRaouf force-pushed the MS-720-Add-Audio-Notification-for-Finger-Removal-After-Scanning branch from a997e82 to a80d3b6 Compare September 24, 2024 05:58
@meladRaouf meladRaouf requested review from a team, BurningAXE, TristramN, alex-vt, alexandr-simprints, luhmirin-s and ybourgery and removed request for a team September 24, 2024 06:14
@meladRaouf meladRaouf marked this pull request as ready for review September 24, 2024 06:14
private fun isAudioEnabled() =
PreferenceManager
.getDefaultSharedPreferences(requireContext())
.getBoolean(AUDIO_PREFERENCE_KEY, true)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't yet reached an agreement with Jon regarding the default value of the preference.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final agreement is to make it false

}

private fun playBeep() {
val mediaPlayer = MediaPlayer.create(context, R.raw.beep)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the MediaPlayer instance be created on the Fragment properties level so that we don't have to re-initialize it every time? If memory serves me right, the MediaPlayer creation might be resource-intensive due to codec and decoders initialization etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you decide that creating a media player instance makes sense, then please also make sure that it is re-created correctly once the device is rotated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also suggest moving it together with the PreferenceManager to some kind of injectable (ideally singleton) manager class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem to me that the LiveData object is the way to go in a tracker that might be used outside of the lifecycle-aware classes.

Using SharedFlow seems more appropriate

class FingerprintScanningStatusTracker @Inject constructor() {
    private val _scanCompleted = MutableSharedFlow<Unit>()
    val scanCompleted = _scanCompleted.asSharedFlow()

    suspend fun notifyScanCompleted() {
        _scanCompleted.emit(Unit)
    }
}

}

private fun playBeep() {
val mediaPlayer = MediaPlayer.create(context, R.raw.beep)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also suggest moving it together with the PreferenceManager to some kind of injectable (ideally singleton) manager class.

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a part of version bump PR, not a feature PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing the KSP rollback


// Android X
implementation(libs.androidX.ui.viewpager2)
implementation(libs.androidX.ui.preference)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need preferences UI in this module?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To access the PrefsManger class as it is part of the androidx prefs lib

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to decouple the actual setting from the UI?

Copy link
Copy Markdown
Contributor

@luhmirin-s luhmirin-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pressed the wrong button :( Was supposed to be just comments.

@luhmirin-s luhmirin-s self-requested a review September 24, 2024 07:23
@sonarqubecloud
Copy link
Copy Markdown

import javax.inject.Singleton

@Singleton
class FingerprintScanningStatusTracker @Inject constructor() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a nitpick, but from the name and usage in the code above, I expected this to handle multiple status values. IMO, this class should either handle all the status changes (at least have an easy way to extend to do so) or have a less generic name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luhmirin-s in this story I will introduce the idle success and failure flows

@meladRaouf meladRaouf dismissed alexandr-simprints’s stale review October 1, 2024 07:55

The media player is now initialized when first needed and then reused for subsequent scans.

@meladRaouf meladRaouf merged commit f612c28 into main Oct 1, 2024
@meladRaouf meladRaouf deleted the MS-720-Add-Audio-Notification-for-Finger-Removal-After-Scanning branch October 1, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants