2024-01-10 18:54:00 +01:00
|
|
|
/* Copyright (C) 2015-2024 Andreas Shimokawa, Arjan Schrijver, Carsten
|
|
|
|
Pfeiffer, Daniele Gobbetti
|
2017-03-10 14:53:19 +01:00
|
|
|
|
|
|
|
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
|
2024-01-10 18:54:00 +01:00
|
|
|
along with this program. If not, see <https://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
|
|
|
|
2022-06-16 23:53:58 +02:00
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
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;
|
2022-06-16 23:53:58 +02:00
|
|
|
private final Bitmap previewImage;
|
2022-07-14 13:02:04 +02:00
|
|
|
private boolean isUpToDate = true;
|
2022-06-16 23:53:58 +02:00
|
|
|
|
|
|
|
public GBDeviceApp(UUID uuid, String name, String creator, String version, Type type, Bitmap previewImage) {
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.name = name;
|
|
|
|
this.creator = creator;
|
|
|
|
this.version = version;
|
|
|
|
this.type = type;
|
|
|
|
this.previewImage = previewImage;
|
|
|
|
//FIXME: do not assume
|
|
|
|
this.inCache = false;
|
|
|
|
this.configurable = false;
|
|
|
|
this.isOnDevice = false;
|
|
|
|
}
|
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;
|
2022-06-16 23:53:58 +02:00
|
|
|
this.previewImage = null;
|
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
|
|
|
}
|
|
|
|
|
2022-06-16 23:53:58 +02:00
|
|
|
public GBDeviceApp(JSONObject json, boolean configurable, Bitmap previewImage) {
|
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;
|
2022-06-16 23:53:58 +02:00
|
|
|
this.previewImage = previewImage;
|
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;
|
|
|
|
}
|
|
|
|
|
2022-06-16 23:53:58 +02:00
|
|
|
public Bitmap getPreviewImage() {
|
|
|
|
return previewImage;
|
|
|
|
}
|
|
|
|
|
2015-03-31 23:34:19 +02:00
|
|
|
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;
|
|
|
|
}
|
2022-07-14 13:02:04 +02:00
|
|
|
|
|
|
|
public void setUpToDate(boolean isUpToDate) {
|
|
|
|
this.isUpToDate = isUpToDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isUpToDate() {
|
|
|
|
return isUpToDate;
|
|
|
|
}
|
2015-03-25 22:23:45 +01:00
|
|
|
}
|