From 81ab123c32bca9793810b00bc7557da7bb5175ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 14 May 2026 23:46:29 +0100 Subject: [PATCH] iGPSPORT: Improve upload progress --- .../install/FwAppInstallerActivity.java | 24 +++---- .../igpsport/IGPSportAbstractCoordinator.java | 5 ++ .../btle/actions/SetProgressAction.java | 8 ++- .../igpsport/IGPSportDeviceSupport.java | 12 ++-- .../igpsport/IGPSportRoutesManager.java | 3 +- .../main/res/layout/activity_appinstaller.xml | 62 +++++++++---------- .../res/layout/activity_installer_gpx.xml | 62 +++++++++---------- 7 files changed, 89 insertions(+), 87 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/install/FwAppInstallerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/install/FwAppInstallerActivity.java index 7ae4c45c4f..49c1ee655e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/install/FwAppInstallerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/install/FwAppInstallerActivity.java @@ -88,19 +88,21 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal String action = intent.getAction(); if (GBDevice.ACTION_DEVICE_CHANGED.equals(action)) { final GBDevice changedDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE); - if (changedDevice != null && changedDevice.equals(device)) { - refreshBusyState(device); - if (!device.isInitialized()) { - setInstallEnabled(false); - if (mayConnect) { - GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO); - connect(); - } else { - setInfoText(getString(R.string.fwappinstaller_connection_state, device.getStateString(context))); - } + if(changedDevice == null || !changedDevice.equals(device)) { + return; + } + device = changedDevice; + refreshBusyState(device); + if (!device.isInitialized()) { + setInstallEnabled(false); + if (mayConnect) { + GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO); + connect(); } else { - validateInstallation(); + setInfoText(getString(R.string.fwappinstaller_connection_state, device.getStateString(context))); } + } else { + validateInstallation(); } } else if (GB.ACTION_SET_PROGRESS_BAR.equals(action)) { if (intent.hasExtra(GB.PROGRESS_BAR_INDETERMINATE)) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/igpsport/IGPSportAbstractCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/igpsport/IGPSportAbstractCoordinator.java index 2833e9b90f..86c64d4815 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/igpsport/IGPSportAbstractCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/igpsport/IGPSportAbstractCoordinator.java @@ -73,6 +73,11 @@ public abstract class IGPSportAbstractCoordinator extends AbstractBLEDeviceCoord return true; } + @Override + public boolean supportsFlashing(@NonNull GBDevice device) { + return true; + } + @Override public boolean supportsAppsManagement(final GBDevice device) { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java index 61bed73b17..0bb75c3d4e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/actions/SetProgressAction.java @@ -52,7 +52,13 @@ public class SetProgressAction extends PlainAction { GB.updateInstallNotification(this.text, this.ongoing, this.percentage, this.context); final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(context); - broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_BAR).putExtra(GB.PROGRESS_BAR_PROGRESS, percentage)); + final Intent intent = new Intent(GB.ACTION_SET_PROGRESS_BAR); + if (ongoing && percentage == 0) { + intent.putExtra(GB.PROGRESS_BAR_INDETERMINATE, true); + } else { + intent.putExtra(GB.PROGRESS_BAR_PROGRESS, percentage); + } + broadcastManager.sendBroadcast(intent); return true; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportDeviceSupport.java index 5aca082137..c32a960084 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportDeviceSupport.java @@ -30,6 +30,7 @@ import android.os.Bundle; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.google.protobuf.ByteString; import com.google.protobuf.InvalidProtocolBufferException; @@ -358,15 +359,14 @@ public class IGPSportDeviceSupport extends AbstractBTLESingleDeviceSupport { if (mainOperation == Common.SERVICE_OPERATE_TYPE.enum_SERVICE_OPERATE_TYPE_ADD_VALUE) { gbDevice.unsetBusyTask(); gbDevice.sendDeviceUpdateIntent(getContext()); - TransactionBuilder builder = createTransactionBuilder("Route upload finished"); + final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(GBApplication.getContext()); + broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_INFO_TEXT).putExtra(GB.DISPLAY_MESSAGE_MESSAGE, "")); if (result == 0) { - builder.setProgress(R.string.route_upload_completed, false, 100); - handleGBDeviceEvent(new GBDeviceEventDisplayMessage("Route upload completed", Toast.LENGTH_LONG, GB.INFO)); + broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_TEXT).putExtra(GB.DISPLAY_MESSAGE_MESSAGE, getContext().getString(R.string.route_upload_completed))); } else { - builder.setProgress(R.string.route_upload_failed, false, 0); - handleGBDeviceEvent(new GBDeviceEventDisplayMessage("Failed to upload route", Toast.LENGTH_LONG, GB.ERROR)); + broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_TEXT).putExtra(GB.DISPLAY_MESSAGE_MESSAGE, getContext().getString(R.string.route_upload_failed))); } - builder.queue(); + broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_FINISHED)); } break; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportRoutesManager.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportRoutesManager.java index f1775acfaa..1a2a55eca1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportRoutesManager.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/igpsport/IGPSportRoutesManager.java @@ -125,8 +125,9 @@ public class IGPSportRoutesManager { fileOperationbuilder.getOperateType().getNumber(), fileOperationbuilder.build().toByteArray(), handler.getBytes()); - builder.writeChunkedData(support.writeCharacteristicFourth, fileOperationBytes, support.getMTU()); builder.setBusyTask(R.string.task_installing_route); + builder.setProgress(R.string.task_installing_route, true, 0); + builder.writeChunkedData(support.writeCharacteristicFourth, fileOperationBytes, support.getMTU()); builder.queue(); } catch (final Exception e) { diff --git a/app/src/main/res/layout/activity_appinstaller.xml b/app/src/main/res/layout/activity_appinstaller.xml index 6c981f9c03..0a35073d1f 100644 --- a/app/src/main/res/layout/activity_appinstaller.xml +++ b/app/src/main/res/layout/activity_appinstaller.xml @@ -61,37 +61,6 @@ android:indeterminate="true" android:visibility="gone" /> -