mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
Update dependencies, clean code
This commit is contained in:
parent
0350ff5f40
commit
40270f4da4
14 changed files with 36 additions and 55 deletions
|
@ -1,22 +1,21 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.github.ben-manes.versions'
|
apply plugin: 'com.github.ben-manes.versions'
|
||||||
apply plugin: 'com.github.triplet.play'
|
apply plugin: 'com.github.triplet.play'
|
||||||
apply plugin: 'me.tatarka.retrolambda'
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'eu.chainfire:libsuperuser:1.0.0.201704021214'
|
implementation 'eu.chainfire:libsuperuser:1.0.0.201704021214'
|
||||||
compile 'com.android.support:design:27.0.1'
|
implementation 'com.android.support:design:27.0.2'
|
||||||
compile 'com.google.zxing:android-integration:3.3.0'
|
implementation 'com.google.zxing:android-integration:3.3.0'
|
||||||
compile 'com.google.code.gson:gson:2.8.2'
|
implementation 'com.google.code.gson:gson:2.8.2'
|
||||||
compile 'org.mindrot:jbcrypt:0.4'
|
implementation 'org.mindrot:jbcrypt:0.4'
|
||||||
compile 'com.google.guava:guava:20.0'
|
implementation 'com.google.guava:guava:20.0'
|
||||||
compile 'com.annimon:stream:1.1.9'
|
implementation 'com.annimon:stream:1.1.9'
|
||||||
compile 'com.android.volley:volley:1.0.0'
|
implementation 'com.android.volley:volley:1.1.0'
|
||||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
compile "com.google.dagger:dagger:2.13"
|
implementation "com.google.dagger:dagger:2.13"
|
||||||
annotationProcessor "com.google.dagger:dagger-compiler:2.13"
|
annotationProcessor "com.google.dagger:dagger-compiler:2.13"
|
||||||
androidTestCompile 'com.android.support.test:rules:1.0.1'
|
androidTestImplementation 'com.android.support.test:rules:1.0.1'
|
||||||
androidTestCompile 'com.android.support:support-annotations:27.0.1'
|
androidTestImplementation 'com.android.support:support-annotations:27.0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -35,16 +34,12 @@ import com.nutomic.syncthingandroid.SyncthingApp;
|
||||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||||
import com.nutomic.syncthingandroid.util.Util;
|
import com.nutomic.syncthingandroid.util.Util;
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that allows selecting a directory in the local file system.
|
* Activity that allows selecting a directory in the local file system.
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +49,7 @@ public class FolderPickerActivity extends SyncthingActivity
|
||||||
private static final String EXTRA_INITIAL_DIRECTORY =
|
private static final String EXTRA_INITIAL_DIRECTORY =
|
||||||
"com.nutomic.syncthingandroid.activities.FolderPickerActivity.INITIAL_DIRECTORY";
|
"com.nutomic.syncthingandroid.activities.FolderPickerActivity.INITIAL_DIRECTORY";
|
||||||
|
|
||||||
public static final String EXTRA_ROOT_DIRECTORY =
|
private static final String EXTRA_ROOT_DIRECTORY =
|
||||||
"com.nutomic.syncthingandroid.activities.FolderPickerActivity.ROOT_DIRECTORY";
|
"com.nutomic.syncthingandroid.activities.FolderPickerActivity.ROOT_DIRECTORY";
|
||||||
|
|
||||||
public static final String EXTRA_RESULT_DIRECTORY =
|
public static final String EXTRA_RESULT_DIRECTORY =
|
||||||
|
|
|
@ -274,9 +274,9 @@ public class ShareActivity extends StateDialogActivity
|
||||||
|
|
||||||
private class CopyFilesTask extends AsyncTask<Void, Void, Boolean> {
|
private class CopyFilesTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
private ProgressDialog mProgress;
|
private ProgressDialog mProgress;
|
||||||
private Map<Uri, String> mFiles;
|
private final Map<Uri, String> mFiles;
|
||||||
private Folder mFolder;
|
private final Folder mFolder;
|
||||||
private File mDirectory;
|
private final File mDirectory;
|
||||||
private int mCopied = 0, mIgnored = 0;
|
private int mCopied = 0, mIgnored = 0;
|
||||||
|
|
||||||
CopyFilesTask(Map<Uri, String> files, Folder folder, File directory) {
|
CopyFilesTask(Map<Uri, String> files, Folder folder, File directory) {
|
||||||
|
|
|
@ -127,9 +127,8 @@ public abstract class StateDialogActivity extends SyncthingActivity {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
binding.loadingSlowMessage.setVisibility(View.VISIBLE);
|
binding.loadingSlowMessage.setVisibility(View.VISIBLE);
|
||||||
binding.viewLogs.setOnClickListener(v -> {
|
binding.viewLogs.setOnClickListener(v ->
|
||||||
startActivity(new Intent(this, LogActivity.class));
|
startActivity(new Intent(this, LogActivity.class)));
|
||||||
});
|
|
||||||
}, SLOW_LOADING_TIME);
|
}, SLOW_LOADING_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
|
||||||
/**
|
/**
|
||||||
* Used for Fragments to use the Activity's service connection.
|
* Used for Fragments to use the Activity's service connection.
|
||||||
*/
|
*/
|
||||||
public void registerOnServiceConnectedListener(OnServiceConnectedListener listener) {
|
void registerOnServiceConnectedListener(OnServiceConnectedListener listener) {
|
||||||
if (mSyncthingService != null) {
|
if (mSyncthingService != null) {
|
||||||
listener.onServiceConnected();
|
listener.onServiceConnected();
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,7 +94,7 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
|
||||||
/**
|
/**
|
||||||
* Returns service object (or null if not bound).
|
* Returns service object (or null if not bound).
|
||||||
*/
|
*/
|
||||||
public SyncthingService getService() {
|
SyncthingService getService() {
|
||||||
return mSyncthingService;
|
return mSyncthingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.nutomic.syncthingandroid.http;
|
package com.nutomic.syncthingandroid.http;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -30,10 +29,8 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSession;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
|
|
||||||
|
@ -73,14 +70,14 @@ public abstract class ApiRequest {
|
||||||
private final String mPath;
|
private final String mPath;
|
||||||
private final String mApiKey;
|
private final String mApiKey;
|
||||||
|
|
||||||
public ApiRequest(Context context, URL url, String path, String apiKey) {
|
ApiRequest(Context context, URL url, String path, String apiKey) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mUrl = url;
|
mUrl = url;
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mApiKey = apiKey;
|
mApiKey = apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Uri buildUri(Map<String, String> params) {
|
Uri buildUri(Map<String, String> params) {
|
||||||
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
|
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
.path(mPath);
|
.path(mPath);
|
||||||
|
@ -93,7 +90,7 @@ public abstract class ApiRequest {
|
||||||
/**
|
/**
|
||||||
* Opens the connection, then returns success status and response string.
|
* Opens the connection, then returns success status and response string.
|
||||||
*/
|
*/
|
||||||
protected void connect(int requestMethod, Uri uri, @Nullable String requestBody,
|
void connect(int requestMethod, Uri uri, @Nullable String requestBody,
|
||||||
@Nullable OnSuccessListener listener, @Nullable OnErrorListener errorListener) {
|
@Nullable OnSuccessListener listener, @Nullable OnErrorListener errorListener) {
|
||||||
StringRequest request = new StringRequest(requestMethod, uri.toString(), reply -> {
|
StringRequest request = new StringRequest(requestMethod, uri.toString(), reply -> {
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
|
@ -125,7 +122,7 @@ public abstract class ApiRequest {
|
||||||
/**
|
/**
|
||||||
* Opens the connection, then returns success status and response bitmap.
|
* Opens the connection, then returns success status and response bitmap.
|
||||||
*/
|
*/
|
||||||
protected void makeImageRequest(Uri uri, @Nullable OnImageSuccessListener imageListener,
|
void makeImageRequest(Uri uri, @Nullable OnImageSuccessListener imageListener,
|
||||||
@Nullable OnErrorListener errorListener) {
|
@Nullable OnErrorListener errorListener) {
|
||||||
ImageRequest imageRequest = new ImageRequest(uri.toString(), bitmap -> {
|
ImageRequest imageRequest = new ImageRequest(uri.toString(), bitmap -> {
|
||||||
if (imageListener != null) {
|
if (imageListener != null) {
|
||||||
|
@ -158,13 +155,7 @@ public abstract class ApiRequest {
|
||||||
@Override
|
@Override
|
||||||
protected HttpURLConnection createConnection(URL url) throws IOException {
|
protected HttpURLConnection createConnection(URL url) throws IOException {
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
|
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
|
||||||
connection.setHostnameVerifier(new HostnameVerifier() {
|
connection.setHostnameVerifier((hostname, session) -> true);
|
||||||
@SuppressLint("BadHostnameVerifier")
|
|
||||||
@Override
|
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@ public class AppConfigReceiver extends BroadcastReceiver {
|
||||||
/**
|
/**
|
||||||
* Start the Syncthing-Service
|
* Start the Syncthing-Service
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_START = "com.nutomic.syncthingandroid.action.START";
|
private static final String ACTION_START = "com.nutomic.syncthingandroid.action.START";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the Syncthing-Service
|
* Stop the Syncthing-Service
|
||||||
* If alwaysRunInBackground is enabled the service must not be stopped. Instead a
|
* If alwaysRunInBackground is enabled the service must not be stopped. Instead a
|
||||||
* notification is presented to the user.
|
* notification is presented to the user.
|
||||||
*/
|
*/
|
||||||
public static final String ACTION_STOP = "com.nutomic.syncthingandroid.action.STOP";
|
private static final String ACTION_STOP = "com.nutomic.syncthingandroid.action.STOP";
|
||||||
|
|
||||||
@Inject NotificationHandler mNotificationHandler;
|
@Inject NotificationHandler mNotificationHandler;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.os.PowerManager;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import com.nutomic.syncthingandroid.service.DeviceStateHolder;
|
import com.nutomic.syncthingandroid.service.DeviceStateHolder;
|
||||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
|
||||||
|
|
||||||
public class PowerSaveModeChangedReceiver extends BroadcastReceiver {
|
public class PowerSaveModeChangedReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Constants {
|
||||||
/**
|
/**
|
||||||
* File in the config folder that contains configuration.
|
* File in the config folder that contains configuration.
|
||||||
*/
|
*/
|
||||||
static String CONFIG_FILE = "config.xml";
|
static final String CONFIG_FILE = "config.xml";
|
||||||
|
|
||||||
public static File getConfigFile(Context context) {
|
public static File getConfigFile(Context context) {
|
||||||
return new File(context.getFilesDir(), CONFIG_FILE);
|
return new File(context.getFilesDir(), CONFIG_FILE);
|
||||||
|
@ -40,7 +40,7 @@ public class Constants {
|
||||||
/**
|
/**
|
||||||
* Name of the public key file in the data directory.
|
* Name of the public key file in the data directory.
|
||||||
*/
|
*/
|
||||||
static String PUBLIC_KEY_FILE = "cert.pem";
|
static final String PUBLIC_KEY_FILE = "cert.pem";
|
||||||
|
|
||||||
static File getPublicKeyFile(Context context) {
|
static File getPublicKeyFile(Context context) {
|
||||||
return new File(context.getFilesDir(), PUBLIC_KEY_FILE);
|
return new File(context.getFilesDir(), PUBLIC_KEY_FILE);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class NotificationHandler {
|
||||||
private static final int ID_RESTART = 2;
|
private static final int ID_RESTART = 2;
|
||||||
private static final int ID_STOP_BACKGROUND_WARNING = 3;
|
private static final int ID_STOP_BACKGROUND_WARNING = 3;
|
||||||
private static final int ID_CRASH = 9;
|
private static final int ID_CRASH = 9;
|
||||||
public static final String CHANNEL_PERSISTENT = "01_syncthing_persistent";
|
private static final String CHANNEL_PERSISTENT = "01_syncthing_persistent";
|
||||||
private static final String CHANNEL_INFO = "02_syncthing_notifications";
|
private static final String CHANNEL_INFO = "02_syncthing_notifications";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
|
@ -471,7 +471,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
/**
|
/**
|
||||||
* Normalizes a given device ID.
|
* Normalizes a given device ID.
|
||||||
*/
|
*/
|
||||||
public void normalizeDeviceId(String id, OnResultListener1<String> listener,
|
private void normalizeDeviceId(String id, OnResultListener1<String> listener,
|
||||||
OnResultListener1<String> errorListener) {
|
OnResultListener1<String> errorListener) {
|
||||||
new GetRequest(mContext, mUrl, GetRequest.URI_DEVICEID, mApiKey,
|
new GetRequest(mContext, mUrl, GetRequest.URI_DEVICEID, mApiKey,
|
||||||
ImmutableMap.of("id", id), result -> {
|
ImmutableMap.of("id", id), result -> {
|
||||||
|
|
|
@ -355,7 +355,7 @@ public class SyncthingRunnable implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, String> buildEnvironment() {
|
private HashMap<String, String> buildEnvironment() {
|
||||||
HashMap<String, String> targetEnv = new HashMap<String, String>();
|
HashMap<String, String> targetEnv = new HashMap<>();
|
||||||
// Set home directory to data folder for web GUI folder picker.
|
// Set home directory to data folder for web GUI folder picker.
|
||||||
targetEnv.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath());
|
targetEnv.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||||
targetEnv.put("STTRACE", mPreferences.getString("sttrace", ""));
|
targetEnv.put("STTRACE", mPreferences.getString("sttrace", ""));
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.nutomic.syncthingandroid.R;
|
import com.nutomic.syncthingandroid.R;
|
||||||
|
|
|
@ -8,10 +8,9 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
|
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
|
||||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
|
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
|
||||||
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
Loading…
Reference in a new issue