From c53c907a02e9ec71fedd6b989e33c747f6608919 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 14 May 2014 13:08:04 +0200 Subject: [PATCH] Re-organized URI handling. --- .../nutomic/syncthingandroid/SettingsActivity.java | 2 +- .../nutomic/syncthingandroid/service/GetTask.java | 5 +++++ .../nutomic/syncthingandroid/service/PostTask.java | 7 +++++++ .../syncthingandroid/service/SyncthingService.java | 12 +----------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/SettingsActivity.java index ec37c275..c38c9692 100644 --- a/src/main/java/com/nutomic/syncthingandroid/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/SettingsActivity.java @@ -30,7 +30,7 @@ public class SettingsActivity extends PreferenceActivity { ? versionName : getString(R.string.syncthing_version_error)); } - }.execute(SyncthingService.SYNCTHING_URL + SyncthingService.PATH_VERSION); + }.execute(GetTask.URI_VERSION); } diff --git a/src/main/java/com/nutomic/syncthingandroid/service/GetTask.java b/src/main/java/com/nutomic/syncthingandroid/service/GetTask.java index 302fa899..1ee8e6c2 100644 --- a/src/main/java/com/nutomic/syncthingandroid/service/GetTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/service/GetTask.java @@ -24,6 +24,11 @@ public class GetTask extends AsyncTask { private static final String TAG = "GetTask"; + /** + * URI to call to get version name. + */ + public static final String URI_VERSION = SyncthingService.SYNCTHING_URL + "/rest/version"; + @Override protected String doInBackground(String... uri) { HttpClient httpclient = new DefaultHttpClient(); diff --git a/src/main/java/com/nutomic/syncthingandroid/service/PostTask.java b/src/main/java/com/nutomic/syncthingandroid/service/PostTask.java index 1d563cfc..5f544157 100644 --- a/src/main/java/com/nutomic/syncthingandroid/service/PostTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/service/PostTask.java @@ -4,6 +4,8 @@ package com.nutomic.syncthingandroid; import android.os.AsyncTask; import android.util.Log; +import com.nutomic.syncthingandroid.service.SyncthingService; + import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; @@ -18,6 +20,11 @@ public class PostTask extends AsyncTask { private static final String TAG = "PostTask"; + /** + * URI to call for shutdown. + */ + public static final String URI_SHUTDOWN = SyncthingService.SYNCTHING_URL + "/rest/shutdown"; + @Override protected Void doInBackground(String... uri) { HttpClient httpclient = new DefaultHttpClient(); diff --git a/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index 4b31aa34..8525f0da 100644 --- a/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -37,16 +37,6 @@ public class SyncthingService extends Service { */ public static final String SYNCTHING_URL = "http://127.0.0.1:8080"; - /** - * Path to call for shutdown (with POST). - */ - private static final String PATH_SHUTDOWN = "/rest/shutdown"; - - /** - * Path to call to get version name (with GET). - */ - public static final String PATH_VERSION = "/rest/version"; - private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this); @Override @@ -133,7 +123,7 @@ public class SyncthingService extends Service { @Override public void onDestroy() { super.onDestroy(); - new PostTask().execute(SYNCTHING_URL + PATH_SHUTDOWN); + new PostTask().execute(PostTask.URI_SHUTDOWN); } }