Update to moasdawiki-server 3.4.4

This commit is contained in:
Herbert Reiter
2022-04-14 19:49:49 +02:00
parent 3cfe7a5a79
commit 2014c0509b
4 changed files with 16 additions and 17 deletions
+1 -8
View File
@@ -10,13 +10,6 @@ android {
versionName "3.2.1.0" versionName "3.2.1.0"
archivesBaseName = "moasdawiki-" + versionName + "-" + versionCode archivesBaseName = "moasdawiki-" + versionName + "-" + versionCode
} }
sourceSets {
main {
java {
exclude "net/moasdawiki/plugin/sync/SynchronizationPlugin*"
}
}
}
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_11 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11
@@ -28,7 +21,7 @@ android {
} }
dependencies { dependencies {
implementation 'net.moasdawiki:moasdawiki-server:3.2.1' implementation 'net.moasdawiki:moasdawiki-server:3.4.4'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.1'
// androidx.preference 1.2.0 causes dependency conflict // androidx.preference 1.2.0 causes dependency conflict
@@ -52,7 +52,8 @@ import androidx.preference.PreferenceManager;
import net.moasdawiki.base.ServiceException; import net.moasdawiki.base.ServiceException;
import net.moasdawiki.base.Settings; import net.moasdawiki.base.Settings;
import net.moasdawiki.server.HttpRequest; import net.moasdawiki.http.ContentType;
import net.moasdawiki.http.HttpRequest;
import net.moasdawiki.server.RequestDispatcher; import net.moasdawiki.server.RequestDispatcher;
import net.moasdawiki.service.HttpResponse; import net.moasdawiki.service.HttpResponse;
import net.moasdawiki.service.repository.RepositoryService; import net.moasdawiki.service.repository.RepositoryService;
@@ -175,8 +176,14 @@ public class MainActivity extends AppCompatActivity {
HttpResponse response = requestDispatcher.handleRequest(httpRequest); HttpResponse response = requestDispatcher.handleRequest(httpRequest);
// send wiki content to browser // send wiki content to browser
InputStream responseData = new ByteArrayInputStream(response.content); String mimeType;
return new WebResourceResponse(response.contentType, "UTF-8", responseData); if (response.getContentType() != null) {
mimeType = response.getContentType().getMediaType();
} else {
mimeType = ContentType.BINARY.getMediaType();
}
InputStream responseData = new ByteArrayInputStream(response.getContent());
return new WebResourceResponse(mimeType, "UTF-8", responseData);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -270,15 +277,15 @@ public class MainActivity extends AppCompatActivity {
} }
} }
public void onConfigurationHintClicked(View view) { public void onConfigurationHintClicked(@SuppressWarnings("unused") View view) {
showSettingsDialog(); showSettingsDialog();
} }
public void onSynchronizeHintClicked(View view) { public void onSynchronizeHintClicked(@SuppressWarnings("unused") View view) {
synchronizeWithServer(); synchronizeWithServer();
} }
public void onSearch(View view) { public void onSearch(@SuppressWarnings("unused") View view) {
EditText searchInput = findViewById(R.id.search_input); EditText searchInput = findViewById(R.id.search_input);
String query = searchInput.getText().toString(); String query = searchInput.getText().toString();
query = query.trim(); query = query.trim();
@@ -49,6 +49,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@SuppressWarnings("ConstantConditions")
WikiEngineApplication app = (WikiEngineApplication) getContext().getApplicationContext(); WikiEngineApplication app = (WikiEngineApplication) getContext().getApplicationContext();
synchronizeWikiClient = app.getSynchronizeWikiClient(); synchronizeWikiClient = app.getSynchronizeWikiClient();
repositoryService = app.getRepositoryService(); repositoryService = app.getRepositoryService();
@@ -167,7 +167,6 @@ public class SynchronizeWikiClient {
return new BigInteger(130, random).toString(32); return new BigInteger(130, random).toString(32);
} }
@NotNull
private boolean[] checkSession(@NotNull String serverHostPort) throws ServiceException { private boolean[] checkSession(@NotNull String serverHostPort) throws ServiceException {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
String serverSessionId = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_SESSION_ID, null); String serverSessionId = preferences.getString(Constants.PREFERENCES_SYNC_SERVER_SESSION_ID, null);
@@ -409,9 +408,8 @@ public class SynchronizeWikiClient {
while ((bytesRead = in.read(buffer)) != -1) { while ((bytesRead = in.read(buffer)) != -1) {
byteStream.write(buffer, 0, bytesRead); byteStream.write(buffer, 0, bytesRead);
} }
byte[] responseBytes = byteStream.toByteArray();
String responseXml = new String(responseBytes, StandardCharsets.UTF_8); String responseXml = byteStream.toString("UTF-8");
Log.d(TAG, "Response: " + truncateLogText(responseXml, 400)); Log.d(TAG, "Response: " + truncateLogText(responseXml, 400));
return responseXml; return responseXml;
} catch (Exception e) { } catch (Exception e) {