ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.51k stars 2.21k forks source link

fullscreen refresh on Nook simple touch (NST N2E) #1873

Closed hssm closed 9 years ago

hssm commented 9 years ago

Originally reported on Google Code with ID 971

What steps will reproduce the problem?
1. Open deck and start review
2. Click show answer.
3. Click any of the buttons (easy, hard etc.)

What is the expected output?
a. There shouldn't be a full screen refresh after every fact is rated...
b. the horizontal line that separates Q from A should remain centered

What do you see instead?
a. A full screen refresh occurs before the Question of a new fact is displayed.
b. the horizontal line moves up, creates ghosting effect and now seems that Answer
is centered on screen, or at least it moves up the Q and horiz line

Versions tested> AnkiDroid-1.1beta 8 & 9, and AnkiDroid-1.0beta24
Nook simple touch firmware 1.1 rooted with Salsichanooter0.4

So from what I can see thread http://groups.google.com/group/anki-android/browse_frm/thread/1d024bfb878e89ac
starts with an important tip to DarkNights work in FBreader. The library was then implemented
in CoolReader3, and the results are quite interesting. In the Menu, one can find
   (string id from res)
   options_screen_update_mode: fast, fast2, quality
   options_screen_update_interval: int 1-10 pages

Files used 
   DeviceInfo.java - for eink device detection
   N2EpdController.java - original work from DarkNight
   EinkScreen.java - to update the the refresh mode from options menu; also, every
time a view is redrawn EinkScreen.PrepareController is called. (see DrawCallback method
in /coolreader/crengine/ReaderView.java)

This is what I was able to dig up. I have absolutely no experience with Android development
in particular, and have not been programming for long long time.

Maybe someone could implement a similar device detection, or use the one already created!
Go OpenSource!! :D

Thanks for taking the time to read this!

Reported by cighir.victor on 2012-01-28 13:24:09

hssm commented 9 years ago
Cighir, you are right, this has been solved in Cool Reader and recently also in Aard
Dictionary (Offline Wikipedia), the annoying flashing is gone.

Device detection for e-ink screens
https://github.com/aarddict/android/blob/master/src/aarddict/android/DeviceInfo.java

useAnimation = false;
N2EpdController.setGL16Mode(2);  // force full screen refresh when changing articles
https://github.com/aarddict/android/blob/master/src/aarddict/android/ArticleViewActivity.java

Please implement and show on Android Market that AnkiDroid is not only the best flashcard
app but also e-ink friendly!

Reported by Bardo.Mueller on 2012-02-07 22:34:38

hssm commented 9 years ago
Thanks for your research Bardo :-)

Most of the developers don't have e-ink devices and are thus more motivated to work
on other things, but good news: AnkiDroid is open source!
You seem very motivated and could become a great force in AnkiDroid, just install the
Android SDK, learn Java, and you can make it happen :-)
Java programming is not really difficult, just be prepared to spend a few days studying
patiently AnkiDroid's code and Aardict's code. We are ready to help you if you have
any question.

Here is how to get started in less than a day:
https://code.google.com/p/ankidroid/wiki/Contribution#Source_code

In parallel, could you please investigate what is the purpose of each of the methods
in the class below? This class has zero documentation, having it documented would probably
help a lot.
http://code.google.com/p/apv/source/browse/pdfview/src/cx/hell/android/lib/pagesview/N2EpdController.java

Reported by nicolas.raoul on 2012-02-08 08:13:27

hssm commented 9 years ago
Nicolas,
when trying to import into the Eclipse workspace via 
Import/General/Existing Projects into Workspace/Select archive File
nicolas-raoul-Anki-Android-v0.7-1084-gcadaff0.zip
I get "No projects are found to import"
Can you help out?

My understanding of the N2EpdController.java is rudimentary at best.
It works by controlling the refresh behavior to avoid black flashing.
In the above Aardict it was simply included and the command N2EpdController.setGL16Mode(2);

executed after the creation of the view. That's basically it and should work in AnkiDroid
as well.

Reported by Bardo.Mueller on 2012-02-09 11:04:13

hssm commented 9 years ago
Importing worked well for me. Try to extract first. Select existing source and enter
into extracted directory.

I didn't try to modify the code. But in CoolReader there is a class with overridden
View method, where the N2EpdController.setGL16mode is called, or depending on menu
option.

On the other hand, ankiDroid has a different method of creating the view, with templates,
and I don't know if you can setup there this method.

Now, I wish I had tried to simply call N2EpdController.setGL16Mode inside ankiDroid
main constructor. Just for testing...

Good luck with patching!

Reported by cighir.victor on 2012-02-09 12:33:29

hssm commented 9 years ago
Bardo: As Victor said, you have to uncompress the ZIP first, then "existing source".

Reported by nicolas.raoul on 2012-02-09 14:36:21

hssm commented 9 years ago
Ok, got AnkiDroid compiled now.
Started with inserting N2EpdController commands before possible page updates.
Appears to help, appears to have less "action" before settling on final display.
What still is visible is a short time of intermediate black screen.

- Does anyone know if the background can be made transparent instead like
View.setBackgroundColor(0x00000000); ?

- Another "animation" appearing on e-ink is that there is an intermediate inverted
display. Is this programmatic and could be turned off?

- Page refreshes are full page at the moment. Could this be changed to half the screen
or even printed area?

I guess things would get easier if I would better understand the code - or if developers
would have an e-ink device at hand.

At the moment my testing cycle is slow because I did not yet succeed in testing with
adb on the device.

Reported by Bardo.Mueller on 2012-02-09 22:25:26

hssm commented 9 years ago
Whao, congratulations Bardo, great to know that the first results are coming that fast
:-)
Keep up the good work!
Do not hesitate to post your work on Git regularly, or just zip the code and post it
here from time to time, so that we can merge it and many people can test it.

Reported by nicolas.raoul on 2012-02-09 23:27:02

hssm commented 9 years ago
I'm really happy to that you started work on this issue! Keep up the good work Bardo!
Thank you for taking time for this!

You could try setting different refresh modes.

Check out http://forum.xda-developers.com/showthread.php?t=1183173 post #1 ; post #17
describes all update methods, maybe you could try those.

Maybe this can help a little to understand  https://github.com/geometer/FBReaderJ-alex/blob/master/src/org/geometerplus/android/fbreader/EPDView.java

Good luck!

Reported by cighir.victor on 2012-02-10 09:33:57

hssm commented 9 years ago
@Nicolas et al.

I see at the moments two effects more annoying than the actual page refresh:

- when showing the answer below, the question + separator shift.

- before showing the new question, the old question becomes shortly inverted

The relevant code should be in 
https://github.com/nicolas-raoul/Anki-Android/blob/master/src/com/ichi2/anki/Reviewer.java

Any idea where this could happen?

Reported by Bardo.Mueller on 2012-02-11 10:10:02

hssm commented 9 years ago
Pls find enclosed a first version to make AnkiDroid doing better on e-ink devices.
All changes are in Reviewer.java / MyWebView

Normal e-ink operation is slow, display updates result in black intermediate flashes,
for scrolling there are multiple flashes. Compared to ebook readers, learning with
flash cards needs more frequent page turns .

In order to control the refresh behavior, WebView and other classes in E-ink devices
have an added parameter. Since so far e-ink Androids only (?) exist as rooted versions
of bookshop frontends (Kindle, Nook, Sony, ..), there is no official documentation
available.

This is how it works: the code tries to inject the update parameter with a wanted value
by try/catch (no need to identify the device first). The original idea is due to hberntsen
on http://www.mobileread.com/forums/showthread.php?t=165376&page=2

The fast e-ink mode results in fast display updates, but leaves some ghosting (leftovers
from previous contents), plus the contrast is somewhat reduced. 

It appears that it leaves only ghosting from not fast mode, so a clear before entering
fast mode might fix it.

No big deal for the reviewer's Q/A display, but might want to revert for other AnkiDroid
screens.

At the moment, the fast e-ink mode only gets reset when running a stock (Sony PRS-T1
for me, I guess it is the same for the Nook) application.

I tried to reset the fast e-ink mode in closeReviewer, but this resulted in no fast
e-ink mode at all.

This is where I would need your help: where is the best place to reset the update mode?

Have fun!

Reported by Bardo.Mueller on 2012-02-12 11:05:44


hssm commented 9 years ago
Hi

http://code.google.com/p/apv/source/detail?r=638914bf8d739f4ab66bd13fd6e4749a560cb32c

This is the implementation of the nook partial refresh support on APV PDF Viewer, maybe
it helps.

I tried your apk but the reviewer screen didn't refresh. If you need a tester I can
help you.

Thanks

Reported by salsichad2 on 2012-02-13 04:22:35

hssm commented 9 years ago
Thanks for testing, salsich! 
What device are you using? Can you give further info what exactly you see or don't
see?
I will try to figure out this evening.

Reported by Bardo.Mueller on 2012-02-13 06:07:41

hssm commented 9 years ago
Nook color

That is the bug:
http://code.google.com/p/ankidroid/issues/detail?id=762

Norbert  fixed the last time.

Reported by salsichad2 on 2012-02-13 11:31:37

hssm commented 9 years ago
The changes I addressed should only make a difference on an e-ink device (Sony PRS-T1
or Nook Touch, but not Nook Color). 

Can it be that I downloaded a code version where "your" bug was not yet fixed? Can
you point to a repository with this fix?

Reported by Bardo.Mueller on 2012-02-13 14:31:56

hssm commented 9 years ago
Sorry, I have both, my test was in Nook Touch.

Reported by salsichad2 on 2012-02-13 14:34:24

hssm commented 9 years ago
https://github.com/nicolas-raoul/Anki-Android/commit/8bd1415c7329f016ce178f6c5bd286226da680f9
https://github.com/nicolas-raoul/Anki-Android/commit/136ba543c1eb45e66a10c79ff2e16cc7b67e4105

Reported by salsichad2 on 2012-02-13 14:40:07

hssm commented 9 years ago
The code I compiled already had the fixes added.
From the bug description I am a bit confused: is it a gesture problem, does the device
FC or just doesn'nt shot anything/only the question?

I made progress on the moving question and separator line when displaying the answer.
Part of the fix is to fake display the answer already when posing the question, but
with color=backgroundcolor. Then also user settable font and button appears to influence
the move. Best results where obtained when leaving everything at 100%.

Reported by Bardo.Mueller on 2012-02-13 19:43:00

hssm commented 9 years ago
You can see what is happening in that video:

http://www.youtube.com/watch?v=x5VO-vv624c

but now, sometimes the screen goes all white, sametimes only the answer, sometimes
Q&A blink in the screen. 

Reported by salsichad2 on 2012-02-13 19:59:19

hssm commented 9 years ago
The thumbs-up was for Norbert and nicolas.raoul!

Reported by salsichad2 on 2012-02-13 20:03:20

hssm commented 9 years ago
(salsichad2: Thumbs up for me? I did absolutely nothing!)

Reported by nicolas.raoul on 2012-02-13 23:49:16

hssm commented 9 years ago
those interested in fast e-ink mode on Nook Touch might try
hberntsens norefreshenabler
http://www.mobileread.com/forums/showthread.php?t=165376&page=2 (version 2 did not
work for me)

Run the app first, then start AnkiDroid and you know how fast it can be.

If this app gets you in fast e-ink mode, then my code should work with Nook in principle
and the error must lie elsewhere. 

Reported by Bardo.Mueller on 2012-02-14 00:00:07


hssm commented 9 years ago
I could not install the NoRefreshEnabler.apk. "There is a ploblem parsing the package".

Reported by salsichad2 on 2012-02-14 00:11:50

hssm commented 9 years ago
So the Nook does not augment its WebView classes by an updateparameter as does the Sony.
N2EpdController is supposed to work on both, I will try to make it work on my Sony.

Reported by Bardo.Mueller on 2012-02-14 07:21:58

hssm commented 9 years ago
It looks like the nook and the prs-t1 have different methods of changing the display
mode. The nook has a EpdController class in its android framework, the prs-t1 does
not have that class so N2EpdController does not work on the prs-t1. 

My NoRefreshEnabler should not work on the nook because the nook does not have the
extra methods available that sony added in the android view class.

Reported by hberntsen on 2012-02-14 09:19:00

hssm commented 9 years ago
Hi hbertsen, thanks for joining!

Aargh, it was even in the log:
W / System.err (2497): java.lang.ClassNotFoundException: android.hardware.EpdController

W / System.err (2497): java.lang.ClassNotFoundException: android.hardware.EpdController

Now the big question: can we combine the two approaches into one WebView derived class?

Reported by Bardo.Mueller on 2012-02-14 09:43:34

hssm commented 9 years ago
@hbertsen

is it possible to write a norefreshenabler_nook using EpdController?

Reported by Bardo.Mueller on 2012-02-14 14:00:15

hssm commented 9 years ago
It should be possible to make one webview class. Add mehods to the webview class to
set the update mode. The webview class should then do the rest. For the nook it looks
like the N2EpdController class is designed for changing the display modes. You have
to call that class in the webview. 

I don't own a nook, you can change my norefreshenabler by adding the N2EpdController
and call the right method.

Reported by hberntsen on 2012-02-14 14:12:52

hssm commented 9 years ago
Pls find enclosed a modification of hberntsen's norefreshenabler which should work both
on PRS-T1 and Nook Touch e-ink devices.
This is a proof of concept only, working here means devices should be switched to A2
mode (which I prefer for AnkiDroid because it is the fastest).

Although both devices use the same Freescale chip with onboard EPD controller, their
driver is different. I thought to be able to write a common driver but I am not yet
there.

The code already uses automatic device recognition, which works on PRS-T1 and *should*
work on Nook (I don't have one). So if the display does not change, we should verify
the deviceinfo code. Just let me know.

Reported by Bardo.Mueller on 2012-02-16 23:10:45


hssm commented 9 years ago
I could not install on nook. The same "There is a problem parsing the package". 

Reported by salsichad2 on 2012-02-16 23:21:01

hssm commented 9 years ago
echoes from the web on "There is a problem parsing the package"
- Did you enable 3rd party installation first?
- Once I moved .apk's to system/app, using Root Explorer, they installed just fine,
using Package Installer.

Reported by Bardo.Mueller on 2012-02-16 23:44:43

hssm commented 9 years ago
- Did you enable 3rd party installation first?

Yes

- Once I moved .apk's to system/app, using Root Explorer, they installed just fine,
using Package Installer.

Same error for me.

Is the apk compiled for android 2.1 ? 

Reported by salsichad2 on 2012-02-16 23:54:38

hssm commented 9 years ago
It is compiled against 2.2, will try later with 2.1
is this a general restriction for Nook Touch?

Reported by Bardo.Mueller on 2012-02-17 05:59:54

hssm commented 9 years ago
I'm really not sure. But that is the nook's android version.

Could you open a tread on XDA forum asking for testers?

Reported by salsichad2 on 2012-02-17 16:05:33

hssm commented 9 years ago
here comes compile against 2.1
I think you make a good beta tester.

I had to change some function names, see
http://stackoverflow.com/questions/3000131/android-ndk-r4-san-angeles-problem

Reported by Bardo.Mueller on 2012-02-17 18:08:09


hssm commented 9 years ago
Thanks. 

Still the same "There is a problem parsing the package" error. 

Reported by salsichad2 on 2012-02-17 18:42:02

hssm commented 9 years ago
Posted on
http://forum.xda-developers.com/showthread.php?p=22650831

Reported by Bardo.Mueller on 2012-02-17 20:51:55

hssm commented 9 years ago
Hi

You posted the thread 2 times on XDA App forum. 
Can I add a thread on development forum? I think we will have better chance there.

Reported by salsichad2 on 2012-02-18 00:06:19

hssm commented 9 years ago
I could not wai:

http://forum.xda-developers.com/showthread.php?t=1503015

Reported by salsichad2 on 2012-02-18 00:15:23

hssm commented 9 years ago
In the meantime, I compared to Mnemododo (Mnemosyne on Android) and compiled the sources
from
http://www.tbrk.org/software/mnemogogo-devel.html
Surprise: nice, clean interface and displaying smoothly on e-ink, all without any e-ink
specific driver in the code. Especially no multiple flicker when changing cards.

I guess by proper separation of data prep and display the display part of Mnemododo
can be implemented in Ankidroid.

Reported by Bardo.Mueller on 2012-02-20 07:46:13

hssm commented 9 years ago
Thanks Bardo, great news!
Here is how Mnemogogo implemented its review interface:
http://tbrk.org/cgi-bin/hgwebdir.cgi/mnemododo/file/78c1e2dc4a3b/res/layout/main.xml
http://tbrk.org/cgi-bin/hgwebdir.cgi/mnemododo/file/78c1e2dc4a3b/src/org/tbrk/mnemododo/LoadCardTask.java

Full source: http://tbrk.org/cgi-bin/hgwebdir.cgi/mnemododo/file/78c1e2dc4a3b

Not sure what differs from AnkiDroid's implementation... let's find out :-)

Reported by nicolas.raoul on 2012-02-20 08:01:44

hssm commented 9 years ago
Nicolas,

Mnemododo:
LoadCardTask.java contains all the append html = data prep part, the display is then
done in MnemododoMain.java

   164     private Handler handler = new Handler();
   165     private Animation buttonAnimation;
   166     private Runnable makeViewVisible = new Runnable() {
   167         public void run() {
   168             if (hidden_view != null) {
   169                 hidden_view.setVisibility(View.VISIBLE);
   170                 if (buttonAnimation != null) {
   171                     hidden_view.startAnimation(buttonAnimation);
   172                 }
   173             }
   174         }
   175     };

AnkiDroid:
I need your help on these questions:
- where does the actual display action happen?
- is the base mechanism different for question/anwer?

Differences between Mnemododo and Ankidroid:
Mnemododo uses just html, AnkiDroid a FrameLayout mCardContainer to organize views?
Mnemododo uses Handler / Runnable, Ankidroid not, influence on display timing?

My knowledge of Android is not sufficient to answer these questions. And you possibly
do not see the difference if not on an e-ink screen. Just think what might cause the
difference in making one flashing the screen and the other not.

Reported by Bardo.Mueller on 2012-02-20 10:46:52

hssm commented 9 years ago
1. all basics should be all in reviewer.java
2. the card container is just there for theming issues and animations.
3. It's a framelayout because the webview is created in code (it needs to be recreated
if using a custom font due a memory leak bug in android)

Reported by NorbertNagold on 2012-02-20 11:47:39

hssm commented 9 years ago
We are going to remove support for Android 2.1 in release 2.5, so this issue is irrelevant
now

Reported by perceptualchaos2 on 2015-02-16 07:50:06

hssm commented 9 years ago

Reported by perceptualchaos2 on 2015-02-16 07:50:24