Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rx markdown, Undo for "Swipe to delete", Nextcloud rebrand #164

Merged
merged 10 commits into from
Jan 19, 2017
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

<a href="https://play.google.com/store/apps/details?id=it.niedermann.owncloud.notes">
<img src="http://www.android.com/images/brand/android_app_on_play_large.png" alt="Download from Google Play" />
</a>
<a href="https://f-droid.org/repository/browse/?fdid=it.niedermann.owncloud.notes">
<img src="https://camo.githubusercontent.com/7df0eafa4433fa4919a56f87c3d99cf81b68d01c/68747470733a2f2f662d64726f69642e6f72672f77696b692f696d616765732f632f63342f462d44726f69642d627574746f6e5f617661696c61626c652d6f6e2e706e67" alt="ownCloud Notes App on fdroid.org" />
</a>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K7HVLE6J7SXXA">
<img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" alt="Donate with PayPal" />
</a>
[![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
Expand All @@ -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)
Expand All @@ -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).

18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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'])
}
Binary file modified app/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="24" />
android:targetSdkVersion="25" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
Expand Down Expand Up @@ -58,8 +58,8 @@
<activity
android:name="it.niedermann.owncloud.notes.android.activity.EditNoteActivity"
android:label="@string/menu_edit"
android:windowSoftInputMode="stateVisible"
android:parentActivityName="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity"></activity>
android:parentActivityName="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity"
android:windowSoftInputMode="stateVisible"></activity>
<activity
android:name="it.niedermann.owncloud.notes.android.activity.AboutActivity"
android:label="@string/menu_about"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
import android.support.v7.app.AppCompatActivity;
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 it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.persistence.NoteSQLiteOpenHelper;
import it.niedermann.owncloud.notes.util.MarkDownUtil;
import rx.Subscriber;

public class CreateNoteActivity extends AppCompatActivity {
private EditText editTextField = null;
private RxMDEditText editTextField = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create);
editTextField = (EditText) findViewById(R.id.createContent);
editTextField = (RxMDEditText) findViewById(R.id.createContent);

// Get intent, action and MIME type
Intent intent = getIntent();
Expand All @@ -29,6 +35,25 @@ protected void onCreate(Bundle savedInstanceState) {
editTextField.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
}
}

RxMarkdown.live(editTextField)
.config(MarkDownUtil.getMarkDownConfiguration(getApplicationContext()))
.factory(EditFactory.create())
.intoObservable()
.subscribe(new Subscriber<CharSequence>() {
@Override
public void onCompleted() {
}

@Override
public void onError(Throwable e) {
}

@Override
public void onNext(CharSequence charSequence) {
editTextField.setText(charSequence, TextView.BufferType.SPANNABLE);
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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;
Expand All @@ -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<CharSequence>() {
@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<CharSequence>() {
@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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading