Skip to content

Commit

Permalink
fix: change vibration pattern for ping (WPB-10804) (#3443)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored Sep 13, 2024
1 parent 1e8ac6d commit 26d0d7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/src/main/kotlin/com/wire/android/media/PingRinger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ class PingRinger @Inject constructor(private val context: Context) {
if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
appLogger.i("Starting vibration")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
it.vibrate(VibrationEffect.createWaveform(VIBRATE_PATTERN, VibrationEffect.DEFAULT_AMPLITUDE))
it.vibrate(VibrationEffect.createWaveform(VIBRATE_PATTERN, DO_NOT_REPEAT))
} else {
@Suppress("DEPRECATION")
it.vibrate(VIBRATE_PATTERN, VibrationEffect.DEFAULT_AMPLITUDE)
it.vibrate(VIBRATE_PATTERN, DO_NOT_REPEAT)
}
} else {
appLogger.i("Skipping vibration")
Expand All @@ -101,6 +101,7 @@ class PingRinger @Inject constructor(private val context: Context) {
}

companion object {
private val VIBRATE_PATTERN: LongArray = longArrayOf(0L, 1000L, 1000L, 1000L)
val VIBRATE_PATTERN: LongArray = longArrayOf(50, 50, 100, 150, 200, 250)
const val DO_NOT_REPEAT = -1 // Do not repeat.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationChannelGroupCompat
import androidx.core.app.NotificationManagerCompat
import com.wire.android.appLogger
import com.wire.android.media.PingRinger
import com.wire.kalium.logic.data.user.SelfUser
import com.wire.kalium.logic.data.user.UserId
import javax.inject.Inject
Expand Down Expand Up @@ -170,6 +171,7 @@ class NotificationChannelsManager @Inject constructor(
.Builder(NotificationConstants.getPingsChannelId(userId), NotificationManagerCompat.IMPORTANCE_HIGH)
.setName(NotificationConstants.PING_CHANNEL_NAME)
.setGroup(channelGroupId)
.setVibrationPattern(PingRinger.VIBRATE_PATTERN)
.setSound(knockSoundUri, audioAttributes)
.build()

Expand Down

0 comments on commit 26d0d7b

Please sign in to comment.