From 2830eeb9679d8a81e6e4881f512109fdf63a4305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20J=C3=B6rg=20Wurzer?= Date: Fri, 12 Apr 2024 14:20:01 +0200 Subject: [PATCH 1/3] Prepare vollaboard setup --- Collections.qml | 1 + SttSetup.qml | 67 +++++++++++++++++++ .../src/com/volla/launcher/util/AppUtil.java | 54 +++++++++++++++ main.qml | 11 +++ qml.qrc | 5 +- 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 SttSetup.qml diff --git a/Collections.qml b/Collections.qml index 2795c5a4..a8c6e65a 100644 --- a/Collections.qml +++ b/Collections.qml @@ -917,6 +917,7 @@ LauncherPage { kind = "Signal" } + cThread.c_SBADGE = thread["read"] === "true" ? false : true cThread.c_STEXT = mainView.parseTime(Number(thread["date"])) + " • " + qsTr(kind) cThread.c_TSTAMP = Number(thread["date"]) diff --git a/SttSetup.qml b/SttSetup.qml new file mode 100644 index 00000000..b2105e44 --- /dev/null +++ b/SttSetup.qml @@ -0,0 +1,67 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.5 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Window 2.2 +import QtQuick.Controls.Universal 2.12 +import QtGraphicalEffects 1.12 +import AndroidNative 1.0 as AN + +Dialog { + id: dialog + anchors.centerIn: Overlay.overlay + height: 200 + width: 250 + padding: popup.innerSpacing + focus: true + modal: true + dim: false + closePolicy: Popup.NoAutoClose + standardButtons: Dialog.Ok | Dialog.Cancel + + property var fontSize + property int innerSpacing + + enter: Transition { + NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 } + } + + exit: Transition { + NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 } + } + + background: Item { + ShaderEffectSource { + id: effectSource + sourceItem: mainView + anchors.fill: parent + sourceRect: Qt.rect(popup.x,popup.y,popup.width,popup.height) + } + FastBlur{ + id: blur + anchors.fill: effectSource + source: effectSource + radius: 32 + } + Rectangle { + anchors.fill: parent + color: "#2e2e2e" + border.color: "transparent" + opacity: 0.6 + } + } + + contentItem: Text { + text: qsTr("Setup speech to text") + color: Universal.foreground + wrapMode: Text.WordWrap + font.pointSize: dialog.fontSize + } + + onAccepted: { + AN.SystemDispatcher.dispatch("volla.launcher.checkSttAvailability", {}) + } + + onRejected: { + dialog.close() + } +} diff --git a/android/src/com/volla/launcher/util/AppUtil.java b/android/src/com/volla/launcher/util/AppUtil.java index 54488e27..3235d09b 100644 --- a/android/src/com/volla/launcher/util/AppUtil.java +++ b/android/src/com/volla/launcher/util/AppUtil.java @@ -19,6 +19,7 @@ import android.telecom.TelecomManager; import android.content.Context; import android.net.Uri; +import android.speech.RecognizerIntent; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -48,6 +49,7 @@ public class AppUtil { public static final String GOT_SECURITY_STATE = "volla.launcher.securityStateResponse"; public static final String GET_IS_SECURITY_PW_SET = "volla.launcher.checkSecurityPasswordAction"; public static final String GOT_IS_SECURITY_PW_SET = "volla.launcher.checkSecurityPasswordResponse"; + public static final String GET_IS_STT_AVAILABLE = "volla.launcher.checkSttAvailability"; static { SystemDispatcher.addListener(new SystemDispatcher.Listener() { @@ -244,6 +246,58 @@ public void run() { Map reply = new HashMap(); reply.put("isPasswordSet", childModeManager.isPasswortSet() ); SystemDispatcher.dispatch(GOT_IS_SECURITY_PW_SET, reply); + } else if (type.equals(GET_IS_STT_AVAILABLE)) { + Intent speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + List speechActivities = pm.queryIntentActivities(speechIntent, 0); + Log.d(TAG, "STT activities: " + speechActivities.size()); + if (speechActivities.size() == 0) { //we have a microphone + PackageInfo pi; + String packageName = "com.volla.vollaboard"; + try { + pi = activity.getPackageManager().getPackageInfo(packageName, 0); + Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); + resolveIntent.setPackage(pi.packageName); + List apps = pm.queryIntentActivities(resolveIntent, 0); + for (ResolveInfo app: apps){ + Log.d(TAG,String.format("%s %s",app.activityInfo.packageName,app.activityInfo.name)); + packageName = app.activityInfo.packageName; + String className = app.activityInfo.name; + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + ComponentName cn = new ComponentName(packageName, className); + intent.setComponent(cn); + try { + activity.startActivity(intent); + } catch (SecurityException se){ + Log.e(TAG, "Security exception: " + se.getMessage()); + } + } + } catch (PackageManager.NameNotFoundException nnfe) { + Log.e(TAG, "Package Name not found: " + nnfe.getMessage() + ", App is not installed."); + } + try { + pi = activity.getPackageManager().getPackageInfo(packageName, 0); + Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); + resolveIntent.setPackage(pi.packageName); + List apps = pm.queryIntentActivities(resolveIntent, 0); + for (ResolveInfo app: apps){ + Log.d(TAG,String.format("%s %s",app.activityInfo.packageName,app.activityInfo.name)); + packageName = app.activityInfo.packageName; + String className = app.activityInfo.name; + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + ComponentName cn = new ComponentName(packageName, className); + intent.setComponent(cn); + try { + activity.startActivity(intent); + } catch (SecurityException se){ + Log.e(TAG, "Security exception: " + se.getMessage()); + } + } + } catch (PackageManager.NameNotFoundException nnfe) { + Log.e(TAG, "Package Name not found: " + nnfe.getMessage() + ", App is not installed."); + } + } } } }; diff --git a/main.qml b/main.qml index fb7745d2..be3c898b 100644 --- a/main.qml +++ b/main.qml @@ -65,6 +65,16 @@ ApplicationWindow { var object = component.createObject(mainView, properties) object.open() settings.firstStart = false + } else if (!settings.sttchecked) { + console.debug("MainView", "Will start stt dialog") + component = Qt.createComponent("/SttSetup.qml") + properties = { "fontSize" : mainView.mediumFontSize, "innerSpacing" : mainView.innerSpacing } + if (component.status !== Component.Ready) { + if (component.status === Component.Error) + console.debug("MainView | Error: "+ component.errorString() ); + } + object = component.createObject(mainView, properties) + object.open() } // Check new pinned shortcut AN.SystemDispatcher.dispatch("volla.launcher.checkNewShortcut", {}) @@ -1052,6 +1062,7 @@ ApplicationWindow { property int searchMode: mainView.searchMode.StartPage property bool fullscreen: false property bool firstStart: true + property bool sttChecked: false property bool signalIsActivated: false property bool useColoredIcons: false property bool showAppsAtStartup: false diff --git a/qml.qrc b/qml.qrc index 7eeef2e4..e7b141ae 100644 --- a/qml.qrc +++ b/qml.qrc @@ -15,13 +15,10 @@ Shortcut.qml Springboard.qml qtquickcontrols2.conf - scripts/apps.mjs scripts/contacts.mjs scripts/springboard.mjs - android/res/drawable/wallpaper_image.png - icons/amazon@4x.png icons/argenta@4x.png icons/attachment@4x.png @@ -98,11 +95,11 @@ icons/woolsocks@4x.png icons/xmpp@4x_104x104px.png icons/yalp-store@4x.png - images/contact-mask.png images/open-in-signal_dark@2x.png images/open-in-signal_dark_2x.png images/open-in-signal_light@2x.png images/open-in-signal_light_2x.png + SttSetup.qml From 4b497fb5d86a0d28d9a1de9c335592bd2d9e8917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20J=C3=B6rg=20Wurzer?= Date: Fri, 12 Apr 2024 14:20:19 +0200 Subject: [PATCH 2/3] Prepare vollaboard setup --- SttSetup.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SttSetup.qml b/SttSetup.qml index b2105e44..f3024eb6 100644 --- a/SttSetup.qml +++ b/SttSetup.qml @@ -11,12 +11,12 @@ Dialog { anchors.centerIn: Overlay.overlay height: 200 width: 250 - padding: popup.innerSpacing + padding: dialog.innerSpacing focus: true modal: true dim: false closePolicy: Popup.NoAutoClose - standardButtons: Dialog.Ok | Dialog.Cancel + standardButtons: Dialog.Cancel | Dialog.Ok property var fontSize property int innerSpacing @@ -51,10 +51,13 @@ Dialog { } contentItem: Text { + anchors.fill: dialog text: qsTr("Setup speech to text") color: Universal.foreground wrapMode: Text.WordWrap font.pointSize: dialog.fontSize + horizontalAlignment: Text.AlignNCenter + verticalAlignment: Text.AlignVCenter } onAccepted: { From 1deb2f24354170d3c951384a718b41644a001a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20J=C3=B6rg=20Wurzer?= Date: Sun, 14 Apr 2024 18:51:34 +0200 Subject: [PATCH 3/3] stt setup dialog --- SttSetup.qml | 8 +-- android/AndroidManifest.xml | 2 +- main.qml | 3 +- qml.qrc | 1 - translations/Volla_be.ts | 7 +++ translations/Volla_bg.ts | 7 +++ translations/Volla_cn.ts | 7 +++ translations/Volla_cs.ts | 7 +++ translations/Volla_de.ts | 122 +++++++++++++++++++----------------- translations/Volla_dk.ts | 7 +++ translations/Volla_en.ts | 7 +++ translations/Volla_es.ts | 122 +++++++++++++++++++----------------- translations/Volla_fi.ts | 7 +++ translations/Volla_fr.ts | 122 +++++++++++++++++++----------------- translations/Volla_it.ts | 7 +++ translations/Volla_jp.ts | 7 +++ translations/Volla_nl.ts | 122 +++++++++++++++++++----------------- translations/Volla_pt.ts | 7 +++ translations/Volla_ro.ts | 122 +++++++++++++++++++----------------- translations/Volla_se.ts | 122 +++++++++++++++++++----------------- translations/Volla_sk.ts | 7 +++ 21 files changed, 474 insertions(+), 349 deletions(-) diff --git a/SttSetup.qml b/SttSetup.qml index f3024eb6..9a3ff605 100644 --- a/SttSetup.qml +++ b/SttSetup.qml @@ -9,8 +9,8 @@ import AndroidNative 1.0 as AN Dialog { id: dialog anchors.centerIn: Overlay.overlay - height: 200 - width: 250 + height: 240 + width: 260 padding: dialog.innerSpacing focus: true modal: true @@ -52,11 +52,11 @@ Dialog { contentItem: Text { anchors.fill: dialog - text: qsTr("Setup speech to text") + text: qsTr("Now set up voice recognition for text input, which you can then activate using the microphone icon on the keyboard.") color: Universal.foreground wrapMode: Text.WordWrap font.pointSize: dialog.fontSize - horizontalAlignment: Text.AlignNCenter + horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 3f86bf0e..731240c7 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - +