[#355] Lock screen to portrait
- Adds capability to customize the screen lock via gradle.properties to enable it while developing or testing the app UI easily - Closes #355
This commit is contained in:
parent
692e5fc0d2
commit
a15bea738f
|
@ -103,6 +103,7 @@ tasks {
|
||||||
"ZCASH_SUPPORT_EMAIL_ADDRESS" to "support@electriccoin.co",
|
"ZCASH_SUPPORT_EMAIL_ADDRESS" to "support@electriccoin.co",
|
||||||
"IS_SECURE_SCREEN_PROTECTION_ACTIVE" to "true",
|
"IS_SECURE_SCREEN_PROTECTION_ACTIVE" to "true",
|
||||||
"IS_DARK_MODE_ENABLED" to "false",
|
"IS_DARK_MODE_ENABLED" to "false",
|
||||||
|
"IS_SCREEN_ROTATION_ENABLED" to "false",
|
||||||
|
|
||||||
"ZCASH_DEBUG_KEYSTORE_PATH" to "",
|
"ZCASH_DEBUG_KEYSTORE_PATH" to "",
|
||||||
"ZCASH_RELEASE_KEYSTORE_PATH" to "",
|
"ZCASH_RELEASE_KEYSTORE_PATH" to "",
|
||||||
|
|
|
@ -64,10 +64,11 @@ ZCASH_SUPPORT_EMAIL_ADDRESS=support@electriccoin.co
|
||||||
# Recommended protection of screens with sensitive data.
|
# Recommended protection of screens with sensitive data.
|
||||||
# It is enabled by default to protect the developers from revealing their wallet secrets by mistake.
|
# It is enabled by default to protect the developers from revealing their wallet secrets by mistake.
|
||||||
IS_SECURE_SCREEN_PROTECTION_ACTIVE=true
|
IS_SECURE_SCREEN_PROTECTION_ACTIVE=true
|
||||||
|
|
||||||
# Forcibly turn on or off the UI dark mode support. If enabled, then the device's dark mode system setting value is
|
# Forcibly turn on or off the UI dark mode support. If enabled, then the device's dark mode system setting value is
|
||||||
# applied.
|
# applied.
|
||||||
IS_DARK_MODE_ENABLED=false
|
IS_DARK_MODE_ENABLED=false
|
||||||
|
# Set whether the screen rotation is enabled or the screen orientation is locked in the portrait mode.
|
||||||
|
IS_SCREEN_ROTATION_ENABLED=false
|
||||||
|
|
||||||
# Set keystore details to enable build signing. Typically these
|
# Set keystore details to enable build signing. Typically these
|
||||||
# are overridden via ~/.gradle/gradle.properties to allow secure injection.
|
# are overridden via ~/.gradle/gradle.properties to allow secure injection.
|
||||||
|
|
|
@ -64,6 +64,15 @@ androidComponents {
|
||||||
comment = "Whether is the SecureScreen sensitive data protection enabled"
|
comment = "Whether is the SecureScreen sensitive data protection enabled"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
// To configure screen orientation in runtime
|
||||||
|
variant.buildConfigFields.put(
|
||||||
|
"IS_SCREEN_ROTATION_ENABLED",
|
||||||
|
BuildConfigField(
|
||||||
|
type = "boolean",
|
||||||
|
value = project.property("IS_SCREEN_ROTATION_ENABLED").toString(),
|
||||||
|
comment = "Whether is the screen rotation enabled, otherwise, it's locked in the portrait mode"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package co.electriccoin.zcash.ui
|
package co.electriccoin.zcash.ui
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
|
@ -66,6 +68,8 @@ class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
setAllowedScreenOrientation()
|
||||||
|
|
||||||
setupSplashScreen()
|
setupSplashScreen()
|
||||||
|
|
||||||
setupUiContent()
|
setupUiContent()
|
||||||
|
@ -73,6 +77,18 @@ class MainActivity : ComponentActivity() {
|
||||||
monitorForBackgroundSync()
|
monitorForBackgroundSync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the screen rotation is enabled or screen orientation is locked in the portrait mode.
|
||||||
|
*/
|
||||||
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
|
private fun setAllowedScreenOrientation() {
|
||||||
|
requestedOrientation = if (BuildConfig.IS_SCREEN_ROTATION_ENABLED) {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
|
} else {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupSplashScreen() {
|
private fun setupSplashScreen() {
|
||||||
val splashScreen = installSplashScreen()
|
val splashScreen = installSplashScreen()
|
||||||
val start = SystemClock.elapsedRealtime().milliseconds
|
val start = SystemClock.elapsedRealtime().milliseconds
|
||||||
|
|
Loading…
Reference in New Issue