mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 06:15:12 +00:00
remove unused code
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
e121d32984
commit
d33857e603
@ -243,7 +243,6 @@ class CallNotificationActivity : CallBaseActivity() {
|
||||
var isNotificationOpen = true
|
||||
while (isNotificationOpen) {
|
||||
Thread.sleep(1000)
|
||||
Log.d(TAG, ".")
|
||||
if (!NotificationUtils.isNotificationVisible(context, notificationTimestamp!!.toInt())) {
|
||||
isNotificationOpen = false
|
||||
finish()
|
||||
|
@ -25,7 +25,6 @@ import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Vibrator
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
|
||||
@ -60,28 +59,4 @@ object DoNotDisturbUtils {
|
||||
|
||||
return shouldPlaySound
|
||||
}
|
||||
|
||||
private fun hasVibrator(context: Context?): Boolean {
|
||||
val vibrator = context?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
return vibrator.hasVibrator()
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun shouldVibrate(
|
||||
context: Context? = NextcloudTalkApplication.sharedApplication?.applicationContext,
|
||||
vibrate: Boolean
|
||||
): Boolean {
|
||||
|
||||
if (hasVibrator(context)) {
|
||||
val audioManager = context?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
|
||||
return if (vibrate) {
|
||||
audioManager.ringerMode != AudioManager.RINGER_MODE_SILENT
|
||||
} else {
|
||||
audioManager.ringerMode == AudioManager.RINGER_MODE_VIBRATE
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.os.Vibrator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -32,7 +31,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class DoNotDisturbUtilsTest {
|
||||
@ -46,18 +44,14 @@ public class DoNotDisturbUtilsTest {
|
||||
@Mock
|
||||
private AudioManager audioManager;
|
||||
|
||||
@Mock
|
||||
private Vibrator vibrator;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
when(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager);
|
||||
when(context.getSystemService(Context.AUDIO_SERVICE)).thenReturn(audioManager);
|
||||
when(context.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(vibrator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldPlaySound_givenAndroidMAndInterruptionFilterNone_assertReturnsFalse() {
|
||||
DoNotDisturbUtils.INSTANCE.setTestingBuildVersion(Build.VERSION_CODES.M);
|
||||
@ -77,32 +71,4 @@ public class DoNotDisturbUtilsTest {
|
||||
assertFalse("shouldPlaySound incorrectly returned true",
|
||||
DoNotDisturbUtils.INSTANCE.shouldPlaySound(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldVibrate_givenNoVibrator_assertReturnsFalse() {
|
||||
when(vibrator.hasVibrator()).thenReturn(false);
|
||||
|
||||
assertFalse("shouldVibrate returned true despite no vibrator",
|
||||
DoNotDisturbUtils.INSTANCE.shouldVibrate(context, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldVibrate_givenVibratorAndRingerModeNormal_assertReturnsTrue() {
|
||||
when(vibrator.hasVibrator()).thenReturn(true);
|
||||
|
||||
when(audioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||
|
||||
assertTrue("shouldVibrate incorrectly returned false",
|
||||
DoNotDisturbUtils.INSTANCE.shouldVibrate(context, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldVibrate_givenVibratorAndRingerModeSilent_assertReturnsFalse() {
|
||||
when(vibrator.hasVibrator()).thenReturn(true);
|
||||
|
||||
when(audioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||
|
||||
assertFalse("shouldVibrate returned true despite ringer mode set to silent",
|
||||
DoNotDisturbUtils.INSTANCE.shouldVibrate(context, true));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user