Bugfix
This commit is contained in:
@@ -113,11 +113,11 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
||||
}
|
||||
|
||||
// Port
|
||||
int serverPort = preferences.getInt(Constants.PREFERENCES_SYNC_SERVER_PORT, 0);
|
||||
String serverPort = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_PORT, null);
|
||||
EditTextPreference syncServerPort = findPreference("sync_server_port");
|
||||
if (syncServerPort != null) {
|
||||
if (serverPort > 0) {
|
||||
syncServerPort.setSummary(Integer.toString(serverPort));
|
||||
if (serverPort != null && !serverPort.isEmpty()) {
|
||||
syncServerPort.setSummary(serverPort);
|
||||
} else {
|
||||
String summary = getString(R.string.settings_port_summary_empty, settings.getServerPort());
|
||||
syncServerPort.setSummary(summary);
|
||||
|
||||
@@ -99,17 +99,14 @@ public class SynchronizeWikiClient {
|
||||
* weiter verwendet.
|
||||
*/
|
||||
public boolean createAndCheckSession() {
|
||||
PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
String host = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_HOST, null);
|
||||
int port = preferences.getInt(Constants.PREFERENCES_SYNC_SERVER_PORT, settings.getServerPort());
|
||||
String serverSessionId = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_SESSION_ID, null);
|
||||
|
||||
// Host konfiguriert?
|
||||
if (host == null) {
|
||||
String serverHostPort = getServerHostPort();
|
||||
if (serverHostPort == null) {
|
||||
return false;
|
||||
}
|
||||
String serverHostPort = host + ':' + port;
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
String serverSessionId = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_SESSION_ID, null);
|
||||
|
||||
try {
|
||||
// Wenn noch keine Session vorhanden ist, eine erzeugen
|
||||
@@ -228,12 +225,12 @@ public class SynchronizeWikiClient {
|
||||
* @return Anzahl der synchronisierten Dateien.
|
||||
*/
|
||||
public int synchronizeRepository(ProgressFeedback feedback) throws ServiceException {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
String host = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_HOST, null);
|
||||
int port = preferences.getInt(Constants.PREFERENCES_SYNC_SERVER_PORT, settings.getServerPort());
|
||||
if (host == null) {
|
||||
String serverHostPort = getServerHostPort();
|
||||
if (serverHostPort == null) {
|
||||
throw new ServiceException("No wiki server configured");
|
||||
}
|
||||
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
String serverSessionId = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_SESSION_ID, null);
|
||||
if (serverSessionId == null) {
|
||||
throw new ServiceException("Not server session ID found");
|
||||
@@ -245,7 +242,6 @@ public class SynchronizeWikiClient {
|
||||
}
|
||||
|
||||
// Aktuelle Session überprüfen
|
||||
String serverHostPort = host + ':' + port;
|
||||
boolean[] checkResult = checkSession(serverHostPort);
|
||||
if (!checkResult[1]) {
|
||||
throw new ServiceException("Client not authenticated at wiki server");
|
||||
@@ -315,6 +311,24 @@ public class SynchronizeWikiClient {
|
||||
Log.d(TAG, "File '" + filePath + "' replaced by newer content from server");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getServerHostPort() {
|
||||
PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
|
||||
String host = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_HOST, null);
|
||||
if (host == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String port = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_PORT, null);
|
||||
if (port == null || port.trim().isEmpty()) {
|
||||
port = Integer.toString(settings.getServerPort());
|
||||
}
|
||||
|
||||
return host + ':' + port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Versucht den Wifi-Hostnamen zu ermitteln und gibt ihn zurück.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user