Skip to content

Commit

Permalink
Merge pull request #221 from HelloVolla/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wurzer authored Apr 27, 2024
2 parents 64eb632 + aa25abf commit a0680b1
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 81 deletions.
84 changes: 68 additions & 16 deletions SttSetup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Dialog {
modal: true
dim: false
closePolicy: Popup.NoAutoClose
standardButtons: Dialog.Cancel | Dialog.Ok

property var fontSize
property int innerSpacing
Expand All @@ -30,11 +29,12 @@ Dialog {
}

background: Item {
anchors.fill: parent
ShaderEffectSource {
id: effectSource
sourceItem: mainView
anchors.fill: parent
sourceRect: Qt.rect(popup.x,popup.y,popup.width,popup.height)
sourceRect: Qt.rect(dialog.x,dialog.y,dialog.width,dialog.height)
}
FastBlur{
id: blur
Expand All @@ -50,21 +50,73 @@ Dialog {
}
}

contentItem: Text {
anchors.fill: dialog
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.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
contentItem: Column {
//anchors.fill: parent
width: dialog.width
height: dialog.height
spacing: dialog.innerSpacing
Text {
width: parent.width
height: parent.height - buttonRow.height - dialog.innerSpacing
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.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Row {
id: buttonRow
width: parent.width
spacing: dialog.innerSpacing

onAccepted: {
AN.SystemDispatcher.dispatch("volla.launcher.checkSttAvailability", {})
}
Button {
id: cancelButton
flat: true
padding: dialog.innerSpacing / 2
width: parent.width / 2 - dialog.innerSpacing / 2
text: qsTr("Cancel")

contentItem: Text {
text: cancelButton.text
color: Universal.foreground
font.pointSize: dialog.fontSize
horizontalAlignment: Text.AlignHCenter
}

background: Rectangle {
color: "transparent"
border.color: "gray"
}

onRejected: {
dialog.close()
onClicked: {
dialog.close()
}
}

Button {
id: okButton
width: parent.width / 2 - mainView.innerSpacing / 2
padding: dialog.innerSpacing / 2
flat: true
text: qsTr("Ok")

contentItem: Text {
text: okButton.text
color: Universal.foreground
font.pointSize: dialog.fontSize
horizontalAlignment: Text.AlignHCenter
}

background: Rectangle {
color: "transparent"
border.color: "gray"
}

onClicked: {
AN.SystemDispatcher.dispatch("volla.launcher.runAppAction", {"appId": "com.volla.vollaboard"})
}
}
}
}
}
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="com.volla.launcher" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.3.4" android:versionCode="295" android:installLocation="auto">
<manifest package="com.volla.launcher" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.4.0" android:versionCode="297" android:installLocation="auto">
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29"/>

<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Expand Down
70 changes: 19 additions & 51 deletions android/src/com/volla/launcher/util/AppUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import lineageos.childmode.ChildModeManager;
import com.volla.launcher.activity.ReceiveTextActivity;

import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodInfo;

public class AppUtil {

private static final String TAG = "AppUtil";
Expand All @@ -50,6 +53,8 @@ public class AppUtil {
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";
public static final String GOT_IS_STT_AVAILABLE = "volla.launcher.checkSttAvailabilityResponse";


static {
SystemDispatcher.addListener(new SystemDispatcher.Listener() {
Expand Down Expand Up @@ -89,7 +94,7 @@ public void run() {
try {
Intent app = pm.getLaunchIntentForPackage(packageName);
activity.startActivity(app);
} catch (SecurityException e){
} catch (Exception e){
PackageInfo pi;
try {
pi = activity.getPackageManager().getPackageInfo(packageName, 0);
Expand Down Expand Up @@ -246,58 +251,21 @@ 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<ResolveInfo> 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<ResolveInfo> 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<ResolveInfo> 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.");
} else if (type.equals(GET_IS_STT_AVAILABLE)) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList();
final int N = mInputMethodProperties.size();
boolean isActivated = false;
for (int i = 0; i < N; i++) {
InputMethodInfo imi = mInputMethodProperties.get(i);
Log.d(TAG, "Inputmethod: " + imi.getId());
if (imi.getId().equals("com.volla.vollaboard/.ime.IME")) {
isActivated = true;
break;
}
}
Map reply = new HashMap();
reply.put("isActivated", isActivated );
SystemDispatcher.dispatch(GOT_IS_STT_AVAILABLE, reply);
}
}
};
Expand Down
4 changes: 1 addition & 3 deletions android/src/com/volla/launcher/worker/MessageWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public void run() {
});
}


private static void updateMessageHandler(Map message, Activity activity) {
private static void updateMessageHandler(Map message, Activity activity) {
Runnable runnable = new Runnable () {
public void run() {
Looper.prepare();
Expand Down Expand Up @@ -183,7 +182,6 @@ static void updateMessageReadStatus(Map message, Activity activity) {

}


static void getConversation(Map message, Activity activity) {
Log.d(TAG, "Invoked JAVA getConversation" );

Expand Down
25 changes: 15 additions & 10 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,10 @@ ApplicationWindow {
var object = component.createObject(mainView, properties)
object.open()
settings.firstStart = false
} else if (!settings.sttchecked) {
console.debug("MainView", "Will start stt dialog")
} else if (!settings.sttChecked) {
console.debug("MainView", "Will check stt availability")
settings.sttChecked = true
component = Qt.createComponent("/SttSetup.qml")
properties = { "fontSize" : 18, "innerSpacing" : 22 }
if (component.status !== Component.Ready) {
if (component.status === Component.Error)
console.debug("MainView | Error: "+ component.errorString() );
}
object = component.createObject(mainView, properties)
object.open()
AN.SystemDispatcher.dispatch("volla.launcher.checkSttAvailability", {})
}
// Check new pinned shortcut
AN.SystemDispatcher.dispatch("volla.launcher.checkNewShortcut", {})
Expand Down Expand Up @@ -1039,6 +1032,18 @@ ApplicationWindow {
mainView.switchTheme(mainView.theme.Dark, true)
}
}
} else if (type === "volla.launcher.checkSttAvailabilityResponse") {
console.debug("MainView | STT activation status: " + message["isActivated"])
if (!message["isActivated"]) {
var component = Qt.createComponent("/SttSetup.qml")
var properties = { "fontSize" : 18, "innerSpacing" : 22 }
if (component.status !== Component.Ready) {
if (component.status === Component.Error)
console.debug("MainView | Error: "+ component.errorString() );
}
var object = component.createObject(mainView, properties)
object.open()
}
}
}
}
Expand Down

0 comments on commit a0680b1

Please # to comment.