PIN code: request PIN code if phone has been locked
This commit is contained in:
parent
d0ec5a13f3
commit
77f06b962d
|
@ -5,7 +5,7 @@ Features ✨:
|
||||||
-
|
-
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
-
|
- PIN code: request PIN code if phone has been locked
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Fix Splash layout on small screens
|
- Fix Splash layout on small screens
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
package im.vector.app
|
package im.vector.app
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.HandlerThread
|
import android.os.HandlerThread
|
||||||
|
@ -92,6 +95,15 @@ class VectorApplication :
|
||||||
// font thread handler
|
// font thread handler
|
||||||
private var fontThreadHandler: Handler? = null
|
private var fontThreadHandler: Handler? = null
|
||||||
|
|
||||||
|
private val powerKeyReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent) {
|
||||||
|
if (intent.action == Intent.ACTION_SCREEN_OFF
|
||||||
|
&& vectorPreferences.useFlagPinCode()) {
|
||||||
|
pinLocker.screenIsOff()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
enableStrictModeIfNeeded()
|
enableStrictModeIfNeeded()
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
@ -163,6 +175,12 @@ class VectorApplication :
|
||||||
ProcessLifecycleOwner.get().lifecycle.addObserver(pinLocker)
|
ProcessLifecycleOwner.get().lifecycle.addObserver(pinLocker)
|
||||||
// This should be done as early as possible
|
// This should be done as early as possible
|
||||||
// initKnownEmojiHashSet(appContext)
|
// initKnownEmojiHashSet(appContext)
|
||||||
|
|
||||||
|
applicationContext.registerReceiver(powerKeyReceiver, IntentFilter().apply {
|
||||||
|
// Looks like i cannot receive OFF, if i don't have both ON and OFF
|
||||||
|
addAction(Intent.ACTION_SCREEN_OFF)
|
||||||
|
addAction(Intent.ACTION_SCREEN_ON)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun enableStrictModeIfNeeded() {
|
private fun enableStrictModeIfNeeded() {
|
||||||
|
|
|
@ -81,6 +81,11 @@ class PinLocker @Inject constructor(
|
||||||
computeState()
|
computeState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun screenIsOff() {
|
||||||
|
shouldBeLocked = true
|
||||||
|
computeState()
|
||||||
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||||
fun entersForeground() {
|
fun entersForeground() {
|
||||||
val timeElapsedSinceBackground = SystemClock.elapsedRealtime() - entersBackgroundTs
|
val timeElapsedSinceBackground = SystemClock.elapsedRealtime() - entersBackgroundTs
|
||||||
|
|
Loading…
Reference in New Issue