-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open with... improvement #11056
Open with... improvement #11056
Conversation
@@ -161,7 +161,7 @@ function FileManagerCollection:showCollDialog() | |||
path = G_reader_settings:readSetting("home_dir"), | |||
select_directory = false, | |||
file_filter = function(file) | |||
return DocumentRegistry:getProviders(file) ~= nil | |||
return DocumentRegistry:hasProvider(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the behavior the same for normally hidden files with a custom assigned engine and similar edge cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give an example what do you mean.
We add to favorites only documents (ie they have a provider).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mainly meant I assumed it was a line I wrote a few years back, but I see now that it's in something you wrote. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm in principle, not able to test atm though
You can't cache the providers registered from plugins; they reinstantiate on view changes, so you'd be pinning stale objects ;). (IIRC, that's less of a problem for real Doc* providers, as we either feed it the class, or they're singletons, can't recall and a bit short on time right now). |
Thank you, I understand. I'll change the architecture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a thorough review (this provider business is a bit too much for me :)), but nothing jumps out. Trusting you.
Just a nitpick.
local util = require("util") | ||
|
||
local DocumentRegistry = { | ||
registry = {}, | ||
providers = {}, | ||
providers_hash = {}, -- hash table of registered providers { provider_key = provider } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providers_hash
sounds like it would be a hash value (a string or a number).
It is a Lua hash (not an array) table, ok, but we don't advertize that fact in most of our names :)
So, may be known_providers
or provider_names
?
@pazos, regarding your #9615 and #11001, I do not follow your way: I think your non-document handlers (plugins?) can be registered as auxiliary provider (see Text editor and Archive viewer here). Then any packet/non-document extension can be associated (manually in Open with... dialog or automatically by the plugin itself) with your aux provider. It will be opened just by a tap in the file browser and in the file search results. |
Thanks for the hints. Feel free to do it your way. Mine was a quick attempt. Anyhow, I won't probably have time for that stuff until I'm retired :/ Will close those, while I'm at it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 9 of 14 files at r1, 1 of 2 files at r2, 4 of 4 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @hius07)
frontend/apps/filemanager/filemanagerfilesearcher.lua
line 322 at r4 (raw file):
close_dialog_callback() local FileManager = require("apps/filemanager/filemanager") FileManager.openFile(self.ui, file, nil, self.close_callback)
Unfamiliar with all this, but I don't follow why close_callback
is now limited to running when opening via auxiliary providers?
Code quote:
close_dialog_callback()
local FileManager = require("apps/filemanager/filemanager")
FileManager.openFile(self.ui, file, nil, self.close_callback)
frontend/document/documentregistry.lua
line 285 at r4 (raw file):
require("document/djvudocument"):register(DocumentRegistry) require("document/picdocument"):register(DocumentRegistry) -- auxuliary built-in
nit: auxiliary
;)
frontend/ui/widget/imageviewer.lua
line 863 at r4 (raw file):
return registry:isImageFile(file) end, callback = function(file)
You should be able to use a direct assignment here, e.g., callback = ImageViewer.openFile,
, the signatures are identical, and the closure doesn't do anything fancy at all ;).
frontend/ui/widget/textviewer.lua
line 544 at r4 (raw file):
callback = function(file) TextViewer.openFile(file) end,
Ditto ;).
Code quote:
callback = function(file)
TextViewer.openFile(file)
end,
I also wouldn't mind clearer comments about the fact that none of these aux stuff actually implement the Document* API, and we're just shoe-horning those in |
We are in the search results list.
Actually, |
koreader/frontend/document/documentregistry.lua Lines 49 to 55 in 4027288
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @hius07)
frontend/ui/widget/infomessage.lua
Outdated
function InfoMessage:init() | ||
if not self.font_adjusted then | ||
self.face = Font:getFace(self.monospace_font and "infont" or "infofont") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just if not self.face then self.face = ...
?
(Will allow passing a face=
when we want something other of infont/infofont?)
Fix koreader#11390 Regression since koreader#11056
The previous check was inlined in the dir walk, so it always saw a relative path. Here, it gets an absolute one instead, so act accordingly ;). Fix koreader#11390 Regression since koreader#11056
The purpose is to open non-document files by a tap in file browser and file search results.
Currently we have 4 auxiliary (non-document) providers: Image viewer, Text viewer, Text editor plugin, Archive viewer plugin.
Changes:
(1) DocumentRegistry
-a plugin can register itself as an auxiliary provider
-deduplicated code and run
(2) Open with... dialog
-associate a file type with an auxiliary provider
-view the list of providers associated with a file type
-reset the provider associated with a single file
Unchanged:
A single file cannot be associated with an auxiliary provider.
Document providers' standard behaviour.
(3) Archive viewer
-view images in an archive as a multi-page image (useful to view cbz content)
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)