Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-06-13 14:15:16 +0300
committerStefan Niedermann <info@niedermann.it>2020-06-13 14:15:16 +0300
commite63eb19ce41f367895db4f5da4c811303d0153b4 (patch)
treefcb1f95aa91bdac10262a2a22d08f8fa14ba1339 /app/src/main/java
parentbe0260950bdfc3e95267ddacf154aa6923e3e7a2 (diff)
Adjust icon style to master
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java78
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java8
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_17_18.java14
3 files changed, 37 insertions, 63 deletions
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 7b955de2..7caa120a 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
@@ -7,7 +7,6 @@ import android.content.Intent;
import android.database.sqlite.SQLiteException;
import android.graphics.Color;
import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@@ -137,8 +136,6 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi
protected ItemAdapter adapter;
- private Menu currentMenu;
-
protected NotesDatabase db = null;
private NavigationAdapter adapterCategories;
private NavigationItem itemRecent;
@@ -397,6 +394,23 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi
}
startActivityForResult(createIntent, create_note_cmd);
});
+
+ activityBinding.sortingMethod.setOnClickListener((v) -> {
+ final String unexpectedSortMethod = "Unexpected sort method";
+ CategorySortingMethod method;
+
+ Log.d("onOptionsItemSelected", navigationSelection.category + localAccount.getId());
+ method = db.getCategoryOrder(localAccount.getId(), navigationSelection);
+
+ if (method == CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC) {
+ method = CategorySortingMethod.SORT_MODIFIED_DESC;
+ } else {
+ method = CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC;
+ }
+ db.modifyCategoryOrder(localAccount.getId(), navigationSelection, method);
+ refreshLists();
+ updateSortMethodIcon();
+ });
}
private void setupNavigationList(final String selectedItem) {
@@ -690,69 +704,17 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi
* Updates sorting method icon.
*/
private void updateSortMethodIcon() {
- if (localAccount == null || currentMenu == null) {
+ if (localAccount == null) {
return;
}
- MenuItem sortMethod = currentMenu.findItem(R.id.sorting_method);
CategorySortingMethod method = db.getCategoryOrder(localAccount.getId(), navigationSelection);
if (method == CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC) {
- sortMethod.setIcon(R.drawable.alphabetical_asc);
- } else {
- sortMethod.setIcon(R.drawable.modification_desc);
- }
- }
-
- /**
- * Responses to two sorting method icons on the menu.
- * @param item The touched item.
- * @return boolean
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- final String unexpectedSortMethod = "Unexpected sort method";
- CategorySortingMethod method;
-
- if (item.getItemId() == R.id.sorting_method) {
- Log.d("onOptionsItemSelected", navigationSelection.category + localAccount.getId());
- method = db.getCategoryOrder(localAccount.getId(), navigationSelection);
-
- if (method == CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC) {
- method = CategorySortingMethod.SORT_MODIFIED_DESC;
- } else {
- method = CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC;
- }
- db.modifyCategoryOrder(localAccount.getId(), navigationSelection, method);
- refreshLists();
- return true;
+ activityBinding.sortingMethod.setImageResource(R.drawable.alphabetical_asc);
} else {
- return super.onOptionsItemSelected(item);
+ activityBinding.sortingMethod.setImageResource(R.drawable.modification_desc);
}
}
- /**
- * Gets menu object.
- * @param menu Menu.
- * @return boolean
- */
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- currentMenu = menu;
- updateSortMethodIcon();
- return super.onPrepareOptionsMenu(menu);
- }
-
- /**
- * Adds the Menu Items to the Action Bar.
- *
- * @param menu Menu
- * @return boolean
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_list_view, menu);
- return true;
- }
-
@Override
protected void onNewIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
index 66635dd6..c97f4368 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
@@ -14,6 +14,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_13_14;
import it.niedermann.owncloud.notes.persistence.migration.Migration_14_15;
import it.niedermann.owncloud.notes.persistence.migration.Migration_15_16;
import it.niedermann.owncloud.notes.persistence.migration.Migration_16_17;
+import it.niedermann.owncloud.notes.persistence.migration.Migration_17_18;
import it.niedermann.owncloud.notes.persistence.migration.Migration_4_5;
import it.niedermann.owncloud.notes.persistence.migration.Migration_5_6;
import it.niedermann.owncloud.notes.persistence.migration.Migration_6_7;
@@ -60,7 +61,6 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
protected static final String key_theme_mode = "THEME_MODE";
protected static final String key_mode = "MODE";
protected static final String key_scroll_y = "SCROLL_Y";
-
protected static final String key_category_sorting_method = "CATEGORY_SORTING_METHOD";
protected AbstractNotesDatabase(@NonNull Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory) {
@@ -189,10 +189,8 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
new Migration_15_16(db, context, this::notifyWidgets);
case 16:
new Migration_16_17(db);
- case 17: {
- // add a new column to store the sorting method for a category note list
- db.execSQL("ALTER TABLE " + table_category + " ADD COLUMN " + key_category_sorting_method + " INTEGER DEFAULT 0");
- }
+ case 17:
+ new Migration_17_18(db);
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_17_18.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_17_18.java
new file mode 100644
index 00000000..6faa9016
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_17_18.java
@@ -0,0 +1,14 @@
+package it.niedermann.owncloud.notes.persistence.migration;
+
+import android.database.sqlite.SQLiteDatabase;
+
+import androidx.annotation.NonNull;
+
+public class Migration_17_18 {
+ /**
+ * Add a new column to store the sorting method for a category note list
+ */
+ public Migration_17_18(@NonNull SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE CATEGORIES ADD COLUMN CATEGORY_SORTING_METHOD INTEGER DEFAULT 0");
+ }
+}