mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-23 13:26:15 +03:00
Add icon and frontend code
This commit is contained in:
parent
c9da790226
commit
3dab7989ff
6 changed files with 80 additions and 2 deletions
|
@ -4,6 +4,7 @@ import android.app.SearchManager;
|
|||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.sqlite.SQLiteConstraintException;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -68,6 +69,7 @@ import it.niedermann.owncloud.notes.persistence.LoadNotesListTask;
|
|||
import it.niedermann.owncloud.notes.persistence.LoadNotesListTask.NotesLoadedListener;
|
||||
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper;
|
||||
import it.niedermann.owncloud.notes.persistence.NotesDatabase;
|
||||
import it.niedermann.owncloud.notes.util.CategorySortingMethod;
|
||||
import it.niedermann.owncloud.notes.util.NoteUtil;
|
||||
|
||||
import static it.niedermann.owncloud.notes.util.SSOUtil.askForNewAccount;
|
||||
|
@ -109,6 +111,8 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
|
|||
|
||||
protected ItemAdapter adapter = null;
|
||||
|
||||
private Menu currentMenu;
|
||||
|
||||
protected NotesDatabase db = null;
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
private NavigationAdapter adapterCategories;
|
||||
|
@ -368,7 +372,6 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
|
|||
|
||||
private void selectItem(NavigationItem item, boolean closeNavigation) {
|
||||
adapterCategories.setSelectedItem(item.id);
|
||||
|
||||
// update current selection
|
||||
if (itemRecent.equals(item)) {
|
||||
navigationSelection = new Category(null, null);
|
||||
|
@ -606,6 +609,46 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
|
|||
new LoadCategoryListTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.getCategoryOrderByTitle(localAccount.getId(), navigationSelection.category);
|
||||
|
||||
if (method == CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC) {
|
||||
item.setIcon(R.drawable.modification_desc);
|
||||
method = CategorySortingMethod.SORT_MODIFIED_DESC;
|
||||
} else {
|
||||
item.setIcon(R.drawable.alphabetical_asc);
|
||||
method = CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC;
|
||||
}
|
||||
db.modifyCategoryOrderByTitle(localAccount.getId(), navigationSelection.category, method);
|
||||
refreshLists();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates sorting method icons.
|
||||
* @param menu Menu.
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
currentMenu = menu;
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Menu Items to the Action Bar.
|
||||
|
@ -873,5 +916,12 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
|
|||
mActionMode.finish();
|
||||
searchView.setIconified(true);
|
||||
refreshLists();
|
||||
|
||||
CategorySortingMethod method = db.getCategoryOrderByTitle(localAccount.getId(), navigationSelection.category);
|
||||
if (method == CategorySortingMethod.SORT_LEXICOGRAPHICAL_ASC) {
|
||||
currentMenu.findItem(R.id.sorting_method).setIcon(R.drawable.alphabetical_asc);
|
||||
} else {
|
||||
currentMenu.findItem(R.id.sorting_method).setIcon(R.drawable.modification_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
app/src/main/res/drawable/alphabetical_asc.xml
Normal file
11
app/src/main/res/drawable/alphabetical_asc.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="26dp"
|
||||
android:height="26dp"
|
||||
android:viewportWidth="26"
|
||||
android:viewportHeight="26">
|
||||
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M20.401,13.623L18.877,13.621L18.868,20.218L17.228,18.57L16.145,19.651L19.627,23.145L23.12,19.663L22.039,18.58L20.392,20.219L20.401,13.623ZM15.034,12.122L15.034,13.376L10.691,19.609L10.691,19.684L15.1,19.684L15.1,21.481L7.847,21.481L7.847,20.302L12.292,13.967L12.292,13.91L8.268,13.91L8.268,12.122L15.034,12.122ZM13.051,1.85L15.981,11.208L13.678,11.208L12.949,8.68L10.244,8.68L9.571,11.208L7.352,11.208L10.244,1.85L13.051,1.85ZM12.64,7.165L12.05,5.182L11.807,4.273L11.573,3.374L11.545,3.374L11.339,4.283L11.114,5.2L10.553,7.165L12.64,7.165Z" />
|
||||
</vector>
|
11
app/src/main/res/drawable/modification_desc.xml
Normal file
11
app/src/main/res/drawable/modification_desc.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="26dp"
|
||||
android:height="26dp"
|
||||
android:viewportWidth="26"
|
||||
android:viewportHeight="26">
|
||||
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M23.563,22.69L14.635,22.69L14.635,20.838L23.563,20.838L23.563,22.69ZM11.59,2.133C16.177,2.138 20.131,5.479 20.902,10L18.979,10C18.232,6.53 15.139,4.029 11.59,4.025C7.44,4.026 4.026,7.44 4.025,11.59C4.025,15.74 7.44,19.156 11.59,19.156C12.068,19.155 12.546,19.109 13.016,19.018L13.016,20.922C12.544,21 12.068,21.043 11.59,21.049C6.36,21.049 2.133,16.791 2.133,11.59C2.133,6.402 6.402,2.133 11.59,2.133ZM20.587,18.06L14.635,18.06L14.635,16.208L20.587,16.208L20.587,18.06ZM12.062,6.863L12.062,11.826L13.016,12.393L13.016,13.957L10.645,12.535L10.645,6.863L12.062,6.863ZM17.611,13.429L14.635,13.429L14.635,11.577L17.611,11.577L17.611,13.429Z" />
|
||||
</vector>
|
|
@ -21,7 +21,7 @@
|
|||
app:elevation="4dp"
|
||||
app:titleMarginStart="0dp"
|
||||
tools:navigationIcon="@drawable/ic_arrow_back_white_24dp"
|
||||
tools:title="@string/app_name" />
|
||||
tools:title="@string/app_name"/>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swiperefreshlayout"
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.owncloudnotes.NotesListViewActivity">
|
||||
<item
|
||||
android:id="@+id/sorting_method"
|
||||
android:title="@string/action_sorting_method"
|
||||
android:icon="@drawable/alphabetical_asc"
|
||||
app:showAsAction="collapseActionView|always" />
|
||||
<item
|
||||
android:id="@+id/search"
|
||||
android:title="@string/action_search"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="action_settings">Settings</string>
|
||||
<string name="action_trashbin">Deleted notes</string>
|
||||
<string name="action_search">Search</string>
|
||||
<string name="action_sorting_method">Sorting method</string>
|
||||
<string name="simple_cancel">Cancel</string>
|
||||
<string name="simple_edit">Edit</string>
|
||||
<string name="action_edit_save">Save</string>
|
||||
|
|
Loading…
Reference in a new issue