iGPSPORT: Improve upload progress

This commit is contained in:
José Rebelo
2026-05-14 23:46:29 +01:00
parent cbd92ef6fe
commit 81ab123c32
7 changed files with 89 additions and 87 deletions
@@ -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)) {
@@ -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;
@@ -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;
}
@@ -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;
@@ -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) {
@@ -61,37 +61,6 @@
android:indeterminate="true"
android:visibility="gone" />
<Button
android:id="@+id/installButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/installProgressBar"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/appinstaller_install" />
<Button
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/installProgressBar"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:visibility="gone"
android:text="@string/ok" />
<TextView
android:id="@+id/installProgressText"
android:layout_width="match_parent"
@@ -107,11 +76,36 @@
android:layout_alignParentEnd="false"
android:layout_below="@+id/installProgressText" />
<android.widget.Space
<Button
android:id="@+id/installButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
android:layout_alignParentBottom="false"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/detailsListView"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/appinstaller_install" />
<Button
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/detailsListView"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:visibility="gone"
android:text="@string/ok" />
</RelativeLayout>
@@ -85,37 +85,6 @@
android:inputType="textNoSuggestions" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/installButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/track_name_input_layout"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/appinstaller_install" />
<Button
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/track_name_input_layout"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/ok"
android:visibility="gone" />
<TextView
android:id="@+id/installProgressText"
android:layout_width="match_parent"
@@ -131,11 +100,36 @@
android:layout_below="@+id/installProgressText"
android:layout_alignParentEnd="false" />
<android.widget.Space
<Button
android:id="@+id/installButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/detailsListView"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/appinstaller_install" />
<Button
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="false"
android:layout_below="@+id/detailsListView"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:enabled="false"
android:text="@string/ok"
android:visibility="gone" />
</RelativeLayout>