Logan676 / anymemo

Automatically exported from code.google.com/p/anymemo
GNU General Public License v2.0
0 stars 0 forks source link

Sort categories alphabetically #284

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As mentioned here: http://anymemo.org/forum/viewtopic.php?f=3&t=468

Categories are currently unsorted which is a bit of a problem when you have 
more than 20 or so categories. Here is a simple patch I am using to fix this 
problem.

diff --git a/src/org/liberty/android/fantastischmemo/dao/CategoryDaoImpl.java 
b/src/org/liberty/android/fantastischmemo/dao/CategoryDaoImpl.jav
index cbae4d1..a4eef43 100644
--- a/src/org/liberty/android/fantastischmemo/dao/CategoryDaoImpl.java
+++ b/src/org/liberty/android/fantastischmemo/dao/CategoryDaoImpl.java
@@ -23,6 +23,17 @@ public class CategoryDaoImpl extends 
AbstractHelperDaoImpl<Category, Integer> im
         super(connectionSource, clazz);
     }

+    @Override
+    public List<Category> queryForAll() {
+        try {
+            QueryBuilder query = queryBuilder();
+            query.orderBy("name", true);
+            return query.query();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+     }
+

Original issue reported on code.google.com by rogerkea...@gmail.com on 12 Dec 2013 at 1:31

GoogleCodeExporter commented 9 years ago
Well, in the forum there are several discussions there however I accidently 
delete almost all posts during a spam clean up.

I believe the better way is for user to be able to move around the categories. 
Your patch will change the current behavior and break the users who want the 
categories in the order of creation. Sorry I cannot integrate this patch. 
However I will leave this issue open until we have a good solution.

Original comment by mrlhwlib...@gmail.com on 13 Dec 2013 at 11:12

GoogleCodeExporter commented 9 years ago
Is there a workaround that could do this? I have several categories (maybe 25) 
on one deck and Im wondering how I could do this? 

Original comment by Neofireb...@gmail.com on 7 Jan 2014 at 1:42

GoogleCodeExporter commented 9 years ago
There is currently no easy workaround. The current list is ordered by when you 
added the category. Is there any use case for this behavior? If not I guess I 
can changed the behavior to sort alphabetically like  rogerkeays.RK did.

Original comment by mrlhwlib...@gmail.com on 7 Jan 2014 at 3:33

GoogleCodeExporter commented 9 years ago
I dont see why someone would need it by the date added to be honest. Though 
this is the first time Ive ever used a deck with a large amount of categories. 
Normally I use only 3 or 4 which are all viewable at once. Though, if a user 
needs them in a certain order of date they created the category. They could 
always prepend some numbers to it. Such as 01_Foobar, 02_Foobar, 03_Foobar, 
04_Foobar. That's my thought on it.

Original comment by Neofireb...@gmail.com on 7 Jan 2014 at 12:08

GoogleCodeExporter commented 9 years ago
You could always add an option to sorted by date added if you absolutely must 
have backwards compatibility. Otherwise alphabetical sort would probably be a 
more sensible default.

Original comment by rogerkea...@gmail.com on 7 Jan 2014 at 12:12

GoogleCodeExporter commented 9 years ago
Personally I don't want to add an option. I will tentatively change it to 
sorting alphabetically and see if there are complains. There are some languages 
that does not have alphabetical order and I wonder how the lexicographical 
order is defined in languages like Chinese and Japanese's Kanji.

Original comment by mrlhwlib...@gmail.com on 7 Jan 2014 at 6:36

GoogleCodeExporter commented 9 years ago
The implementation is also more complicated than  rogerkeays.RK's code. It 
doesn't sort:
1. Newly added category
2. Modified category
Also after sorting, the newly added or modified category's radio box should be 
checked.

Original comment by mrlhwlib...@gmail.com on 7 Jan 2014 at 11:57

GoogleCodeExporter commented 9 years ago
Ok this is the actual change:
http://code.google.com/p/anymemo/source/detail?r=adb082b3a166502f2d79228e0627714
7936465b7

Please verify it and let me know if there are problems in tomorrow's nightly 
build. Otherwise I will keep this issue closed.

Original comment by mrlhwlib...@gmail.com on 8 Jan 2014 at 1:42

GoogleCodeExporter commented 9 years ago
I tried the latest build #82 and the lists are sorted alphanumerically now. Can 
confirm it works for me T

(Though, now the application will close when I use the application switcher on 
my device.)

Original comment by Neofireb...@gmail.com on 9 Jan 2014 at 12:55

GoogleCodeExporter commented 9 years ago
Could you tell me when it crashes? I tried to go to category dialog and then 
switch applications and it seems working fine.

Original comment by mrlhwlib...@gmail.com on 9 Jan 2014 at 11:15

GoogleCodeExporter commented 9 years ago
Sure. It happens when I open and view a large number of databases. I load maybe 
about 6-7 most containing 600-1000 words into the recent list. Then I "Study" 
one of those decks. I then, press the "HOME" key to Android, I may open another 
app (usually the Browser), I hold "HOME" again to get the appliation switcher 
and select Anymemo. I recieve the error message "Unfortunately, Anymemo has 
stopped". 

I tried reusing the previous nightlies from December 22, 2013 and December 24, 
2013 and they do not have this issue. Something seemed to have changed since 
then when it tries to redraw (or render the screen) because I tried Nightly #82 
and Nightly #80 and the problem happens. So the problem may've started to 
somewhere between builds of Nightlies #76 and #80

Original comment by Neofireb...@gmail.com on 10 Jan 2014 at 11:41

GoogleCodeExporter commented 9 years ago
Between that time, there were a very big change for issue 101. I completely 
rewrite the display code in AnyMemo. So it is quite hard to pin-point where the 
error would be. I don't know if you are able to get the android logs using and 
app called "CatLog" or plain adb logcat command line. That would be really 
helpful. My phone's memory is too large to reproduce the issue, I will try some 
emulator.

Original comment by mrlhwlib...@gmail.com on 10 Jan 2014 at 11:51

GoogleCodeExporter commented 9 years ago
Ok, I can get it after trying a lot for 20 minutes finally I reproduce it once. 
The crash is unrelated to category changes. I opened issue 295 for you and 
close this bug.

Original comment by mrlhwlib...@gmail.com on 11 Jan 2014 at 12:13

GoogleCodeExporter commented 9 years ago

Original comment by mrlhwlib...@gmail.com on 6 Apr 2014 at 8:35

GoogleCodeExporter commented 9 years ago
I'm one person who liked having the categories in the order they were in the 
category database table (note: this is not necessarily the order they were 
added, since a user familiar with simple SQL statements can reorder categories 
as desired). I had sorted my categories so that they were in an order that made 
sense for the material I was studying (based on a logical progression from one 
topic to the next, with related topics together). Now that they are in 
alphabetical order, they are actually UNordered from my point of view, because 
the alphabetical order has no intrinsic meaning.

I'd very much like an option to not use alphabetical sorting. (Although for 
simplicity, it would probably be best if the option was labelled "sort 
categories alphabetically" and it was on by default, and then users who wanted 
database order could untick it.)

I'm aware of the workaround of adding 01, 02, 03, etc to the start of the 
category names, but this looks pretty ugly and takes up screen space that's at 
a premium on a small screen.

Original comment by lady.a...@gmail.com on 7 Apr 2014 at 10:04