mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-02 17:21:17 +00:00
Immediately update GUI after config was changed (fixes #355).
This commit is contained in:
parent
5996e134c2
commit
90331bb7ab
4 changed files with 19 additions and 4 deletions
|
@ -266,6 +266,7 @@ public class DeviceFragment extends Fragment implements
|
||||||
|
|
||||||
if (!mIsCreateMode) {
|
if (!mIsCreateMode) {
|
||||||
List<RestApi.Device> devices = mSyncthingService.getApi().getDevices(false);
|
List<RestApi.Device> devices = mSyncthingService.getApi().getDevices(false);
|
||||||
|
mDevice = null;
|
||||||
for (int i = 0; i < devices.size(); i++) {
|
for (int i = 0; i < devices.size(); i++) {
|
||||||
if (devices.get(i).deviceID.equals(
|
if (devices.get(i).deviceID.equals(
|
||||||
getActivity().getIntent().getStringExtra(EXTRA_NODE_ID))) {
|
getActivity().getIntent().getStringExtra(EXTRA_NODE_ID))) {
|
||||||
|
@ -274,7 +275,7 @@ public class DeviceFragment extends Fragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mDevice == null) {
|
if (mDevice == null) {
|
||||||
Log.w(TAG, "Device not found in API update");
|
Log.w(TAG, "Device not found in API update, maybe it was deleted?");
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,7 @@ public class FolderFragment extends Fragment
|
||||||
if (!mIsCreateMode) {
|
if (!mIsCreateMode) {
|
||||||
List<RestApi.Folder> folders = mSyncthingService.getApi().getFolders();
|
List<RestApi.Folder> folders = mSyncthingService.getApi().getFolders();
|
||||||
String passedId = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID);
|
String passedId = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID);
|
||||||
|
mFolder = null;
|
||||||
for (RestApi.Folder currentFolder : folders) {
|
for (RestApi.Folder currentFolder : folders) {
|
||||||
if (currentFolder.id.equals(passedId)) {
|
if (currentFolder.id.equals(passedId)) {
|
||||||
mFolder = currentFolder;
|
mFolder = currentFolder;
|
||||||
|
@ -241,7 +242,7 @@ public class FolderFragment extends Fragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mFolder == null) {
|
if (mFolder == null) {
|
||||||
Log.w(TAG, "Folder not found in API update");
|
Log.w(TAG, "Folder not found in API update, maybe it was deleted?");
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
public String invalid;
|
public String invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnConfigChangedListener {
|
||||||
|
void onConfigChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
private String mVersion;
|
private String mVersion;
|
||||||
|
@ -179,14 +183,15 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
private final Map<String, String> mCacheFolderPathLookup = new HashMap<String, String>();
|
private final Map<String, String> mCacheFolderPathLookup = new HashMap<String, String>();
|
||||||
|
|
||||||
public RestApi(Context context, String url, String apiKey, String guiUser, String guiPassword,
|
public RestApi(Context context, String url, String apiKey, String guiUser, String guiPassword,
|
||||||
OnApiAvailableListener listener) {
|
OnApiAvailableListener apiListener, OnConfigChangedListener configListener) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mUrl = url;
|
mUrl = url;
|
||||||
mApiKey = apiKey;
|
mApiKey = apiKey;
|
||||||
mGuiUser = guiUser;
|
mGuiUser = guiUser;
|
||||||
mGuiPassword = guiPassword;
|
mGuiPassword = guiPassword;
|
||||||
mHttpsCertPath = mContext.getFilesDir() + "/" + SyncthingService.HTTPS_CERT_FILE;
|
mHttpsCertPath = mContext.getFilesDir() + "/" + SyncthingService.HTTPS_CERT_FILE;
|
||||||
mOnApiAvailableListener = listener;
|
mOnApiAvailableListener = apiListener;
|
||||||
|
mOnConfigChangedListener = configListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,6 +210,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
|
|
||||||
private final OnApiAvailableListener mOnApiAvailableListener;
|
private final OnApiAvailableListener mOnApiAvailableListener;
|
||||||
|
|
||||||
|
private final OnConfigChangedListener mOnConfigChangedListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets local device ID, syncthing version and config, then calls all OnApiAvailableListeners.
|
* Gets local device ID, syncthing version and config, then calls all OnApiAvailableListeners.
|
||||||
*/
|
*/
|
||||||
|
@ -348,6 +355,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
} else {
|
} else {
|
||||||
activity.startActivity(new Intent(mContext, RestartActivity.class));
|
activity.startActivity(new Intent(mContext, RestartActivity.class));
|
||||||
}
|
}
|
||||||
|
mOnConfigChangedListener.onConfigChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -401,6 +401,11 @@ public class SyncthingService extends Service implements
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
}, new RestApi.OnConfigChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onConfigChanged() {
|
||||||
|
onApiChange();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mEventProcessor = new EventProcessor(SyncthingService.this, mApi);
|
mEventProcessor = new EventProcessor(SyncthingService.this, mApi);
|
||||||
|
|
Loading…
Reference in a new issue