WaniKani / Android-Notification

Android Notifier for WaniKani
GNU General Public License v3.0
34 stars 8 forks source link

Use custom font #4

Closed yacoob closed 10 years ago

yacoob commented 11 years ago

Given that the default font used for displaying kanji on Android is Chinese, it'd be nice if we can specify a custom font in WKMobile. Is that feasible with current architecture of the application?

s84606 commented 11 years ago

Yes and no. Here we have to distinguish between the "native" part and the "web" part. On the native part (so far just the items browser) we have a lot more control: the app already uses the japanese font if available on the device. I'd like to let the user download a different font from the web, because I find the default one ugly. It is something at a lower priority, however. The web part is trickier: I am not aware of any possible way to force a Webview to use a specific font on a remote web page, if that font is not in the system catalogue (and the japanese font is not). The only possibility I see is to place an android textview on top of the radica/kanji/vocab. I have still to explore this but, being somehow related to the "local IME" feature, I believe I'll give it a try once that patch is stable.

yacoob commented 11 years ago

How about hooking on WebViewClient.onPageFinished() and then calling loadUrl('javascript:...')? Unless there are functions for modifying the content of fetched page directly, then it should be easier.

s84606 commented 11 years ago

This is exactly how I do all of my personalizations. The problem is the javascript to put there: since the font is not in the catalogue, you must use the @font-face CSS construct. Apparently, however, it is not possible to customize the font-face of a page loaded remotely using a locally defined font. Doing it on an HTML page loaded from the local file system can be easily done, but it is of no help in our case.

s84606 commented 10 years ago

As a side effect of the new IME, the solution devised above (i.e. placing a textview on top of the HTML page) became easier to implement. Here is an APK that does exactly that: https://www.dropbox.com/s/2oaa61owl4q1n40/WaniKaniMobile-1.7.0pre1-meters0.apk I satisfactory, I will close this issue when this patch will go live (I believe the release after the next)

yacoob commented 10 years ago

I've tested this APK - take a look at some screenshots I've taken. Number 5 is not directly related - I think it's a side effect of new IME.

s84606 commented 10 years ago

Thanks! I knew of the background problem, but I think I won't fix it: this arises from the fact that the web page background is a gradient, while the textview has a solid background. To fix this I could either:

yacoob commented 10 years ago

Three more problems I've bumped into while JP fonts thingy was on:

Layout gets messed up when browser loses contact with WK: screenshot_2013-10-23-09-28-07

This happened... at some point. Can't really recall anything special, I was in the middle of review session, with full network connectivity - and I've ended up with the custom edit box hiding the question: screenshot_2013-10-24-16-31-31

Sometimes - but not always - your extra button gets slightly transparent, and you can see both buttons overlapping: screenshot_2013-10-22-11-28-06

s84606 commented 10 years ago

Ok, let's see: 1- This happens to me too.. well, it is somehow expected because I have no triggers when the "refresh" splash screen appears and disappers. I'll look into it, but it is somehow at a lower priority because it causes no big problems 2- Never happened to be: I wonder if it's really related to the JP font patch or the placement on top of the question is just a coincidence. It would really help me if you could remember the circumstances: did you scroll the page of the previous item before pushing the "next" button? Did you change orientation? 3- I've slightly changed the layout, and I hope this will fix the problem

yacoob commented 10 years ago

1/ - Agreed, it's just ugly :p 2/ - No idea tbh, I was walking across a train station, did a review, gazed at nice green bar, pressed 'next', put phone into my pocket (not sure if locked). Took it out past the gates, saw this. 3/ If it's on the meters branch, I'll test it later.

s84606 commented 10 years ago

Regarding issue 3, there's a tentative fix on the same release that should fix issue #5 https://www.dropbox.com/s/mh5d43i9vyburtj/WaniKaniMobile-1.8.0pre2.apk Apparently, the layout that contains the button and the edit box, sometimes, becomes transparent. Of course I do nothing of that sort in my code. In 1.8.0pre2 I reset the correct background, though I'm not much confident this can solve it.

yacoob commented 10 years ago

The third problem (doubled semi-transparent button) is still present in that apk.

s84606 commented 10 years ago

Ok, yet another try: https://www.dropbox.com/s/gbbny0xu4y8gw1x/WaniKaniMobile-1.8.0pre3.apk this time I simply avoid touching the box if it is already at the right place. Unless there are cases when the button is visible already when the first item is shown, I'm confident that this fixes the issue (well, at least more confident than the last try)

yacoob commented 10 years ago

No good news I'm afraid.

screenshot_2013-10-30-19-44-39

I've paid some attention - there doesn't seem to be a clear rule for the double button to appear. Sometimes it's there straight away, appearing together with a new question. Sometimes it's ok initially, and it turns bad once you press it. Sometimes it's OK all the time except from the moment you press it - as long as you have it pressed, it's ugly.

s84606 commented 10 years ago

I believe it's an android bug, or an undocumented behaviour. Apparently the view which hides the button, sometimes, is brought to back. This APK, apart from trying to solve again this problem, contains some code that is meant to fix the first issue as well (elements still visible when connection times out). https://www.dropbox.com/s/7w8e8nknz3olqh9/WaniKaniMobile-1.8.0rc0-portl0.apk For the second one I really have no clue...

yacoob commented 10 years ago

Looks like 1.8.0 (from market) fixes the problem with the double button. Yay!

I've found one small snag with JP fonts, but I'll put it elsewhere. I think we can close this one.