From 7a7d36d010ccfdf2a039b7ad28768bb1c8200e2d Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 21 Mar 2022 16:23:19 +0100 Subject: [PATCH] Renames functions and variables --- .../home/room/detail/RoomDetailActivity.kt | 8 +++---- .../home/room/detail/TimelineFragment.kt | 8 +++---- .../detail/composer/VoiceMessageHelper.kt | 14 ++++++------ .../voice/VoiceMessageRecorderView.kt | 14 ++++++------ .../composer/voice/VoiceMessageViews.kt | 4 ++-- .../timeline/factory/MessageItemFactory.kt | 8 +++---- ...cker.kt => AudioMessagePlaybackTracker.kt} | 4 ++-- .../detail/timeline/item/MessageAudioItem.kt | 22 +++++++++---------- 8 files changed, 41 insertions(+), 41 deletions(-) rename vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/{VoiceMessagePlaybackTracker.kt => AudioMessagePlaybackTracker.kt} (97%) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt index aa4ee825dc..5784e6e264 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt @@ -38,7 +38,7 @@ import im.vector.app.databinding.ActivityRoomDetailBinding import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.room.breadcrumbs.BreadcrumbsFragment import im.vector.app.features.home.room.detail.arguments.TimelineArgs -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.matrixto.MatrixToBottomSheet import im.vector.app.features.navigation.Navigator import im.vector.app.features.room.RequireActiveMembershipAction @@ -75,7 +75,7 @@ class RoomDetailActivity : } private var lastKnownPlayingOrRecordingState: Boolean? = null - private val playbackActivityListener = VoiceMessagePlaybackTracker.ActivityListener { isPlayingOrRecording -> + private val playbackActivityListener = AudioMessagePlaybackTracker.ActivityListener { isPlayingOrRecording -> if (lastKnownPlayingOrRecordingState == isPlayingOrRecording) return@ActivityListener when (isPlayingOrRecording) { true -> keepScreenOn() @@ -86,7 +86,7 @@ class RoomDetailActivity : override fun getCoordinatorLayout() = views.coordinatorLayout - @Inject lateinit var playbackTracker: VoiceMessagePlaybackTracker + @Inject lateinit var playbackTracker: AudioMessagePlaybackTracker private lateinit var sharedActionViewModel: RoomDetailSharedActionViewModel private val requireActiveMembershipViewModel: RequireActiveMembershipViewModel by viewModel() @@ -152,7 +152,7 @@ class RoomDetailActivity : override fun onDestroy() { supportFragmentManager.unregisterFragmentLifecycleCallbacks(fragmentLifecycleCallbacks) views.drawerLayout.removeDrawerListener(drawerListener) - playbackTracker.unTrackActivity(playbackActivityListener) + playbackTracker.untrackActivity(playbackActivityListener) super.onDestroy() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 8fad376a0b..aa08ba2b93 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -156,7 +156,7 @@ import im.vector.app.features.home.room.detail.timeline.action.MessageActionsBot import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActionViewModel import im.vector.app.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.home.room.detail.timeline.image.buildImageContentRendererData import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem import im.vector.app.features.home.room.detail.timeline.item.MessageFileItem @@ -259,7 +259,7 @@ class TimelineFragment @Inject constructor( private val roomDetailPendingActionStore: RoomDetailPendingActionStore, private val pillsPostProcessorFactory: PillsPostProcessor.Factory, private val callManager: WebRtcCallManager, - private val voiceMessagePlaybackTracker: VoiceMessagePlaybackTracker, + private val audioMessagePlaybackTracker: AudioMessagePlaybackTracker, private val clock: Clock ) : VectorBaseFragment(), @@ -726,7 +726,7 @@ class TimelineFragment @Inject constructor( } private fun setupVoiceMessageView() { - voiceMessagePlaybackTracker.track(VoiceMessagePlaybackTracker.RECORDING_ID, views.voiceMessageRecorderView) + audioMessagePlaybackTracker.track(AudioMessagePlaybackTracker.RECORDING_ID, views.voiceMessageRecorderView) views.voiceMessageRecorderView.callback = object : VoiceMessageRecorderView.Callback { override fun onVoiceRecordingStarted() { @@ -1260,7 +1260,7 @@ class TimelineFragment @Inject constructor( override fun onPause() { super.onPause() notificationDrawerManager.setCurrentRoom(null) - voiceMessagePlaybackTracker.untrack(VoiceMessagePlaybackTracker.RECORDING_ID) + audioMessagePlaybackTracker.untrack(AudioMessagePlaybackTracker.RECORDING_ID) if (withState(messageComposerViewModel) { it.isVoiceRecording } && requireActivity().isChangingConfigurations) { // we're rotating, maintain any active recordings diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt index 735d356476..bede7a3ce7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt @@ -21,7 +21,7 @@ import android.media.AudioAttributes import android.media.MediaPlayer import androidx.core.content.FileProvider import im.vector.app.BuildConfig -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.voice.VoiceFailure import im.vector.app.features.voice.VoiceRecorder import im.vector.app.features.voice.VoiceRecorderProvider @@ -42,7 +42,7 @@ import javax.inject.Inject */ class VoiceMessageHelper @Inject constructor( private val context: Context, - private val playbackTracker: VoiceMessagePlaybackTracker, + private val playbackTracker: AudioMessagePlaybackTracker, voiceRecorderProvider: VoiceRecorderProvider ) { private var mediaPlayer: MediaPlayer? = null @@ -58,7 +58,7 @@ class VoiceMessageHelper @Inject constructor( amplitudeList.clear() attachmentData.waveform?.let { amplitudeList.addAll(it) - playbackTracker.updateCurrentRecording(VoiceMessagePlaybackTracker.RECORDING_ID, amplitudeList) + playbackTracker.updateCurrentRecording(AudioMessagePlaybackTracker.RECORDING_ID, amplitudeList) } } @@ -127,14 +127,14 @@ class VoiceMessageHelper @Inject constructor( fun startOrPauseRecordingPlayback() { voiceRecorder.getCurrentRecord()?.let { - startOrPausePlayback(VoiceMessagePlaybackTracker.RECORDING_ID, it) + startOrPausePlayback(AudioMessagePlaybackTracker.RECORDING_ID, it) } } fun startOrPausePlayback(id: String, file: File) { stopPlayback() stopRecordingAmplitudes() - if (playbackTracker.getPlaybackState(id) is VoiceMessagePlaybackTracker.Listener.State.Playing) { + if (playbackTracker.getPlaybackState(id) is AudioMessagePlaybackTracker.Listener.State.Playing) { playbackTracker.pausePlayback(id) } else { startPlayback(id, file) @@ -169,7 +169,7 @@ class VoiceMessageHelper @Inject constructor( } fun stopPlayback() { - playbackTracker.stopPlayback(VoiceMessagePlaybackTracker.RECORDING_ID) + playbackTracker.stopPlayback(AudioMessagePlaybackTracker.RECORDING_ID) mediaPlayer?.stop() stopPlaybackTicker() } @@ -190,7 +190,7 @@ class VoiceMessageHelper @Inject constructor( try { val maxAmplitude = voiceRecorder.getMaxAmplitude() amplitudeList.add(maxAmplitude) - playbackTracker.updateCurrentRecording(VoiceMessagePlaybackTracker.RECORDING_ID, amplitudeList) + playbackTracker.updateCurrentRecording(AudioMessagePlaybackTracker.RECORDING_ID, amplitudeList) } catch (e: IllegalStateException) { Timber.e(e, "Cannot get max amplitude. Amplitude recording timer will be stopped.") stopRecordingAmplitudes() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt index 9a643796a9..a9f6e33d50 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt @@ -28,7 +28,7 @@ import im.vector.app.core.hardware.vibrate import im.vector.app.core.time.Clock import im.vector.app.core.utils.DimensionConverter import im.vector.app.databinding.ViewVoiceMessageRecorderBinding -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.lib.core.utils.timer.CountUpTimer import javax.inject.Inject import kotlin.math.floor @@ -41,7 +41,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), VoiceMessagePlaybackTracker.Listener { +) : ConstraintLayout(context, attrs, defStyleAttr), AudioMessagePlaybackTracker.Listener { interface Callback { fun onVoiceRecordingStarted() @@ -207,16 +207,16 @@ class VoiceMessageRecorderView @JvmOverloads constructor( recordingTicker = null } - override fun onUpdate(state: VoiceMessagePlaybackTracker.Listener.State) { + override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) { when (state) { - is VoiceMessagePlaybackTracker.Listener.State.Recording -> { + is AudioMessagePlaybackTracker.Listener.State.Recording -> { voiceMessageViews.renderRecordingWaveform(state.amplitudeList.toTypedArray()) } - is VoiceMessagePlaybackTracker.Listener.State.Playing -> { + is AudioMessagePlaybackTracker.Listener.State.Playing -> { voiceMessageViews.renderPlaying(state) } - is VoiceMessagePlaybackTracker.Listener.State.Paused, - is VoiceMessagePlaybackTracker.Listener.State.Idle -> { + is AudioMessagePlaybackTracker.Listener.State.Paused, + is AudioMessagePlaybackTracker.Listener.State.Idle -> { voiceMessageViews.renderIdle() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt index 09284ea5fc..5070785569 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt @@ -36,7 +36,7 @@ import im.vector.app.core.utils.DimensionConverter import im.vector.app.databinding.ViewVoiceMessageRecorderBinding import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView.DraggingState import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView.RecordingUiState -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker class VoiceMessageViews( private val resources: Resources, @@ -287,7 +287,7 @@ class VoiceMessageViews( views.voicePlaybackWaveform.post { views.voicePlaybackWaveform.recreate() } } - fun renderPlaying(state: VoiceMessagePlaybackTracker.Listener.State.Playing) { + fun renderPlaying(state: AudioMessagePlaybackTracker.Listener.State.Playing) { views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause) views.voicePlaybackControlButton.contentDescription = resources.getString(R.string.a11y_pause_voice_message) val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong()) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 71e546e5f0..30e36d33d3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -41,7 +41,7 @@ import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvid import im.vector.app.features.home.room.detail.timeline.helper.MessageInformationDataFactory import im.vector.app.features.home.room.detail.timeline.helper.MessageItemAttributesFactory import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem import im.vector.app.features.home.room.detail.timeline.item.MessageAudioItem import im.vector.app.features.home.room.detail.timeline.item.MessageAudioItem_ @@ -126,7 +126,7 @@ class MessageItemFactory @Inject constructor( private val lightweightSettingsStorage: LightweightSettingsStorage, private val spanUtils: SpanUtils, private val session: Session, - private val voiceMessagePlaybackTracker: VoiceMessagePlaybackTracker, + private val audioMessagePlaybackTracker: AudioMessagePlaybackTracker, private val locationPinProvider: LocationPinProvider, private val vectorPreferences: VectorPreferences, private val urlMapProvider: UrlMapProvider, @@ -323,7 +323,7 @@ class MessageItemFactory @Inject constructor( .attributes(attributes) .duration(messageContent.audioInfo?.duration ?: 0) .playbackControlButtonClickListener(playbackControlButtonClickListener) - .voiceMessagePlaybackTracker(voiceMessagePlaybackTracker) + .audioMessagePlaybackTracker(audioMessagePlaybackTracker) .isLocalFile(localFilesHelper.isLocalFile(fileUrl)) .mxcUrl(fileUrl) .contentUploadStateTrackerBinder(contentUploadStateTrackerBinder) @@ -366,7 +366,7 @@ class MessageItemFactory @Inject constructor( .duration(messageContent.audioWaveformInfo?.duration ?: 0) .waveform(messageContent.audioWaveformInfo?.waveform?.toFft().orEmpty()) .playbackControlButtonClickListener(playbackControlButtonClickListener) - .voiceMessagePlaybackTracker(voiceMessagePlaybackTracker) + .audioMessagePlaybackTracker(audioMessagePlaybackTracker) .isLocalFile(localFilesHelper.isLocalFile(fileUrl)) .mxcUrl(fileUrl) .contentUploadStateTrackerBinder(contentUploadStateTrackerBinder) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/VoiceMessagePlaybackTracker.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt similarity index 97% rename from vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/VoiceMessagePlaybackTracker.kt rename to vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt index c033af1ef5..774b0d797e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/VoiceMessagePlaybackTracker.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt @@ -22,7 +22,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class VoiceMessagePlaybackTracker @Inject constructor() { +class AudioMessagePlaybackTracker @Inject constructor() { private val mainHandler = Handler(Looper.getMainLooper()) private val listeners = mutableMapOf() @@ -33,7 +33,7 @@ class VoiceMessagePlaybackTracker @Inject constructor() { activityListeners.add(listener) } - fun unTrackActivity(listener: ActivityListener) { + fun untrackActivity(listener: ActivityListener) { activityListeners.remove(listener) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt index e2fac439f7..29f6ab7d62 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt @@ -32,7 +32,7 @@ import im.vector.app.R import im.vector.app.core.epoxy.ClickListener import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder -import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.home.room.detail.timeline.helper.AudioMessagePlaybackTracker import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout import im.vector.app.features.themes.ThemeUtils @@ -66,7 +66,7 @@ abstract class MessageAudioItem : AbsMessageItem() { var playbackControlButtonClickListener: ClickListener? = null @EpoxyAttribute - lateinit var voiceMessagePlaybackTracker: VoiceMessagePlaybackTracker + lateinit var audioMessagePlaybackTracker: AudioMessagePlaybackTracker override fun bind(holder: Holder) { super.bind(holder) @@ -96,13 +96,13 @@ abstract class MessageAudioItem : AbsMessageItem() { holder.audioPlaybackLayout.backgroundTintList = ColorStateList.valueOf(backgroundTint) holder.audioPlaybackControlButton.setOnClickListener { playbackControlButtonClickListener?.invoke(it) } - voiceMessagePlaybackTracker.track(attributes.informationData.eventId, object : VoiceMessagePlaybackTracker.Listener { - override fun onUpdate(state: VoiceMessagePlaybackTracker.Listener.State) { + audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener { + override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) { when (state) { - is VoiceMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder) - is VoiceMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state) - is VoiceMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state) - is VoiceMessagePlaybackTracker.Listener.State.Recording -> Unit + is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder) + is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state) + is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state) + is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit } } }) @@ -122,7 +122,7 @@ abstract class MessageAudioItem : AbsMessageItem() { if (isVoiceMessage) R.string.a11y_play_voice_message else R.string.a11y_play_audio_message ) - private fun renderPlayingState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Playing) { + private fun renderPlayingState(holder: Holder, state: AudioMessagePlaybackTracker.Listener.State.Playing) { holder.audioPlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause) holder.audioPlaybackControlButton.contentDescription = getPauseMessageContentDescription(holder.view.context) holder.audioPlaybackTime.text = formatPlaybackTime(state.playbackTime) @@ -132,7 +132,7 @@ abstract class MessageAudioItem : AbsMessageItem() { if (isVoiceMessage) R.string.a11y_pause_voice_message else R.string.a11y_pause_audio_message ) - private fun renderPausedState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Paused) { + private fun renderPausedState(holder: Holder, state: AudioMessagePlaybackTracker.Listener.State.Paused) { holder.audioPlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play) holder.audioPlaybackControlButton.contentDescription = getPlayMessageContentDescription(holder.view.context) holder.audioPlaybackTime.text = formatPlaybackTime(state.playbackTime) @@ -144,7 +144,7 @@ abstract class MessageAudioItem : AbsMessageItem() { super.unbind(holder) contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId) contentDownloadStateTrackerBinder.unbind(mxcUrl) - voiceMessagePlaybackTracker.untrack(attributes.informationData.eventId) + audioMessagePlaybackTracker.untrack(attributes.informationData.eventId) } override fun getViewStubId() = STUB_ID