-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from lucasnlm/fix-bugs
Fix bugs
- Loading branch information
Showing
28 changed files
with
348 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...mocks/DisabledHapticFeedbackInteractor.kt → ...ne/mocks/DisabledHapticFeedbackManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
common/src/main/java/dev/lucasnlm/antimine/common/level/utils/HapticFeedbackInteractor.kt
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
common/src/main/java/dev/lucasnlm/antimine/common/level/utils/HapticFeedbackManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.lucasnlm.antimine.common.level.utils | ||
|
||
import android.content.Context | ||
import android.content.Context.VIBRATOR_SERVICE | ||
import android.os.Build | ||
import android.os.VibrationEffect | ||
import android.os.Vibrator | ||
|
||
interface IHapticFeedbackManager { | ||
fun longPressFeedback() | ||
fun explosionFeedback() | ||
} | ||
|
||
class HapticFeedbackManager( | ||
context: Context | ||
) : IHapticFeedbackManager { | ||
|
||
private val vibrator by lazy { context.getSystemService(VIBRATOR_SERVICE) as Vibrator } | ||
|
||
override fun longPressFeedback() { | ||
vibrateTo(70, 240) | ||
vibrateTo(10, 100) | ||
} | ||
|
||
override fun explosionFeedback() { | ||
vibrateTo(400, -1) | ||
} | ||
|
||
private fun vibrateTo(time: Long, amplitude: Int) { | ||
if (Build.VERSION.SDK_INT >= 26) { | ||
vibrator.vibrate( | ||
VibrationEffect.createOneShot(time, amplitude) | ||
) | ||
} else { | ||
@Suppress("DEPRECATION") | ||
vibrator.vibrate(time) | ||
} | ||
} | ||
} |
Oops, something went wrong.