mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
iGPSPORT: Improve upload progress
This commit is contained in:
+4
-2
@@ -88,7 +88,10 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
|||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (GBDevice.ACTION_DEVICE_CHANGED.equals(action)) {
|
if (GBDevice.ACTION_DEVICE_CHANGED.equals(action)) {
|
||||||
final GBDevice changedDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
final GBDevice changedDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||||
if (changedDevice != null && changedDevice.equals(device)) {
|
if(changedDevice == null || !changedDevice.equals(device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
device = changedDevice;
|
||||||
refreshBusyState(device);
|
refreshBusyState(device);
|
||||||
if (!device.isInitialized()) {
|
if (!device.isInitialized()) {
|
||||||
setInstallEnabled(false);
|
setInstallEnabled(false);
|
||||||
@@ -101,7 +104,6 @@ public class FwAppInstallerActivity extends AbstractGBActivity implements Instal
|
|||||||
} else {
|
} else {
|
||||||
validateInstallation();
|
validateInstallation();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (GB.ACTION_SET_PROGRESS_BAR.equals(action)) {
|
} else if (GB.ACTION_SET_PROGRESS_BAR.equals(action)) {
|
||||||
if (intent.hasExtra(GB.PROGRESS_BAR_INDETERMINATE)) {
|
if (intent.hasExtra(GB.PROGRESS_BAR_INDETERMINATE)) {
|
||||||
setProgressIndeterminate(intent.getBooleanExtra(GB.PROGRESS_BAR_INDETERMINATE, false));
|
setProgressIndeterminate(intent.getBooleanExtra(GB.PROGRESS_BAR_INDETERMINATE, false));
|
||||||
|
|||||||
+5
@@ -73,6 +73,11 @@ public abstract class IGPSportAbstractCoordinator extends AbstractBLEDeviceCoord
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsFlashing(@NonNull GBDevice device) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsAppsManagement(final GBDevice device) {
|
public boolean supportsAppsManagement(final GBDevice device) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+7
-1
@@ -52,7 +52,13 @@ public class SetProgressAction extends PlainAction {
|
|||||||
GB.updateInstallNotification(this.text, this.ongoing, this.percentage, this.context);
|
GB.updateInstallNotification(this.text, this.ongoing, this.percentage, this.context);
|
||||||
|
|
||||||
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -30,6 +30,7 @@ import android.os.Bundle;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
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) {
|
if (mainOperation == Common.SERVICE_OPERATE_TYPE.enum_SERVICE_OPERATE_TYPE_ADD_VALUE) {
|
||||||
gbDevice.unsetBusyTask();
|
gbDevice.unsetBusyTask();
|
||||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
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) {
|
if (result == 0) {
|
||||||
builder.setProgress(R.string.route_upload_completed, false, 100);
|
broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_TEXT).putExtra(GB.DISPLAY_MESSAGE_MESSAGE, getContext().getString(R.string.route_upload_completed)));
|
||||||
handleGBDeviceEvent(new GBDeviceEventDisplayMessage("Route upload completed", Toast.LENGTH_LONG, GB.INFO));
|
|
||||||
} else {
|
} else {
|
||||||
builder.setProgress(R.string.route_upload_failed, false, 0);
|
broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_TEXT).putExtra(GB.DISPLAY_MESSAGE_MESSAGE, getContext().getString(R.string.route_upload_failed)));
|
||||||
handleGBDeviceEvent(new GBDeviceEventDisplayMessage("Failed to upload route", Toast.LENGTH_LONG, GB.ERROR));
|
|
||||||
}
|
}
|
||||||
builder.queue();
|
broadcastManager.sendBroadcast(new Intent(GB.ACTION_SET_FINISHED));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -125,8 +125,9 @@ public class IGPSportRoutesManager {
|
|||||||
fileOperationbuilder.getOperateType().getNumber(),
|
fileOperationbuilder.getOperateType().getNumber(),
|
||||||
fileOperationbuilder.build().toByteArray(),
|
fileOperationbuilder.build().toByteArray(),
|
||||||
handler.getBytes());
|
handler.getBytes());
|
||||||
builder.writeChunkedData(support.writeCharacteristicFourth, fileOperationBytes, support.getMTU());
|
|
||||||
builder.setBusyTask(R.string.task_installing_route);
|
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();
|
builder.queue();
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
|||||||
@@ -61,37 +61,6 @@
|
|||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:visibility="gone" />
|
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
|
<TextView
|
||||||
android:id="@+id/installProgressText"
|
android:id="@+id/installProgressText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -107,11 +76,36 @@
|
|||||||
android:layout_alignParentEnd="false"
|
android:layout_alignParentEnd="false"
|
||||||
android:layout_below="@+id/installProgressText" />
|
android:layout_below="@+id/installProgressText" />
|
||||||
|
|
||||||
<android.widget.Space
|
<Button
|
||||||
|
android:id="@+id/installButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="false"
|
||||||
android:layout_centerHorizontal="true" />
|
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>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -85,37 +85,6 @@
|
|||||||
android:inputType="textNoSuggestions" />
|
android:inputType="textNoSuggestions" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</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
|
<TextView
|
||||||
android:id="@+id/installProgressText"
|
android:id="@+id/installProgressText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -131,11 +100,36 @@
|
|||||||
android:layout_below="@+id/installProgressText"
|
android:layout_below="@+id/installProgressText"
|
||||||
android:layout_alignParentEnd="false" />
|
android:layout_alignParentEnd="false" />
|
||||||
|
|
||||||
<android.widget.Space
|
<Button
|
||||||
|
android:id="@+id/installButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignWithParentIfMissing="false"
|
||||||
android:layout_centerHorizontal="true" />
|
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>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user