2019-02-13 20:43:30 +01:00
|
|
|
/* Copyright (C) 2015-2019 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
2017-03-10 14:53:19 +01:00
|
|
|
Gobbetti
|
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.impl;
|
2015-03-25 22:23:45 +01:00
|
|
|
|
2015-12-07 18:15:26 +01:00
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
2015-05-18 20:56:19 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2015-03-25 22:23:45 +01:00
|
|
|
public class GBDeviceApp {
|
|
|
|
private final String name;
|
|
|
|
private final String creator;
|
|
|
|
private final String version;
|
2015-05-18 20:56:19 +02:00
|
|
|
private final UUID uuid;
|
2015-03-31 23:34:19 +02:00
|
|
|
private final Type type;
|
2016-01-02 12:24:23 +01:00
|
|
|
private final boolean inCache;
|
2016-05-22 22:48:45 +02:00
|
|
|
private boolean isOnDevice;
|
2016-03-18 16:47:14 +01:00
|
|
|
private final boolean configurable;
|
2015-03-25 22:23:45 +01:00
|
|
|
|
2015-05-18 20:56:19 +02:00
|
|
|
public GBDeviceApp(UUID uuid, String name, String creator, String version, Type type) {
|
|
|
|
this.uuid = uuid;
|
2015-03-25 22:23:45 +01:00
|
|
|
this.name = name;
|
|
|
|
this.creator = creator;
|
|
|
|
this.version = version;
|
2015-03-31 23:34:19 +02:00
|
|
|
this.type = type;
|
2016-01-02 12:24:23 +01:00
|
|
|
//FIXME: do not assume
|
|
|
|
this.inCache = false;
|
2016-03-18 16:47:14 +01:00
|
|
|
this.configurable = false;
|
2016-05-22 22:48:45 +02:00
|
|
|
this.isOnDevice = false;
|
2015-03-25 22:23:45 +01:00
|
|
|
}
|
|
|
|
|
2016-03-18 16:47:14 +01:00
|
|
|
public GBDeviceApp(JSONObject json, boolean configurable) {
|
2015-12-07 18:15:26 +01:00
|
|
|
UUID uuid = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
|
|
|
String name = "";
|
|
|
|
String creator = "";
|
|
|
|
String version = "";
|
|
|
|
Type type = Type.UNKNOWN;
|
|
|
|
|
|
|
|
try {
|
|
|
|
uuid = UUID.fromString(json.getString("uuid"));
|
|
|
|
name = json.getString("name");
|
|
|
|
creator = json.getString("creator");
|
|
|
|
version = json.getString("version");
|
|
|
|
type = Type.valueOf(json.getString("type"));
|
|
|
|
} catch (JSONException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.name = name;
|
|
|
|
this.creator = creator;
|
|
|
|
this.version = version;
|
|
|
|
this.type = type;
|
2016-01-02 12:24:23 +01:00
|
|
|
//FIXME: do not assume
|
|
|
|
this.inCache = true;
|
2016-03-18 16:47:14 +01:00
|
|
|
this.configurable = configurable;
|
2016-01-02 12:24:23 +01:00
|
|
|
}
|
|
|
|
|
2016-05-22 22:48:45 +02:00
|
|
|
public void setOnDevice(boolean isOnDevice) {
|
|
|
|
this.isOnDevice = isOnDevice;
|
|
|
|
}
|
|
|
|
|
2016-01-02 12:24:23 +01:00
|
|
|
public boolean isInCache() {
|
|
|
|
return inCache;
|
2015-12-07 18:15:26 +01:00
|
|
|
}
|
|
|
|
|
2016-05-22 22:48:45 +02:00
|
|
|
public boolean isOnDevice() {
|
|
|
|
return isOnDevice;
|
|
|
|
}
|
|
|
|
|
2015-03-25 22:23:45 +01:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
2015-03-26 18:11:47 +01:00
|
|
|
|
2015-05-18 20:56:19 +02:00
|
|
|
public UUID getUUID() {
|
|
|
|
return uuid;
|
2015-03-26 18:11:47 +01:00
|
|
|
}
|
2015-03-31 23:34:19 +02:00
|
|
|
|
|
|
|
public Type getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum Type {
|
|
|
|
UNKNOWN,
|
|
|
|
WATCHFACE,
|
2016-06-14 20:04:54 +02:00
|
|
|
WATCHFACE_SYSTEM,
|
2015-03-31 23:34:19 +02:00
|
|
|
APP_GENERIC,
|
|
|
|
APP_ACTIVITYTRACKER,
|
2015-12-12 11:59:52 +01:00
|
|
|
APP_SYSTEM,
|
2015-03-31 23:34:19 +02:00
|
|
|
}
|
2015-12-07 18:15:26 +01:00
|
|
|
|
|
|
|
public JSONObject getJSON() {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
try {
|
|
|
|
json.put("uuid", uuid.toString());
|
|
|
|
json.put("name", name);
|
|
|
|
json.put("creator", creator);
|
|
|
|
json.put("version", version);
|
|
|
|
json.put("type", type.name());
|
|
|
|
} catch (JSONException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return json;
|
|
|
|
}
|
2016-03-18 16:47:14 +01:00
|
|
|
|
|
|
|
public boolean isConfigurable() {
|
|
|
|
return configurable;
|
|
|
|
}
|
2015-03-25 22:23:45 +01:00
|
|
|
}
|