1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 19:36:50 +01: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.TimeZone;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
@ -219,7 +220,8 @@ public class FossilWatchAdapter extends WatchAdapter {
requestQueue.clear(); requestQueue.clear();
} }
log("characteristic write failed: " + status); 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; fossilRequest = null;
queueNextRequest(); queueNextRequest();
@ -551,7 +553,8 @@ public class FossilWatchAdapter extends WatchAdapter {
provider.addGBActivitySamples(samples); provider.addGBActivitySamples(samples);
queueWrite(new FileDeleteRequest(getHandle())); 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) { } catch (Exception ex) {
GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext()); GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
@ -561,7 +564,7 @@ public class FossilWatchAdapter extends WatchAdapter {
@Override @Override
public void handleFileLookupError(FILE_LOOKUP_ERROR error) { 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); GB.toast("activity file empty", Toast.LENGTH_SHORT, GB.INFO);
} }
} }
@ -651,7 +654,8 @@ public class FossilWatchAdapter extends WatchAdapter {
// setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED); // setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
}else { }else {
GB.log("error", GB.ERROR, e); 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; requestFinished = true;

View File

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