Commit 6ebe08f1 authored by m2ko's avatar m2ko Committed by eekkelund

Add most animations and lockscreen functions

parent ab5bb3aa
...@@ -13,49 +13,9 @@ import "scripts/desktop.js" as Desktop ...@@ -13,49 +13,9 @@ import "scripts/desktop.js" as Desktop
Item { Item {
id: root id: root
property bool shouldAuthenticate: Lipstick.compositor.visible //&& asd.availableMethods !== 0 property bool shouldAuthenticate: Lipstick.compositor.visible
property int remainingAttempts property int remainingAttempts
property AuthenticationInput authenticationInput property AuthenticationInput authenticationInput
signal codeEntered(string code)
onShouldAuthenticateChanged: {
if (shouldAuthenticate) {
console.log("Requesting security code "+JSON.stringify(authenticationInput))//+ authenticationInput.status)
//authenticationInput.requestSecurityCode()
//DeviceLock.authorization.requestChallenge()
} else {
//authenticator.cancel()
//DeviceLock.authorization.relinquishChallenge()
}
}
/*Component.onCompleted: {
console.log("Requesting security code "+ authenticationInput.Status)
authenticationInput.requestSecurityCode()
}*/
/*Connections {
target: DeviceLock.authorization
onChallengeIssued: {
authenticator.authenticate(
DeviceLock.authorization.challengeCode,
DeviceLock.authorization.allowedMethods)
}
}*/
/*authenticationInput.onAuthenticationUnavailable: {
console.log("Authentication unavailable: "+error)
}
authenticationInput.onFeedback: {
console.log("Feedback: "+feedback)
}
authenticationInput.onAuthenticationStarted: {
console.log("Authentication started")
}
authenticationInput.onAuthenticationEnded: {
console.log("Ended "+confirmed)
}*/
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
...@@ -70,14 +30,23 @@ Item { ...@@ -70,14 +30,23 @@ Item {
} }
NumberAnimation { target: codePad; property: "anchors.horizontalCenterOffset"; to: 0; duration: 100 } NumberAnimation { target: codePad; property: "anchors.horizontalCenterOffset"; to: 0; duration: 100 }
} }
Label { Row {
font.pixelSize: Theme.fontSizeMedium
width: parent.width
text: remainingAttempts > 0 ? qsTr("Attempts remaining:") + " " + remainingAttempts : ""
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
Label {
id: feedbackLabel
font.pixelSize: Theme.fontSizeMedium
text: " "
}
Label {
id: attemptsRemainingLabel
font.pixelSize: Theme.fontSizeMedium
text: " "
}
} }
TextField { TextField {
id: lockCodeField id: lockCodeField
anchors.topMargin: Theme.itemSpacingMedium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
readOnly: true readOnly: true
echoMode: TextInput.PasswordEchoOnEdit echoMode: TextInput.PasswordEchoOnEdit
...@@ -107,16 +76,14 @@ Item { ...@@ -107,16 +76,14 @@ Item {
color: "white" color: "white"
} }
onClicked: { onClicked: {
displayOffTimer.restart()
feedbackLabel.text = " "
attemptsRemainingLabel.text = " "
if (numLabel.text !== "Ca" && numLabel.text !== "OK") { if (numLabel.text !== "Ca" && numLabel.text !== "OK") {
//console.log(authenticationInput.Status)
lockCodeField.insert(lockCodeField.cursorPosition, numLabel.text) lockCodeField.insert(lockCodeField.cursorPosition, numLabel.text)
authenticationInput.requestSecurityCode()
} else { } else {
if (numLabel.text === "OK") { if (numLabel.text === "OK") {
console.log("DeviceLockUI: "+JSON.stringify(authenticationInput))
//auth.authenticate(Authorization.challengeCode, auth.availableMethods)
authenticationInput.enterSecurityCode(lockCodeField.text) authenticationInput.enterSecurityCode(lockCodeField.text)
//codeEntered(lockCodeField.text)
lockCodeField.text = "" lockCodeField.text = ""
} else if (numLabel.text === "Ca"){ } else if (numLabel.text === "Ca"){
lockCodeField.text = "" lockCodeField.text = ""
...@@ -128,17 +95,34 @@ Item { ...@@ -128,17 +95,34 @@ Item {
} }
} }
function displayFeedback(feedback, data) { function displayFeedback(feedback, data) {
console.log("DisplayFeedBack "+feedback+" "+data)
switch(feedback) {
case AuthenticationInput.EnterSecurityCode:
feedbackLabel.text = qsTr("Enter security code")
break
case AuthenticationInput.IncorrectSecurityCode:
feedbackLabel.text = qsTr("Incorrect code")
if(authenticationInput.maximumAttempts !== -1) {
attemptsRemainingLabel.text = qsTr("("+(authenticationInput.maximumAttempts-data.attemptsRemaining)+
"/"+authenticationInput.maximumAttempts+")")
}
animation.start()
break
case AuthenticationInput.TemporarilyLocked:
feedbackLabel.text = qsTr("Temporarily locked")
}
} }
function displayError(error) { function displayError(error) {
console.log("displayError "+error) console.log("displayError "+error)
} }
Connections { Connections {
target: root.authenticationInput target: root.authenticationInput
onFeedback: root.displayFeedback(feedback, data) onFeedback: root.displayFeedback(feedback, data)
onError: root.displayError(error) onError: root.displayError(error)
} }
} }
...@@ -44,7 +44,7 @@ Image { ...@@ -44,7 +44,7 @@ Image {
startX = mouseX; startX = mouseX;
} }
onMouseXChanged: { onMouseXChanged: {
// Checks which swipe // Checks which was it left or right swipe
if(mouseX > (startX+threshold)) { if(mouseX > (startX+threshold)) {
gesture = "right" gesture = "right"
gestureStarted = true; gestureStarted = true;
...@@ -76,8 +76,9 @@ Image { ...@@ -76,8 +76,9 @@ Image {
} }
} }
// Animation to sna codepad into view or out of view // Animation to snap codepad into view or out of view
onReleased: { onReleased: {
displayOffTimer.restart()
if(codePad.inView) { if(codePad.inView) {
if(gesture == "right") { if(gesture == "right") {
if(swipeDistance > threshold) { if(swipeDistance > threshold) {
...@@ -133,6 +134,25 @@ Image { ...@@ -133,6 +134,25 @@ Image {
easing.type: Easing.OutQuint easing.type: Easing.OutQuint
} }
} }
SequentialAnimation {
id: unlockAnimation
property alias valueTo: unlockNumAnimation.to
property alias setProperty: unlockNumAnimation.property
NumberAnimation {
id: unlockNumAnimation
target: lockScreen
property: "y"
to: -height
duration: 250
easing.type: Easing.OutQuint
}
onStopped: {
setLockScreen(false)
}
}
Connections { Connections {
target:Lipstick.compositor target:Lipstick.compositor
onDisplayOff: { onDisplayOff: {
...@@ -175,49 +195,46 @@ Image { ...@@ -175,49 +195,46 @@ Image {
property bool inView: false property bool inView: false
property bool gestureStarted: mouseArea.gestureStarted property bool gestureStarted: mouseArea.gestureStarted
x: 1000 x: width * 2
visible: DeviceLock.state == DeviceLock.Locked && lockscreenVisible() visible: DeviceLock.state == DeviceLock.Locked && lockscreenVisible()
width: lockScreen.width width: lockScreen.width
height: lockScreen.height / 2 height: lockScreen.height / 2
onCodeEntered: { opacity: (1-Math.abs((1 - (-1)) * (x - (-parent.width)) / (parent.width - (-parent.width)) + (-1)))
//authenticationInput.enterSecurityCode(code)
console.log("Security code entered: "+authenticationInput.minimumCodeLength)
}
authenticationInput: DeviceLockAuthenticationInput { authenticationInput: DeviceLockAuthenticationInput {
//property bool unlocked: DeviceLock.state >= DeviceLock.Locked
readonly property bool unlocking: registered readonly property bool unlocking: registered
&& DeviceLock.state >= DeviceLock.Locked && DeviceLock.state < DeviceLock.Undefined && DeviceLock.state >= DeviceLock.Locked && DeviceLock.state < DeviceLock.Undefined
registered: true registered: lockscreenVisible()
active: true active: lockscreenVisible()
//active: lockscreenVisible()
// onUnlockedChanged: console.log("Unlock")
onStatusChanged: {
console.log("Status changed")
}
onUnlockingChanged: { onUnlockingChanged: {
console.log("Unlock")
if (unlocking) { if (unlocking) {
DeviceLock.unlock() DeviceLock.unlock()
} else { } else {
DeviceLock.cancel() DeviceLock.cancel()
} }
} }
onAuthenticationUnavailable: { onAuthenticationEnded: {
console.log("Authentication unavailable: "+error) if(confirmed) {
} unlockAnimationHelper(mouseArea.gesture)
}else {
onFeedback: { }
console.log("Feedback: "+feedback)
}
onAuthenticationStarted: {
console.log("Authentication started")
} }
onAuthenticationEnded: { function unlockAnimationHelper(gesture) {
console.log("Ended "+confirmed) if(gesture == "left") {
unlockAnimation.setProperty = "x"
unlockAnimation.valueTo = -width
unlockAnimation.start()
}
if(gesture == "right") {
unlockAnimation.setProperty = "x"
unlockAnimation.valueTo = width
unlockAnimation.start()
}
} }
} }
......
...@@ -66,7 +66,6 @@ Page { ...@@ -66,7 +66,6 @@ Page {
id: desktop id: desktop
property alias lockscreen: lockScreen property alias lockscreen: lockScreen
property alias switcher: switcher property alias switcher: switcher
//property alias codepad: codePad
property int statusBarHeight: statusbar.height property int statusBarHeight: statusbar.height
property bool codepadVisible: false property bool codepadVisible: false
property bool deviceLocked: DeviceLock.state >= DeviceLock.Locked property bool deviceLocked: DeviceLock.state >= DeviceLock.Locked
......
...@@ -114,7 +114,6 @@ Compositor { ...@@ -114,7 +114,6 @@ Compositor {
id: overlayLayer id: overlayLayer
z: 5 z: 5
//visible: root.appActive
} }
Item { Item {
...@@ -150,12 +149,6 @@ Compositor { ...@@ -150,12 +149,6 @@ Compositor {
else if (!root.appActive && DeviceLock.state !== DeviceLock.Locked) { else if (!root.appActive && DeviceLock.state !== DeviceLock.Locked) {
state = "cover" state = "cover"
} }
else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && !Desktop.instance.codepadVisible) {
//state = "pullCodepad"
}
else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && Desktop.instance.codepadVisible) {
//state = "pushCodepad"
}
} }
onGestureFinished: { onGestureFinished: {
...@@ -182,15 +175,7 @@ Compositor { ...@@ -182,15 +175,7 @@ Compositor {
if(gesture == "down") { if(gesture == "down") {
setDisplayOff() setDisplayOff()
} }
}/*
// Brings up codepad, only left and right swipes allowed for it for now
else if (Desktop.instance.lockscreenVisible() && !Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && (gesture !== "down" && gesture !== "up")) {
Desktop.instance.codepadVisible = true
} }
// Hides codepad but does not unlock the code, only left and right swipes allowed for now
else if (Desktop.instance.lockscreenVisible() && Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && gesture !== "down" && gesture !== "up") {
Desktop.instance.codepadVisible = false
}*/
// Unlocks if no security code required // Unlocks if no security code required
else if (DeviceLock.state !== DeviceLock.Locked && Desktop.instance.lockscreenVisible()) { else if (DeviceLock.state !== DeviceLock.Locked && Desktop.instance.lockscreenVisible()) {
Desktop.instance.setLockScreen(false) Desktop.instance.setLockScreen(false)
...@@ -249,65 +234,7 @@ Compositor { ...@@ -249,65 +234,7 @@ Compositor {
Desktop.instance.lockscreen.height : Desktop.instance.lockscreen.height :
Desktop.instance.lockscreen.width)+gestureArea.value) ) ) Desktop.instance.lockscreen.width)+gestureArea.value) ) )
} }
}/* }
// pullCodepad is when you are pulling codepad into view to enter security code
State {
name: "pullCodepad"
when: DeviceLock.state >= DeviceLock.Locked//Desktop.instance.codepadVisible
PropertyChanges {
target: Desktop.instance
codepadVisible: true
}
PropertyChanges {
target: gestureArea
delayReset: true
}
PropertyChanges {
target: Desktop.instance.codepad
// Confusing logic and math to get the codepad follow your finger
x: gestureArea.lockscreenX + (gestureArea.value < 0 ? Desktop.instance.lockscreen.width : -Desktop.instance.lockscreen.width) +
((gestureArea.horizontal) ? (Desktop.instance.lockscreenVisible()?(gestureArea.value) :
(gestureArea.gesture == "right" ?
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
-Desktop.instance.lockscreen.width :
-Desktop.instance.lockscreen.height)+Math.abs(gestureArea.value) :
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.width :
Desktop.instance.lockscreen.height)+gestureArea.value) ) : 0 )
// Bringing up the codepad opacity from 0 to 1
opacity: gestureArea.horizontal ? (gestureArea.value < 0 ? (gestureArea.value / -Desktop.instance.lockscreen.width) :
gestureArea.value / Desktop.instance.lockscreen.width) : 0
}
},
// pushCodepad is when you are pushing the codepad away without entering a security code
State {
name: "pushCodepad"
when: Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && Desktop.instance.codepadVisible
PropertyChanges {
target: gestureArea
delayReset: true
}
PropertyChanges {
target: Desktop.instance.codepad
// Confusing logic for the codepad to follow your swipe
x: gestureArea.lockscreenX +
((gestureArea.horizontal) ? (Desktop.instance.lockscreenVisible()?(gestureArea.value) :
(gestureArea.gesture == "right" ?
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
-Desktop.instance.lockscreen.width :
-Desktop.instance.lockscreen.height)+Math.abs(gestureArea.value) :
((Desktop.instance.lockscreen.width === topmostWindow.width) ?
Desktop.instance.lockscreen.width :
Desktop.instance.lockscreen.height)+gestureArea.value) ) : 0 )
// Hiding the codepad with opacity fading from 1 to 0
opacity: 1 - (gestureArea.horizontal ? (gestureArea.value < 0 ? (gestureArea.value / -Desktop.instance.lockscreen.width) :
gestureArea.value / Desktop.instance.lockscreen.width) : 0)
}
}*/
] ]
SequentialAnimation { SequentialAnimation {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment