1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-22 06:41:06 +02:00

Fossil/Skagen Hybrids: Show some toasts only on debug builds

This commit is contained in:
Arjan Schrijver 2023-09-18 22:32:02 +02:00
parent ee3ce06899
commit b8912976f1
2 changed files with 13 additions and 6 deletions

View File

@ -46,6 +46,7 @@ import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
@ -219,7 +220,8 @@ public class FossilWatchAdapter extends WatchAdapter {
requestQueue.clear();
}
log("characteristic write failed: " + status);
GB.toast(fossilRequest.getName() + " characteristic write failed: " + status, Toast.LENGTH_SHORT, GB.ERROR);
if (BuildConfig.DEBUG)
GB.toast(fossilRequest.getName() + " characteristic write failed: " + status, Toast.LENGTH_SHORT, GB.ERROR);
fossilRequest = null;
queueNextRequest();
@ -551,7 +553,8 @@ public class FossilWatchAdapter extends WatchAdapter {
provider.addGBActivitySamples(samples);
queueWrite(new FileDeleteRequest(getHandle()));
GB.toast("synced activity data", Toast.LENGTH_SHORT, GB.INFO);
if (BuildConfig.DEBUG)
GB.toast("synced activity data", Toast.LENGTH_SHORT, GB.INFO);
} catch (Exception ex) {
GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
@ -561,7 +564,7 @@ public class FossilWatchAdapter extends WatchAdapter {
@Override
public void handleFileLookupError(FILE_LOOKUP_ERROR error) {
if(error == FILE_LOOKUP_ERROR.FILE_EMPTY){
if(error == FILE_LOOKUP_ERROR.FILE_EMPTY && BuildConfig.DEBUG){
GB.toast("activity file empty", Toast.LENGTH_SHORT, GB.INFO);
}
}
@ -651,7 +654,8 @@ public class FossilWatchAdapter extends WatchAdapter {
// setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
}else {
GB.log("error", GB.ERROR, e);
GB.toast(fossilRequest.getName() + " failed", Toast.LENGTH_SHORT, GB.ERROR);
if (BuildConfig.DEBUG)
GB.toast(fossilRequest.getName() + " failed", Toast.LENGTH_SHORT, GB.ERROR);
}
requestFinished = true;

View File

@ -82,6 +82,7 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
@ -1239,7 +1240,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
writeFile(String.valueOf(System.currentTimeMillis()), fileData);
}
queueWrite(new FileDeleteRequest(fileHandle));
GB.toast(getContext().getString(R.string.fossil_hr_synced_activity_data), Toast.LENGTH_SHORT, GB.INFO);
if (BuildConfig.DEBUG)
GB.toast(getContext().getString(R.string.fossil_hr_synced_activity_data), Toast.LENGTH_SHORT, GB.INFO);
} catch (Exception ex) {
GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
@ -1252,7 +1254,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
@Override
public void handleFileLookupError(FILE_LOOKUP_ERROR error) {
if (error == FILE_LOOKUP_ERROR.FILE_EMPTY) {
GB.toast("activity file empty yet", Toast.LENGTH_LONG, GB.ERROR);
if (BuildConfig.DEBUG)
GB.toast("activity file empty yet", Toast.LENGTH_LONG, GB.ERROR);
} else {
throw new RuntimeException("strange lookup stuff");
}