diff --git a/app/app.iml b/app/app.iml index 62447734..d3a4160e 100644 --- a/app/app.iml +++ b/app/app.iml @@ -67,7 +67,6 @@ - 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 04474b53..912ed25e 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 @@ -6,6 +6,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.text.Editable; import android.text.TextWatcher; +import android.view.MenuItem; import android.widget.EditText; import java.util.Timer; @@ -23,6 +24,7 @@ public class EditNoteActivity extends AppCompatActivity { private EditText content = null; private Note note = null; private Timer timer = new Timer(); + private ActionBar actionBar; @Override protected void onCreate(final Bundle savedInstanceState) { @@ -34,6 +36,12 @@ public class EditNoteActivity extends AppCompatActivity { content.setEnabled(false); content.setText(note.getContent()); content.setEnabled(true); + actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setTitle(note.getTitle()); + actionBar.setSubtitle(getString(R.string.action_edit_editing)); + actionBar.setDisplayHomeAsUpEnabled(true); + } content.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, @@ -76,6 +84,22 @@ public class EditNoteActivity extends AppCompatActivity { finish(); } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + content.setEnabled(false); + saveData(); + Intent data = new Intent(); + data.setAction(Intent.ACTION_VIEW); + data.putExtra(NoteActivity.EDIT_NOTE, note); + setResult(RESULT_OK, data); + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + private void saveData() { ActionBar ab = getSupportActionBar(); if (ab != null) { 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 333f0f1a..71ab8093 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 @@ -168,7 +168,7 @@ public class NotesListViewActivity extends AppCompatActivity implements itemList.add(currentNote); } - adapter = new ItemAdapter(getApplicationContext(), itemList); + adapter = new ItemAdapter(itemList); ItemAdapter.setNoteClickListener(this); listView = (RecyclerView) findViewById(R.id.list_view); listView.setAdapter(adapter); @@ -223,9 +223,12 @@ public class NotesListViewActivity extends AppCompatActivity implements if (requestCode == create_note_cmd) { // Make sure the request was successful if (resultCode == RESULT_OK) { - Note createdNote = (Note) data.getExtras().getSerializable( + //not need because of db.synchronisation in createActivity + + /*Note createdNote = (Note) data.getExtras().getSerializable( CREATED_NOTE); - adapter.add(createdNote); + adapter.add(createdNote);*/ + setListView(db.getNotes()); } } else if (requestCode == show_single_note_cmd) { if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) { @@ -340,9 +343,12 @@ public class NotesListViewActivity extends AppCompatActivity implements for (Integer i : selection) { Note note = (Note) adapter.getItem(i); db.deleteNoteAndSync(note.getId()); - adapter.remove(note); + // Not needed because of dbsync + //adapter.remove(note); } mode.finish(); // Action picked, so close the CAB + //after delete selection has to be cleared + setListView(db.getNotes()); return true; default: return false; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java index a775b682..b5e4824f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java @@ -65,7 +65,7 @@ public class SelectSingleNoteActivity extends AppCompatActivity implements Adapt private void setListView(List noteList) { List itemList = new ArrayList<>(); itemList.addAll(noteList); - adapter = new ItemAdapter(getApplicationContext(), itemList); + adapter = new ItemAdapter(itemList); listView = (RecyclerView) findViewById(R.id.select_single_note_list_view); listView.setAdapter(adapter); listView.setLayoutManager(new LinearLayoutManager(this)); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java b/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java index 2813cfa4..8641ffc9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/ItemAdapter.java @@ -23,7 +23,7 @@ public class ItemAdapter extends RecyclerView.Adapter { private static NoteClickListener noteClickListener; private List itemList = null; private List selected = null; - public ItemAdapter(Context context, List itemList) { + public ItemAdapter(List itemList) { //super(context, android.R.layout.simple_list_item_1, itemList); super(); this.itemList = itemList; diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 5ad19a91..c9f61b56 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -7,6 +7,7 @@ Einstellungen Speichern Abbrechen + Bearbeiten Speichern Speichern… Gespeichert diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79a2d494..293112ac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,7 @@ Settings Save Cancel + Edit Save Saving… Saved