1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

Re-organized URI handling.

This commit is contained in:
Felix Ableitner 2014-05-14 13:08:04 +02:00
parent ef8b424500
commit c53c907a02
4 changed files with 14 additions and 12 deletions

View file

@ -30,7 +30,7 @@ public class SettingsActivity extends PreferenceActivity {
? versionName ? versionName
: getString(R.string.syncthing_version_error)); : getString(R.string.syncthing_version_error));
} }
}.execute(SyncthingService.SYNCTHING_URL + SyncthingService.PATH_VERSION); }.execute(GetTask.URI_VERSION);
} }

View file

@ -24,6 +24,11 @@ public class GetTask extends AsyncTask<String, Void, String> {
private static final String TAG = "GetTask"; 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 @Override
protected String doInBackground(String... uri) { protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();

View file

@ -4,6 +4,8 @@ package com.nutomic.syncthingandroid;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import com.nutomic.syncthingandroid.service.SyncthingService;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
@ -18,6 +20,11 @@ public class PostTask extends AsyncTask<String, Void, Void> {
private static final String TAG = "PostTask"; private static final String TAG = "PostTask";
/**
* URI to call for shutdown.
*/
public static final String URI_SHUTDOWN = SyncthingService.SYNCTHING_URL + "/rest/shutdown";
@Override @Override
protected Void doInBackground(String... uri) { protected Void doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();

View file

@ -37,16 +37,6 @@ public class SyncthingService extends Service {
*/ */
public static final String SYNCTHING_URL = "http://127.0.0.1:8080"; 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); private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
@Override @Override
@ -133,7 +123,7 @@ public class SyncthingService extends Service {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
new PostTask().execute(SYNCTHING_URL + PATH_SHUTDOWN); new PostTask().execute(PostTask.URI_SHUTDOWN);
} }
} }