1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 04:41:16 +00:00

Fixed various lint issues

This commit is contained in:
Felix Ableitner 2016-09-21 12:34:19 +09:00
parent 1cce70986b
commit d8a05ed392
67 changed files with 246 additions and 485 deletions

View file

@ -47,6 +47,10 @@ android {
testInstrumentationRunner 'android.test.InstrumentationTestRunner'
testHandleProfiling true
testFunctionalTest true
jackOptions {
enabled true
}
}
// Without this parameter, all builds fail with error:
// Execution failed for task ':mergeArmeabiDebugResources'.
@ -99,6 +103,10 @@ android {
versionCode Integer.parseInt("0" + defaultConfig.versionCode)
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
task buildNative(type: Exec) {

View file

@ -15,8 +15,8 @@ import java.util.List;
*/
public class MockContext extends ContextWrapper {
private ArrayList<Intent> mReceivedIntents = new ArrayList<>();
private ArrayList<Intent> mStopServiceIntents = new ArrayList<>();
private final ArrayList<Intent> mReceivedIntents = new ArrayList<>();
private final ArrayList<Intent> mStopServiceIntents = new ArrayList<>();
/**
* Use the actual context for calls that aren't easily mocked. May be null if those

View file

@ -3,6 +3,7 @@ package com.nutomic.syncthingandroid.test;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import com.nutomic.syncthingandroid.syncthing.RestApi;
import java.util.ArrayList;
@ -65,7 +66,7 @@ public class MockRestApi extends RestApi {
}
@Override
public void editDevice(Device device, Activity activity, OnDeviceIdNormalizedListener listener) {
public void editDevice(@NonNull Device device, Activity activity, OnDeviceIdNormalizedListener listener) {
throw new UnsupportedOperationException();
}

View file

@ -10,7 +10,7 @@ import java.util.LinkedList;
public class MockSyncthingService extends SyncthingService {
private LinkedList<OnApiChangeListener> mOnApiChangedListeners = new LinkedList<>();
private final LinkedList<OnApiChangeListener> mOnApiChangedListeners = new LinkedList<>();
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

View file

@ -10,7 +10,7 @@ import com.nutomic.syncthingandroid.test.MockSyncthingService;
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
private MockSyncthingService mService = new MockSyncthingService();
private final MockSyncthingService mService = new MockSyncthingService();
public MainActivityTest() {
super(MainActivity.class);

View file

@ -3,7 +3,6 @@ package com.nutomic.syncthingandroid.test.syncthing;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.BatteryReceiver;
import com.nutomic.syncthingandroid.syncthing.DeviceStateHolder;

View file

@ -3,7 +3,6 @@ package com.nutomic.syncthingandroid.test.syncthing;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.BootReceiver;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;

View file

@ -3,7 +3,6 @@ package com.nutomic.syncthingandroid.test.syncthing;
import android.content.Intent;
import android.os.BatteryManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.DeviceStateHolder;
import com.nutomic.syncthingandroid.test.MockContext;

View file

@ -2,7 +2,6 @@ package com.nutomic.syncthingandroid.test.syncthing;
import android.net.Uri;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.GetTask;
import com.nutomic.syncthingandroid.syncthing.RestApi;

View file

@ -4,7 +4,6 @@ import android.content.Intent;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.DeviceStateHolder;
import com.nutomic.syncthingandroid.syncthing.NetworkReceiver;

View file

@ -1,8 +1,6 @@
package com.nutomic.syncthingandroid.test.syncthing;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import com.nutomic.syncthingandroid.syncthing.PollWebGuiAvailableTask;
import com.nutomic.syncthingandroid.syncthing.RestApi;
@ -38,12 +36,7 @@ public class RestApiTest extends AndroidTestCase {
}
}.execute(config.getWebGuiUrl());
mApi = new RestApi(getContext(), config.getWebGuiUrl(), config.getApiKey(),
new RestApi.OnApiAvailableListener() {
@Override
public void onApiAvailable() {
latch.countDown();
}
}, null);
latch::countDown, null);
latch.await(1, TimeUnit.SECONDS);
}

View file

@ -1,7 +1,6 @@
package com.nutomic.syncthingandroid.test.syncthing;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.nutomic.syncthingandroid.syncthing.SyncthingRunnable;
import com.nutomic.syncthingandroid.test.MockContext;

View file

@ -1,7 +1,6 @@
package com.nutomic.syncthingandroid.test.syncthing;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import com.nutomic.syncthingandroid.syncthing.SyncthingServiceBinder;

View file

@ -1,16 +1,10 @@
package com.nutomic.syncthingandroid.test.util;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import com.nutomic.syncthingandroid.test.MockContext;
import com.nutomic.syncthingandroid.util.ConfigXml;
import java.io.File;
import java.io.IOException;
public class ConfigXmlTest extends AndroidTestCase {
private MockContext mContext;

View file

@ -1,7 +1,6 @@
package com.nutomic.syncthingandroid.test.util;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import com.nutomic.syncthingandroid.syncthing.RestApi;
import com.nutomic.syncthingandroid.test.MockContext;

View file

@ -17,8 +17,6 @@ import com.nutomic.syncthingandroid.R;
public class FirstStartActivity extends Activity implements Button.OnClickListener {
private static final String TAG = "FirstStartActivity";
private static final int REQUEST_WRITE_STORAGE = 142;
private SharedPreferences mPreferences;

View file

@ -5,7 +5,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
@ -31,7 +30,6 @@ import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;
/**
@ -90,13 +88,10 @@ public class FolderPickerActivity extends SyncthingActivity
@SuppressLint("NewApi")
private void populateRoots() {
// Use own comparator to handle null values.
TreeSet<File> roots = new TreeSet<>(new Comparator<File>() {
@Override
public int compare(File lhs, File rhs) {
if (lhs == null | rhs == null)
return 0;
return lhs.compareTo(rhs);
}
TreeSet<File> roots = new TreeSet<>((lhs, rhs) -> {
if (lhs == null | rhs == null)
return 0;
return lhs.compareTo(rhs);
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@ -152,22 +147,12 @@ public class FolderPickerActivity extends SyncthingActivity
.setTitle(R.string.create_folder)
.setView(et)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
createFolder(et.getText().toString());
}
}
(dialogInterface, i) -> createFolder(et.getText().toString())
)
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
}
});
dialog.setOnShowListener(dialogInterface -> ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT));
dialog.show();
return true;
case R.id.select:
@ -207,14 +192,12 @@ public class FolderPickerActivity extends SyncthingActivity
if (contents == null)
contents = new File[]{};
Arrays.sort(contents, new Comparator<File>() {
public int compare(File f1, File f2) {
if (f1.isDirectory() && f2.isFile())
return -1;
if (f1.isFile() && f2.isDirectory())
return 1;
return f1.getName().compareTo(f2.getName());
}
Arrays.sort(contents, (f1, f2) -> {
if (f1.isDirectory() && f2.isFile())
return -1;
if (f1.isFile() && f2.isDirectory())
return 1;
return f1.getName().compareTo(f2.getName());
});
for (File f : contents) {

View file

@ -91,18 +91,13 @@ public class LogActivity extends SyncthingActivity {
}
private void scrollToBottom() {
mScrollView.post(new Runnable() {
@Override
public void run() {
mScrollView.scrollTo(0, mLog.getBottom());
}
});
mScrollView.post(() -> mScrollView.scrollTo(0, mLog.getBottom()));
}
private void updateLog() {
if (mFetchLogTask != null)
mFetchLogTask.cancel(true);
mLog.setText("Retrieving logs...");
mLog.setText(R.string.retrieving_logs);
mFetchLogTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
@ -137,7 +132,7 @@ public class LogActivity extends SyncthingActivity {
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream(), "UTF-8"), 8192);
StringBuilder log = new StringBuilder();
String line = "";
String line;
String sep = System.getProperty("line.separator");
while ((line = bufferedReader.readLine()) != null) {
log.append(line);

View file

@ -286,30 +286,17 @@ public class MainActivity extends SyncthingActivity
.setTitle(R.string.syncthing_disabled_title)
.setMessage(R.string.syncthing_disabled_message)
.setPositiveButton(R.string.syncthing_disabled_change_settings,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
Intent intent = new Intent(MainActivity.this, SettingsActivity.class)
.setAction(SettingsActivity.ACTION_APP_SETTINGS);
startActivity(intent);
}
(dialogInterface, i) -> {
finish();
Intent intent = new Intent(MainActivity.this, SettingsActivity.class)
.setAction(SettingsActivity.ACTION_APP_SETTINGS);
startActivity(intent);
}
)
.setNegativeButton(R.string.exit,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
}
(dialogInterface, i) -> finish()
)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
finish();
}
})
.setOnCancelListener(dialogInterface -> finish())
.show();
mDisabledDialog.setCanceledOnTouchOutside(false);
}
@ -402,43 +389,37 @@ public class MainActivity extends SyncthingActivity
* Displays dialog asking user to accept/deny usage reporting.
*/
private void showUsageReportingDialog() {
final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_ACCEPTED,
MainActivity.this);
break;
case DialogInterface.BUTTON_NEGATIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_DENIED,
MainActivity.this);
break;
case DialogInterface.BUTTON_NEUTRAL:
Uri uri = Uri.parse("https://data.syncthing.net");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
}
final DialogInterface.OnClickListener listener = (dialog, which) -> {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_ACCEPTED,
MainActivity.this);
break;
case DialogInterface.BUTTON_NEGATIVE:
getApi().setUsageReportAccepted(RestApi.USAGE_REPORTING_DENIED,
MainActivity.this);
break;
case DialogInterface.BUTTON_NEUTRAL:
Uri uri = Uri.parse("https://data.syncthing.net");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
break;
}
};
getApi().getUsageReport(new RestApi.OnReceiveUsageReportListener() {
@Override
public void onReceiveUsageReport(String report) {
@SuppressLint("InflateParams")
View v = LayoutInflater.from(MainActivity.this)
.inflate(R.layout.dialog_usage_reporting, null);
TextView tv = (TextView) v.findViewById(R.id.example);
tv.setText(report);
new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.usage_reporting_dialog_title)
.setView(v)
.setPositiveButton(R.string.yes, listener)
.setNegativeButton(R.string.no, listener)
.setNeutralButton(R.string.open_website, listener)
.show();
}
getApi().getUsageReport(report -> {
@SuppressLint("InflateParams")
View v = LayoutInflater.from(MainActivity.this)
.inflate(R.layout.dialog_usage_reporting, null);
TextView tv = (TextView) v.findViewById(R.id.example);
tv.setText(report);
new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.usage_reporting_dialog_title)
.setView(v)
.setPositiveButton(R.string.yes, listener)
.setNegativeButton(R.string.no, listener)
.setNeutralButton(R.string.open_website, listener)
.show();
});
}

View file

@ -5,7 +5,6 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
@ -30,26 +29,17 @@ public class RestartActivity extends SyncthingActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.restart_title)
.setPositiveButton(R.string.restart_now, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getService().getApi().updateConfig();
finish();
}
.setPositiveButton(R.string.restart_now, (dialogInterface, i) -> {
getService().getApi().updateConfig();
finish();
})
.setNegativeButton(R.string.restart_later, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
createRestartNotification();
finish();
}
.setNegativeButton(R.string.restart_later, (dialogInterface, i) -> {
createRestartNotification();
finish();
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
createRestartNotification();
finish();
}
.setOnCancelListener(dialog -> {
createRestartNotification();
finish();
})
.show();
}

View file

@ -2,7 +2,6 @@ package com.nutomic.syncthingandroid.activities;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import com.nutomic.syncthingandroid.R;
@ -96,12 +95,7 @@ public class SettingsActivity extends SyncthingActivity {
if (getIsCreate() && (mFragment instanceof DeviceFragment || mFragment instanceof FolderFragment)) {
new AlertDialog.Builder(this)
.setMessage(R.string.dialog_discard_changes)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setPositiveButton(android.R.string.ok, (dialog, which) -> finish())
.setNegativeButton(android.R.string.cancel, null)
.show();
}

View file

@ -20,7 +20,7 @@ public abstract class SyncthingActivity extends ToolbarBindingActivity implement
private SyncthingService mSyncthingService;
private LinkedList<OnServiceConnectedListener> mServiceConnectedListeners = new LinkedList<>();
private final LinkedList<OnServiceConnectedListener> mServiceConnectedListeners = new LinkedList<>();
/**
* To be used for Fragments.

View file

@ -83,7 +83,7 @@ public class DeviceFragment extends Fragment implements
private boolean mDeviceNeedsToUpdate;
private DialogInterface.OnClickListener mCompressionEntrySelectedListener = new DialogInterface.OnClickListener() {
private final DialogInterface.OnClickListener mCompressionEntrySelectedListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
@ -99,7 +99,7 @@ public class DeviceFragment extends Fragment implements
}
};
private TextWatcher mIdTextWatcher = new TextWatcherAdapter() {
private final TextWatcher mIdTextWatcher = new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
if (!s.toString().equals(mDevice.deviceID)) {
@ -110,7 +110,7 @@ public class DeviceFragment extends Fragment implements
}
};
private TextWatcher mNameTextWatcher = new TextWatcherAdapter() {
private final TextWatcher mNameTextWatcher = new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
if (!s.toString().equals(mDevice.name)) {
@ -121,7 +121,7 @@ public class DeviceFragment extends Fragment implements
}
};
private TextWatcher mAddressesTextWatcher = new TextWatcherAdapter() {
private final TextWatcher mAddressesTextWatcher = new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
if (!s.toString().equals(displayableAddresses())) {
@ -132,7 +132,7 @@ public class DeviceFragment extends Fragment implements
}
};
private CompoundButton.OnCheckedChangeListener mIntroducerCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
private final CompoundButton.OnCheckedChangeListener mIntroducerCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mDevice.introducer != isChecked) {
@ -262,10 +262,10 @@ public class DeviceFragment extends Fragment implements
if (!mIsCreateMode) {
List<RestApi.Device> devices = mSyncthingService.getApi().getDevices(false);
mDevice = null;
for (int i = 0; i < devices.size(); i++) {
if (devices.get(i).deviceID.equals(
for (RestApi.Device device : devices) {
if (device.deviceID.equals(
getActivity().getIntent().getStringExtra(EXTRA_DEVICE_ID))) {
mDevice = devices.get(i);
mDevice = device;
break;
}
}
@ -327,12 +327,7 @@ public class DeviceFragment extends Fragment implements
case R.id.remove:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.remove_device_confirm)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mSyncthingService.getApi().deleteDevice(mDevice, getActivity());
}
})
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> mSyncthingService.getApi().deleteDevice(mDevice, getActivity()))
.setNegativeButton(android.R.string.no, null)
.show();
return true;

View file

@ -29,12 +29,7 @@ import java.util.TimerTask;
public class DeviceListFragment extends ListFragment implements SyncthingService.OnApiChangeListener,
ListView.OnItemClickListener {
private final static Comparator<RestApi.Device> DEVICES_COMPARATOR = new Comparator<RestApi.Device>() {
@Override
public int compare(RestApi.Device lhs, RestApi.Device rhs) {
return lhs.name.compareTo(rhs.name);
}
};
private final static Comparator<RestApi.Device> DEVICES_COMPARATOR = (lhs, rhs) -> lhs.name.compareTo(rhs.name);
private DevicesAdapter mAdapter;
@ -47,12 +42,7 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
mTimer.schedule(new TimerTask() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
updateList();
}
});
getActivity().runOnUiThread(DeviceListFragment.this::updateList);
}
}, 0, SyncthingService.GUI_UPDATE_INTERVAL);

View file

@ -1,7 +1,6 @@
package com.nutomic.syncthingandroid.fragments;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -156,12 +155,7 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
return;
mDeviceId.setText(info.myID);
mDeviceId.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.getApi().copyDeviceId(mDeviceId.getText().toString());
}
});
mDeviceId.setOnClickListener(v -> mActivity.getApi().copyDeviceId(mDeviceId.getText().toString()));
mCpuUsage.setText(new DecimalFormat("0.00").format(info.cpuPercent) + "%");
mRamUsage.setText(RestApi.readableFileSize(mActivity, info.sys));
mAnnounceServer.setText(Integer.toString(info.extAnnounceConnected) + "/" +
@ -217,13 +211,8 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
mActivity.closeDrawer();
new AlertDialog.Builder(getContext())
.setMessage(R.string.dialog_confirm_restart)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getContext().startService(new Intent(getContext(), SyncthingService.class)
.setAction(SyncthingService.ACTION_RESTART));
}
})
.setPositiveButton(android.R.string.yes, (dialogInterface, i1) -> getContext().startService(new Intent(getContext(), SyncthingService.class)
.setAction(SyncthingService.ACTION_RESTART)))
.setNegativeButton(android.R.string.no, null)
.show();
break;

View file

@ -3,7 +3,6 @@ package com.nutomic.syncthingandroid.fragments;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -71,9 +70,9 @@ public class FolderFragment extends Fragment
private boolean mIsCreateMode;
private boolean mFolderNeedsToUpdate;
private KeepVersionsDialogFragment mKeepVersionsDialogFragment = new KeepVersionsDialogFragment();
private final KeepVersionsDialogFragment mKeepVersionsDialogFragment = new KeepVersionsDialogFragment();
private TextWatcher mTextWatcher = new TextWatcherAdapter() {
private final TextWatcher mTextWatcher = new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
mFolder.label = mLabelView.getText().toString();
@ -83,7 +82,7 @@ public class FolderFragment extends Fragment
}
};
private CompoundButton.OnCheckedChangeListener mCheckedListener =
private final CompoundButton.OnCheckedChangeListener mCheckedListener =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
@ -105,7 +104,7 @@ public class FolderFragment extends Fragment
}
};
private KeepVersionsDialogFragment.OnValueChangeListener mOnValueChangeListener =
private final KeepVersionsDialogFragment.OnValueChangeListener mOnValueChangeListener =
new KeepVersionsDialogFragment.OnValueChangeListener() {
@Override
public void onValueChange(int intValue) {
@ -121,7 +120,7 @@ public class FolderFragment extends Fragment
}
};
private View.OnClickListener mPathViewClickListener = new View.OnClickListener() {
private final View.OnClickListener mPathViewClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FolderPickerActivity.class);
@ -197,12 +196,7 @@ public class FolderFragment extends Fragment
mDevicesContainer = (ViewGroup) view.findViewById(R.id.devicesContainer);
mPathView.setOnClickListener(mPathViewClickListener);
view.findViewById(R.id.versioningContainer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mKeepVersionsDialogFragment.show(getFragmentManager(), KEEP_VERSIONS_DIALOG_TAG);
}
});
view.findViewById(R.id.versioningContainer).setOnClickListener(v -> mKeepVersionsDialogFragment.show(getFragmentManager(), KEEP_VERSIONS_DIALOG_TAG));
if (mIsCreateMode) {
// Open keyboard on label view in edit mode.
@ -326,12 +320,7 @@ public class FolderFragment extends Fragment
case R.id.remove:
new AlertDialog.Builder(getActivity())
.setMessage(R.string.remove_folder_confirm)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mSyncthingService.getApi().deleteFolder(mFolder, getActivity());
}
})
.setPositiveButton(android.R.string.yes, (dialogInterface, i) -> mSyncthingService.getApi().deleteFolder(mFolder, getActivity()))
.setNegativeButton(android.R.string.no, null)
.show();
return true;
@ -355,7 +344,7 @@ public class FolderFragment extends Fragment
private void initFolder() {
mFolder = new RestApi.Folder();
mFolder.id = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_ID);
mFolder.label = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_LABEL);;
mFolder.label = getActivity().getIntent().getStringExtra(EXTRA_FOLDER_LABEL);
mFolder.path = "";
mFolder.rescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes)
mFolder.deviceIds = new ArrayList<>();

View file

@ -32,14 +32,11 @@ public class FolderListFragment extends ListFragment implements SyncthingService
/**
* Compares folders by labels, uses the folder ID as fallback if the label is empty
*/
private final static Comparator<RestApi.Folder> FOLDERS_COMPARATOR = new Comparator<RestApi.Folder>() {
@Override
public int compare(RestApi.Folder lhs, RestApi.Folder rhs) {
String lhsLabel = lhs.label != null && !lhs.label.isEmpty() ? lhs.label : lhs.id;
String rhsLabel = rhs.label != null && !rhs.label.isEmpty() ? rhs.label : rhs.id;
private final static Comparator<RestApi.Folder> FOLDERS_COMPARATOR = (lhs, rhs) -> {
String lhsLabel = lhs.label != null && !lhs.label.isEmpty() ? lhs.label : lhs.id;
String rhsLabel = rhs.label != null && !rhs.label.isEmpty() ? rhs.label : rhs.id;
return lhsLabel.compareTo(rhsLabel);
}
return lhsLabel.compareTo(rhsLabel);
};
private FoldersAdapter mAdapter;
@ -53,12 +50,7 @@ public class FolderListFragment extends ListFragment implements SyncthingService
mTimer.schedule(new TimerTask() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
updateList();
}
});
getActivity().runOnUiThread(FolderListFragment.this::updateList);
}
}, 0, SyncthingService.GUI_UPDATE_INTERVAL);

View file

@ -1,9 +1,7 @@
package com.nutomic.syncthingandroid.fragments;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
@ -11,11 +9,8 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.support.v4.app.NavUtils;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
@ -27,7 +22,6 @@ import com.nutomic.syncthingandroid.syncthing.RestApi;
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import eu.chainfire.libsuperuser.Shell;
@ -284,14 +278,6 @@ public class SettingsFragment extends PreferenceFragment
return true;
}
private String formatWifiNameList(Set<String> ssids) {
Set<String> formatted = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (String ssid : ssids) {
formatted.add(ssid.replaceFirst("^\"", "").replaceFirst("\"$", ""));
}
return TextUtils.join(", ", formatted);
}
/**
* Changes the owner of syncthing files so they can be accessed without root.
*/
@ -324,15 +310,12 @@ public class SettingsFragment extends PreferenceFragment
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_export)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSyncthingService.exportConfig();
Toast.makeText(getActivity(),
getString(R.string.config_export_successful,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
}
})
(dialog, which) -> {
mSyncthingService.exportConfig();
Toast.makeText(getActivity(),
getString(R.string.config_export_successful,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
@ -340,22 +323,19 @@ public class SettingsFragment extends PreferenceFragment
new AlertDialog.Builder(getActivity())
.setMessage(R.string.dialog_confirm_import)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mSyncthingService.importConfig()) {
Toast.makeText(getActivity(),
getString(R.string.config_imported_successful),
Toast.LENGTH_SHORT).show();
// No need to restart, as we shutdown to import the config, and
// then have to start Syncthing again.
} else {
Toast.makeText(getActivity(),
getString(R.string.config_import_failed,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
}
}
})
(dialog, which) -> {
if (mSyncthingService.importConfig()) {
Toast.makeText(getActivity(),
getString(R.string.config_imported_successful),
Toast.LENGTH_SHORT).show();
// No need to restart, as we shutdown to import the config, and
// then have to start Syncthing again.
} else {
Toast.makeText(getActivity(),
getString(R.string.config_import_failed,
SyncthingService.EXPORT_PATH), Toast.LENGTH_LONG).show();
}
})
.setNegativeButton(android.R.string.no, null)
.show();
return true;
@ -366,17 +346,11 @@ public class SettingsFragment extends PreferenceFragment
new AlertDialog.Builder(getActivity())
.setTitle(R.string.streset_title)
.setMessage(R.string.streset_question)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
getActivity().startService(intent);
Toast.makeText(getActivity(), R.string.streset_done, Toast.LENGTH_LONG).show();
}
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
getActivity().startService(intent);
Toast.makeText(getActivity(), R.string.streset_done, Toast.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
.setNegativeButton(android.R.string.no, (dialogInterface, i) -> {
})
.show();
return true;

View file

@ -16,7 +16,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
public class KeepVersionsDialogFragment extends DialogFragment {
private OnValueChangeListener mOnValueChangeListener = OnValueChangeListener.NO_OP;
private OnValueChangeListener mOnValueChangeListener;
private NumberPicker mNumberPickerView;
@ -28,7 +28,8 @@ public class KeepVersionsDialogFragment extends DialogFragment {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mValue = mNumberPickerView.getValue();
mOnValueChangeListener.onValueChange(mValue);
if (mOnValueChangeListener != null)
mOnValueChangeListener.onValueChange(mValue);
break;
}
}
@ -47,10 +48,6 @@ public class KeepVersionsDialogFragment extends DialogFragment {
}
public void setOnValueChangeListener(OnValueChangeListener onValueChangeListener) {
if (onValueChangeListener == null) {
onValueChangeListener = OnValueChangeListener.NO_OP;
}
mOnValueChangeListener = onValueChangeListener;
}
@ -73,11 +70,6 @@ public class KeepVersionsDialogFragment extends DialogFragment {
}
public interface OnValueChangeListener {
OnValueChangeListener NO_OP = new OnValueChangeListener() {
@Override
public void onValueChange(int value) {}
};
void onValueChange(int value);
}
}

View file

@ -11,7 +11,6 @@ import android.widget.Toast;
import com.nutomic.syncthingandroid.R;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -53,7 +52,7 @@ public class WifiSsidPreference extends MultiSelectListPreference {
protected void showDialog(Bundle state) {
WifiConfiguration[] networks = loadConfiguredNetworksSorted();
if (networks != null) {
Set<String> selected = getSharedPreferences().getStringSet(getKey(), new HashSet<String>());
Set<String> selected = getSharedPreferences().getStringSet(getKey(), new HashSet<>());
// from JavaDoc: Note that you must not modify the set instance returned by this call.
// therefore required to make a defensive copy of the elements
selected = new HashSet<>(selected);
@ -114,14 +113,11 @@ public class WifiSsidPreference extends MultiSelectListPreference {
// if WiFi is turned off, getConfiguredNetworks returns null on many devices
if (configuredNetworks != null) {
WifiConfiguration[] result = configuredNetworks.toArray(new WifiConfiguration[configuredNetworks.size()]);
Arrays.sort(result, new Comparator<WifiConfiguration>() {
@Override
public int compare(WifiConfiguration lhs, WifiConfiguration rhs) {
// See #620: There may be null-SSIDs
String l = lhs.SSID != null ? lhs.SSID : "";
String r = rhs.SSID != null ? rhs.SSID : "";
return l.compareToIgnoreCase(r);
}
Arrays.sort(result, (lhs, rhs) -> {
// See #620: There may be null-SSIDs
String l = lhs.SSID != null ? lhs.SSID : "";
String r = rhs.SSID != null ? rhs.SSID : "";
return l.compareToIgnoreCase(r);
});
return result;
}

View file

@ -40,7 +40,7 @@ public class DeviceStateHolder extends BroadcastReceiver {
public static final String EXTRA_IS_CHARGING =
"com.nutomic.syncthingandroid.syncthing.DeviceStateHolder.IS_CHARGING";
private Context mContext;
private final Context mContext;
private boolean mIsWifiConnected = false;
@ -132,7 +132,7 @@ public class DeviceStateHolder extends BroadcastReceiver {
boolean wifiConnected = isWifiConnected();
if (wifiConnected) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
Set<String> ssids = sp.getStringSet(SyncthingService.PREF_SYNC_ONLY_WIFI_SSIDS, new HashSet<String>());
Set<String> ssids = sp.getStringSet(SyncthingService.PREF_SYNC_ONLY_WIFI_SSIDS, new HashSet<>());
if (ssids.isEmpty()) {
Log.d(TAG, "All SSIDs allowed for syncing");
return true;

View file

@ -70,7 +70,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
// If that's the case we've to start at zero because syncthing was restarted.
mApi.getEvents(0, 1, new RestApi.OnReceiveEventListener() {
@Override
public void onEvent(long id, String eventType, JSONObject data) throws JSONException {
public void onEvent(String eventType, JSONObject data) throws JSONException {
}
@ -89,7 +89,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
* Performs the actual event handling.
*/
@Override
public void onEvent(long id, String type, JSONObject data) throws JSONException {
public void onEvent(String type, JSONObject data) throws JSONException {
switch (type) {
case "DeviceRejected":
String deviceId = data.getString("device");
@ -159,7 +159,7 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
//noinspection CommitPrefEdits
sp.edit().putLong(PREF_LAST_SYNC_ID, mLastEventId).commit();
sp.edit().putLong(PREF_LAST_SYNC_ID, mLastEventId).apply();
}
synchronized (mMainThreadHandler) {

View file

@ -38,7 +38,7 @@ public class GetTask extends AsyncTask<String, Void, String> {
public static final String URI_REPORT = "/rest/svc/report";
public static final String URI_EVENTS = "/rest/events";
private String mHttpsCertPath;
private final String mHttpsCertPath;
public GetTask(String httpsCertPath) {
mHttpsCertPath = httpsCertPath;

View file

@ -28,14 +28,14 @@ public abstract class PollWebGuiAvailableTask extends AsyncTask<String, Void, Vo
*/
private static final long WEB_GUI_POLL_INTERVAL = 100;
private String mHttpsCertPath;
private final String mHttpsCertPath;
public PollWebGuiAvailableTask(String httpsCertPath) {
mHttpsCertPath = httpsCertPath;
}
/**
* @param @url The URL of the web GUI (eg 127.0.0.1:8384).
* @param url The URL of the web GUI (eg 127.0.0.1:8384).
*/
@Override
protected Void doInBackground(String... url) {

View file

@ -22,7 +22,7 @@ public class PostConfigTask extends AsyncTask<String, Void, Boolean> {
public static final String URI_CONFIG = "/rest/system/config";
private String mHttpsCertPath;
private final String mHttpsCertPath;
public PostConfigTask(String httpsCertPath) {
mHttpsCertPath = httpsCertPath;

View file

@ -26,7 +26,7 @@ public class PostScanTask extends AsyncTask<String, Void, Void> {
public static final String URI_SCAN = "/rest/db/scan";
private String mHttpsCertPath;
private final String mHttpsCertPath;
public PostScanTask(String httpsCertPath) {
mHttpsCertPath = httpsCertPath;

View file

@ -13,7 +13,6 @@ import android.util.Log;
import android.widget.Toast;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.google.gson.annotations.SerializedName;
import com.nutomic.syncthingandroid.BuildConfig;
@ -170,7 +169,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
private String mVersion;
private String mUrl;
private final String mUrl;
private final String mApiKey;
@ -197,12 +196,12 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* Stores the latest result of {@link #getModel(String, OnReceiveModelListener)} for each folder,
* for calculating device percentage in {@link #getConnections(OnReceiveConnectionsListener)}.
*/
private HashMap<String, Model> mCachedModelInfo = new HashMap<>();
private final HashMap<String, Model> mCachedModelInfo = new HashMap<>();
/**
* Stores a hash map to resolve folders to paths for events.
*/
private final Map<String, String> mCacheFolderPathLookup = new HashMap<String, String>();
private final Map<String, String> mCacheFolderPathLookup = new HashMap<>();
public RestApi(Context context, String url, String apiKey, OnApiAvailableListener apiListener,
OnConfigChangedListener configListener) {
@ -214,14 +213,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
mOnConfigChangedListener = configListener;
}
public void setWebGuiUrl(String newUrl) {
mUrl = newUrl;
}
/**
* Number of previous calls to {@link #tryIsAvailable()}.
*/
private AtomicInteger mAvailableCount = new AtomicInteger(0);
private final AtomicInteger mAvailableCount = new AtomicInteger(0);
/**
* Number of asynchronous calls performed in {@link #onWebGuiAvailable()}.
@ -270,12 +265,9 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
}
}
}.execute(mUrl, GetTask.URI_CONFIG, mApiKey);
getSystemInfo(new OnReceiveSystemInfoListener() {
@Override
public void onReceiveSystemInfo(SystemInfo info) {
mLocalDeviceId = info.myID;
tryIsAvailable();
}
getSystemInfo(info -> {
mLocalDeviceId = info.myID;
tryIsAvailable();
});
}
@ -712,12 +704,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
* Called for each event.
*
* Events with a "folder" field in the data have an extra "folderpath" element added.
*
* @param id ID of the event. Monotonously increasing.
* @param eventType Name of the event. (See Syncthing documentation)
* @param eventType Name of the event. (See Syncthing documentation)
* @param data Contains the data fields of the event.
*/
void onEvent(long id, String eventType, JSONObject data) throws JSONException;
void onEvent(String eventType, JSONObject data) throws JSONException;
/**
* Called after all available events have been processed.
@ -816,7 +806,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
data.put("folderpath", folderPath);
}
listener.onEvent(id, type, data);
listener.onEvent(type, data);
}
listener.onDone(lastId);
@ -838,46 +828,43 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public void editDevice(@NonNull final Device device, final Activity activity,
final OnDeviceIdNormalizedListener listener) {
normalizeDeviceId(device.deviceID,
new RestApi.OnDeviceIdNormalizedListener() {
@Override
public void onDeviceIdNormalized(String normalizedId, String error) {
if (listener != null) listener.onDeviceIdNormalized(normalizedId, error);
if (normalizedId == null)
return;
(normalizedId, error) -> {
if (listener != null) listener.onDeviceIdNormalized(normalizedId, error);
if (normalizedId == null)
return;
device.deviceID = normalizedId;
// If the device already exists, just update it.
boolean create = true;
for (RestApi.Device n : getDevices(true)) {
if (n.deviceID.equals(device.deviceID)) {
create = false;
}
device.deviceID = normalizedId;
// If the device already exists, just update it.
boolean create = true;
for (Device n : getDevices(true)) {
if (n.deviceID.equals(device.deviceID)) {
create = false;
}
}
try {
JSONArray devices = mConfig.getJSONArray("devices");
JSONObject n = null;
if (create) {
n = new JSONObject();
devices.put(n);
} else {
for (int i = 0; i < devices.length(); i++) {
JSONObject json = devices.getJSONObject(i);
if (device.deviceID.equals(json.getString("deviceID"))) {
n = devices.getJSONObject(i);
break;
}
try {
JSONArray devices = mConfig.getJSONArray("devices");
JSONObject n = null;
if (create) {
n = new JSONObject();
devices.put(n);
} else {
for (int i = 0; i < devices.length(); i++) {
JSONObject json = devices.getJSONObject(i);
if (device.deviceID.equals(json.getString("deviceID"))) {
n = devices.getJSONObject(i);
break;
}
}
n.put("deviceID", device.deviceID);
n.put("name", device.name);
n.put("addresses", new JSONArray(device.addresses));
n.put("compression", device.compression);
n.put("introducer", device.introducer);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
}
n.put("deviceID", device.deviceID);
n.put("name", device.name);
n.put("addresses", new JSONArray(device.addresses));
n.put("compression", device.compression);
n.put("introducer", device.introducer);
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
}
}
);
@ -909,7 +896,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
/**
* Updates or creates the given device.
*/
public boolean editFolder(Folder folder, boolean create, Activity activity) {
public void editFolder(Folder folder, boolean create, Activity activity) {
try {
JSONArray folders = mConfig.getJSONArray("folders");
JSONObject r = null;
@ -950,11 +937,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
requireRestart(activity);
} catch (JSONException e) {
Log.w(TAG, "Failed to edit folder " + folder.id + " at " + folder.path, e);
return false;
return;
}
clearFolderCache();
return true;
}
/**

View file

@ -42,7 +42,7 @@ public class SyncthingRunnable implements Runnable {
private final Context mContext;
private String mSyncthingBinary;
private final String mSyncthingBinary;
private String[] mCommand;
@ -91,7 +91,7 @@ public class SyncthingRunnable implements Runnable {
@Override
public void run() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
int ret = 1;
int ret;
// Make sure Syncthing is executable
try {
ProcessBuilder pb = new ProcessBuilder("chmod", "500", mSyncthingBinary);
@ -313,22 +313,19 @@ public class SyncthingRunnable implements Runnable {
* @param saveLog True if the log should be stored to {@link #mErrorLog}.
*/
private Thread log(final InputStream is, final int priority, final boolean saveLog) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
Log.println(priority, TAG_NATIVE, line);
Thread t = new Thread(() -> {
try {
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
Log.println(priority, TAG_NATIVE, line);
if (saveLog)
mErrorLog += line + "\n";
}
} catch (IOException e) {
Log.w(TAG, "Failed to read Syncthing's command line output", e);
if (saveLog)
mErrorLog += line + "\n";
}
} catch (IOException e) {
Log.w(TAG, "Failed to read Syncthing's command line output", e);
}
});
t.start();

View file

@ -5,7 +5,6 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@ -32,11 +31,9 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.security.SecureRandom;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
@ -107,7 +104,7 @@ public class SyncthingService extends Service implements
private EventProcessor mEventProcessor;
private LinkedList<FolderObserver> mObservers = new LinkedList<>();
private final LinkedList<FolderObserver> mObservers = new LinkedList<>();
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
@ -347,14 +344,10 @@ public class SyncthingService extends Service implements
}
mApi = new RestApi(SyncthingService.this, urlAndKey.first, urlAndKey.second,
new RestApi.OnApiAvailableListener() {
@Override
public void onApiAvailable() {
mCurrentState = State.ACTIVE;
onApiChange();
new Thread(new Runnable() {
@Override
public void run() {
() -> {
mCurrentState = State.ACTIVE;
onApiChange();
new Thread(() -> {
for (RestApi.Folder r : mApi.getFolders()) {
try {
mObservers.add(new FolderObserver(mApi, r));
@ -368,15 +361,8 @@ public class SyncthingService extends Service implements
.show();
}
}
}
}).start();
}
}, new RestApi.OnConfigChangedListener() {
@Override
public void onConfigChanged() {
onApiChange();
}
});
}).start();
}, SyncthingService.this::onApiChange);
mEventProcessor = new EventProcessor(SyncthingService.this, mApi);
@ -472,7 +458,7 @@ public class SyncthingService extends Service implements
* The listener is called immediately with the current state, and again whenever the state
* changes. The call is always from the GUI thread.
*
* @see {@link #unregisterOnApiChangeListener}
* @see #unregisterOnApiChangeListener
*/
public void registerOnApiChangeListener(OnApiChangeListener listener) {
// Make sure we don't send an invalid state or syncthing might show a "disabled" message
@ -484,7 +470,7 @@ public class SyncthingService extends Service implements
/**
* Unregisters a previously registered listener.
*
* @see {@link #registerOnApiChangeListener}
* @see #registerOnApiChangeListener
*/
public void unregisterOnApiChangeListener(OnApiChangeListener listener) {
mOnApiChangeListeners.remove(listener);

View file

@ -63,7 +63,7 @@ public class ConfigXml {
private final Context mContext;
private File mConfigFile;
private final File mConfigFile;
private Document mConfig;

View file

@ -1,5 +1,6 @@
package com.nutomic.syncthingandroid.util;
import android.annotation.SuppressLint;
import android.util.Log;
import org.apache.http.conn.ssl.SSLSocketFactory;
@ -61,13 +62,14 @@ public class CustomX509TrustManager implements X509TrustManager {
}
}
private String mHttpsCertPath;
private final String mHttpsCertPath;
public CustomX509TrustManager(String httpsCertPath) {
mHttpsCertPath = httpsCertPath;
}
@Override
@SuppressLint("TrustAllX509TrustManager")
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}

View file

@ -6,7 +6,6 @@ import android.util.Log;
import com.nutomic.syncthingandroid.syncthing.RestApi;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
/**
@ -35,7 +34,7 @@ public class FolderObserver extends FileObserver {
public class FolderNotExistingException extends Exception {
private String mPath;
private final String mPath;
public FolderNotExistingException(String path) {
mPath = path;
@ -69,12 +68,7 @@ public class FolderObserver extends FileObserver {
if (!currentFolder.exists()) {
throw new FolderNotExistingException(currentFolder.getAbsolutePath());
}
File[] directories = currentFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
return new File(current, name).isDirectory();
}
});
File[] directories = currentFolder.listFiles((current, name) -> new File(current, name).isDirectory());
if (directories != null) {
for (File f : directories) {

View file

@ -24,8 +24,8 @@ import static com.nutomic.syncthingandroid.syncthing.RestApi.readableFileSize;
public class FoldersAdapter extends ArrayAdapter<RestApi.Folder>
implements RestApi.OnReceiveModelListener {
private HashMap<String, RestApi.Model> mModels = new HashMap<>();
private LayoutInflater mInflater;
private final HashMap<String, RestApi.Model> mModels = new HashMap<>();
private final LayoutInflater mInflater;
public FoldersAdapter(Context context) {
super(context, R.layout.item_folder_list);

View file

@ -34,11 +34,9 @@ public class EnhancedEditText extends EditText {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (isEnabled()) {
return super.onTouchEvent(event);
} else {
return false;
}
return (isEnabled())
? super.onTouchEvent(event)
: false;
}
@Override

View file

@ -141,9 +141,7 @@
<string name="sync_only_charging">Само по време на зареждане</string>
<string name="sync_only_wifi">Само чрез WiFi</string>
<string name="sync_only_wifi_ssids">Ограничаване до определени WiFi мрежи</string>
<string name="sync_only_wifi_ssids_all">Синхронизиране чрез всяка WiFi мрежа</string>
<string name="sync_only_wifi_ssids_values">Синхронизиране само чрез: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">За да изберете мрежа, моля включете WiFi</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">За да изберете мрежа, моля включете WiFi</string>
<string name="advanced_folder_picker">Избор на папка, за напреднали</string>
<string name="advanced_folder_picker_summary">Изберете папка, от устройството, за синхронизиране</string>
<string name="use_root_title">Стартира Syncthing с права на Superuser</string>

View file

@ -144,9 +144,7 @@ Všechny problémy, se kterými se setkáte, nahlašte prosím přes Github.</st
<string name="sync_only_charging">Synchronizovat pouze při nabíjení</string>
<string name="sync_only_wifi">Synchronizovat pouze přes wifi</string>
<string name="sync_only_wifi_ssids">Omezit na vybrané sítě wifi</string>
<string name="sync_only_wifi_ssids_all">Synchronizovat na všech wifi sítích</string>
<string name="sync_only_wifi_ssids_values">Synchronizovat pouze při připojení k: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Pro výběr sítí prosím zapněte WiFi.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Pro výběr sítí prosím zapněte WiFi.</string>
<string name="advanced_folder_picker">Použít rozšířený výběr adresáře</string>
<string name="advanced_folder_picker_summary">Vyberte jakýkoliv adresář v přístroji pro synchronizaci</string>
<string name="use_root_title">Spustit syncthing jako superuživatel</string>

View file

@ -142,9 +142,7 @@ Bitte auftretenden Probleme via Github melden.</string>
<string name="sync_only_charging">Sync nur mit Ladegerät</string>
<string name="sync_only_wifi">Sync nur im WLAN</string>
<string name="sync_only_wifi_ssids">Nur in bestimmten WLAN Netzwerken</string>
<string name="sync_only_wifi_ssids_all">Synchronisiere in allen WLAN Netzwerken</string>
<string name="sync_only_wifi_ssids_values">Synchronisiere nur in folgendem WLAN: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Bitte WLAN aktivieren, um eines zu wählen.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Bitte WLAN aktivieren, um eines zu wählen.</string>
<string name="advanced_folder_picker">Erweiterte Verzeichnisauswahl benutzen</string>
<string name="advanced_folder_picker_summary">Alle Verzeichnisse auf dem Gerät für Synchronisation auswählbar</string>
<string name="use_root_title">Syncthing mit Superuser Rechten ausführen</string>

View file

@ -142,9 +142,7 @@ Por favor reporte cualquier problema que encuentre por medio de Github.</string>
<string name="sync_only_charging">Sincronizar sólo cuando se está cargando</string>
<string name="sync_only_wifi">Sincronizar sólo por wifi</string>
<string name="sync_only_wifi_ssids">Restringir a ciertas redes wifi</string>
<string name="sync_only_wifi_ssids_all">Sincronizar en todas las redes wifi</string>
<string name="sync_only_wifi_ssids_values">Sincronizar sólo cuando esté conectado a: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Por favor encienda el WiFi para seleccionar redes.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Por favor encienda el WiFi para seleccionar redes.</string>
<string name="advanced_folder_picker">Usar el avanzado Seleccionador de Carpetas</string>
<string name="advanced_folder_picker_summary">Seleccionar cualquier carpeta en el dispositivo para sincronizar</string>
<string name="use_root_title">Ejecutar Syncthing como Superusuario</string>

View file

@ -137,9 +137,7 @@ Por favor informe de qualquier problema que encuentres via Github.</string>
<string name="sync_only_charging">Sincronizar solo cuando esté cargando</string>
<string name="sync_only_wifi">Sincronizar sólo en wifi</string>
<string name="sync_only_wifi_ssids">Restringir a algunas redes wifi</string>
<string name="sync_only_wifi_ssids_all">Sincronizar en todas las redes wifi</string>
<string name="sync_only_wifi_ssids_values">Sincronizar solo cuando se está conectado a: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Por favor enciende el WIFI en las redes seleccionadas.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Por favor enciende el WIFI en las redes seleccionadas.</string>
<string name="advanced_folder_picker">Usar Selección Avanzada de carpeta</string>
<string name="advanced_folder_picker_summary">Escoja una carpeta del dispositivo para sincronizar</string>
<string name="use_root_title">Ejecutar Syncthing como Superusuario</string>

View file

@ -144,9 +144,7 @@ S\'il vous plait, signalez les problèmes que vous rencontrez via Gihub.</string
<string name="sync_only_charging">Synchro uniquement sur chargeur</string>
<string name="sync_only_wifi">Synchro uniquement en WiFi</string>
<string name="sync_only_wifi_ssids">Limiter à certains réseaux WiFi</string>
<string name="sync_only_wifi_ssids_all">Synchroniser sur tous réseaux WiFi</string>
<string name="sync_only_wifi_ssids_values">Synchroniser seulement si connecté à: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">S\'il vous plait, activer le WiFi pour sélectionner un réseau</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">S\'il vous plait, activer le WiFi pour sélectionner un réseau</string>
<string name="advanced_folder_picker">Choix étendu des dossiers</string>
<string name="advanced_folder_picker_summary">Autorise la sélection n\'importe quel dossier de cette machine pour la synchronisation</string>
<string name="use_root_title">Faire fonctionner syncthing en super-utilisateur</string>

View file

@ -120,8 +120,7 @@
<string name="sync_only_charging">Csak töltés közbeni szinkronizálás</string>
<string name="sync_only_wifi">Szinkronizálás csak WiFi-n keresztül</string>
<string name="sync_only_wifi_ssids">Korlátozás bizonyos wifi hálózatokra</string>
<string name="sync_only_wifi_ssids_all">Szinkronizálás minden wifi hálózaton</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Hálózat választásához kapcsold be a wifit.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Hálózat választásához kapcsold be a wifit.</string>
<string name="use_root_title">Syncthing futtatása Superuser-ként</string>
<string name="notification_type_title">Értesítés</string>
<string name="notification_type_summary">Értesítés típusának kiválasztása</string>

View file

@ -144,9 +144,7 @@ Riferisci tramite Github i problemi che incontri.</string>
<string name="sync_only_charging">Sincr. solo in Ricarica</string>
<string name="sync_only_wifi">Sincr. solo in Wifi</string>
<string name="sync_only_wifi_ssids">Solo determinate reti wifi</string>
<string name="sync_only_wifi_ssids_all">Sincronizzazione su tutte le reti wifi</string>
<string name="sync_only_wifi_ssids_values">Sincronizzazione solo quando connessi a: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Prego accendere wifi per selezionare reti.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Prego accendere wifi per selezionare reti.</string>
<string name="advanced_folder_picker">Selettore Cartella Avanzato</string>
<string name="advanced_folder_picker_summary">Selezionare una cartella sul dispositivo per la sincronizzazione</string>
<string name="use_root_title">Esegui Syncthing come Superutente</string>

View file

@ -144,9 +144,7 @@
<string name="sync_only_charging">充電中のみ同期</string>
<string name="sync_only_wifi">Wifi 時のみ同期</string>
<string name="sync_only_wifi_ssids">特定の WiFi ネットワークに制限する</string>
<string name="sync_only_wifi_ssids_all">すべての WiFi ネットワークで共有する</string>
<string name="sync_only_wifi_ssids_values">%1$s に接続時のみ同期する</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">ネットワークを選択するために WiFi をオンにしてください。</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">ネットワークを選択するために WiFi をオンにしてください。</string>
<string name="advanced_folder_picker">高度なフォルダー選択を使用する</string>
<string name="advanced_folder_picker_summary">同期するデバイスのフォルダーを選択してください</string>
<string name="use_root_title">スーパーユーザーとして同期を実行します</string>

View file

@ -144,9 +144,7 @@
<string name="sync_only_charging">충전 중일 때만 동기화</string>
<string name="sync_only_wifi">Wi-Fi에서만 동기화</string>
<string name="sync_only_wifi_ssids">특정 WI-FI 네트워크로 제한하기</string>
<string name="sync_only_wifi_ssids_all">모든 WI-FI 네트워크에서 동기화</string>
<string name="sync_only_wifi_ssids_values">%1$s에 연결되어 있을 때만 동기화</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">WI-FI를 활성화하고 네트워크를 선택해주세요.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">WI-FI를 활성화하고 네트워크를 선택해주세요.</string>
<string name="advanced_folder_picker">고급 폴더 선택기 사용</string>
<string name="advanced_folder_picker_summary">기기에서 동기화에 사용할 폴더를 골라 주세요</string>
<string name="use_root_title">Syncthing을 Superuser로 실행</string>

View file

@ -144,9 +144,7 @@ Vennligst rapporter eventuelle problemer som oppstår via GitHub.</string>
<string name="sync_only_charging">Synkroniser kun ved lading</string>
<string name="sync_only_wifi">Synkroniser kun over WiFi</string>
<string name="sync_only_wifi_ssids">Begrens til visse wifi-nettverk</string>
<string name="sync_only_wifi_ssids_all">Synkroniser på alle wifi-nettverk</string>
<string name="sync_only_wifi_ssids_values">Synkroniser bare når koblet til: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Vennligst skru på WiFi for å velge nettverk.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Vennligst skru på WiFi for å velge nettverk.</string>
<string name="advanced_folder_picker">Bruk avansert mappevelger</string>
<string name="advanced_folder_picker_summary">Velg en mappe på enheten for synkronisering</string>
<string name="use_root_title">Kjør Syncthing som superbruker</string>

View file

@ -144,9 +144,7 @@ Gelieve alle problemen die je tegenkomt via GitHub te melden.</string>
<string name="sync_only_charging">Synchroniseer alleen tijdens opladen</string>
<string name="sync_only_wifi">Synchroniseer alleen via Wi-Fi</string>
<string name="sync_only_wifi_ssids">Tot bepaalde Wi-Fi-netwerken beperken</string>
<string name="sync_only_wifi_ssids_all">Synchroniseer op alle Wi-Fi-netwerken</string>
<string name="sync_only_wifi_ssids_values">Louter synchroniseren terwijl verbonden met: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Wi-Fi aanzetten t.b.v. netwerkselectie.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Wi-Fi aanzetten t.b.v. netwerkselectie.</string>
<string name="advanced_folder_picker">Gebruik geavanceerd map-kiezer</string>
<string name="advanced_folder_picker_summary">Selecteer een map op het toestel om te synchroniseren</string>
<string name="use_root_title">Syncthing uitvoeren als superuser</string>

View file

@ -144,9 +144,7 @@ Om du skulle støyte på problem, ver snill å rapportere dei via Github.</strin
<string name="sync_only_charging">Synkroniser berre mens eg laddar</string>
<string name="sync_only_wifi">Synkroniser berre over WiFi</string>
<string name="sync_only_wifi_ssids">Avgrens til visse WiFi-nettverk</string>
<string name="sync_only_wifi_ssids_all">Synkroniser på alle WiFi-nettverk</string>
<string name="sync_only_wifi_ssids_values">Synkroniser berre på: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Skru på WiFi for å velje nettverk.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Skru på WiFi for å velje nettverk.</string>
<string name="advanced_folder_picker">Bruk avansert mappeveljar</string>
<string name="advanced_folder_picker_summary">Vel kva mappe som helst for synkronisering</string>
<string name="use_root_title">Køyr Syncthing som superbrukar</string>

View file

@ -143,9 +143,7 @@ Proszę zgłaszać błędy programu w serwisie Github.</string>
<string name="sync_only_charging">Synchronizowanie tylko podczas ładowania</string>
<string name="sync_only_wifi">Synchronizowanie tylko przy użyciu Wi-Fi</string>
<string name="sync_only_wifi_ssids">Ogranicz do określonych sieci WiFi</string>
<string name="sync_only_wifi_ssids_all">Synchronizowanie przy użyciu wszystkich sieci wifi</string>
<string name="sync_only_wifi_ssids_values">Synchronizuj jedynie gdy połączono z: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Proszę włącz WiFi dla wybranych sieci</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Proszę włącz WiFi dla wybranych sieci</string>
<string name="advanced_folder_picker">Zaawansowane wybieranie katalogów</string>
<string name="advanced_folder_picker_summary">Wskazuje dowolny katalog na urządzeniu do zsynchronizowania</string>
<string name="use_root_title">Synchronizuje zawartość z uprawnieniami użytkownika Superuser</string>

View file

@ -144,9 +144,7 @@ Por favor, informe-nos sobre quaisquer problemas via Github.</string>
<string name="sync_only_charging">Somente durante o carregamento</string>
<string name="sync_only_wifi">Somente conectado ao WiFi</string>
<string name="sync_only_wifi_ssids">Limitar a certas redes WiFi</string>
<string name="sync_only_wifi_ssids_all">Sincronizar em todas as redes WiFi</string>
<string name="sync_only_wifi_ssids_values">Sincronizar somente quando conectado a %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Ligue o WiFi para selecionar as redes</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Ligue o WiFi para selecionar as redes</string>
<string name="advanced_folder_picker">Usar seletor de pasta avançado</string>
<string name="advanced_folder_picker_summary">Selecione qualquer pasta do dispositivo para sincronização</string>
<string name="use_root_title">Executar como Superusuário</string>

View file

@ -143,9 +143,7 @@
<string name="sync_only_charging">Синхронизация только во время зарядки</string>
<string name="sync_only_wifi">Синхронизация только по WIFI</string>
<string name="sync_only_wifi_ssids">Ограничить определёнными wifi сетями</string>
<string name="sync_only_wifi_ssids_all">Синхронизировать в любых wifi сетях</string>
<string name="sync_only_wifi_ssids_values">Синхронизировать только в: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Включите WiFi, чтобы выбрать сети</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Включите WiFi, чтобы выбрать сети</string>
<string name="advanced_folder_picker">Использовать продвинутый выбор папок</string>
<string name="advanced_folder_picker_summary">Выберите любую папку на устройстве для синхронизации</string>
<string name="use_root_title">Запуск Syncthing с рут-правами</string>

View file

@ -144,9 +144,7 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
<string name="sync_only_charging">Synkronisera endast vid laddning</string>
<string name="sync_only_wifi">Synkronisera endast trådlöst</string>
<string name="sync_only_wifi_ssids">Begränsa till vissa WiFi-nätverk</string>
<string name="sync_only_wifi_ssids_all">Synkronisera på alla WiFi-nätverk</string>
<string name="sync_only_wifi_ssids_values">Synkronisera endast när den är ansluten till: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Sätt på WiFi för att välja nätverk.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Sätt på WiFi för att välja nätverk.</string>
<string name="advanced_folder_picker">Använd avancerad katalogväljare</string>
<string name="advanced_folder_picker_summary">Välj någon katalog på enheten för synkronisering</string>
<string name="use_root_title">Kör Syncthing som superanvändare</string>

View file

@ -144,9 +144,7 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
<string name="sync_only_charging">Synkronisera endast vid laddning</string>
<string name="sync_only_wifi">Synkronisera endast trådlöst</string>
<string name="sync_only_wifi_ssids">Begränsa till vissa WiFi-nätverk</string>
<string name="sync_only_wifi_ssids_all">Synkronisera på alla WiFi-nätverk</string>
<string name="sync_only_wifi_ssids_values">Synkronisera endast när den är ansluten till: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Slå på WiFi för att välja nätverk.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Slå på WiFi för att välja nätverk.</string>
<string name="advanced_folder_picker">Använd avancerade katalogväljaren</string>
<string name="advanced_folder_picker_summary">Välj någon katalog på enheten för synkronisering</string>
<string name="use_root_title">Kör Syncthing som superanvändare</string>

View file

@ -137,9 +137,7 @@ Lütfen, herhangi bir sorunla karşılaştığınızda Github üzerinden bildiri
<string name="sync_only_charging">Sadece şarj edilirken eşzamanlama yap</string>
<string name="sync_only_wifi">Sadece kablosuz ağ üzerindeyken eşzamanlama yap</string>
<string name="sync_only_wifi_ssids">Belirlenmiş kablosuz ağlarla sınırlandır.</string>
<string name="sync_only_wifi_ssids_all">Herhangi bir kablosuz ağ üzerindeyken eşzamanlama yap</string>
<string name="sync_only_wifi_ssids_values">Sadece %1$s\'e bağlıyken eşzamanlama yap</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Ağ seçmek için lütfen kablosuz bağlantınızıın.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Ağ seçmek için lütfen kablosuz bağlantınızıın.</string>
<string name="advanced_folder_picker">Gelişmiş Klasör Seçici Kullan</string>
<string name="advanced_folder_picker_summary">Eşzamanlama yapmak için cihazdan herhangi bir klasör seçin</string>
<string name="use_root_title">Syncthing\'i Superuser/Ayrıcalıklı Kullanıcı olarak Çalıştır</string>

View file

@ -142,9 +142,7 @@ Xin báo cáo mọi vấn đề phát sinh thông qua Github.</string>
<string name="sync_only_charging">Chỉ đ.bộ khi sạc pin</string>
<string name="sync_only_wifi">Chỉ đ.bộ khi dùng wifi</string>
<string name="sync_only_wifi_ssids">Hạn chế với vài mạng wifi nhất định</string>
<string name="sync_only_wifi_ssids_all">Đồng bộ trên t.cả mạng wifi</string>
<string name="sync_only_wifi_ssids_values">Chỉ đồng bộ khi kết nối đến: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Hãy bật WiFi để lựa chọn mạng.</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Hãy bật WiFi để lựa chọn mạng.</string>
<string name="advanced_folder_picker">S.dụng trình chọn th.mục nâng cao</string>
<string name="advanced_folder_picker_summary">Chọn bất kỳ th.mục nào trên th.bị để đồng bộ</string>
<string name="use_root_title">Chạy Syncthing với quyền Superuser</string>

View file

@ -144,9 +144,7 @@
<string name="sync_only_charging">仅在充电时同步</string>
<string name="sync_only_wifi">仅在无线网络下同步</string>
<string name="sync_only_wifi_ssids">对某些无线网络下限制同步</string>
<string name="sync_only_wifi_ssids_all">在所有网络环境下同步</string>
<string name="sync_only_wifi_ssids_values">仅当连接到 %1$s 网络中才进行同步</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">请打开无线网络连接并选择网络</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">请打开无线网络连接并选择网络</string>
<string name="advanced_folder_picker">使用高级文件夹选择器</string>
<string name="advanced_folder_picker_summary">可以选择设备上任何文件夹</string>
<string name="use_root_title">Syncthing 运行于超级用户</string>

View file

@ -237,10 +237,6 @@ Please report any problems you encounter via Github.</string>
<string name="sync_only_wifi_ssids">Restrict to certain wifi networks</string>
<string name="sync_only_wifi_ssids_all">Sync on all wifi networks</string>
<string name="sync_only_wifi_ssids_values">Sync only while connected to: %1$s</string>
<string name="sync_only_wifi_ssids_wifi_turn_on_wifi">Please turn on WiFi to select networks.</string>
<string name="advanced_folder_picker">Use advanced Folder Picker</string>
@ -406,6 +402,8 @@ Please report any problems you encounter via Github.</string>
<!-- Title of the "log Syncthing" menu button -->
<string name="log_syncthing_title">View Syncthing Log</string>
<string name="retrieving_logs">Retrieving logs…</string>
<!-- Title of the "share log" menu button -->
<string name="share_title">Share</string>

View file

@ -49,12 +49,7 @@ public class SyncthingServiceTest {
@Test
public void testBindService() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(2);
mService.registerOnWebGuiAvailableListener(new SyncthingService.OnWebGuiAvailableListener() {
@Override
public void onWebGuiAvailable() {
latch.countDown();
}
});
mService.registerOnWebGuiAvailableListener(latch::countDown);
mService.registerOnApiChangeListener(new SyncthingService.OnApiChangeListener() {
@Override
public void onApiChange(SyncthingService.State currentState) {