mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-18 06:37:47 +01:00
Updated progress string and context handling
This commit is contained in:
parent
9988e3f3f5
commit
2cd783feca
@ -91,7 +91,6 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
|
||||
private final DfuProgressListener progressListener = new DfuProgressListenerAdapter() {
|
||||
private final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getContext());
|
||||
private final Context context = getContext();
|
||||
|
||||
/**
|
||||
* Sets the progress bar to indeterminate or not, also makes it visible
|
||||
@ -121,53 +120,53 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
@Override
|
||||
public void onDeviceConnecting(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_connecting));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_connecting));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceConnected(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_connected));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_connected));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnablingDfuMode(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_starting));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_starting));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDfuProcessStarting(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_starting));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_starting));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDfuProcessStarted(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_started));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_started));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceDisconnecting(final String mac) {
|
||||
this.setProgressText(context.getString(R.string.devicestatus_disconnecting));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_disconnecting));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceDisconnected(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_disconnected));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_disconnected));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDfuCompleted(final String mac) {
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_completed));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_completed));
|
||||
this.setIndeterminate(false);
|
||||
this.setProgress(100);
|
||||
|
||||
handler = null;
|
||||
controller = null;
|
||||
DfuServiceListenerHelper.unregisterProgressListener(context, progressListener);
|
||||
DfuServiceListenerHelper.unregisterProgressListener(getContext(), progressListener);
|
||||
|
||||
// TODO: Request reconnection
|
||||
}
|
||||
@ -175,17 +174,17 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
@Override
|
||||
public void onFirmwareValidating(final String mac) {
|
||||
this.setIndeterminate(true);
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_validating));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_validating));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDfuAborted(final String mac) {
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_aborted));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_aborted));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final String mac, int error, int errorType, final String message) {
|
||||
this.setProgressText(context.getString(R.string.devicestatus_upload_failed));
|
||||
this.setProgressText(getContext().getString(R.string.devicestatus_upload_failed));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,7 +197,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
||||
this.setProgress(percent);
|
||||
this.setIndeterminate(false);
|
||||
this.setProgressText(String.format(Locale.ENGLISH,
|
||||
context.getString(R.string.firmware_update_progress),
|
||||
getContext().getString(R.string.firmware_update_progress),
|
||||
percent, speed, averageSpeed, segment, totalSegments));
|
||||
}
|
||||
};
|
||||
|
@ -456,7 +456,7 @@
|
||||
<string name="devicestatus_upload_validating">Upload is being validated</string>
|
||||
<string name="devicestatus_upload_aborted">Upload has been aborted!</string>
|
||||
<string name="devicestatus_upload_failed">Upload has failed</string>
|
||||
<string name="firmware_update_progress">Upload is in progress\n%1i%% at %.2fkbps (average %.2fkbps)\nPart %1d of %1d</string>
|
||||
<string name="firmware_update_progress">Upload is in progress\n%1d%% at %.2fkbps (average %.2fkbps)\nPart %1d of %1d</string>
|
||||
<string name="updating_firmware">Flashing firmware…</string>
|
||||
|
||||
<string name="fwapp_install_device_not_ready">File cannot be installed, device not ready.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user