Skip to content

Commit

Permalink
make transliteration configurable
Browse files Browse the repository at this point in the history
fixes piggz#13
  • Loading branch information
jmlich committed Oct 10, 2023
1 parent 7a3b0d2 commit 7b46423
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
19 changes: 14 additions & 5 deletions daemon/src/deviceinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "bipfirmwareservice.h"
#include "devicefactory.h"
#include "amazfishconfig.h"
#include "transliterator.h"

#include <QDir>
#include <QFile>
Expand Down Expand Up @@ -158,7 +159,7 @@ void DeviceInterface::onNotification(watchfish::Notification *notification)
{
if (m_device && m_device->connectionState() == "authenticated" && m_device->supportsFeature(AbstractDevice::FEATURE_ALERT)){
qDebug() << "Sending alert to device";
m_device->sendAlert(notification->appName(), notification->summary(), notification->body());
sendAlert(notification->appName(), notification->summary(), notification->body());
} else {
qDebug() << "no notification service, buffering notification";

Expand Down Expand Up @@ -519,8 +520,7 @@ void DeviceInterface::onEventTimer()
if (m_eventlist.isEmpty())
return;
watchfish::CalendarEvent event = m_eventlist.takeFirst();
if (m_device)
m_device->sendAlert("calendar", event.title(), event.description().isEmpty()?" ":event.description());
sendAlert("calendar", event.title(), event.description().isEmpty()?" ":event.description());
scheduleNextEvent();
}

Expand Down Expand Up @@ -694,8 +694,17 @@ void DeviceInterface::sendAlert(const QString &sender, const QString &subject, c
m_lastAlertHash = hash;

if (m_device && m_device->connectionState() == "authenticated" && m_device->supportsFeature(AbstractDevice::FEATURE_ALERT)){
qDebug() << "Sending alert to device";
m_device->sendAlert(sender, subject, message);
qDebug() << "Snding alert to device";

if (AmazfishConfig::instance()->appTransliterate()) {
m_device->sendAlert(
Transliterator::convert(sender),
Transliterator::convert(subject),
Transliterator::convert(message)
);
} else {
m_device->sendAlert(sender, subject, message);
}
}
}

Expand Down
7 changes: 1 addition & 6 deletions daemon/src/devices/pinetimejfdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "infinitimeweatherservice.h"
#include "adafruitblefsservice.h"
#include "batteryservice.h"
#include "transliterator.h"
#include <QtXml/QtXml>

namespace {
Expand Down Expand Up @@ -92,11 +91,7 @@ void PinetimeJFDevice::sendAlert(const QString &sender, const QString &subject,
AlertNotificationService *alert = qobject_cast<AlertNotificationService*>(service(AlertNotificationService::UUID_SERVICE_ALERT_NOTIFICATION));
if (alert) {
qDebug() << "PT Have an alert service";
alert->sendAlert(
Transliterator::convert(sender),
Transliterator::convert(subject),
Transliterator::convert(message)
);
alert->sendAlert(sender, subject, message);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/amazfishconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class AmazfishConfig : public QObject
BOOL_OPTION(QStringLiteral("app/overridefwcheck"), appOverrideFwCheck, setAppOverrideFwCheck, false)
BOOL_OPTION(QStringLiteral("app/navigationnotification"), appNavigationNotification, setAppNavigationNotification, false)
BOOL_OPTION(QStringLiteral("app/simulateevents"), appSimulateEventSupport, setSimulateEventSupport, false)
BOOL_OPTION(QStringLiteral("app/transliterate"), appTransliterate, setTransliterate, false)

STRING_OPTION(QStringLiteral("app/button-double-action"), appButtonDoublePressAction, setAppButtonDoublePressAction, "action-none")
STRING_OPTION(QStringLiteral("app/button-triple-action"), appButtonTriplePressAction, setAppButtonTriplePressAction, "action-none")
Expand Down
11 changes: 11 additions & 0 deletions ui/qml/pages/Settings-app.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ PagePL {
text: qsTr("Navigation notifications")
}

TextSwitchPL {
id: chkTransliterate
visible: supportsFeature(Amazfish.FEATURE_ALERT)

width: parent.width
text: qsTr("Transliterate notifications")
}

TextSwitchPL {
id: chkSimulateEventSupport
visible: supportsFeature(Amazfish.FEATURE_ALERT) && !supportsFeature(Amazfish.FEATURE_EVENT_REMINDER)
Expand Down Expand Up @@ -169,6 +177,7 @@ PagePL {
text: qsTr("Save Settings")
onClicked: {
saveSettings();
app.pages.pop();
}
}
}
Expand All @@ -181,6 +190,7 @@ PagePL {
chkNotifyLowBattery.checked = AmazfishConfig.appNotifyLowBattery;
chkNavigationNotification.checked = AmazfishConfig.appNavigationNotification;
chkSimulateEventSupport.checked = AmazfishConfig.appSimulateEventSupport;
chkTransliterate.checked = AmazfishConfig.appTransliterate;

chkServiceEnabled.checked = serviceEnabledState;
_ready = true;
Expand All @@ -195,6 +205,7 @@ PagePL {
AmazfishConfig.appNavigationNotification = chkNavigationNotification.checked;
AmazfishConfig.appSimulateEventSupport = chkSimulateEventSupport.checked;
AmazfishConfig.localAdapter = cboLocalAdapter.value;
AmazfishConfig.appTransliterate = chkTransliterate.checked ;
}

}

0 comments on commit 7b46423

Please sign in to comment.