Skip to content

News downloader: wifi off prompt after download#3395

Merged
Frenzie merged 7 commits intokoreader:masterfrom
mwoz123:news-downloader-wifi-off-after-use
Oct 28, 2017
Merged

News downloader: wifi off prompt after download#3395
Frenzie merged 7 commits intokoreader:masterfrom
mwoz123:news-downloader-wifi-off-after-use

Conversation

@mwoz123
Copy link
Copy Markdown
Contributor

@mwoz123 mwoz123 commented Oct 22, 2017

Prompt to turn off wifi after download.
Extracted from #3388

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 22, 2017

Can I trigger rebuild (without doning blank commit)?

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Oct 22, 2017

There's no need to rush this into a PR if there is no working code imo. We still have a couple of days of design process to go through.

My initial proposal is pretty simple:

  • A function named, e.g., afterWifiAction.
  • That function then handles what happens. Default: nothing.
  • Network menu: setting for prompt, timeout, whatever. We could start by only making prompt an option but we'll have to create a forward-thinking setting. Pinging @poire-z about that timeout stuff.

Writing this is not something you have to do, but you did kind of volunteer by opening this PR. :-P

With a proposal written down, I'll ping a few other people (e.g., @KenMaltby, @gerroon, @bahusoid) to ask what they think of it.

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Oct 22, 2017

Can I trigger rebuild (without doning blank commit)?

It will fail until you do a git pull -r upstream master followed by a git push -f. These are destructive actions, but a temporary placeholder commit like this is the perfect time to familiarize yourself with it.

See the docs for that upstream master thing: http://koreader.rocks/doc/topics/Collaborating.html

@mwoz123 mwoz123 changed the title News downloader wifi prompt News downloader: wifi off prompt after download Oct 22, 2017
@KenMaltby
Copy link
Copy Markdown

KenMaltby commented Oct 22, 2017

For those of us still paranoid about power consumption, the idea of having a way to be reminded that you are done with a function that used the WiFi and can insure it is turned off when it's not needed, is a great idea. Would there be an issue if the plug-in is checking periodically for news to download, doesn't it then turn itself, and WiFi on and off?

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 23, 2017

(..) the idea of having a way to be reminded that you are done with a function that used the WiFi and can insure it is turned off when it's not needed, is a great idea

Agree. That's exactly what this commit is about: Popup asking if wifi should be turn off when downloading news is finished.

Would there be an issue if the plug-in is checking periodically for news to download, doesn't it then turn itself, and WiFi on and off?

This should be a new, separate topic. It would require a lot more changes - new configuration to turn auto-downloading on/off. It could check wifi state before downloading and leave it in the same as before download (if was off, turn it on & leave it off after download), auto wifi enabling, etc.
The major problem I see here is the notification user that new news are available.

But if really needed/requested the discussion should be continued in a separate thread.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 25, 2017

How about latest comit?

Ask to turn off wifi only if it was off before downloading news.

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Oct 25, 2017

It's an interesting idea for one of the settings, but like I said in #3388 (comment) I mean a NetworkMgr:afterWifiAction().

I would structure it the same as the Save document menu.

Network → After Wi-Fi action

  • Do nothing (the default)
  • Prompt when previously off (interesting idea)
  • Always prompt
  • (Timeout) (potential future enhancement)

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 28, 2017

I think prompt when previously off provides the best U. X.
Why it cannot be default ?
What other guys think? @KenMaltby?

@Frenzie I might implement your proposal in next PR if I had time.
Let's merge this for now.

@Frenzie Frenzie merged commit c2bed63 into koreader:master Oct 28, 2017
@KenMaltby
Copy link
Copy Markdown

I guess "do nothing" would mean leave on? Why not just return it to what ever state it was in prior to the action that required WiFi? If WiFi was already on (no turn on prompt was required), then leave it on. If it was off (and a turn on Wifi prompt was used) then turn the Wifi back off.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 28, 2017

What you described is nearly the same what we've after that merge ;)

The only difference is that if it was off before action it prompt user to disable wifi instead of silent turn off.

I thought about that and think that silent turn off might be sometime a surprise, when user planned to use internet afterwards. That's why I think that prompt off is better.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Oct 28, 2017

Anyway silent off is also ok for me. If you guys think it's better than prompt I'd be able to change it quickly

@KenMaltby
Copy link
Copy Markdown

KenMaltby commented Oct 28, 2017

If the user was having his WiFi on all the time it would have been on to start and would remain on. My guess would be if a user was using the Wifi a lot, they would eventually learn to turn it on thru the Network option and it would never give them the prompt when going to different WiFi features. Also the WiFi on after resume feature. There is also someone adding a WiFi indicator to the readerfooter. That said, a prompt is also fine with me.

@mwoz123 mwoz123 deleted the news-downloader-wifi-off-after-use branch October 28, 2017 17:48
@mwoz123 mwoz123 restored the news-downloader-wifi-off-after-use branch October 28, 2017 17:50
@mwoz123 mwoz123 deleted the news-downloader-wifi-off-after-use branch October 28, 2017 17:50
mwoz123 added a commit to mwoz123/koreader that referenced this pull request Nov 4, 2017
* Timer Reader with normal time format (koreader#3244)

* [fix, UX] Remove rounded corners from fullscreen History (koreader#3256)

Prevent visibility of readers's footer edges.

* [UX] Smaller bottom menu icons (koreader#3257)

And unrelated small optimisation in imagewidget

* Adapt ND to changes in code where 0 means no limit (koreader#3258)

+ reorganize config, improved comments

* Bump base for smoother image scaling (koreader#3259)

* README: fix typo

* ImageWidget: use MuPDF for scaling images (koreader#3260)

* Cache scaled images with scale_for_dpi

* Don't update original self.scale_for_dpi

A same ImageWidget object can be free()'d and re-render()ed,
and we would then lose scale_for_dpi on next renderings

* [fix] Some Android issues (koreader#3262)

Bump base for versioned Android libs.

Fixes koreader#3214. Fixes koreader#3112. Fixes koreader#3091. Fixes koreader#3039. Fixes koreader#2976. Fixes koreader#2960. Fixes koreader#2947.

* [UX] Add home button (koreader#3263)

Tap to go HOME. Hold to set current folder as HOME. When no HOME is set yet tap also asks to set current folder as HOME.

See koreader#2957 (comment)

Closes koreader#3200.

* [fix, Android] restore patch.lua and fix odd anonymous function issue

See koreader#3214 (comment) and koreader#3118 (comment)

* [Android] Enable CoverBrowser (koreader#3264)

I was reminded by @KenMaltby that this is disabled on Android.

https://www.mobileread.com/forums/showthread.php?p=3586162#post3586162

* Add back button to statistics (koreader#3267)

Closes: koreader#3236 and koreader#3235
Details:

> Also, when looking in days, we see info how many hours we read. It would be great if we could tap a day, it opens info on book(s) we read that day with info pertaining to that day, and if we tap on book, we receive book info for that book.

>  Statistics plugin is really great, I started to look in my reading statistics now much more, but all the time I can go only in one way. And I need to exit at lowest level of info. It would be great if I can use statistics plugin like part of menu, to go up and down within statistics data and exit at my wish, not when I have to.

Also added:

 * new statistics book by week
 * new statistics book by month
 * last year by week now we can see days in selected week

* [UX] Smaller borders (koreader#3266)

For years they've been smaller on higher DPI devices and likely very few people realized it was technically a bug. These values round up on lower DPI and smaller screen devices.

References koreader#3265

* README: update Android NDK/SDK info

* [fix] Avoid crash when set home (koreader#3269)

* README: various style, grammar, clarifications & updates

* [fix] Add hold_callback to IconButton (koreader#3271)

Also fix path display update.

Fixes koreader#3270.

* CoverBrowser: use MuPDF for down-scaling images (koreader#3272)

* README: more grammar

* README: update info about screen size/DPI

* README: typo and grammar

* CoverBrowser: use a cache for crengine books extraction (koreader#3277)

We previously disabled cache, but that may cause excessive
memory usage with big books. We now use a temporary
cache directory, that we clean when no more needed.

* Rename bookmark (koreader#3275)

* Allow for colored rendering (koreader#3276)

* Allow for colored rendering

Available with all engines (CRE, PDF, Images).
Needs to manually add setting: "color_rendering" = true

* Disable color for djvudocument

* Use Screen:isColorEnabled()

* Bump base

* [lang] OPDSCatalog ConfirmBox ok_text/cancel_text (koreader#3281)

* Fix refresh in Time range (koreader#3278)

* kodev: run with catchsegv by default (koreader#3283)

See koreader#2878 (comment)

Also fix `./kodev run -h` as alias for `--help` as it's always overwritten by `-h` in the sense of the much more important `--screen-height`.

* Time reader with normal time format v2 (koreader#3279)

* Allow for toggling color rendering

New menu item in Screen submenu.
hasColorScreen enabled for SDL device.

* Enable color rendering on Android

* [Fix] Show 'Follow Link' even when no dict installed

* [Fix] Full refresh when showing ImageViewer

* [fix] KOSync plugin server location (koreader#3288)

This is only step one. It remains to be determined why the connection is downgraded to sslv3, which will result in a handshake failure.

* Inform once about color rendering on supported devices (koreader#3289)

* [fix] KOSync server TLS connection (koreader#3291)

Bumps base for updated luasec.

The forum reminded me Sync was broken https://www.mobileread.com/forums/showthread.php?p=3587993 (as I don't use it myself). This finishes 23e2183.

Thanks to @houqp for helping with debugging Cloudflare. See https://support.cloudflare.com/hc/en-us/articles/203135314-How-can-I-enable-SSLv3-

Fixes koreader#2738. Fixes koreader#2178. (Duplicate bug reports by @Hzj-jie. :-P) Fixes koreader#3159. Fixes koreader#3158. Fixes koreader#2877.

* README: Change gcc requirement to 4.8

Technically 4.7 is probably fine for all but debugging symbols, for which a simple version check and workaround could be added. However, since all of the CI tests run 4.8 there is no regression prevention and it would be more future maintenance trouble than it's worth.

* credocument reader optimisation (avoid multiple TOC builds) (koreader#3292)

Avoid unnecessary work in ReaderView:onSetViewMode() and
ReaderRolling:updatePos() that would result in TOC being reset
and rebuilt (which can take time on books with huge TOC) during
reader setup.

* CoverBrowser: avoid crash when indexing some cre documents (koreader#3293)

* [feat] Pocketbook840 enable frontlight (koreader#3294)

* Detect PocketBook840 by GetSoftwareVersion()

* implement Frontlight-support for 840 via inkview

* [fix] Android frontlight control

* Revert 2 commits that caused crengine scroll mode side effects (koreader#3295)

394be8a (koreader#2855) and 2b3b310 (koreader#3183) introduced side effects (scroll mode
crashing and TOC being reset and rebuild). This reverts parts of them
not yet reverted.

* README: small typo

* kodev: add run android convenience shortcut (koreader#3297)

* [fix] kodev: default NDKABI=14 if not set for NDK 15 standalone toolkit

* ISSUE_TEMPLATE: add request to share crash.log (koreader#3296)

* Migrate Goodreads to https (koreader#3298)

* Bump base (koreader#3301)

Includes:

* [fix] Android viewport (fixes koreader#3148)
* Makefile: add luajit-clean target and auto-call it (koreader/koreader-base#531)

* [fix] Avoid multiple refreshes when opening credocuments (koreader#3300)

Only noticeable on Kindle (which uses REAGL as partial refresh).

* [fix] Android screen blackout on first light change (koreader#3303)

* Fix footer, stats, TOC position with cre in scroll mode (koreader#3304)

This gives the page position to these modules even in scroll mode.
Also, in readerrolling: don't query battery/charging status
when crengine does not need it (used only when it shows its top
progress bar).

* [fix] Crash on highlight in some situations (koreader#3306)

* Fix crash with keyboard navigation of onHold buttontables (koreader#3307)

* Fix crash with keyboard navigation of onHold buttontables

Would crash when encountering a separator or when the number
of buttons in a row changes.

* Reset previous selected item on new buttontable

* refresh footer (koreader#3313)

* Bump base to prevent Travis LuaJIT rebuild (koreader#3314)

* Avoid some full refreshes on Kindle (koreader#3315)

"partial" refresh causes a full (without black flash) refresh on
Kindle (which uses REAGL mode for partial refresh). This causes a
full redraw of widgets, which is a bit distracting with some of them:
- dictquicklookup: when showing next definition
- infomessage: when displaying a new one (Wikipedia Save as epub)

Also fix bottom menu, that even when closed, would still register
bottom area as dirty: this would cause top menu navigation to
cause a full partial refresh, only noticable on Kindle.

* [ReadTimer] Time from now (koreader#3311)

* Add LuaData and Dictionary Lookup History (koreader#3161)

* Add dictionary history

Fixes koreader#2033, fixes koreader#2998.

* Add LuaData

* table handling in base settings

* Add LuaData spec

* Option to disable show bottom menu on top menu activation (koreader#3316)

* Bump base (koreader#3318)

Includes koreader/koreader-base#539.

Changes to koptcontext.lua. Look here if anything weird changes in PDFs.

* [fix, Android] Don't steal frontlight control on start (koreader#3319)

I believe this should be `if isKobo()`, or better yet that the entire
block should be moved to `KoboPowerD:init()` because afaik that is the
only platform where the system doesn't provide trustworthy frontlight
information. But to be absolutely sure that I don't break anything (and I
don't want to spend any time on this atm) I'm temporarily excluding only
Android where this behavior is known to be problematic.

See discussion in koreader#3118 (comment)

References koreader#3118 (using keyword "references" because phrases like "possibly fixes"
result in GH autoclose).

* Add CircleCI (koreader#3321)

* CircleCI fixes

* shellcheck 0.4.5 fix `LC_ALL: en_US.UTF8` (can be removed for shellcheck 0.4.6)

* hush updated luacheck on `reader.lua`; we're not assigning any variables but `= nil` is redundant

* Better vertical centering of text in its box

Decide baseline vertical position according to font metrics, instead
of the hardcoded 0.7 (in textwidget, which made the text a little
bit up in its box), and 0.75 (in toggleswitch, which made the text a
little bit down in its box). This usually gives a value around 0.72
or 0.73 with our ui fonts, which looks about right.
ReaderFooter: add bottom padding, now that our text goes a few pixels lower

* Normalize some widgets appearance (those using ButtonTable)

This makes button heights similar in all uses of ButtonTable.
It depended on how the ButtonTable was used in each widget
(previously, first and last row may have different sizes than
the others).

buttontable.lua: more even buttons height whether zero_sep or not
framecontainer.lua: added padding_top/bottom/left/right (similar to
what was done for iconbutton)

The following widgets have been adapted for this, with some
additional fixes:

buttondialog.lua
buttondialogtitle.lua: wider title with adequate padding
confirmbox.lua + multiconfirmbox.lua: dismissable via tap outside
inputdialog.lua + multiinputdialog.lua: more even vertical padding between elements
imageviewer.lua
textviewer.lua
datewidget.lua
timewidget.lua

Additionaly: frontlightwidget.lua: fixed width of progress bar that
was exceeding window width since the Size scaling adjustements

* Flash KeyValuePage item when callback (koreader#3322)

* Fix readerfooter_spec (koreader#3326)

My bad, leftover from koreader#3323 but not caught due to some Travis → CircleCI migration birth pains.

* CircleCI docs (koreader#3327)

* Environment variable key replaced by CircleCI GitHub push key.
  See <https://circleci.com/docs/1.0/adding-read-write-deployment-key/>.

* Temporarily added `|| true` to luacov so it won't cause a fail.

* Fix stats in cre scroll mode (koreader#3331)

* CircleCI cache fix (koreader#3329)

* Update luarocks/shellcheck/shfmt check based on `deps-{{ arch }}-{{ checksum ".ci/install.sh" }}`
* We generate a git-rev-base to check whether we can trust the cache
  with `build-{{ arch }}-{{ checksum "git-rev-base" }}`

Binary dependencies require `{{ arch }}` because there are different CPUs used on the servers.
More information here: https://discuss.circleci.com/t/use-the-arch-cache-template-key-if-you-rely-on-cached-compiled-binary-dependencies/16129

* [fix] Statistics: onPosUpdate and save stats when closing document (koreader#3332)

* Fix cre scroll page update and allow jumping to page (koreader#3333)

This makes Go to, Skim to and TOC page selection work in
scroll mode, and page given to other module more accurate
(previously, we were one action lagging).

* CircleCI parallelization

* Enable parallelism in .circleci/config.yml
* Add BUSTED_SPEC_FILE to Makefile testfront
* Use it in .ci/test.sh with xargs for test parallelization

NB This is the dumb method of improving test time.
Ideally we want a workflow fan-in/fan-out approach.

* [fix] MockTime spec

* [fix] #nocov on broken scroll mode tests

* CircleCI: run docs & coverage in first container only (koreader#3335)

I wrote this whole complicated wofkflow-based config file, but except
in the case of a base rebuild it wouldn't really be any faster than
this simple tweak.

```
defaults: &defaults
    docker:
      - image: houqp/kobase:0.0.5
        environment:
          EMULATE_READER: 1
          # this is for shellcheck 0.4.5 and lower; can be removed for 0.4.6
          LC_ALL: en_US.UTF8

version: 2
jobs:
  install-and-build:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            # binary dependencies require {{ arch }} because there are different CPUs in use on the servers
            - deps-{{ arch }}-{{ checksum ".ci/install.sh" }}
      # need to init some stuff first or git will complain when sticking in base cache
      - run: git submodule init base && git submodule update base && pushd base && git submodule init && git submodule update && popd
      # we can't use command output directly for cache check so we write it to git-rev-base
      - run: pushd base && git_rev_base=$(git describe HEAD) && popd && echo $git_rev_base && echo $git_rev_base >git-rev-base
      - restore_cache:
          keys:
            - build-{{ arch }}-{{ checksum "git-rev-base" }}
      - run: echo 'export PATH=${HOME}/bin:${PATH}' >> $BASH_ENV
      - run:
          name: setup
          command: .ci/before_install.sh
      - run:
          name: install
          command: .ci/install.sh
      - save_cache:
          key: deps-{{ arch }}-{{ checksum ".ci/install.sh" }}
          paths:
            - "/home/ko/bin"
            - "/home/ko/.luarocks"
            # compiled luarocks binaries
            - "install"
      - run:
          name: fetch
          command: .ci/fetch.sh
      - run:
          name: check
          command: .ci/check.sh
      - run:
          name: build
          command: .ci/build.sh
      - save_cache:
          key: build-{{ checksum "base/git-rev" }}
          paths:
            - "/home/ko/.ccache"
            - "base"
      - persist_to_workspace:
          # Must be an absolute path, or relative path from working_directory
          root: "./"
          # Must be relative path from root
          paths:
            # front build
            - "koreader-emulator-x86_64-linux-gnu/koreader"

  test:
    <<: *defaults
    parallelism: 4
    steps:
      - checkout
      - restore_cache:
          keys:
            # binary dependencies require {{ arch }} because there are different CPUs in use on the servers
            - deps-{{ arch }}-{{ checksum ".ci/install.sh" }}
      # need to init some stuff first or git will complain when sticking in base cache
      - run: git submodule init base && git submodule update base && pushd base && git submodule init && git submodule update && popd
      # we can't use command output directly for cache check so we write it to git-rev-base
      - run: pushd base && git_rev_base=$(git describe HEAD) && popd && echo $git_rev_base && echo $git_rev_base >git-rev-base
      - restore_cache:
          keys:
            - build-{{ arch }}-{{ checksum "git-rev-base" }}
      - run: echo 'export PATH=${HOME}/bin:${PATH}' >> $BASH_ENV
      - attach_workspace:
          # Must be absolute path or relative path from working_directory
          at: "./"
      - run:
          name: test
          command: .ci/test.sh

  docs-and-coverage:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            # binary dependencies require {{ arch }} because there are different CPUs in use on the servers
            - deps-{{ arch }}-{{ checksum ".ci/install.sh" }}
      # need to init some stuff first or git will complain when sticking in base cache
      - run: git submodule init base && git submodule update base && pushd base && git submodule init && git submodule update && popd
      # we can't use command output directly for cache check so we write it to git-rev-base
      - run: pushd base && git_rev_base=$(git describe HEAD) && popd && echo $git_rev_base && echo $git_rev_base >git-rev-base
      - restore_cache:
          keys:
            - build-{{ arch }}-{{ checksum "git-rev-base" }}
      - run: echo 'export PATH=${HOME}/bin:${PATH}' >> $BASH_ENV
      - attach_workspace:
          # Must be absolute path or relative path from working_directory
          at: "./"
      - run:
          name: cleanup
          command: .ci/after_success.sh

workflows:
  version: 2
  build-and-test:
    jobs:
      - install-and-build
      - test:
          requires:
            - install-and-build
      - docs-and-coverage:
          requires:
            - install-and-build
```

* [CI] Switch to Codecov (koreader#3336)

The debug output from Coveralls was rubbish. `"Build processing error"`
Besides some basics like checking if we were actually sending
valid JSON that gives us absolutely nothing to work with.

* [feat] VirtualKeyboard cursor navigation (koreader#3290)

Still lacks Japanese due to insufficient knowledge of the language.

* README: style updates (koreader#3337)

Improved some stylistic issues.

* Updated Travis CI reference to CircleCI.
* Switched to CircleCI "shield" style badge to fit in better with the other badges.

* Small visual fixes to Menu (koreader#3338)

Rationalize horizontal construction of Menu items (TOC,
Bookmarks, Classic file views) for more even padding.
Align "x" close button diagonaly with top right border and title.

Also add forgotten scale_for_dpi to MultiConfirmBox

* Allow for disabling flashing of menu, icons and buttons  (koreader#3339)

* CircleCI: finishing touches (koreader#3340)

* junit test results; unfortunately this seems to conflict with the verbose out

* fix deps cache: two files can change independently

* verbose print obsoleted by gtest in upsream busted

* [fix] verbose_print deprecated by gtest

* [fix] gettext: die already you stupid language not found error (koreader#3341)

* Bump base (fixes landscape on Android) (koreader#3342)

Includes koreader/koreader-base#542

* Add gettext_spec stub (koreader#3343)

* dbg_spec: setVerbose test

* [chore] Rework util spec, rework util.secondsToClock: round seconds to minutes in 00:00 mode + spec

Most of the tests in util_spec were the wrong way around.
It's `assert(expected, given)`.

* [chore] Ignore empty files and tables in DocSettings (koreader#3348)

* calibre 'series' metadata fixes (koreader#3349)

Decode XML entities in series metadata and display decimal in series number
if any.

* Menu (TOC, bookmarks): add padding before right text (koreader#3350)

* FileBrowser: change page to show last file or previous subdir (koreader#3351)

When going from reader to filemanager, we are in the directory
containing the last_file. With this, we will also be on the page
showing this file.
When in filemanager and going up (".."), we will also be on the
page containing the directory we came from.

* Avoid recalculation of partial_md5_checksum at each opening (koreader#3352)

This is done by/for kosync plugin at each opening, because
the docsettings was re-opened and saved for this, but later
overwritten by the current koreader docsettings - so it was
redone each time. This correctly adds this partial_md5_checksum
to the current koreader docsettings, which will be saved on
document closing - so it will not be redone next time.
Note: this partial_md5_checksum is not (yet) used by anything.

* kodev: Add $ANDROID_ARCH to enable x86 build (koreader#3353)

You'll still have to call it with `ANDROID_ARCH=x86 ./kodev build/release/run android`.

Don't forget to `./mk-luajit.sh clean` in luajit-launcher when changing architectures.

* Bump android-luajit-launcher
  This includes the fix for Android 8. Fixes koreader#3126.
* Bump base

* [android] fix hide nav bar on activity create (koreader#3357)

* [Goodreads] lookup improvement (koreader#3354)

* add navigation button (next, prev) on the bottom of screen
* flash item when selecting
* small lookup improvements
* fix refresh "Please wait..."

* Small visual fixes to top menu (koreader#3356)

To make it more alike bottom menu:
- left and right border not displayed
- line below icons extends to screen borders
- same bottom border size
And make separator lines have same padding on both sides

* [Android] Enable DjVu (bump base) (koreader#3358)

Closes koreader#1534.

* djvu: enable color rendering (koreader#3361)

* djvu: enable color rendering

* Bump base

* README: fix "unarchieve" typo (koreader#3362)

* Bump base (koreader#3364)

*  Change JPG rendering to RGB in openJPGDocumentFromMem
*  fix build on Mac OSX and fix SDL input issues on OSX
* And some other bumps (glib, crengine, libiconv, libjpeg-turbo).

* Fix some widget title height and close button alignment (koreader#3366)

* close button alignment (koreader#3367)

* Enable Edit (rename bookmark) when tap on highlight (koreader#3369)

Also fix a few crash possibilities when unhighlighting.
Also fix bug with binary search that could not be able to remove bookmark
when there are multiple bookmarks/highlights on the same page.

* [fix] util.secondsToClock 00:60 should be 01:00 (koreader#3371)

* [Kobo] Add preliminary Kobo Aura H2O2 definition (koreader#3372)

Cf. ongoing discussion in KSM8 thread: https://www.mobileread.com/forums/showthread.php?p=3596020#post3596020

* Bump base (sdcv 0.5.2; fix *buntu 17.10 build & segfault) (koreader#3378)

Fixes koreader#3302. Fixes koreader#3071.

* kodev: add debug flags (koreader#3379)

* `--gdb=X`
* `--valgrind=X`

* Book Information: added file size (koreader#3380)

* Added util.getFriendlySize() (koreader#3381)

* Added util.getFriendlySize()

* Allow for GB

* Fix location of progress bar ticks (koreader#3382)

* Added util.getFormattedSize() (koreader#3383)

* Bump android-luajit-launcher (contains x86 nightly build fix) (koreader#3384)

* FileBrowser: optimize 'change page to show last file'

This feature, introduced some days ago, was actually
doing 2 updateItems calls: the initial one, and a second
to switch to focused_file page (cheap with classic display mode,
less cheap with CoverBrowser modes).
This change allows doing that in a single call.

* CoverBrowser: some optimizations

Speedup initialization (needs to be done only once, and avoid
saving current mode to sqlite each time) and reader-to-filebrowser
switch, by doing a single rendering (instead of 2 or 3 previously).
ListMenu: cache sidecar file parsing results (page/percent
completed) for the browsing session duration.
Fix "No choice available" when on last page and changing
to a display mode with less pages.

* Android NetworkManager (koreader#3386)

* Bump base (sdcv patch to allow enable/disable dicts) (koreader#3393)

* Fullscreen android - resize window after toggle fullscreen (koreader#3392)

* [fix, Android] adjust touch location for koreader#3392 (koreader#3394)

* NewsDownloader promptWifiOn (koreader#3388)

* [feat] SkimToWidget chapter markers & next/prev chapter/bookmark (koreader#3389)

koreader#2819 (comment)
+ refactoring code in skimtowidget
+ add chapter markers
+ add next/prev chapter buttons
+ add next/prev bookmark buttons

* [Android] Bump luajit-launcher (more lib loading debug info) (koreader#3401)

* [PocketBook] Use inkview-calls for battery-percentage/charging (koreader#3402)

* PocketBook: Basic device-detection /  PocketBook631 (Touch HD) support (koreader#3403)

Add basic device-detection via libinkview, support PocketBook631. Fixes koreader#3312

* Bump base (sdcv -u patch and framebuffer setViewport dynamically fix) (koreader#3404)

* KeyValuePage: option to align value to the right when half-overflow (koreader#3407)

Applied in FileManagerBookInfo.

* Bump base (sdcv -u patch for android) (koreader#3413)

* [UX] Fix dict title width to not go over CloseButton (koreader#3414)

* Wiki save as epub: close highlight menu when switching document (koreader#3417)

* separate strings for singular and plural (koreader#3420)

* Bump base (sdcv -u patch for android again) (koreader#3421)

* DataStorage: also create data/tessdata and minor string concat performance improvements (koreader#3430)

* [fix] Dictionary no fuzzy search flag (koreader#3433)

Upstream uses `-e` rather than the `-f` that was first introduced in our fork.

References koreader#3429 (comment)

* NewsDownloader: use feed.description as news context instead download full web page (koreader#3426)

Fixes koreader#3425.

* Bump base (updated libk2pdfopt) (koreader#3437)

* kodev: add assert_ret_zero after make android-ndk (koreader#3438)

Fixes koreader#3408.

* [build] Add -debug suffix to KODEBUG builds (koreader#3439)

* NewsDownloader: Remove NewsDownloader files from history  (koreader#3424)

* kodev: added setup_env to run android

Otherwise it didn't pick up on the -debug suffix.

* Bump android-luajit-launcher

* [Android] Wifi status in footer (koreader#3396)

Implemented through the Android API so it's reasonably cheap.

* NewsDownloader: wifi off prompt after download (koreader#3395)

* [UX] Improve ConfigDialog (koreader#3443)

* [CI] Also run coverage on plugins (koreader#3447)

* NewsDownloader: Compatibility for users with previous configuration files (koreader#3445)

* Bump base (fix wpa crash by @civalin) (koreader#3449)

For:
* [fix] filter out more bad lines in wpa scan result (koreader/lj-wpaclient#3)

Fixes koreader#3436

* [CI] apply patch for busted junit testcase time (koreader#3450)

Apply junit testcase time fix so CircleCI can actually do something useful
with the results. This can be removed once there is a busted 2.0.rc13 or final

See lunarmodules/busted@830f175

* [fix, CI] silly typo in busted junit output patch

* README: tiny grammar fix (koreader#3453)

* ConfigDialog improvements 2 (koreader#3455)

+ Fix height for ToggleWidget
+ Able ToggleWidget width more than half of width of screen

* [fix] Disable Highlight button when text is not selected (koreader#3457)

* i10n/README: small stylistic changes

* doc/Unit tests: minor extra explanation (koreader#3462)

* More contrast settings (koreader#3463)

Close: koreader#2133 
More info: koreader#2133
@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Jan 15, 2018

Answering #3482 (comment) here, as this topic is the most complete with idea and proposals.

To me, I would replace all these (@robert00s did the work of making them all consistent this way):

            if NetworkMgr:isOnline() then
                self:lookupInput() -- do some wikiepdia queries
            else
                NetworkMgr:promptWifiOn()
            end

with something like

if NetworkMgr:beforeWifiAction(needs_internet) then
    self:lookupInput()
    NetworkMgr:afterWifiAction()
end

We could find better names, but these give the idea.

function NetworkMgr:beforeWifiAction(needs_internet)
  if isWifiEnabled() then -- quickly check if wifi is enabled (cat /proc/modules)
    if needs_internet == true and isOnline() then
        _startOrResetAutoWifiOffTimer()
        return true
    end
    if needs_internet == false and isConnected() then
        _startOrResetAutoWifiOffTimer()
        return true
    end
    disableWifi() -- current connexion is not valid
  end
  needs_wifi_action = G_reader_settings.readSetting("needs_wifi_action")
  if needs_wifi_action == "prompt" then
    NetworkMgr:promptWifiOn()
  elseif needs_wifi_action == "script" then
    -- execute a script (that could use a homemade wpa_supplicant.conf to connect to known network without prompting)
  else ...
  end
  -- do the same stuff we did at start
  return false -- if we still fail them
end

and what you suggested above for:

function NetworkMgr:afterWifiAction(needs_internet)
  done_with_wifi_action= G_reader_settings.readSetting("done_with_wifi_action")
  if done_with_wifi_action== "go_off" then
    disableWifi()
  elseif done_with_wifi_action== "prompt" then
  elseif done_with_wifi_action== "previous_state" then
  elseif done_with_wifi_action== "timer" then
    _startOrResetAutoWifiOffTimer()
  end
end

I have done my own private hacking (#3388 (comment)), kobo specific, using script/timer (inspired by the old autoSuspend code for kobo that was formerly in UIManager). Sharing it in case it can give some ideas. It comes down to this added to UIManager:

-- we don't want to suspend if wifi modules are inserted, otherwise crash
function UIManager:isWifiEnabled()
    local wifi = false
    local fd =  io.open("/proc/modules", "r")
    if fd then
        local modules = fd:read("*all")
        fd:close()
        -- lsmod is usually empty, unless wifi or usb enabled
        --     dhd 240713 0 - Live 0x7f19c000   (= directory /proc/sys/net/ipv4/conf/eth0 present)
        --     sdio_wifi_pwr 486 0 - Live 0x7f198000
        -- we could alternatively check if lfs.attributes("/proc/sys/net/ipv4/conf/eth0", "mode") == "directory"
        if modules:len() > 0 then
            if modules:find("dhd ") or modules:find("sdio_wifi_pwr ") then
                wifi = true
            end
        end
    end
    return wifi
end

-- enable our personal wifi without the need for NetworkMaanger widgets
function UIManager:quickEnableWifi(noautowifioff)
    if self.auto_wifi_off_sec == nil then
        -- On first call, load this setting and create the functions
        local sec = G_reader_settings:readSetting("auto_wifi_off_seconds")
        if sec > 0 then
            self.auto_wifi_off_sec = sec
            self.wifi_off_action = function()
                -- For safety, cancel scheduled stuff
                self:unschedule(self.wifi_off_action)
                self:quickDisableWifi(false) -- no Infomessage
            end
            function UIManager:_startOrResetAutoWifiOffTimer()
                -- do simple, just unschedule/scheduleIn
                self:unschedule(self.wifi_off_action)
                self:scheduleIn(self.auto_wifi_off_sec, self.wifi_off_action)
            end
            function UIManager:_stopAutoWifiOffTimer()
                self:unschedule(self.wifi_off_action)
            end
        else
            self.auto_wifi_off_sec = 0   -- default = 0 => not enabled
            self._startOrResetAutoWifiOffTimer = noop
            self._stopAutoWifiOffTimer = noop
        end
    end
    local connected = true
    if not self:isWifiEnabled() then
        local InfoMessage = require("ui/widget/infomessage")
        local info = InfoMessage:new{
            text = "Connecting to friendly WIFI...",
        }
        local sleep_and_discard_sec
        self:show(info)
        self:forceRePaint()
        ret = os.execute("../my_enable-wifi.sh")
        self:close(info)
        if ret == 0 then
            local ssid = "???" -- shouldn't happen
            local fd =  io.open("/tmp/mykossid", "r") -- i put my connected SSID here
            if fd then
                ssid = fd:read("*all")
                fd:close()
            end
            self.connected_ssid = ssid
            info = InfoMessage:new{
                text = "Connected to "..ssid,
            }
            -- block for display and cleanup (avoid InfoMessage being masked
            -- by a quickdictlookup for example)
            sleep_and_discard_sec = 1
        else
            self.connected_ssid = nil
            info = InfoMessage:new{
                text = "No friendly WIFI available",
                timeout=4,
            }
            -- disable wifi, so we don't have to do it manually if we want to re-enable it
            UIManager:scheduleIn(0.1, function() self:quickDisableWifi(false) end)
            connected = false
        end
        self:broadcastEvent(Event:new("UpdateFooter"))
        self:show(info)
        self:forceRePaint()
        if sleep_and_discard_sec then
            util.sleep(sleep_and_discard_sec)
            self:close(info)
            self:forceRePaint()
        end
    end
    if connected then
        if noautowifioff then
            self:_stopAutoWifiOffTimer()
        else
            self:_startOrResetAutoWifiOffTimer()
        end
    end
    return connected
end

-- Disable wifi if it was enabled
function UIManager:quickDisableWifi(showmsg)
    -- We can touch this file to keep wifi on and allow restarting koreader
    if lfs.attributes("/tmp/keep_wifi_on", "mode") == "file" then
        return
    end
    if self:isWifiEnabled() then
        local InfoMessage = require("ui/widget/infomessage")
        local info = nil
        if showmsg then
            info = InfoMessage:new{
                text = "Shutting down WIFI...",
            }
            self:show(info)
            self:forceRePaint()
        end
        local network_manager = require("ui/network/manager")
        network_manager:releaseIP()
        network_manager:turnOffWifi()
        self.connected_ssid = nil
        UIManager:broadcastEvent(Event:new("UpdateFooter"))
        if info then
            self:close(info)
            self:forceRePaint()
        end
    end
    if self._stopAutoWifiOffTimer then -- may not yet be defined
        self:_stopAutoWifiOffTimer()
    end
end

I had replaced all the isOnline()/promptWifiOn() with:

    local UIManager = require("ui/uimanager")
    if not UIManager:quickEnableWifi() then
        return -- abort wikipedia lookup if not connected
    end

(I personally don't care about isOnline() or isConnected(), my isEnabled() is enough for the action to go on and fail in its own way of failing if no network or no internet).
I also added at various place (suspend, koreader exit):

        -- my own check for turning off wifi
        UIManager:quickDisableWifi(true)
        logger.dbg("Suspending...")

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Jan 16, 2018

if NetworkMgr:beforeWifiAction(needs_internet) then
    self:lookupInput()
    NetworkMgr:afterWifiAction()
end

I like that a lot, although I doubt we can keep the afterWifi(Action) positioning that neat. Perhaps especially in this particular example. In Wikipedia you can easily look around in a few entries and it wouldn't be very helpful to kill the wifi connection before you close the dialog directly after you've looked up one term.

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Jan 16, 2018

Yes, it would depend on the done_with_wifi_action setting. May be the code could give hint to afterWifiAction about whether it may do some other network stuff soon, so the action could be tweaked (I get NewsDownloaded needs just : go online, fetch rss, go offline)
For wikipedia, it works great with a timer: connect, get page, stays connected for 2mn in case we need to fetch more stuff (images soon), go offline if user is reading/idling too long. If he looks up other thing after that, just reconnect, reset timer, goes offline in 2mn...
It works like this nicely for me for months, but I am just not familiar enough with the other use cases - I'm not even sure how it works for you all (do you really go thru prompt and tap on your access point each time? or just have wifi on all the time? having wifi on eats battery like crazy on my kobo...)

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Jan 16, 2018

Like I probably said somewhere around here, I disable that new "turn wifi back on" default which I don't like and I just kill the wifi when I want it with a quick "standby". I thought my battery was starting to show its age when I realized the wifi now automatically turns itself back on after standby. On my phone three years might be starting to have an effect, but that poor thing recharges every few days.

Like I definitely said, I think the timeout idea is great. A default of a few minutes[1] with the option to tweak it.

[1] For the timeout. I'm less sure about making the timeout itself the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants