Loading app/src/main/java/it/niedermann/owncloud/notes/model/LoginStatus.java +2 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ import it.niedermann.owncloud.notes.R; public enum LoginStatus { OK(0), NO_NETWORK(R.string.error_no_network), JSON_FAILED(R.string.error_json); JSON_FAILED(R.string.error_json), PROBLEM_WITH_FILES_APP(R.string.error_files_app); @StringRes public final int str; Loading app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java +8 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.preference.PreferenceManager; import android.util.Log; import android.widget.Toast; import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; Loading Loading @@ -332,6 +333,9 @@ public class NoteServerSyncHelper { } else { e.printStackTrace(); } } catch (NextcloudApiNotRespondingException e) { Log.e(TAG, "Exception", e); e.printStackTrace(); } } } Loading Loading @@ -391,6 +395,8 @@ public class NoteServerSyncHelper { e.printStackTrace(); return LoginStatus.JSON_FAILED; } } catch (NextcloudApiNotRespondingException e) { return LoginStatus.PROBLEM_WITH_FILES_APP; } return status; } Loading app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java +10 −6 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ package it.niedermann.owncloud.notes.persistence; import android.content.Context; import android.util.Log; import androidx.annotation.WorkerThread; import com.google.gson.GsonBuilder; import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.api.AidlNetworkRequest; import com.nextcloud.android.sso.api.NextcloudAPI; import com.nextcloud.android.sso.api.Response; import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; Loading @@ -26,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import androidx.annotation.WorkerThread; import it.niedermann.owncloud.notes.model.CloudNote; import it.niedermann.owncloud.notes.util.ServerResponse.NoteResponse; import it.niedermann.owncloud.notes.util.ServerResponse.NotesResponse; Loading Loading @@ -118,13 +120,13 @@ public class NotesClient { } } NotesResponse getNotes(long lastModified, String lastETag) throws NextcloudHttpRequestFailedException { NotesResponse getNotes(long lastModified, String lastETag) throws NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { Map<String, String> parameter = new HashMap<>(); parameter.put(GET_PARAM_KEY_PRUNE_BEFORE, Long.toString(lastModified)); return new NotesResponse(requestServer("notes", METHOD_GET, parameter, null, lastETag)); } private NoteResponse putNote(CloudNote note, String path, String method) throws JSONException, NextcloudHttpRequestFailedException { private NoteResponse putNote(CloudNote note, String path, String method) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { JSONObject paramObject = new JSONObject(); paramObject.accumulate(JSON_CONTENT, note.getContent()); paramObject.accumulate(JSON_MODIFIED, note.getModified().getTimeInMillis() / 1000); Loading @@ -141,11 +143,11 @@ public class NotesClient { * @throws JSONException * @throws NextcloudHttpRequestFailedException */ NoteResponse createNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException { NoteResponse createNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { return putNote(note, "notes", METHOD_POST); } NoteResponse editNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException { NoteResponse editNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { return putNote(note, "notes/" + note.getRemoteId(), METHOD_PUT); } Loading @@ -167,7 +169,7 @@ public class NotesClient { * @param lastETag optional ETag of last response * @return Body of answer */ private ResponseData requestServer(String target, String method, Map<String, String> parameter, JSONObject requestBody, String lastETag) throws NextcloudHttpRequestFailedException { private ResponseData requestServer(String target, String method, Map<String, String> parameter, JSONObject requestBody, String lastETag) throws NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { NextcloudRequest.Builder requestBuilder = new NextcloudRequest.Builder() .setMethod(method) .setUrl(API_PATH + target); Loading Loading @@ -216,6 +218,8 @@ public class NotesClient { } catch (Exception e) { if(e instanceof NextcloudHttpRequestFailedException) { throw (NextcloudHttpRequestFailedException) e; } else if(e instanceof NextcloudApiNotRespondingException) { throw (NextcloudApiNotRespondingException) e; } else { e.printStackTrace(); } Loading app/src/main/java/it/niedermann/owncloud/notes/util/ServerResponse.java +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class ServerResponse { private final NotesClient.ResponseData response; public ServerResponse(NotesClient.ResponseData response) { ServerResponse(NotesClient.ResponseData response) { this.response = response; } Loading @@ -62,7 +62,7 @@ public class ServerResponse { return response.getLastModified(); } protected CloudNote getNoteFromJSON(JSONObject json) throws JSONException { CloudNote getNoteFromJSON(JSONObject json) throws JSONException { long id = 0; String title = ""; String content = ""; Loading app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ <string name="error_sync">Synchronization failed: %1$s</string> <string name="error_json">is the Notes app activated on the server?</string> <string name="error_no_network">no network connection</string> <string name="error_files_app">do you have installed the files app?</string> <!-- Snackbar Actions --> Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/model/LoginStatus.java +2 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ import it.niedermann.owncloud.notes.R; public enum LoginStatus { OK(0), NO_NETWORK(R.string.error_no_network), JSON_FAILED(R.string.error_json); JSON_FAILED(R.string.error_json), PROBLEM_WITH_FILES_APP(R.string.error_files_app); @StringRes public final int str; Loading
app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java +8 −2 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.preference.PreferenceManager; import android.util.Log; import android.widget.Toast; import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; Loading Loading @@ -332,6 +333,9 @@ public class NoteServerSyncHelper { } else { e.printStackTrace(); } } catch (NextcloudApiNotRespondingException e) { Log.e(TAG, "Exception", e); e.printStackTrace(); } } } Loading Loading @@ -391,6 +395,8 @@ public class NoteServerSyncHelper { e.printStackTrace(); return LoginStatus.JSON_FAILED; } } catch (NextcloudApiNotRespondingException e) { return LoginStatus.PROBLEM_WITH_FILES_APP; } return status; } Loading
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesClient.java +10 −6 Original line number Diff line number Diff line Loading @@ -3,11 +3,14 @@ package it.niedermann.owncloud.notes.persistence; import android.content.Context; import android.util.Log; import androidx.annotation.WorkerThread; import com.google.gson.GsonBuilder; import com.nextcloud.android.sso.aidl.NextcloudRequest; import com.nextcloud.android.sso.api.AidlNetworkRequest; import com.nextcloud.android.sso.api.NextcloudAPI; import com.nextcloud.android.sso.api.Response; import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; Loading @@ -26,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; import androidx.annotation.WorkerThread; import it.niedermann.owncloud.notes.model.CloudNote; import it.niedermann.owncloud.notes.util.ServerResponse.NoteResponse; import it.niedermann.owncloud.notes.util.ServerResponse.NotesResponse; Loading Loading @@ -118,13 +120,13 @@ public class NotesClient { } } NotesResponse getNotes(long lastModified, String lastETag) throws NextcloudHttpRequestFailedException { NotesResponse getNotes(long lastModified, String lastETag) throws NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { Map<String, String> parameter = new HashMap<>(); parameter.put(GET_PARAM_KEY_PRUNE_BEFORE, Long.toString(lastModified)); return new NotesResponse(requestServer("notes", METHOD_GET, parameter, null, lastETag)); } private NoteResponse putNote(CloudNote note, String path, String method) throws JSONException, NextcloudHttpRequestFailedException { private NoteResponse putNote(CloudNote note, String path, String method) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { JSONObject paramObject = new JSONObject(); paramObject.accumulate(JSON_CONTENT, note.getContent()); paramObject.accumulate(JSON_MODIFIED, note.getModified().getTimeInMillis() / 1000); Loading @@ -141,11 +143,11 @@ public class NotesClient { * @throws JSONException * @throws NextcloudHttpRequestFailedException */ NoteResponse createNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException { NoteResponse createNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { return putNote(note, "notes", METHOD_POST); } NoteResponse editNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException { NoteResponse editNote(CloudNote note) throws JSONException, NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { return putNote(note, "notes/" + note.getRemoteId(), METHOD_PUT); } Loading @@ -167,7 +169,7 @@ public class NotesClient { * @param lastETag optional ETag of last response * @return Body of answer */ private ResponseData requestServer(String target, String method, Map<String, String> parameter, JSONObject requestBody, String lastETag) throws NextcloudHttpRequestFailedException { private ResponseData requestServer(String target, String method, Map<String, String> parameter, JSONObject requestBody, String lastETag) throws NextcloudHttpRequestFailedException, NextcloudApiNotRespondingException { NextcloudRequest.Builder requestBuilder = new NextcloudRequest.Builder() .setMethod(method) .setUrl(API_PATH + target); Loading Loading @@ -216,6 +218,8 @@ public class NotesClient { } catch (Exception e) { if(e instanceof NextcloudHttpRequestFailedException) { throw (NextcloudHttpRequestFailedException) e; } else if(e instanceof NextcloudApiNotRespondingException) { throw (NextcloudApiNotRespondingException) e; } else { e.printStackTrace(); } Loading
app/src/main/java/it/niedermann/owncloud/notes/util/ServerResponse.java +2 −2 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class ServerResponse { private final NotesClient.ResponseData response; public ServerResponse(NotesClient.ResponseData response) { ServerResponse(NotesClient.ResponseData response) { this.response = response; } Loading @@ -62,7 +62,7 @@ public class ServerResponse { return response.getLastModified(); } protected CloudNote getNoteFromJSON(JSONObject json) throws JSONException { CloudNote getNoteFromJSON(JSONObject json) throws JSONException { long id = 0; String title = ""; String content = ""; Loading
app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ <string name="error_sync">Synchronization failed: %1$s</string> <string name="error_json">is the Notes app activated on the server?</string> <string name="error_no_network">no network connection</string> <string name="error_files_app">do you have installed the files app?</string> <!-- Snackbar Actions --> Loading