Skip to content

Commit

Permalink
Merge pull request #179 from HelloVolla/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wurzer committed Oct 22, 2023
2 parents 0879622 + 9a10914 commit 8fa2887
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 257 deletions.
46 changes: 39 additions & 7 deletions AppGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Qt.labs.settings 1.0
import AndroidNative 1.0 as AN
import FileIO 1.0

Page {
LauncherPage {
id: appLauncher
anchors.fill: parent

Expand Down Expand Up @@ -119,11 +119,6 @@ Page {

property double lastAppsCheck: 0.0

background: Rectangle {
anchors.fill: parent
color: "transparent"
}

onTextInputChanged: {
console.log("AppGrid | Text input changed: " + appLauncher.textInput)
for (var i = 0; i < appLauncher.appGroups.length; i++) {
Expand Down Expand Up @@ -354,10 +349,11 @@ Page {
property var app
property var gridView
property bool isPinnedShortcut: false
property bool canBeDeleted: false
property int menuItemHeight: 40

background: Rectangle {
id: menuBackground
height: contextMenu.isPinnedShortcut ? 150 : 110
implicitWidth: contextMenu.menuWidth
color: Universal.accent
radius: mainView.innerSpacing
Expand Down Expand Up @@ -401,6 +397,7 @@ Page {
}
leftPadding: mainView.innerSpacing
rightPadding: mainView.innerSpacing
bottomPadding: removeAppItem.visible ? 0 : mainView.innerSpacing
background: Rectangle {
anchors.fill: parent
color: "transparent"
Expand All @@ -424,8 +421,30 @@ Page {
}
}
}
MenuItem {
id: removeAppItem
height: removeAppItem.visible ? contextMenu.menuItemHeight : 0
font.pointSize: appLauncher.labelPointSize
contentItem: Label {
width: contextMenu.menuWidth
text: qsTr("Remove App")
horizontalAlignment: Text.AlignHCenter
}
leftPadding: mainView.innerSpacing
rightPadding: mainView.innerSpacing
bottomPadding: mainView.innerSpacing
background: Rectangle {
anchors.fill: parent
color: "transparent"
}
visible: contextMenu.canBeDeleted
onClicked: {
AN.SystemDispatcher.dispatch("volla.launcher.deleteAppAction", {"appId": contextMenu.app["package"]})
}
}
MenuItem {
id: removePinnedShortcutItem
height: removePinnedShortcutItem.visible ? contextMenu.menuItemHeight : 0
font.pointSize: appLauncher.labelPointSize
contentItem: Label {
width: contextMenu.menuWidth
Expand All @@ -452,6 +471,19 @@ Page {
disabledPinnedShortcuts.disableShortcut(shortcutId)
}
}

onAboutToShow: {
AN.SystemDispatcher.dispatch("volla.launcher.canDeleteAppAction", {"appId": contextMenu.app["package"]})
}

Connections {
target: AN.SystemDispatcher
onDispatched: {
if (type === "volla.launcher.canDeleteAppResponce") {
contextMenu.canBeDeleted = message["canDeleteApp"]
}
}
}
}

Connections {
Expand Down
15 changes: 5 additions & 10 deletions Collections.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Qt.labs.settings 1.0
import AndroidNative 1.0 as AN
import FileIO 1.0

Page {
LauncherPage {
id: collectionPage
anchors.fill: parent

Expand Down Expand Up @@ -42,11 +42,6 @@ Page {
property string c_TYPE: "type" // rss or atpm feed type
property string c_SIGNAL: "signal" // has a signal account

background: Rectangle {
anchors.fill: parent
color: "transparent"
}

onTextInputChanged: {
console.log("Collections | text input changed")
currentCollectionModel.update(textInput)
Expand Down Expand Up @@ -134,7 +129,7 @@ Page {
AN.SystemDispatcher.dispatch("volla.launcher.threadAction", filter)
// load threads from further source
// address (phone or contact), body (message), date, type
AN.SystemDispatcher.dispatch("volla.launcher.signalThreadsAction", filter)
if (mainView.isSignalActive) AN.SystemDispatcher.dispatch("volla.launcher.signalThreadsAction", filter)
}

function loadCalls(filter) {
Expand Down Expand Up @@ -628,9 +623,9 @@ Page {
var now = new Date()

collectionPage.threads.forEach(function (thread, index) {
console.log("Collections | Thread: " + thread["date"])
console.log("Collections | Thread: " + thread["address"])
if ((!thread["read"] || now.getTime() - thread["date"] < collectionPage.messageAge) && thread["address"] !== undefined) {
console.log("Collections | Thread matched: " + thread["id"])
console.log("Collections | Thread matched: " + thread["address"])
if (thread["isSignal"]) contactThreads[thread["person"]] = thread
else contactThreads[thread["address"]] = thread
}
Expand Down Expand Up @@ -798,7 +793,7 @@ Page {
filteredModelItem = modelArr[i]
var modelItemName = modelArr[i].c_TITLE
if (text.length === 0 || modelItemName.toLowerCase().includes(text.toLowerCase())) {
//console.log("Collections | Add " + modelItemName + " to filtered items")
// console.log("Collections | Add " + modelItemName + " to filtered items")
filteredModelDict[modelItemName] = filteredModelItem
}
}
Expand Down
7 changes: 1 addition & 6 deletions Conversation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import QtQuick.Controls.Universal 2.12
import QtGraphicalEffects 1.12
import AndroidNative 1.0 as AN

Page {
LauncherPage {
id: conversationPage
anchors.fill: parent

Expand Down Expand Up @@ -36,11 +36,6 @@ Page {
property string m_DATE: "date" // date in milliseconds of the item
property string m_ERROR: "error" // error message under message

background: Rectangle {
anchors.fill: parent
color: "transparent"
}

Connections {
target: Qt.inputMethod

Expand Down
76 changes: 47 additions & 29 deletions Details.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import QtWebView 1.12
import QtGraphicalEffects 1.12
import AndroidNative 1.0 as AN

Page {
LauncherPage {
id: detailPage
objectName: "detailPage"
anchors.fill: parent
Expand All @@ -16,11 +16,6 @@ Page {
property var currentTitle
property var currentDetailHasBadge: false

background: Rectangle {
anchors.fill: parent
color: "transparent"
}

header: Rectangle {
id: detailPageHeader
width: parent.width
Expand Down Expand Up @@ -206,28 +201,49 @@ Page {

function prepareNoteView(note, curserPosition) {
console.log("Details | Process note " + currentDetailId + " with curser at " + curserPosition)

// console.debug("================")
// var noteArr = note.split("\n")
// for (var l = 0;l < noteArr.length; l++) console.debug("LINE: " + noteArr[l])

detailEdit.isBlocked = true
detailEdit.textLength = note.length

var styledText = note.slice()
var urlRegex = /(((https?:\/\/)|([^\s]+\.))[^\s,]+)/g;
styledText = styledText.replace(urlRegex, function(url,b,c) {
var url2 = !c.startsWith('http') ? 'http://' + url : url;
return '<a href="' +url2+ '" target="_blank">' + url + '</a>';
})

styledText = styledText.replace(/^(### .*$)/gim, '<h3><$1</h3>') // h3 tag
.replace(/^(## .*$)/gim, '<h2>$1</h2>') // h2 tag
.replace(/^(# .*$)/gim, '<h1>$1</h1>') // h1 tag
.replace(/^(.*\n)/m, '<p style=\"font-size:36pt;font-weight:bold\">$1</p>') // trailing text
styledText = styledText.replace(/^(.*$)/gim, '<p>$1</p>')
.replace(/<p>(### .*)<\/p>/gim, '<h3><$1</h3>') // h3 tag
.replace(/<p>(## .*)<\/p>/gim, '<h2>$1</h2>') // h2 tag
.replace(/<p>(# .*)<\/p>/gim, '<h1>$1</h1>') // h1 tag
.replace(/<p>(.*)<\/p>/m, '<p style=\"font-size:36pt;font-weight:bold\">$1</p>') // trailing text
.replace(/(\*\*.*\*\*)/gim, '<b>$1</b>') // bold text
.replace(/(\*.*\*)/gim, '<i>$1</i>') // italic text
.replace(/^(\* .*)/gim, '<p style=\"margin-left:12px;text-indent:-12px;\">$1</p>') // unsorted list
.replace(/^(- .*)/gim, '<p style=\"margin-left:12px;text-indent:-12px;\">$1</p>') // unsorted list
.replace(/^([0-9]+\. .*)/gim, '<p style=\"margin-left:20px;text-indent:-20px;\">$1</p>') // ordered list
.replace(/^(.*$)/gim, '<p>$1</p>')
.trim()
.replace(/<p>(\* .*)<\/p>/gim, '<p style=\"margin-left:12px;text-indent:-12px;\">$1</p>') // unsorted list
.replace(/<p>(- .*)<\/p>/gim, '<p style=\"margin-left:12px;text-indent:-12px;\">$1</p>') // unsorted list
.replace(/<p>([0-9]+\. .*)<\/p>/gim, '<p style=\"margin-left:20px;text-indent:-20px;\">$1</p>') // ordered list
.replace(/(<p><\/p>)/gim, '')
.replace(/\n\n/gim, '')
//.trim()

// console.debug("----------------")
// var textArr = styledText.split("\n")
// for (l = 0;l < textArr.length; l++) console.debug("LINE: " + textArr[l])
// console.debug("================")

detailEdit.text = styledText

if (curserPosition !== undefined) detailEdit.cursorPosition = curserPosition
if (curserPosition !== undefined) {
detailEdit.cursorPosition = curserPosition
}

detailEdit.isBlocked = false

console.log("Details | Process note finished")
}

Flickable {
Expand Down Expand Up @@ -335,30 +351,33 @@ Page {
bottomPadding: mainView.innerSpacing
font.pointSize: mainView.largeFontSize
wrapMode: TextEdit.Wrap
textFormat: Text.RichText
textFormat: TextEdit.RichText
inputMethodHints: Qt.ImhNoPredictiveText
verticalAlignment: Text.AlignTop
background: Rectangle {
color: "transparent"
border.color: "transparent"
}

property bool isBlocked: true
property bool isBlocked: false
property int lastCurserPosition: 0
property int textLength

onCursorRectangleChanged: detailFlickable.ensureVisible(cursorRectangle)

onCursorPositionChanged: {
console.log("Details | Curser postion changed to " + detailEdit.cursorPosition)
if (!isBlocked) {
isBlocked = true
lastCurserPosition = detailEdit.cursorPosition
console.debug("Details | Plain Text: " + detailEdit.getText(0, detailEdit.length))
var plainText = detailEdit.getText(0, detailEdit.length)
//detailEdit.text.replace(/p, li \{ white-space: pre-wrap; \}/gim, '').replace(/<[^>]+>/g, '').trim()
detailPage.prepareNoteView(plainText, lastCurserPosition)
mainView.updateNote(detailPage.currentDetailId, plainText, detailPage.currentDetailHasBadge)
if (detailEdit.isBlocked === false) {
console.debug("Details | Curser postion changed from " + lastCurserPosition + " to " + detailEdit.cursorPosition)

var plainText = detailEdit.getText(0, 10000)

if (plainText.length !== detailEdit.textLength) {
mainView.updateNote(detailPage.currentDetailId, plainText, detailPage.currentDetailHasBadge)
}

detailPage.prepareNoteView(plainText, detailEdit.cursorPosition)
}
if (lastCurserPosition === detailEdit.cursorPosition) isBlocked = false
lastCurserPosition = detailEdit.cursorPosition
}

onActiveFocusChanged: {
Expand All @@ -368,7 +387,6 @@ Page {
} else {
var plainText = detailEdit.text.replace(/p, li \{ white-space: pre-wrap; \}/gim, '').replace(/<[^>]+>/g, '').trim()
mainView.updateNote(detailPage.currentDetailId, plainText, detailPage.currentDetailHasBadge)
isBlocked = true
detailFlickable.height = mainView.height
}
}
Expand Down
2 changes: 1 addition & 1 deletion Feed.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import QtQuick.Controls.Universal 2.12
import QtGraphicalEffects 1.12
import AndroidNative 1.0 as AN

Page {
LauncherPage {
id : feedPage
anchors.fill: parent

Expand Down
28 changes: 28 additions & 0 deletions HighlightButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls.Universal 2.12

Button {
id: root

property bool boldText: false
property alias textColor: buttonText.color
property alias textOpacity: buttonText.opacity
property alias backgroundColor: buttonBackground.color
property real fontPointSize: mainView.largeFontSize

contentItem: Text {
id: buttonText
width: parent.width - 2 * root.padding
font.pointSize: root.fontPointSize
font.weight: root.boldText ? Font.Black : Font.Normal
text: root.text
color: Universal.foreground
}
background: Rectangle {
id: buttonBackground
anchors.fill: parent
color: "transparent"
}
}
9 changes: 9 additions & 0 deletions LauncherPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import QtQuick 2.12
import QtQuick.Controls 2.5

Page {
background: Rectangle {
anchors.fill: parent
color: "transparent"
}
}
Loading

0 comments on commit 8fa2887

Please sign in to comment.