diff --git a/README.md b/README.md
index 6567e3a5f..e1a8cc8de 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,26 @@
# Nextcloud Notes
An android client for [Nextcloud Notes App](https://github.com/nextcloud/notes/).
+[![GitHub issues](https://img.shields.io/github/issues/stefan-niedermann/Owncloud-Notes.svg)](https://github.com/stefan-niedermann/Owncloud-Notes/issues)
+[![GitHub stars](https://img.shields.io/github/stars/stefan-niedermann/Owncloud-Notes.svg)](https://github.com/stefan-niedermann/Owncloud-Notes/stargazers)
+[![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg)](https://raw.githubusercontent.com/stefan-niedermann/Owncloud-Notes/master/LICENSE)
+
## :arrow_forward: Access
-
-
-
-
-
-
-
-
-
+[![Download from Google Play](http://www.android.com/images/brand/android_app_on_play_large.png)](https://play.google.com/store/apps/details?id=it.niedermann.owncloud.notes)
+[![Nextcloud Notes App on fdroid.org](https://camo.githubusercontent.com/7df0eafa4433fa4919a56f87c3d99cf81b68d01c/68747470733a2f2f662d64726f69642e6f72672f77696b692f696d616765732f632f63342f462d44726f69642d627574746f6e5f617661696c61626c652d6f6e2e706e67)](https://f-droid.org/repository/browse/?fdid=it.niedermann.owncloud.notes)
+[![Donate with PayPal](https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K7HVLE6J7SXXA)
+
+## :eyes: Screenshots
+![Screenshot of list view](/demo-list.png)
+![Screenshot of edit view](/demo-edit.png)
## :rocket: Features
* List, create, edit, share, search and delete notes
* Share text and links as new note into the app
* Mark notes as favorite
* Bulk delete
-* Render MarkDown (using [Bypass](https://github.com/Uncodin/bypass))
+* Render MarkDown (using [RxMarkdown](https://github.com/yydcdut/RxMarkdown))
* English, German, Russian, Armenian, French and Serbian UI
## :checkered_flag: Planned features
@@ -27,10 +29,6 @@ An android client for [Nextcloud Notes App](https://github.com/nextcloud/notes/)
* Make a widget for all notes ([#15](https://github.com/stefan-niedermann/OwnCloud-Notes/issues/15))
* In-note search ([#106](https://github.com/stefan-niedermann/OwnCloud-Notes/issues/106))
-## :eyes: Screenshots
-![Demo 1](/demo-1.png)
-![Demo 2](/demo-2.png)
-
## :wrench: Contribution
* Test the app with different devices
* Write issues in the [issue tracker](https://github.com/stefan-niedermann/OwnCloud-Notes/issues)
@@ -48,4 +46,3 @@ This project is licensed under the [GNU GENERAL PUBLIC LICENSE](/LICENSE).
## :twisted_rightwards_arrows: Alternatives
If you dislike this app and you are looking for alternatives: Have a look at [MyOwnNotes](https://github.com/aykit/MyOwnNotes).
-
diff --git a/app/build.gradle b/app/build.gradle
index 4be4a04f5..8cbd58530 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 24
- buildToolsVersion '24.0.1'
+ compileSdkVersion 25
+ buildToolsVersion '25.0.1'
defaultConfig {
applicationId "it.niedermann.owncloud.notes"
minSdkVersion 11
- targetSdkVersion 24
+ targetSdkVersion 25
versionCode 14
versionName "0.9.0"
}
@@ -20,10 +20,12 @@ android {
}
dependencies {
- compile 'com.commit451:bypasses:1.0.1'
- compile 'com.android.support:support-v4:24.2.1'
- compile 'com.android.support:appcompat-v7:24.2.1'
- compile 'com.android.support:design:24.2.1'
- compile 'com.android.support:recyclerview-v7:24.2.1'
+ compile 'com.yydcdut:rxmarkdown:0.0.7'
+ compile 'io.reactivex:rxandroid:1.2.0'
+ compile 'io.reactivex:rxjava:1.1.5'
+ compile 'com.android.support:support-v4:25.0.1'
+ compile 'com.android.support:appcompat-v7:25.0.1'
+ compile 'com.android.support:design:25.0.1'
+ compile 'com.android.support:recyclerview-v7:25.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/app/ic_launcher-web.png b/app/ic_launcher-web.png
index 92c48f88e..d2c0821c9 100644
Binary files a/app/ic_launcher-web.png and b/app/ic_launcher-web.png differ
diff --git a/app/src/androidTest/java/it/niedermann/owncloud/notes/model/NoteTest.java b/app/src/androidTest/java/it/niedermann/owncloud/notes/model/NoteTest.java
index 03aa63806..7e9d14cfd 100644
--- a/app/src/androidTest/java/it/niedermann/owncloud/notes/model/NoteTest.java
+++ b/app/src/androidTest/java/it/niedermann/owncloud/notes/model/NoteTest.java
@@ -11,7 +11,7 @@
public class NoteTest extends TestCase {
public void testMarkDownStrip() {
- OwnCloudNote note = new OwnCloudNote(0, Calendar.getInstance(), "#Title", "", false);
+ CloudNote note = new CloudNote(0, Calendar.getInstance(), "#Title", "", false);
assertTrue("Title".equals(note.getTitle()));
note.setTitle("* Aufzählung");
assertTrue("Aufzählung".equals(note.getTitle()));
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b55279ee9..d73ebc37a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,7 +6,7 @@
+ android:targetSdkVersion="25" />
@@ -58,8 +58,8 @@
+ android:parentActivityName="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity"
+ android:windowSoftInputMode="stateVisible">
() {
+ @Override
+ public void onCompleted() {
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ }
+
+ @Override
+ public void onNext(CharSequence charSequence) {
+ editTextField.setText(charSequence, TextView.BufferType.SPANNABLE);
+ }
+ });
}
@Override
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java
index e42f61d89..0ba718e94 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java
@@ -10,6 +10,11 @@
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
+import android.widget.TextView;
+
+import com.yydcdut.rxmarkdown.RxMDEditText;
+import com.yydcdut.rxmarkdown.RxMarkdown;
+import com.yydcdut.rxmarkdown.factory.EditFactory;
import java.util.Timer;
import java.util.TimerTask;
@@ -20,6 +25,8 @@
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.persistence.NoteSQLiteOpenHelper;
import it.niedermann.owncloud.notes.util.ICallback;
+import it.niedermann.owncloud.notes.util.MarkDownUtil;
+import rx.Subscriber;
public class EditNoteActivity extends AppCompatActivity {
@@ -31,7 +38,7 @@ public class EditNoteActivity extends AppCompatActivity {
private static final long DELAY = 2000; // in ms
private static final long DELAY_AFTER_SYNC = 5000; // in ms
- private EditText content = null;
+ private RxMDEditText content = null;
private DBNote note, originalNote;
private int notePosition = 0;
private Timer timer, timerNextSync;
@@ -53,9 +60,29 @@ protected void onCreate(final Bundle savedInstanceState) {
originalNote = (DBNote) savedInstanceState.getSerializable(PARAM_ORIGINAL_NOTE);
notePosition = savedInstanceState.getInt(PARAM_NOTE_POSITION);
}
- content = (EditText) findViewById(R.id.editContent);
+ content = (RxMDEditText) findViewById(R.id.editContent);
content.setText(note.getContent());
content.setEnabled(true);
+
+ RxMarkdown.live(content)
+ .config(MarkDownUtil.getMarkDownConfiguration(getApplicationContext()))
+ .factory(EditFactory.create())
+ .intoObservable()
+ .subscribe(new Subscriber() {
+ @Override
+ public void onCompleted() {
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ }
+
+ @Override
+ public void onNext(CharSequence charSequence) {
+ content.setText(charSequence, TextView.BufferType.SPANNABLE);
+ }
+ });
+
db = new NoteSQLiteOpenHelper(this);
actionBar = getSupportActionBar();
if (actionBar != null) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteActivity.java
index b7439a1ab..af2361f3b 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NoteActivity.java
@@ -5,19 +5,28 @@
import android.support.v7.app.AppCompatActivity;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
+import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
+import com.yydcdut.rxmarkdown.RxMDTextView;
+import com.yydcdut.rxmarkdown.RxMarkdown;
+import com.yydcdut.rxmarkdown.factory.TextFactory;
+
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.model.DBNote;
+import it.niedermann.owncloud.notes.util.MarkDownUtil;
+import rx.Subscriber;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
public class NoteActivity extends AppCompatActivity {
public static final String PARAM_NOTE = EditNoteActivity.PARAM_NOTE;
private DBNote note = null;
- private TextView noteContent = null;
+ private RxMDTextView noteContent = null;
private ActionBar actionBar = null;
@Override
@@ -33,8 +42,30 @@ protected void onCreate(Bundle savedInstanceState) {
actionBar.setTitle(note.getTitle());
actionBar.setSubtitle(DateUtils.getRelativeDateTimeString(getApplicationContext(), note.getModified().getTimeInMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0));
}
- noteContent = (TextView) findViewById(R.id.single_note_content);
- noteContent.setText(note.getSpannableContent());
+ noteContent = (RxMDTextView) findViewById(R.id.single_note_content);
+
+ RxMarkdown.with(note.getContent(), this)
+ .config(MarkDownUtil.getMarkDownConfiguration(getApplicationContext()))
+ .factory(TextFactory.create())
+ .intoObservable()
+ .subscribeOn(Schedulers.computation())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Subscriber() {
+ @Override
+ public void onCompleted() {
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ Log.v("Note View -------------", e.getStackTrace().toString());
+ }
+
+ @Override
+ public void onNext(CharSequence charSequence) {
+ noteContent.setText(charSequence, TextView.BufferType.SPANNABLE);
+ }
+ });
+ noteContent.setText(note.getContent());
findViewById(R.id.fab_edit).setVisibility(View.GONE);
((TextView) findViewById(R.id.single_note_content)).setMovementMethod(LinkMovementMethod.getInstance());
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
index 7a60c5337..50b6e7cb1 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
@@ -8,6 +8,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.support.design.widget.Snackbar;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
@@ -300,10 +301,22 @@ public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewH
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.RIGHT) {
- DBNote dbNote = (DBNote) adapter.getItem(viewHolder.getAdapterPosition());
+ final DBNote dbNote = (DBNote) adapter.getItem(viewHolder.getAdapterPosition());
db.deleteNoteAndSync((dbNote).getId());
adapter.remove(dbNote);
+ refreshList();
Log.v("Note", "Item deleted through swipe ----------------------------------------------");
+ Snackbar.make(swipeRefreshLayout, R.string.action_note_deleted, Snackbar.LENGTH_LONG)
+ .setAction(R.string.action_undo, new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ db.addNoteAndSync(dbNote);
+ refreshList();
+ Snackbar.make(swipeRefreshLayout, R.string.action_note_restored, Snackbar.LENGTH_SHORT)
+ .show();
+ }
+ })
+ .show();
}
}
});
@@ -383,22 +396,23 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
//not need because of db.synchronisation in createActivity
- DBNote createdNote = (DBNote) data.getExtras().getSerializable(
- CREATED_NOTE);
+ DBNote createdNote = (DBNote) data.getExtras().getSerializable(CREATED_NOTE);
adapter.add(createdNote);
//setListView(db.getNotes());
}
} else if (requestCode == show_single_note_cmd) {
if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) {
int notePosition = data.getExtras().getInt(EditNoteActivity.PARAM_NOTE_POSITION);
- Item oldItem = adapter.getItem(notePosition);
- if(resultCode == RESULT_FIRST_USER) {
- adapter.remove(oldItem);
- }
- if (resultCode == RESULT_OK) {
- DBNote editedNote = (DBNote) data.getExtras().getSerializable(EditNoteActivity.PARAM_NOTE);
- adapter.replace(editedNote, notePosition);
- refreshList();
+ if(adapter.getItemCount()>notePosition) {
+ Item oldItem = adapter.getItem(notePosition);
+ if (resultCode == RESULT_FIRST_USER) {
+ adapter.remove(oldItem);
+ }
+ if (resultCode == RESULT_OK) {
+ DBNote editedNote = (DBNote) data.getExtras().getSerializable(EditNoteActivity.PARAM_NOTE);
+ adapter.replace(editedNote, notePosition);
+ refreshList();
+ }
}
}
} else if (requestCode == server_settings) {
@@ -474,7 +488,7 @@ public boolean onNoteLongClick(int position, View v) {
@Override
public void onBackPressed() {
- if (searchView.isIconified()) {
+ if (searchView==null || searchView.isIconified()) {
super.onBackPressed();
} else {
searchView.setIconified(true);
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/widget/SingleNoteWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/android/widget/SingleNoteWidget.java
index b82d91463..6ebc7bebd 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/widget/SingleNoteWidget.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/widget/SingleNoteWidget.java
@@ -22,7 +22,8 @@ public class SingleNoteWidget extends AppWidgetProvider {
public static void updateAppWidget(DBNote note, Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_single_note);
if (note != null) {
- updateViews.setTextViewText(R.id.single_note_content, note.getSpannableContent());
+ //TODO switch to RxMD
+ //updateViews.setTextViewText(R.id.single_note_content, note.getSpannableContent());
Intent intent = new Intent(context, EditNoteActivity.class);
intent.putExtra(EditNoteActivity.PARAM_NOTE, note);
// http://stackoverflow.com/questions/4011178/multiple-instances-of-widget-only-updating-last-widget
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/OwnCloudNote.java b/app/src/main/java/it/niedermann/owncloud/notes/model/CloudNote.java
similarity index 89%
rename from app/src/main/java/it/niedermann/owncloud/notes/model/OwnCloudNote.java
rename to app/src/main/java/it/niedermann/owncloud/notes/model/CloudNote.java
index 9c228d336..da1e74b4b 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/model/OwnCloudNote.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/model/CloudNote.java
@@ -9,17 +9,17 @@
import it.niedermann.owncloud.notes.util.NoteUtil;
/**
- * OwnCloudNote represents a remote note from an OwnCloud server.
+ * CloudNote represents a remote note from an OwnCloud server.
* It can be directly generated from the JSON answer from the server.
*/
-public class OwnCloudNote implements Serializable {
+public class CloudNote implements Serializable {
private long remoteId = 0;
private String title = "";
private Calendar modified = null;
private String content = "";
private boolean favorite = false;
- public OwnCloudNote(long remoteId, Calendar modified, String title, String content, boolean favorite) {
+ public CloudNote(long remoteId, Calendar modified, String title, String content, boolean favorite) {
this.remoteId = remoteId;
if (title != null)
setTitle(title);
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java b/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java
index 7ced944fb..887e33184 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/model/DBNote.java
@@ -8,9 +8,9 @@
/**
* DBNote represents a single note from the local SQLite database with all attributes.
- * It extends OwnCloudNote with attributes required for local data management.
+ * It extends CloudNote with attributes required for local data management.
*/
-public class DBNote extends OwnCloudNote implements Item, Serializable {
+public class DBNote extends CloudNote implements Item, Serializable {
private long id;
private DBStatus status;
@@ -43,11 +43,6 @@ private void setExcerpt(String content) {
excerpt = NoteUtil.generateNoteExcerpt(content);
}
- public CharSequence getSpannableContent() {
- // TODO Cache the generated CharSequence not possible because CharSequence does not implement Serializable
- return NoteUtil.parseMarkDown(getContent());
- }
-
public void setContent(String content) {
super.setContent(content);
setExcerpt(content);
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteSQLiteOpenHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteSQLiteOpenHelper.java
index 50a1ae85b..df9a05a26 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteSQLiteOpenHelper.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteSQLiteOpenHelper.java
@@ -16,7 +16,7 @@
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.DBStatus;
-import it.niedermann.owncloud.notes.model.OwnCloudNote;
+import it.niedermann.owncloud.notes.model.CloudNote;
import it.niedermann.owncloud.notes.util.ICallback;
import it.niedermann.owncloud.notes.util.NoteUtil;
@@ -102,8 +102,19 @@ public Context getContext() {
*/
@SuppressWarnings("UnusedReturnValue")
public long addNoteAndSync(String content) {
- DBNote note = new DBNote(0, 0, Calendar.getInstance(), NoteUtil.generateNoteTitle(content), content, false, DBStatus.LOCAL_EDITED);
- long id = addNote(note);
+ CloudNote note = new CloudNote(0, Calendar.getInstance(), NoteUtil.generateNoteTitle(content), content, false);
+ return addNoteAndSync(note);
+ }
+
+ /**
+ * Creates a new Note in the Database and adds a Synchronization Flag.
+ *
+ * @param note Note
+ */
+ @SuppressWarnings("UnusedReturnValue")
+ public long addNoteAndSync(CloudNote note) {
+ DBNote dbNote = new DBNote(0, 0, note.getModified(), note.getTitle(), note.getContent(), note.isFavorite(), DBStatus.LOCAL_EDITED);
+ long id = addNote(dbNote);
getNoteServerSyncHelper().scheduleSync(true);
return id;
}
@@ -112,9 +123,9 @@ public long addNoteAndSync(String content) {
* Inserts a note directly into the Database.
* No Synchronisation will be triggered! Use addNoteAndSync()!
*
- * @param note Note to be added. Remotely created Notes must be of type OwnCloudNote and locally created Notes must be of Type DBNote (with DBStatus.LOCAL_EDITED)!
+ * @param note Note to be added. Remotely created Notes must be of type CloudNote and locally created Notes must be of Type DBNote (with DBStatus.LOCAL_EDITED)!
*/
- long addNote(OwnCloudNote note) {
+ long addNote(CloudNote note) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
if(note instanceof DBNote) {
@@ -312,7 +323,7 @@ public DBNote updateNoteAndSync(DBNote oldNote, String newContent, ICallback cal
*
* @return The number of the Rows affected.
*/
- int updateNote(long id, OwnCloudNote remoteNote, DBNote forceUnchangedDBNoteState) {
+ int updateNote(long id, CloudNote remoteNote, DBNote forceUnchangedDBNoteState) {
SQLiteDatabase db = this.getWritableDatabase();
// First, update the remote ID, since this field cannot be changed in parallel, but have to be updated always.
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
index 6090f9163..76203615d 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java
@@ -25,9 +25,9 @@
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.activity.SettingsActivity;
+import it.niedermann.owncloud.notes.model.CloudNote;
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.DBStatus;
-import it.niedermann.owncloud.notes.model.OwnCloudNote;
import it.niedermann.owncloud.notes.util.ICallback;
import it.niedermann.owncloud.notes.util.NotesClient;
import it.niedermann.owncloud.notes.util.NotesClientUtil.LoginStatus;
@@ -215,14 +215,18 @@ private void pushLocalChanges() {
for (DBNote note : notes) {
Log.d(getClass().getSimpleName(), " Process Local Note: "+note);
try {
- OwnCloudNote remoteNote=null;
+ CloudNote remoteNote=null;
switch(note.getStatus()) {
case LOCAL_EDITED:
Log.d(getClass().getSimpleName(), " ...create/edit");
// if note is not new, try to edit it.
if (note.getRemoteId()>0) {
Log.d(getClass().getSimpleName(), " ...try to edit");
- remoteNote = client.editNote(note);
+ try {
+ remoteNote = client.editNote(note);
+ } catch(FileNotFoundException e) {
+ // Note does not exists anymore
+ }
}
// However, the note may be deleted on the server meanwhile; or was never synchronized -> (re)create
// Please note, thas dbHelper.updateNote() realizes an optimistic conflict resolution, which is required for parallel changes of this Note from the UI.
@@ -268,10 +272,10 @@ private LoginStatus pullRemoteChanges() {
for (DBNote note : localNotes) {
localIDmap.put(note.getRemoteId(), note.getId());
}
- List remoteNotes = client.getNotes();
+ List remoteNotes = client.getNotes();
Set remoteIDs = new HashSet<>();
// pull remote changes: update or create each remote note
- for (OwnCloudNote remoteNote : remoteNotes) {
+ for (CloudNote remoteNote : remoteNotes) {
Log.d(getClass().getSimpleName(), " Process Remote Note: "+remoteNote);
remoteIDs.add(remoteNote.getRemoteId());
if(localIDmap.containsKey(remoteNote.getRemoteId())) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java
new file mode 100644
index 000000000..32194b082
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/util/MarkDownUtil.java
@@ -0,0 +1,32 @@
+package it.niedermann.owncloud.notes.util;
+
+import android.content.Context;
+import android.support.v4.content.res.ResourcesCompat;
+
+import com.yydcdut.rxmarkdown.RxMDConfiguration;
+
+import it.niedermann.owncloud.notes.R;
+
+/**
+ * Created by stefan on 07.12.16.
+ */
+
+public class MarkDownUtil {
+
+ /**
+ * Ensures every instance of RxMD uses the same configuration
+ *
+ * @param context Context
+ * @return RxMDConfiguration
+ */
+ public static RxMDConfiguration getMarkDownConfiguration(Context context) {
+ return new RxMDConfiguration.Builder(context)
+ .setHeader2RelativeSize(1.35f)
+ .setHeader3RelativeSize(1.25f)
+ .setHeader4RelativeSize(1.15f)
+ .setHeader5RelativeSize(1.1f)
+ .setHeader6RelativeSize(1.05f)
+ .setLinkColor(ResourcesCompat.getColor(context.getResources(), R.color.primary, null))
+ .build();
+ }
+}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java
index e17ec78bf..4e4bf42ce 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/util/NoteUtil.java
@@ -2,15 +2,11 @@
import java.util.regex.Pattern;
-import in.uncod.android.bypass.Bypass;
-
/**
* Provides basic functionality for Note operations.
* Created by stefan on 06.10.15.
*/
public class NoteUtil {
- private static final Bypass bypass = new Bypass();
-
private static final Pattern pLists = Pattern.compile("^\\s*[*+-]\\s+", Pattern.MULTILINE);
private static final Pattern pHeadings = Pattern.compile("^#+\\s+(.*?)\\s*#*$", Pattern.MULTILINE);
private static final Pattern pHeadingLine = Pattern.compile("^(?:=*|-*)$", Pattern.MULTILINE);
@@ -18,29 +14,6 @@ public class NoteUtil {
private static final Pattern pSpace1 = Pattern.compile("^\\s+", Pattern.MULTILINE);
private static final Pattern pSpace2 = Pattern.compile("\\s+$", Pattern.MULTILINE);
- /**
- * Parses a MarkDown-String and returns a Spannable
- *
- * @param s String - MarkDown
- * @return Spannable
- */
- public static CharSequence parseMarkDown(String s) {
- /*
- * Appends two spaces at the end of every line to force a line break.
- *
- * @see #24
- */
- StringBuilder sb = new StringBuilder();
- for (String line : s.split("\n")) {
- sb.append(line);
- // If line is not a list item
- if (!line.trim().matches("^([\\-*]|[0-9]+\\.)(.)*")) {
- sb.append(" ");
- }
- sb.append("\n");
- }
- return bypass.markdownToSpannable(sb.toString());
- }
/**
* Strips all MarkDown from the given String
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClient.java b/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClient.java
index 613cff013..f1b161d95 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClient.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClient.java
@@ -19,7 +19,7 @@
import java.util.GregorianCalendar;
import java.util.List;
-import it.niedermann.owncloud.notes.model.OwnCloudNote;
+import it.niedermann.owncloud.notes.model.CloudNote;
public class NotesClient {
@@ -43,7 +43,7 @@ public NotesClient(String url, String username, String password) {
this.password = password;
}
- private OwnCloudNote getNoteFromJSON(JSONObject json) throws JSONException {
+ private CloudNote getNoteFromJSON(JSONObject json) throws JSONException {
long noteId = 0;
String noteTitle = "";
String noteContent = "";
@@ -65,11 +65,11 @@ private OwnCloudNote getNoteFromJSON(JSONObject json) throws JSONException {
if (!json.isNull(key_favorite)) {
noteFavorite = json.getBoolean(key_favorite);
}
- return new OwnCloudNote(noteId, noteModified, noteTitle, noteContent, noteFavorite);
+ return new CloudNote(noteId, noteModified, noteTitle, noteContent, noteFavorite);
}
- public List getNotes() throws JSONException, IOException {
- List notesList = new ArrayList<>();
+ public List getNotes() throws JSONException, IOException {
+ List notesList = new ArrayList<>();
JSONArray notes = new JSONArray(requestServer("notes", METHOD_GET, null));
for (int i = 0; i < notes.length(); i++) {
JSONObject json = notes.getJSONObject(i);
@@ -87,12 +87,12 @@ public List getNotes() throws JSONException, IOException {
* @throws IOException
*/
@SuppressWarnings("unused")
- public OwnCloudNote getNoteById(long id) throws JSONException, IOException {
+ public CloudNote getNoteById(long id) throws JSONException, IOException {
JSONObject json = new JSONObject(requestServer("notes/" + id, METHOD_GET, null));
return getNoteFromJSON(json);
}
- private OwnCloudNote putNote(OwnCloudNote note, String path, String method) throws JSONException, IOException {
+ private CloudNote putNote(CloudNote note, String path, String method) throws JSONException, IOException {
JSONObject paramObject = new JSONObject();
paramObject.accumulate(key_content, note.getContent());
paramObject.accumulate(key_modified, note.getModified().getTimeInMillis()/1000);
@@ -104,16 +104,16 @@ private OwnCloudNote putNote(OwnCloudNote note, String path, String method) thr
/**
* Creates a Note on the Server
*
- * @param note {@link OwnCloudNote} - the new Note
+ * @param note {@link CloudNote} - the new Note
* @return Created Note including generated Title, ID and lastModified-Date
* @throws JSONException
* @throws IOException
*/
- public OwnCloudNote createNote(OwnCloudNote note) throws JSONException, IOException {
+ public CloudNote createNote(CloudNote note) throws JSONException, IOException {
return putNote(note, "notes", METHOD_POST);
}
- public OwnCloudNote editNote(OwnCloudNote note) throws JSONException, IOException {
+ public CloudNote editNote(CloudNote note) throws JSONException, IOException {
return putNote(note, "notes/" + note.getRemoteId(), METHOD_PUT);
}
diff --git a/app/src/main/res/drawable-hdpi/ic_launcher.png b/app/src/main/res/drawable-hdpi/ic_launcher.png
index e376e0f7c..65aa97bce 100644
Binary files a/app/src/main/res/drawable-hdpi/ic_launcher.png and b/app/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_launcher.png b/app/src/main/res/drawable-mdpi/ic_launcher.png
index 437cb6240..c0172e149 100644
Binary files a/app/src/main/res/drawable-mdpi/ic_launcher.png and b/app/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_launcher.png b/app/src/main/res/drawable-xhdpi/ic_launcher.png
index 1f78b58f6..1a58d7b65 100644
Binary files a/app/src/main/res/drawable-xhdpi/ic_launcher.png and b/app/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/app/src/main/res/drawable-xxhdpi/ic_launcher.png
index 395c904e8..ed2f9f470 100644
Binary files a/app/src/main/res/drawable-xxhdpi/ic_launcher.png and b/app/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_launcher.png b/app/src/main/res/drawable-xxxhdpi/ic_launcher.png
new file mode 100644
index 000000000..c4c4dc343
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/layout/activity_create.xml b/app/src/main/res/layout/activity_create.xml
index 69e48fdcd..a3392deab 100644
--- a/app/src/main/res/layout/activity_create.xml
+++ b/app/src/main/res/layout/activity_create.xml
@@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
- Gespeichert
Abbrechen
Notiz auswählen
+ Notiz wurde gelöscht
+ Notiz wurde wiederhergestellt
+ Rückgängig
Über
Löschen
Kopieren
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 8f9ff482a..4f381f50f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,7 +3,7 @@
#0082C9
- #112233
+ #286090
#d2d2d2
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 530a9fe79..e37328719 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -14,6 +14,9 @@
Cancel
About
Select note
+ Note is deleted
+ Note is restored
+ Undo
Delete
Copy
Edit
diff --git a/demo-1.png b/demo-1.png
deleted file mode 100644
index 6d0d5d038..000000000
Binary files a/demo-1.png and /dev/null differ
diff --git a/demo-2.png b/demo-2.png
deleted file mode 100644
index 5b9d74404..000000000
Binary files a/demo-2.png and /dev/null differ
diff --git a/demo-edit.png b/demo-edit.png
new file mode 100644
index 000000000..f971fa089
Binary files /dev/null and b/demo-edit.png differ
diff --git a/demo-list.png b/demo-list.png
new file mode 100644
index 000000000..23d12340f
Binary files /dev/null and b/demo-list.png differ
diff --git a/ic_launcher.svg b/ic_launcher.svg
index 056e9c818..54bd1c6c0 100644
--- a/ic_launcher.svg
+++ b/ic_launcher.svg
@@ -48,8 +48,8 @@
y="32"
x="32"
id="rect4"
- style="fill:#1d2d44" />
\ No newline at end of file
+ id="path4" />
diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml
new file mode 100644
index 000000000..209b211e9
--- /dev/null
+++ b/projectFilesBackup/.idea/workspace.xml
@@ -0,0 +1,2666 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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