Orgzly-android: Resort the search results by time in agenda view

Created on 24 Feb 2018  路  14Comments  路  Source: orgzly/orgzly-android

It would better resort the result and display by time in agenda view, currently in any day this will show the newly created task to the top, even though its s/d is anytime.

feature

Most helpful comment

Following figure is a sample for this issue:

resortresults

All 14 comments

Following figure is a sample for this issue:

resortresults

This also affects the widget.

Maintainers, feel free to point me out to a set of files or give thoughts on how to attack this if you'd like a PR, I can give it a shot.

It should be a matter or building the list in AgendaItems in the right order.

Cool. I'm working on this one.

The AgendaItems doesn't seem to be available in the test directories.
Do we want to keep it private and untested or should I expose it to add some tests for this task?

Since I have no clue about the code-base I'm writing tests to understand it, anyway, so they'll be an easy inclusion should I reach a solution.

Sure, though other two methods in that object are not private, perhaps they could be used.

If someone could figure this out it would be awesome! I want to use the orgzly widget as a calendar but I can't because not having search results for each day sorted by time is too unclear for that purpose.

@Bujiraso Are you still working on this? It'd be great, esp. for the agenda widget! :)

I can't get IntelliJ to run the tests so that halted my development on this.
If anyone can stop it from saying "Test events were not received" on classes like com.orgzly.android.ui.ImageLoaderTest (my new one is similar), that would be appreciated.

Then I could try again at this, as I know where the fix is needed and roughly how to do it (at least in a Java way)

If anyone can stop it from saying "Test events were not received" on classes like com.orgzly.android.ui.ImageLoaderTest (my new one is similar), that would be appreciated.

Perhaps it's https://youtrack.jetbrains.com/issue/IDEA-221159? Are you running it as Android test? Do you get it only for some classes? And which IntelliJ version is that?

Ah! Yes thank you -- it seems I needed to change "Build, Execution, Deployment" -> "Gradle" -> "Run Tests Using" to IntelliJ and then I got past that.
I'll give it another go!

Update -- it works

I have a candidate commit on https://github.com/Bujiraso/orgzly-android/tree/298-sorting wherein the sub-day sorting seems to be working.

Basic AVD Test

A basic test on my AVD shows it working.

Here's input:

Screenshot_1570302341
## Here's output
Screenshot_1570302136

Build Issues

I can't get an APK to try it on my device, I'm seeing this error:

  ...

  Errors found:

  C:\Users\Bujiraso\StudioProjects\orgzly-android\app\build.gradle: Error: xpp3 defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
  C:\Users\Bujiraso\StudioProjects\orgzly-android\app\src\main\java\com\orgzly\android\prefs\AppPreferences.java:774: Error: Field requires API level 19 (current min is 16): android.os.Environment#DIRECTORY_DOCUMENTS [NewApi]
          File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 51s

Requesting Code Review &/ Adoption

Since I'm quite new to Android, Kotlin and Orgzly development, I think I'm quite far out of my knowledge on this one I would appreciate feedback or -- even better -- commits to clean up the work I've done.
For instance, the test isn't great and I don't think it tests right, so I'm happy to squash in commits/branches/patches for that or anything else.

I don't know the processes here so let me know if we want a PR or what not.

Thanks

Thank you.

This seems to be using only note's scheduled time? And not honoring repeaters?

In agenda, a set of time instances (AgendaItem.Note) are created from each note. Note's scheduled, deadline and event times are used and expanded using that time's repeater. Those are the time instances which should be used when comparing.

I would suggest creating a parameterized test like AgendaUtilsTest so it's easier to modify and read. Parameter could be number of agenda days, notebook content (from which you'd create a list of NoteViews) and the resulting list of AgendaItems instances (just divider content and note title are enough).

One example of a test which should pass (illustrating OP's issue):

data class Parameter(val agendaDays: Int, val bookContent: String, val agendaItems: List<String>)

Parameter(
        agendaDays = 2,
        bookContent = """ 
                    * Times can have a repeater
                      SCHEDULED: <2015-02-16 Mon 22:00 .+1d>

                    * Note can have a scheduled time
                      SCHEDULED: <2015-02-17 Fri 09:00>
                """.trimIndent(),
        agendaItems = listOf(
                "Feb 16",
                "Times can have a repeater",
                "Feb 17",
                "Note can have a scheduled time",
                "Times can have a repeater")
)

I can't get an APK to try it on my device, I'm seeing this error:

Yeah, that needs fixing, I've been delaying it until I get to Git sync. You can use ./gradlew build -x lint.

I was about to log a similar request and I saw this one open. It would be great to get Bujiraso's solution implemented as looking at the agenda as currently ordered breaks my brain

While I agree, regrettably all of my systems that are powerful enough to run Android studio have gone on to greener pastures.
I've been hoping someone else might take this on :zipper_mouth_face:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sudomain picture sudomain  路  3Comments

Ypot picture Ypot  路  4Comments

edgimar picture edgimar  路  6Comments

Emilv2 picture Emilv2  路  6Comments

ghost picture ghost  路  3Comments