rockingmaster / openintents

Automatically exported from code.google.com/p/openintents
0 stars 0 forks source link

OI File Manager: Icons for files are not properly chosen. #333

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
* OI File Manager apparently uses the most recently installed app that can 
handle a file type.
* If a file time claims to handle all file types and is newly installed, it is 
used for all files.
* Instead, if a more specific file type handler is available (e.g. music only 
or text only), then that should be used instead.
* Also if a priority is set, that should be taken into accoung.

This was reported here:
http://www.openintents.org/en/node/858

---------

Im using the OI File Manager for testing my new application. I
installed the application and the app contains an icon. The goal of
the app is to serve 'action.VIEW' intent with many different files.
When I now start the File Manager, it now replaces all former icons
(text file icon, music icons, etc..) with the icon of my app. I don't
want the new icon to be shown, ex. I still want text files with the
text file icon and music files with the music file icon and so on. I
tried to play with android:priority of my intent-filter a little bit,
but that did not lead to any success.
So I took a look into the source of OI File Manager and I found this:
(DirectoryScanner.java , lines 257-272)

final List lri = pm.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (lri != null && lri.size() > 0) {
//Log.i(TAG, "lri.size()" + lri.size());
// return first element
int index = 0;

// Actually first element should be "best match",
// but it seems that more recently installed applications
// could be even better match.
index = lri.size()-1;

final ResolveInfo ri = lri.get(index);
return ri.loadIcon(pm);
}

So, the icon of the most recently installed application is rendered,
which is my application's icon. Please, what do you suggest I can do about
this? It would probably be possible to not return the icon of the last installed
application, but instead take the priorities of all the apps that can serve the 
'action.VIEW' intent and
choose the one with the highest priority, woudnt it? 

Original issue reported on code.google.com by peli0...@googlemail.com on 26 Mar 2011 at 5:11

GoogleCodeExporter commented 8 years ago
Android docs state that queryIntentActivities():

"Returns:
A List<ResolveInfo> containing one entry for each matching Activity. 
These are ordered from best to worst match -- that is, the first item in the 
list is what is returned 
by resolveActivity(Intent, int). If there are no matching activities, an empty 
list is returned."

So the first item should be the best Activity to choose, but as stated for 
resolveActivity(Intent,int):

"Returns:
Returns a ResolveInfo containing the final activity intent that was determined 
to be the best action. 
Returns null if no matching activity was found. If multiple matching activities 
are found and there 
is no default set, returns a ResolveInfo containing something else, such as the 
activity resolver."

So, if several Activities have the same priority set, we'll get 
com.android.internal.app.ResolverActivity as 
best matching (first index) Activity, as there is probably no default chosen, 
yet.
As addPreferredActivity() is deprecated since SDK 2.2, the system is 
responsible for assigning Activities and
developers can't register their app as preferred one.

Even if we take priority into consideration and at least two Activities have 
equal priority, how we'll choose
which one to take?

Original comment by dominik....@gmail.com on 26 Mar 2011 at 3:16

GoogleCodeExporter commented 8 years ago
Hello, thanks for your interest in the issue I encountered. Too bad I've been 
into android for such a short time. There's another thing I don't understand. 
Without setting any priority(so the default is 0 i guess) for my intent-filter 
to handle the action.VIEW intent and calling:
(intent is action.VIEW and data is ex. "file:///textfile.txt")
List<ResolveInfo> lri = 
packageManager.queryIntentActivities(intent,MATCH_DEFAULT_ONLY);
The output is:
0: ResolveInfo{44f58378 com.android.htmlviewer.HTMLViewerActivity p=0 o=0}
1: ResolveInfo{44f588d8 com.metago.astro.FileViewer p=0 o=00}
2: ResolveInfo{44f58e50 com.ander.pt.activities.MyNewActivity p=0 o=0}

So the output is fine, all of the activities show their default priority, which 
is p=0.
Now, I expected the output to be different, if I set a different priority to my 
activity thru the intent-filter definition, using the android:priority 
attribute. I set it to "5" and the output remains the same. I have no idea why, 
I probably have quite a few basic misunderstandings about how android works :)

To answer your question Dominik: right now the most recently installed app is 
taken, whatever the priority is.
Instead, i think it would be better to do it like this:
1. find out, if user set any application to open the type of files by default. 
This can be done by checking the checkbox "use by default for this action" when 
choosing an application to use. I dont know how to find out this info, but I 
believe this is not hard to do.
2. if no deafult is found, order all activities by their priority and take the 
one with the highest priority, or the most recently installed one if there are 
more than one with the highest priority.

Besides the 'priority' field, the ResolveInfo instance also has the 'int match' 
field representing 'The system's evaluation of how well the activity matches 
the IntentFilter.' This sound like it could be used well, but I dont know how 
this value is computed (or if it is at all), since whatever I try, it is always 
0, just like the priority is always 0. Im doing smth wrong, or thinkning 
wrong... or both.. or neither? :) thanks

Original comment by igor.dawg on 27 Mar 2011 at 11:17

GoogleCodeExporter commented 8 years ago
Thanks for posting your results so far. As I did not encounter that application 
requirements for now I will do some research on this over the next days. I 
think it will be manageable to figure out how thinks work. Im going to study 
some Android source files to figure out how the system is computing the 
mentioned values. So, I think you are not thinking wrong but there is a trick 
to configure the application in the right way ;)

Original comment by dominik....@gmail.com on 30 Mar 2011 at 11:06

GoogleCodeExporter commented 8 years ago
Hey there, hope you're doing fine... I just want to comment that Im now a 
little further with my app, but this OI FileManager issue still makes it look 
unusable. I have some music files and all icons are just fine before I install 
my app. After installing (therefore registering my intent-filter: <data 
android:scheme="file" android:mimeType="*/*" />), all the music icons(and some 
other types as well) are gone and the icon of my app is shown everywhere. I 
guess the fix must be sooo easy and straightforward as soon as we find out how 
all those priority values are used (or if they are used, but they should be 
somehow...)

Original comment by igor.dawg on 22 May 2011 at 9:38

Attachments:

GoogleCodeExporter commented 8 years ago
Issue 320 has been merged into this issue.

Original comment by peli0...@googlemail.com on 3 Aug 2011 at 10:43

GoogleCodeExporter commented 8 years ago
Google Code-in task:
http://www.google-melange.com/gci/task/view/google/gci2011/7120268

Original comment by peli0...@googlemail.com on 26 Nov 2011 at 1:52

GoogleCodeExporter commented 8 years ago
My first patch for this issue (see task above) aimed at fixing this issue, with 
the current approach. However it appears that it doesn't work on some devices 
(but it did on mine)

Another possible solution would be to allow OI to accept an archive of icons 
(how about Gnome Icon Theme archives?) and use them as generic mimetype icons. 
The latter approach seems more reliable and customisable. 

Original comment by aviraldg on 6 Dec 2011 at 8:19

GoogleCodeExporter commented 8 years ago
Ok, since we have many GCI students who like to work on icons, we could just 
create the icons during GCI.
What would we need?
*.txt
*.pdf
*.doc, *.odt and related?
*.xls, *.ods and related?
*.mid, *.mp3, ... and related?

Original comment by peli0...@googlemail.com on 6 Dec 2011 at 9:18

GoogleCodeExporter commented 8 years ago
That is the beauty of the idea - we would not need to make any icons of our 
own. There are already many good Gnome Icon Themes and OI would be able to use 
any of them.

Original comment by aviraldg on 6 Dec 2011 at 9:29

GoogleCodeExporter commented 8 years ago
But do they follow the Android design guidelines?
http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.
html

There is a unique look to Android which should be maintained.

Original comment by peli0...@googlemail.com on 7 Dec 2011 at 12:07

GoogleCodeExporter commented 8 years ago
I think using generic icons for each mimetype seems like a good idea. The icon 
sets and themes that I've looked at so far on http://art.gnome.org/themes/icon 
have icons sorted by mimetype, so it would be fairly simple to assign icons 
based on mimetype / extension. We're also able to mix icons from different sets 
if one doesn't meet the icon guidelines.

Original comment by philipha...@gmail.com on 28 Dec 2011 at 10:06

GoogleCodeExporter commented 8 years ago
I've added new issues for creating the necessary icons:
issues 442, 443, 444, 445, 446, 447, 448, 449, 450.

Work on this issue can start nevertheless, and you may use any icon as a place 
holder until we have icons in the Android design.

One could add a new tag "icon" to this xml file:
http://code.google.com/p/openintents/source/browse/trunk/filemanager/FileManager
/res/xml/mimetypes.xml
e.g. <type extension=".png" mimetype="image/png" 
icon="@drawable/ic_launcher_image" />

and read the information in MimeTypeParser:
http://code.google.com/p/openintents/source/browse/trunk/filemanager/FileManager
/src/org/openintents/filemanager/util/MimeTypeParser.java

but other suggestions for implementation are also welcome.

Original comment by peli0...@googlemail.com on 29 Dec 2011 at 10:34

GoogleCodeExporter commented 8 years ago
http://www.google-melange.com/gci/task/view/google/gci2011/7179237

Original comment by peli0...@googlemail.com on 14 Jan 2012 at 6:37

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r4053.

Original comment by peli0...@googlemail.com on 15 Jan 2012 at 5:50

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r4054.

Adjust MIME types according to WebKit:
http://www.google.com/codesearch#uX1GffpyOZk/core/java/android/webkit/MimeTypeMa
p.java&q=mimetypemap.java&type=cs&l=163

Original comment by peli0...@googlemail.com on 15 Jan 2012 at 6:11