1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

temporarily fix version identification

This commit is contained in:
MPeter 2022-09-01 22:16:47 +02:00
parent 96f87cf913
commit db37222171

View File

@ -28,6 +28,8 @@ import org.slf4j.LoggerFactory;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity; import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
@ -41,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
public class PineTimeInstallHandler implements InstallHandler { public class PineTimeInstallHandler implements InstallHandler {
private static final Logger LOG = LoggerFactory.getLogger(PineTimeInstallHandler.class); private static final Logger LOG = LoggerFactory.getLogger(PineTimeInstallHandler.class);
private static final Pattern binNameVersionPattern = Pattern.compile(".*-((?:\\d+\\.){2}\\d+).bin$");
private final Context context; private final Context context;
@ -102,7 +105,7 @@ public class PineTimeInstallHandler implements InstallHandler {
GenericItem installItem = new GenericItem(); GenericItem installItem = new GenericItem();
installItem.setIcon(R.drawable.ic_firmware); installItem.setIcon(R.drawable.ic_firmware);
installItem.setName("PineTime firmware"); installItem.setName("PineTime firmware");
installItem.setDetails(version); installItem.setDetails(getVersion());
installActivity.setInfoText(context.getString(R.string.firmware_install_warning, "(unknown)")); installActivity.setInfoText(context.getString(R.string.firmware_install_warning, "(unknown)"));
installActivity.setInstallItem(installItem); installActivity.setInstallItem(installItem);
@ -121,4 +124,14 @@ public class PineTimeInstallHandler implements InstallHandler {
dfuPackageManifest.manifest.application != null && dfuPackageManifest.manifest.application != null &&
dfuPackageManifest.manifest.application.bin_file != null; dfuPackageManifest.manifest.application.bin_file != null;
} }
// TODO: obtain version information from manifest file instead
private String getVersion() {
String binFileName = dfuPackageManifest.manifest.application.bin_file;
Matcher regexMatcher = binNameVersionPattern.matcher(binFileName);
if (regexMatcher.matches())
return regexMatcher.group(1);
return "(Unknown version)";
}
} }