1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Update dependencies, clean code

This commit is contained in:
Felix Ableitner 2017-12-05 20:53:33 +09:00
parent 0350ff5f40
commit 40270f4da4
14 changed files with 36 additions and 55 deletions

View file

@ -1,22 +1,21 @@
apply plugin: 'com.android.application'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.github.triplet.play'
apply plugin: 'me.tatarka.retrolambda'
dependencies {
compile 'eu.chainfire:libsuperuser:1.0.0.201704021214'
compile 'com.android.support:design:27.0.1'
compile 'com.google.zxing:android-integration:3.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'org.mindrot:jbcrypt:0.4'
compile 'com.google.guava:guava:20.0'
compile 'com.annimon:stream:1.1.9'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.google.dagger:dagger:2.13"
implementation 'eu.chainfire:libsuperuser:1.0.0.201704021214'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.zxing:android-integration:3.3.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'org.mindrot:jbcrypt:0.4'
implementation 'com.google.guava:guava:20.0'
implementation 'com.annimon:stream:1.1.9'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.google.dagger:dagger:2.13"
annotationProcessor "com.google.dagger:dagger-compiler:2.13"
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestCompile 'com.android.support:support-annotations:27.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support:support-annotations:27.0.2'
}
android {

View file

@ -16,7 +16,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -35,16 +34,12 @@ import com.nutomic.syncthingandroid.SyncthingApp;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.util.Util;
import org.w3c.dom.Text;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import javax.inject.Inject;
/**
* 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 =
"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";
public static final String EXTRA_RESULT_DIRECTORY =

View file

@ -274,9 +274,9 @@ public class ShareActivity extends StateDialogActivity
private class CopyFilesTask extends AsyncTask<Void, Void, Boolean> {
private ProgressDialog mProgress;
private Map<Uri, String> mFiles;
private Folder mFolder;
private File mDirectory;
private final Map<Uri, String> mFiles;
private final Folder mFolder;
private final File mDirectory;
private int mCopied = 0, mIgnored = 0;
CopyFilesTask(Map<Uri, String> files, Folder folder, File directory) {

View file

@ -127,9 +127,8 @@ public abstract class StateDialogActivity extends SyncthingActivity {
return;
binding.loadingSlowMessage.setVisibility(View.VISIBLE);
binding.viewLogs.setOnClickListener(v -> {
startActivity(new Intent(this, LogActivity.class));
});
binding.viewLogs.setOnClickListener(v ->
startActivity(new Intent(this, LogActivity.class)));
}, SLOW_LOADING_TIME);
}
}

View file

@ -83,7 +83,7 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
/**
* Used for Fragments to use the Activity's service connection.
*/
public void registerOnServiceConnectedListener(OnServiceConnectedListener listener) {
void registerOnServiceConnectedListener(OnServiceConnectedListener listener) {
if (mSyncthingService != null) {
listener.onServiceConnected();
} else {
@ -94,7 +94,7 @@ public abstract class SyncthingActivity extends AppCompatActivity implements Ser
/**
* Returns service object (or null if not bound).
*/
public SyncthingService getService() {
SyncthingService getService() {
return mSyncthingService;
}

View file

@ -1,7 +1,6 @@
package com.nutomic.syncthingandroid.http;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
@ -30,10 +29,8 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
@ -73,14 +70,14 @@ public abstract class ApiRequest {
private final String mPath;
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;
mUrl = url;
mPath = path;
mApiKey = apiKey;
}
protected Uri buildUri(Map<String, String> params) {
Uri buildUri(Map<String, String> params) {
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
.buildUpon()
.path(mPath);
@ -93,8 +90,8 @@ public abstract class ApiRequest {
/**
* Opens the connection, then returns success status and response string.
*/
protected void connect(int requestMethod, Uri uri, @Nullable String requestBody,
@Nullable OnSuccessListener listener, @Nullable OnErrorListener errorListener) {
void connect(int requestMethod, Uri uri, @Nullable String requestBody,
@Nullable OnSuccessListener listener, @Nullable OnErrorListener errorListener) {
StringRequest request = new StringRequest(requestMethod, uri.toString(), reply -> {
if (listener != null)
listener.onSuccess(reply);
@ -125,8 +122,8 @@ public abstract class ApiRequest {
/**
* Opens the connection, then returns success status and response bitmap.
*/
protected void makeImageRequest(Uri uri, @Nullable OnImageSuccessListener imageListener,
@Nullable OnErrorListener errorListener) {
void makeImageRequest(Uri uri, @Nullable OnImageSuccessListener imageListener,
@Nullable OnErrorListener errorListener) {
ImageRequest imageRequest = new ImageRequest(uri.toString(), bitmap -> {
if (imageListener != null) {
imageListener.onImageSuccess(bitmap);
@ -158,13 +155,7 @@ public abstract class ApiRequest {
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpsURLConnection connection = (HttpsURLConnection) super.createConnection(url);
connection.setHostnameVerifier(new HostnameVerifier() {
@SuppressLint("BadHostnameVerifier")
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
connection.setHostnameVerifier((hostname, session) -> true);
return connection;
}
}

View file

@ -19,14 +19,14 @@ public class AppConfigReceiver extends BroadcastReceiver {
/**
* 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
* If alwaysRunInBackground is enabled the service must not be stopped. Instead a
* 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;

View file

@ -8,7 +8,6 @@ import android.os.PowerManager;
import android.support.v4.content.LocalBroadcastManager;
import com.nutomic.syncthingandroid.service.DeviceStateHolder;
import com.nutomic.syncthingandroid.service.SyncthingService;
public class PowerSaveModeChangedReceiver extends BroadcastReceiver {

View file

@ -31,7 +31,7 @@ public class Constants {
/**
* 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) {
return new File(context.getFilesDir(), CONFIG_FILE);
@ -40,7 +40,7 @@ public class Constants {
/**
* 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) {
return new File(context.getFilesDir(), PUBLIC_KEY_FILE);

View file

@ -25,7 +25,7 @@ public class NotificationHandler {
private static final int ID_RESTART = 2;
private static final int ID_STOP_BACKGROUND_WARNING = 3;
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 final Context mContext;

View file

@ -471,8 +471,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
/**
* Normalizes a given device ID.
*/
public void normalizeDeviceId(String id, OnResultListener1<String> listener,
OnResultListener1<String> errorListener) {
private void normalizeDeviceId(String id, OnResultListener1<String> listener,
OnResultListener1<String> errorListener) {
new GetRequest(mContext, mUrl, GetRequest.URI_DEVICEID, mApiKey,
ImmutableMap.of("id", id), result -> {
JsonObject json = new JsonParser().parse(result).getAsJsonObject();

View file

@ -355,7 +355,7 @@ public class SyncthingRunnable implements Runnable {
}
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.
targetEnv.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath());
targetEnv.put("STTRACE", mPreferences.getString("sttrace", ""));

View file

@ -9,7 +9,6 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.nutomic.syncthingandroid.R;

View file

@ -8,10 +8,9 @@ buildscript {
}
}
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.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
// in the individual module build.gradle files