2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] Added Vibration Effect On Scanning QR Code (https://github.com/mozilla-mobile/fenix/pull/6129)

* Added Vibration Effect On Scanning QR Code

Added Vibration Feature for the new feature Request
Vibrate phone upon successful pairing https://github.com/mozilla-mobile/fenix/issues/2928

* Added Vibration Effect On Scanning QR Code

Added Vibration Feature for the new feature Request
Vibrate phone upon successful pairing https://github.com/mozilla-mobile/fenix/issues/2928

* Update PairFragment.kt

Removed unwanted blank lines

* Update PairFragment.kt

Removed the Casting with !!
This commit is contained in:
RAJESH KUMAR ARUMUGAM 2019-11-09 03:07:36 +05:30 committed by Jeff Boek
parent afa25a6978
commit 7a847cdf41
2 changed files with 26 additions and 4 deletions

View File

@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" android:requiredFeature="false"/> <uses-permission android:name="android.permission.USE_BIOMETRIC" android:requiredFeature="false"/>
<!-- Needed to prompt the user to give permission to install a downloaded apk --> <!-- Needed to prompt the user to give permission to install a downloaded apk -->

View File

@ -4,9 +4,13 @@
package org.mozilla.fenix.settings package org.mozilla.fenix.settings
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.VibrationEffect
import android.os.Vibrator
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.getSystemService
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.NavHostFragment.findNavController import androidx.navigation.fragment.NavHostFragment.findNavController
@ -25,8 +29,10 @@ class PairFragment : Fragment(R.layout.fragment_pair), BackHandler {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
pairInstructions.text = HtmlCompat.fromHtml(getString(R.string.pair_instructions), pairInstructions.text = HtmlCompat.fromHtml(
HtmlCompat.FROM_HTML_MODE_LEGACY) getString(R.string.pair_instructions),
HtmlCompat.FROM_HTML_MODE_LEGACY
)
qrFeature.set( qrFeature.set(
QrFeature( QrFeature(
@ -40,8 +46,22 @@ class PairFragment : Fragment(R.layout.fragment_pair), BackHandler {
requireContext(), requireContext(),
pairingUrl pairingUrl
) )
findNavController(this@PairFragment) val vibrator = requireContext().getSystemService<Vibrator>()!!
.popBackStack(R.id.turnOnSyncFragment, false) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(
VibrationEffect.createOneShot(
VIBRATE_LENGTH,
VibrationEffect.DEFAULT_AMPLITUDE
)
)
} else {
@Suppress("Deprecation")
vibrator.vibrate(VIBRATE_LENGTH)
}
findNavController(this@PairFragment).popBackStack(
R.id.turnOnSyncFragment,
false
)
}), }),
owner = this, owner = this,
view = view view = view
@ -66,6 +86,7 @@ class PairFragment : Fragment(R.layout.fragment_pair), BackHandler {
companion object { companion object {
private const val REQUEST_CODE_CAMERA_PERMISSIONS = 1 private const val REQUEST_CODE_CAMERA_PERMISSIONS = 1
private const val VIBRATE_LENGTH = 200L
} }
override fun onRequestPermissionsResult( override fun onRequestPermissionsResult(