From f4c15a98e6f58b36046d1c9c67ca8662f8e98924 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 10 Apr 2016 17:29:05 +0200 Subject: [PATCH] Update Syncthing URL on restart if it was changed (fixes #442). --- .../com/nutomic/syncthingandroid/syncthing/RestApi.java | 6 +++++- .../syncthingandroid/syncthing/SyncthingService.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index a6251675..b5e08a8b 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -150,7 +150,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, private String mVersion; - private final String mUrl; + private String mUrl; private final String mApiKey; @@ -200,6 +200,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, mOnConfigChangedListener = configListener; } + public void setWebGuiUrl(String newUrl) { + mUrl = newUrl; + } + /** * Number of previous calls to {@link #tryIsAvailable()}. */ diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java index 6f5db56f..205c4d4d 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java @@ -227,8 +227,10 @@ public class SyncthingService extends Service implements if (mConfig != null) { mCurrentState = State.STARTING; - if (mApi != null) + if (mApi != null) { registerOnWebGuiAvailableListener(mApi); + mApi.setWebGuiUrl(mConfig.getWebGuiUrl()); + } if (mEventProcessor != null) registerOnWebGuiAvailableListener(mEventProcessor); new PollWebGuiAvailableTaskImpl(getFilesDir() + "/" + HTTPS_CERT_FILE)