Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
Support for watch apps, not installed on phone
Browse files Browse the repository at this point in the history
Needed to show app name instead of "unknown app" on the
app management screen.
  • Loading branch information
smokku committed Jan 3, 2015
1 parent 516dc94 commit eac3796
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 24 deletions.
4 changes: 4 additions & 0 deletions app/pebbledinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ void PebbledInterface::refreshAllApps()

QVariantMap m;
m.insert("uuid", uuid.toString());
m.insert("isLocal", orig.value("local"));
m.insert("shortName", orig.value("short-name"));
m.insert("longName", orig.value("long-name"));
m.insert("companyName", orig.value("company-name"));
m.insert("versionLabel", orig.value("version-label"));
m.insert("isWatchface", orig.value("is-watchface"));

QByteArray pngIcon = orig.value("menu-icon").toByteArray();
if (!pngIcon.isEmpty()) {
Expand Down
4 changes: 3 additions & 1 deletion app/qml/pages/InstallAppDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Dialog {
id: appDelegate
contentHeight: Theme.itemSizeSmall

visible: modelData.isLocal

property string uuid: modelData.uuid
property bool alreadyInstalled: pebbled.isAppInstalled(uuid)

Expand All @@ -41,7 +43,7 @@ Dialog {
Image {
id: appImage
anchors.centerIn: parent
source: "image://pebble-app-icon/" + uuid;
source: appDelegate.visible ? "image://pebble-app-icon/" + uuid : ""
scale: 2
}
}
Expand Down
11 changes: 6 additions & 5 deletions app/qml/pages/WatchPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Page {
property bool isEmptySlot: modelData === ""
property var appInfo: pebbled.appInfoByUuid(modelData)
property bool isKnownApp: appInfo.hasOwnProperty("uuid")
property bool isLocalApp: appInfo.hasOwnProperty("isLocal") && appInfo.isLocal
property bool busy: false

function configure() {
Expand Down Expand Up @@ -155,9 +156,9 @@ Page {
Image {
id: slotImage
anchors.centerIn: parent
source: isKnownApp ? "image://pebble-app-icon/" + modelData : ""
source: isLocalApp ? "image://pebble-app-icon/" + modelData : ""
scale: 2
visible: !isEmptySlot && isKnownApp && !slotBusy.running
visible: !isEmptySlot && isLocalApp && !slotBusy.running
}

Rectangle {
Expand All @@ -170,7 +171,7 @@ Page {
color: slotDelegate.highlighted ? Theme.highlightColor : Theme.primaryColor
}
color: "transparent"
visible: isEmptySlot && !slotBusy.running
visible: (isEmptySlot || !isLocalApp) && !slotBusy.running
}

BusyIndicator {
Expand All @@ -189,7 +190,7 @@ Page {
rightMargin: Theme.paddingLarge
verticalCenter: parent.verticalCenter
}
text: isEmptySlot ? qsTr("(empty slot)") : (isKnownApp ? appInfo.longName : qsTr("(slot in use by unknown app)"))
text: isEmptySlot ? qsTr("(empty slot)") : (isKnownApp ? (isLocalApp ? appInfo.longName : appInfo.shortName) : qsTr("(slot in use by unknown app)"))
color: slotDelegate.highlighted ? Theme.highlightColor : Theme.primaryColor
onTextChanged: slotDelegate.busy = false;
}
Expand All @@ -204,7 +205,7 @@ Page {
}
MenuItem {
text: qsTr("Configure...")
visible: !isEmptySlot && isKnownApp
visible: !isEmptySlot && isLocalApp
onClicked: configure();
}
MenuItem {
Expand Down
12 changes: 6 additions & 6 deletions app/translations/pebble-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,32 +221,32 @@ Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente.</tra
<translation>Aplicaciones instaladas</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="120"/>
<location filename="../qml/pages/WatchPage.qml" line="121"/>
<source>Uninstalling</source>
<translation>Desinstalando</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="192"/>
<location filename="../qml/pages/WatchPage.qml" line="193"/>
<source>(empty slot)</source>
<translation>(hueco libre)</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="192"/>
<location filename="../qml/pages/WatchPage.qml" line="193"/>
<source>(slot in use by unknown app)</source>
<translation>(hueco en uso)</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="201"/>
<location filename="../qml/pages/WatchPage.qml" line="202"/>
<source>Install app...</source>
<translation>Instalar app...</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="206"/>
<location filename="../qml/pages/WatchPage.qml" line="207"/>
<source>Configure...</source>
<translation>Configurar...</translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="211"/>
<location filename="../qml/pages/WatchPage.qml" line="212"/>
<source>Uninstall</source>
<translation>Desinstalar</translation>
</message>
Expand Down
12 changes: 6 additions & 6 deletions app/translations/pebble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,32 +220,32 @@ If it can&apos;t be found please check it&apos;s available and paired in Bluetoo
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="120"/>
<location filename="../qml/pages/WatchPage.qml" line="121"/>
<source>Uninstalling</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="192"/>
<location filename="../qml/pages/WatchPage.qml" line="193"/>
<source>(empty slot)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="192"/>
<location filename="../qml/pages/WatchPage.qml" line="193"/>
<source>(slot in use by unknown app)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="201"/>
<location filename="../qml/pages/WatchPage.qml" line="202"/>
<source>Install app...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="206"/>
<location filename="../qml/pages/WatchPage.qml" line="207"/>
<source>Configure...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/WatchPage.qml" line="211"/>
<location filename="../qml/pages/WatchPage.qml" line="212"/>
<source>Uninstall</source>
<translation type="unfinished"></translation>
</message>
Expand Down
12 changes: 12 additions & 0 deletions daemon/appinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "appinfo.h"

struct AppInfoData : public QSharedData {
bool local;
QUuid uuid;
QString shortName;
QString longName;
Expand All @@ -20,6 +21,7 @@ struct AppInfoData : public QSharedData {

AppInfo::AppInfo() : d(new AppInfoData)
{
d->local = false;
d->versionCode = 0;
d->watchface = false;
d->jskit = false;
Expand All @@ -41,6 +43,16 @@ AppInfo::~AppInfo()
{
}

bool AppInfo::isLocal() const
{
return d->local;
}

void AppInfo::setLocal(const bool local)
{
d->local = local;
}

QUuid AppInfo::uuid() const
{
return d->uuid;
Expand Down
4 changes: 4 additions & 0 deletions daemon/appinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AppInfo
};
Q_DECLARE_FLAGS(Capabilities, Capability)

Q_PROPERTY(bool local READ isLocal WRITE setLocal)
Q_PROPERTY(QUuid uuid READ uuid WRITE setUuid)
Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
Q_PROPERTY(QString longName READ longName WRITE setLongName)
Expand All @@ -37,6 +38,9 @@ class AppInfo
AppInfo &operator=(const AppInfo &);
~AppInfo();

bool isLocal() const;
void setLocal(const bool local);

QUuid uuid() const;
void setUuid(const QUuid &uuid);

Expand Down
17 changes: 12 additions & 5 deletions daemon/appmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ void AppManager::rescan()
emit appsChanged();
}

void AppManager::insertAppInfo(const AppInfo &info)
{
_apps.insert(info.uuid(), info);
_names.insert(info.shortName(), info.uuid());

const char *type = info.isWatchface() ? "watchface" : "app";
const char *local = info.isLocal() ? "local" : "watch";
qCDebug(l) << "found" << local << type << info.shortName() << info.versionCode() << "/" << info.versionLabel() << "with uuid" << info.uuid().toString();
}

void AppManager::scanApp(const QString &path)
{
qCDebug(l) << "scanning app" << path;
Expand All @@ -114,6 +124,7 @@ void AppManager::scanApp(const QString &path)

const QJsonObject root = doc.object();
AppInfo info;
info.setLocal(true);
info.setUuid(QUuid(root["uuid"].toString()));
info.setShortName(root["shortName"].toString());
info.setLongName(root["longName"].toString());
Expand Down Expand Up @@ -183,11 +194,7 @@ void AppManager::scanApp(const QString &path)
return;
}

_apps.insert(info.uuid(), info);
_names.insert(info.shortName(), info.uuid());

const char *type = info.isWatchface() ? "watchface" : "app";
qCDebug(l) << "found installed" << type << info.shortName() << info.versionLabel() << "with uuid" << info.uuid().toString();
insertAppInfo(info);
}

QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_id) const
Expand Down
2 changes: 2 additions & 0 deletions daemon/appmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class AppManager : public QObject
AppInfo info(const QUuid &uuid) const;
AppInfo info(const QString &shortName) const;

void insertAppInfo(const AppInfo &info);

public slots:
void rescan();

Expand Down
9 changes: 9 additions & 0 deletions daemon/bankmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ void BankManager::refresh()
_slots[index].version = version;

AppInfo info = apps->info(name);
if (info.shortName() != name) {
info.setLocal(false);
info.setUuid(QUuid::createUuid());
info.setShortName(name);
info.setCompanyName(company);
info.setVersionCode(version);
info.setCapabilities(AppInfo::Capabilities(flags));
apps->insertAppInfo(info);
}
QUuid uuid = info.uuid();
_slots[index].uuid = uuid;

Expand Down
3 changes: 2 additions & 1 deletion daemon/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ QVariantList PebbledProxy::AllApps() const
foreach (const QUuid &uuid, uuids) {
const AppInfo &info = manager()->apps->info(uuid);
QVariantMap m;
m.insert("uuid", QVariant::fromValue(uuid.toString()));
m.insert("local", QVariant::fromValue(info.isLocal()));
m.insert("uuid", QVariant::fromValue(info.uuid().toString()));
m.insert("short-name", QVariant::fromValue(info.shortName()));
m.insert("long-name", QVariant::fromValue(info.longName()));
m.insert("company-name", QVariant::fromValue(info.companyName()));
Expand Down

0 comments on commit eac3796

Please sign in to comment.