ICE (In Case Of Emergency) field on lock screen

@wetab73 I have a probably stupid noob question about the patch.json file. From where do you get the id: number?

Edit:
Forget it! I found the information.

> id: A numeric ID used by Web Catalog. This MUST NOT be included in Patches which are not distributed via Web Catalog.

Does your device lack Foreca Weather at all (both on Lock screen and on the Events screen)? Is this because it’s a community port? I had no idea about it. If so, then it would mean that the /usr/share/lipstick-jolla-home-qt5/lockscreen/LockItem.qml might be different than in “regular” SFOS. But in such case, Patchmanager should refuse to activate the patch.

Another thing, what is your OS version? I only entered 4.4.0.72 and 4.4.0.68 in the patch.json file because I was too lazy to list all the earlier versions. If your version is different than one of those, you need to either manually add your version (at the end of the patch.json file) or enable the “Allow incompatible patches” option in Patchmanager’s Settings or else it won’t be shown.

Sorry, I took the ID out of nowhere, for my private use (by selecting a random number not used by any other patch of mine), and I forgot to remove it before sharing it here. This patch isn’t in the Web catalog (I’ll publish it there once I find the time to make a settings page to enter/edit the text), but when making the patch I wasn’t sure if that parameter could be just omitted in the json file so I simply took a random number. Please remove it.

I didn’t have Foreca weather because I didn’t want it but I installed it to see - no difference.
My OS version is 4.4.0.58, I entered it to the json file, no change.

So when you installed Foreca, do you now have the weather widget on the Lock screen? I am not familiar with the XZ2c community port, so if you don’t PRECISELY tell me all the details I won’t be able to help.

Let’s start from the very beginning: isn’t the patch even listed on the list of installed patches? Or is it listed but can’t be activated? Or what else?

After you added the 4.4.0.58 version to the patch.json file, did you reboot? If not, please do. Or alternatively temporarily enable the “Allow incompatible patches” option.

It just HAS TO be listed if all the above is correct. It may not get enabled if your community port’s LockItem.qml file is different, but it HAS TO be visible on the list of installed patches.

OK, so I enhanced the patch by adding a simple settings page to easily enter/edit the text. That settings page is accessible in the Patchmanager itself by tapping the patch name on the list of patches. Changes entered there are applied instantenously. Dconf is used to store the text.

Files:

unified_diff.patch

--- a/usr/share/lipstick-jolla-home-qt5/lockscreen/LockItem.qml	Mon Oct  3 18:31:06 2022
+++ b/usr/share/lipstick-jolla-home-qt5/lockscreen/LockItem.qml	Mon Oct  3 18:52:50 2022
@@ -15,6 +15,7 @@
 import com.jolla.lipstick 0.1
 import com.jolla.settings.system 1.0
 import org.nemomobile.lipstick 0.1
+import org.nemomobile.configuration 1.0
 import "../backgrounds"
 import "../main"
 import "../statusarea"
@@ -181,6 +182,13 @@
         enabled: !lockScreen.lowPowerMode && lockScreen.locked && !lockScreen.panning
         onClicked: hintEdges()
     }
+    
+    ConfigurationGroup {
+        id: config
+        path: "/desktop/lipstick-jolla-home/devicelock/customText"
+        property string firstLine: []
+        property string secondLine: []
+}
 
     ContrastBackground {
         id: centerBackground
@@ -190,8 +198,8 @@
                 ? Theme.paddingLarge
                 : (lockItem.height - lockItem.contentTopMargin - height) / 2)
 
-        width: Math.max(clock.width, weatherIndicator.width)
-        height: clock.height + weatherIndicator.height
+        width: Math.max(clock.width, weatherIndicator.width, if_found.width)
+        height: clock.height + weatherIndicator.height + (if_found.height * 2)
 
         opacity: Math.min(clock.transitionOpacity, clock.unlockOpacity)
 
@@ -287,6 +295,25 @@
             temperatureFontPixelSize: clock.weekdayFont.pixelSize
             active: visible
         }
+        
+        Label {
+          id: if_found
+          
+          anchors {
+              horizontalCenter: clock.horizontalCenter
+              top: weatherIndicator.bottom
+              topMargin: Theme.paddingLarge * 2
+              }
+              
+          font.pixelSize: Theme.fontSizeLarge
+          color: lockScreen.textColor
+          textFormat: Text.RichText
+          horizontalAlignment: Text.AlignHCenter
+          visible: true
+
+          text: config.firstLine + "<br>" + config.secondLine
+          }
+          
     }
 
     ContrastBackground {

main.qml (copy it to the same folder as the remaning files)

import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.configuration 1.0

Page {
    id: page

    ConfigurationGroup {
        id: config
        path: "/desktop/lipstick-jolla-home/devicelock/customText"
        property string firstLine: ""
        property string secondLine: ""
    }

    SilicaFlickable {
            anchors.fill: parent
            contentHeight: content.height


            Column {
                id: content
                width: parent.width
                spacing: Theme.paddingLarge

                PageHeader {
                                title: qsTr("Your text on Lock Screen")
                            }

                TextArea {
                    id: firstLine
                    width: parent.width
                    placeholderText: "What to show in the first row"
                    text: config.firstLine
                    onTextChanged: config.firstLine = text
                    }

                TextArea {
                    id: secondLine
                    width: parent.width
                    placeholderText: "What to show in the second row"
                    text: config.secondLine
                    onTextChanged: config.secondLine = text
                    }

            }
    }

}

patch.json

{"description": "Shows two lines of custom text on Lock screen, right below the Clock and Weather widgets", "name": "custom-text-on-lockscreen", "display_name": "Custom text on Lock Screen", "category": "silica", "author": "wetab73", "discussion": "", "donations": "", "sources": "", "version": "0.0.2", "compatible": ["4.4.0.72","4.4.0.68","4.4.0.58"]}

Notes:

  • I listed three OS versions as compatible in patch.json. If you have a different OS version, either add it to patch.json or enable the “Allow incompatible patches” option in Patchmanager’s settings.
  • When I find time, I will probably add the patch to the Web catalog.
2 Likes

Just one note about the ID field in the JSON file:

It is more or less irrelevant for Patchmanager to work correctly. Its only purpose is to detect updates to patches published via Web Catalog.

It is fine, and recommended, to not have this field in JSON files which have not been generated through Web Catalog.

No need to select a random value, just leave it out of the JSON completely. (The same goes for last_updated.)

2 Likes

Oh, thank you! Good to know, I will edit the json file right away and remove that field (as well as last_updated). I was wondering a few times if it is required and I planned to test if it works without it but somehow I never did it. Now I know :slight_smile:

Hi wetab73, thanks for your help.
When Foreca is installed I have the widget on the lockscreen.
I have never had the patch listed under installed patches and I rebooted after every change.
I seem to remember having trouble with patchmanager in the past. This may be port related…when the next update is available I’m going to reflash entirely after some dodgy upgrades.

So there is only one possibility: there is something wrong with either the patch files you copied from here or the folder containing them (e.g. wrong permissions, wrong ownership, wrong encoding, wrong content - not fully copied / truncated, etc.). Maybe you should check if the files and the folder have correct permissions and defaultuser (or nemo, depending on your OS) ownership. Maybe you copied them (and/or created the folder) as root and they are accessible by root only…

Can you provide output of the following commands?

ls -al /usr/share/patchmanager/patches/contact-data-on-lockscreen/ (to see permissions and ownership of files)

ls -al /usr/share/patchmanager/patches/ (to check permissions and ownership of the contact-data-on-lockscreen folder itself)

“Maybe you copied them (and/or created the folder) as root and they are accessible by root only…”
Yes, I tried without root and was denied permission, both for directory and files.

In the terminal type:

devel-su (and then your password from the developer mode settings)

chown defaultuser:defaultuser /usr/share/patchmanager/patches/contact-data-on-lockscreen
chown defaultuser:defaultuser /usr/share/patchmanager/patches/contact-data-on-lockscreen/*

(or replace defaultuser:defaultuser with nemo:nemo if you have nemo user rather than defaultuser)

Reboot and please check if the patch is now visible on the list. If not, temporariy enable the “Show incompatible patches” option, just to check if it makes the patch visible. If it is still not shown then sorry, I’m running out of ideas.

1 Like

Works for me, thanks a lot!
Small remark: modify the chown commands to nemo:nemo if that is your user agent

1 Like

Definitely something I want to see in addtion to a shffle lockpad being integrated into default options.

Very useful patch but to me it would be even more useful with three or four lines of text on screen, as I need to provide some medical info to the ICE text .
I’ve tried to add one more line myself, but with my very limited programming experience, I did not succeed.
Is it possible you @wetab73 could help add one or two more lines (maybe a bit smaller text size)?

1 Like

OK, I’ll play with it over the weekend. One more line shouldn’t be a problem, not sure about two lines because the limit is that multimedia controls (shown when playing media on the lower part of the screen) need to fit there, too.

2 Likes

One more line would be great.

As promised, here’s the new version. I managed to fit four lines, at least on both the 10 III and the XA2 Ultra they fit just fine and do not conflict with the media playback controls.

unified_diff.patch

--- a/usr/share/lipstick-jolla-home-qt5/lockscreen/LockItem.qml	Mon Oct  3 18:31:06 2022
+++ b/usr/share/lipstick-jolla-home-qt5/lockscreen/LockItem.qml	Sat Oct  8 03:45:04 2022
@@ -15,6 +15,7 @@
 import com.jolla.lipstick 0.1
 import com.jolla.settings.system 1.0
 import org.nemomobile.lipstick 0.1
+import org.nemomobile.configuration 1.0
 import "../backgrounds"
 import "../main"
 import "../statusarea"
@@ -181,6 +182,15 @@
         enabled: !lockScreen.lowPowerMode && lockScreen.locked && !lockScreen.panning
         onClicked: hintEdges()
     }
+    
+    ConfigurationGroup {
+        id: config
+        path: "/desktop/lipstick-jolla-home/devicelock/customText"
+        property string firstLine: []
+        property string secondLine: []
+        property string thirdLine: []
+        property string fourthLine: []
+}
 
     ContrastBackground {
         id: centerBackground
@@ -190,8 +200,8 @@
                 ? Theme.paddingLarge
                 : (lockItem.height - lockItem.contentTopMargin - height) / 2)
 
-        width: Math.max(clock.width, weatherIndicator.width)
-        height: clock.height + weatherIndicator.height
+        width: Math.max(clock.width, weatherIndicator.width, if_found.width)
+        height: clock.height + weatherIndicator.height + (Theme.paddingLarge * 2) + if_found.height
 
         opacity: Math.min(clock.transitionOpacity, clock.unlockOpacity)
 
@@ -287,6 +297,25 @@
             temperatureFontPixelSize: clock.weekdayFont.pixelSize
             active: visible
         }
+        
+        Label {
+          id: if_found
+          
+          anchors {
+              horizontalCenter: clock.horizontalCenter
+              top: weatherIndicator.bottom
+              topMargin: Theme.paddingLarge * 2
+              }
+              
+          font.pixelSize: Theme.fontSizeLarge
+          color: lockScreen.textColor
+          textFormat: Text.RichText
+          horizontalAlignment: Text.AlignHCenter
+          visible: true
+
+          text: (config.firstLine ? config.firstLine + "<br>" : "") + (config.secondLine ? config.secondLine + "<br>" : "") + (config.thirdLine ? config.thirdLine + "<br>" : "") + (config.fourthLine ? config.fourthLine : "")
+          }
+          
     }
 
     ContrastBackground {

main.qml

import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.configuration 1.0

Page {
    id: page

    ConfigurationGroup {
        id: config
        path: "/desktop/lipstick-jolla-home/devicelock/customText"
        property string firstLine: ""
        property string secondLine: ""
        property string thirdLine: ""
        property string fourthLine: ""
    }

    SilicaFlickable {
            anchors.fill: parent
            contentHeight: content.height


            Column {
                id: content
                width: parent.width
                spacing: Theme.paddingLarge

                PageHeader {
                                title: "My text on Lock Screen"
                                description: "(To hide a row, just clear its text)"
                            }

                TextArea {
                    id: firstLine
                    label: "First row"
                    width: parent.width
                    placeholderText: "First row"
                    text: config.firstLine
                    onTextChanged: config.firstLine = text
                    rightItem: IconButton {
                         onClicked: {
                             firstLine.text = ""
                         }
                         width: icon.width
                         height: icon.height
                         icon.source: "image://theme/icon-m-input-clear"
                         opacity: firstLine.text.length > 0 ? 1.0 : 0.0
                         Behavior on opacity { FadeAnimation {} }
                     }
                    }

                TextArea {
                    id: secondLine
                    label: "Second row"
                    width: parent.width
                    placeholderText: "Second row"
                    text: config.secondLine
                    onTextChanged: config.secondLine = text
                    rightItem: IconButton {
                         onClicked: {
                             secondLine.text = ""
                         }
                         width: icon.width
                         height: icon.height
                         icon.source: "image://theme/icon-m-input-clear"
                         opacity: secondLine.text.length > 0 ? 1.0 : 0.0
                         Behavior on opacity { FadeAnimation {} }
                     }
                    }
                    
                TextArea {
                    id: thirdLine
                    label: "Third row"
                    width: parent.width
                    placeholderText: "Third row"
                    text: config.thirdLine
                    onTextChanged: config.thirdLine = text
                    rightItem: IconButton {
                         onClicked: {
                             thirdLine.text = ""
                         }
                         width: icon.width
                         height: icon.height
                         icon.source: "image://theme/icon-m-input-clear"
                         opacity: thirdLine.text.length > 0 ? 1.0 : 0.0
                         Behavior on opacity { FadeAnimation {} }
                     }
                    }
                    
                 TextArea {
                    id: fourthLine
                    label: "Fourth row"
                    width: parent.width
                    placeholderText: "Fourth row"
                    text: config.fourthLine
                    onTextChanged: config.fourthLine = text
                    rightItem: IconButton {
                         onClicked: {
                             fourthLine.text = ""
                         }
                         width: icon.width
                         height: icon.height
                         icon.source: "image://theme/icon-m-input-clear"
                         opacity: fourthLine.text.length > 0 ? 1.0 : 0.0
                         Behavior on opacity { FadeAnimation {} }
                     }
                    }

            }
    }

}

patch.json

{"description": "Shows four lines of custom text on Lock screen, right below the Clock and Weather widgets", "name": "custom-text-on-lockscreen", "display_name": "Custom text on Lock Screen", "category": "silica", "author": "wetab73", "discussion": "", "donations": "", "sources": "", "version": "0.0.3", "compatible": ["4.4.0.72","4.4.0.68","4.4.0.58"]}

6 Likes

Thanks a lot, very helpful. In fact, it might even save my life some day.
I also learned some more coding. :wink:

2 Likes

so after a lot of trials the new version now works on my xz2c. I’m not sure what went wrong before. After I got it working I uninstalled the weather app and it still works fine - I don’t know if it’s necessary at all. Anyway, thanks wetab73 for this great feature.
Edit…I went back to my usual setup - no device lock - and the contact data is still there! This for me is perfect.

1 Like

Just tested on my Jolla C, and there fourth row is conflicting with the media playback controls.

1 Like