Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2012, 06:05 AM   #1
rastik
Connoisseur
rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.
 
Posts: 65
Karma: 4662
Join Date: Feb 2011
Location: CZ
Device: Kindle Touch 3G, Kindle Keyboard
Periodicals can be deleted on Kindle Touch

When I moved to KT I found out that reading periodicals is not as comfortable as on K3. When I side-load such a document, I can read it as expected, except for broken section/articles list. But if I send such a document via whispersync, KT does not detect it as a periodical. It goes somewhere in the middle. I managed to live with that, but for one problem - such a document cannot be deleted via GUI as long as it is present in archived items. Long press on the document does not do anything, it's therefore not possible to move it collection or delete it.
In log I get:
Code:
cvm[1328]: E GestureDispatcher:ExceptionCaught::Error in actionPerformed
cvm[1328]: java.util.MissingResourceException: Can't find resource for bundle com.amazon.kindle.apps.util.resources.AreasResources, key remove.label
cvm[1328]:     at java.util.ResourceBundle.getObject(Compiled Method)(Unknown Source)
cvm[1328]:     at java.util.ResourceBundle.getString(Compiled Method)(Unknown Source)
cvm[1328]:     at com.amazon.kindle.apps.util.detailview.DefaultDetailViewFactory.getActions(vtc:873)
cvm[1328]:     at com.amazon.kindle.apps.util.detailview.DefaultDetailViewFactory.getDetails(vtc:1471)
cvm[1328]:     at com.amazon.ebook.booklet.periodicals.impl.detail.PeriodicalsDetailViewFactory.getDetails(yid:1471)
cvm[1328]:     at com.amazon.kindle.restricted.device.impl.ApplicationRegistryImpl.getDetailViewDialog(igb:577)
cvm[1328]:     at com.amazon.kindle.home.action.OpenDetailsAction.actionPerformed(zbc:694)
The problem is that the code tries to find string "remove.label" in com.amazon.kindle.apps.util.resources.UtilResource s. And it's not there
Code:
        if(QueryUtils.hasArchivedCopy(a, D))
        {
            if((a = (Action)a.get("Remove")) != null)
            {
                a.putValue("Name", a.getString("remove.label"));
                a.add(a);
            }
        } else
        if((a = (Action)a.get("Delete")) != null)
        {
            a.putValue("Name", a.getString("delete.document.label"));
            a.add(a);
        }
So, I tried to edit DefaultDetailViewFactory.class in /opt/amazon/ebook/lib/app_utilities.jar with ClassEditor and changed remove.label to delete.document.label. After bind-mounting new jar it works.
I'd like to upload it for others to try (and possibly use), but it would probably violate copyright rights. Do you know how can I do that?
rastik is offline   Reply With Quote
Old 01-17-2012, 06:28 AM   #2
rastik
Connoisseur
rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.
 
Posts: 65
Karma: 4662
Join Date: Feb 2011
Location: CZ
Device: Kindle Touch 3G, Kindle Keyboard
I'm not so good in Java byte code editing, but it would be better to edit com.amazon.kindle.apps.util.resources.UtilResource s and add remove.label string there. This string is referenced from other classes as well. But so far, I was not able to do so. Anyone?
rastik is offline   Reply With Quote
Old 01-17-2012, 07:43 AM   #3
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677559
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
You could try to simply create com.amazon.kindle.apps.util.resources.UtilResource s_en.properties and put that string in there. Then jar up the file and throw it into /opt/amazon/ebook/lib. Not an elegant solution, and an untested one, but I'm quite sure it'll work.

Last edited by ixtab; 01-17-2012 at 07:46 AM. Reason: class -> file. .properties are simple text files.
ixtab is offline   Reply With Quote
Old 01-17-2012, 07:53 AM   #4
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677559
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
btw, your stack trace says com.amazon.kindle.apps.util.resources.AreasResourc es, not UtilResources. Typo or intentional?

In any case, this method of "augmenting" resources via .properties files should work for either bundle. It's exactly the same method that is used for localization. So in this case, you're simply providing a more specific file (_en, or even _en_US) which will take priority over the base bundle. No need to tamper with class bytecode.
ixtab is offline   Reply With Quote
Old 01-17-2012, 08:32 AM   #5
rastik
Connoisseur
rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.
 
Posts: 65
Karma: 4662
Join Date: Feb 2011
Location: CZ
Device: Kindle Touch 3G, Kindle Keyboard
Names are AreasResources and UtilResources, but every time I write the whole com.amazon.kindle.apps.util.resources.UtilResource s string, it is split by the forum. It does not allow words longer than 50 characters
Can I use resource file to replace this?
Code:
public class AreasResources extends ListResourceBundle
{

    public AreasResources()
    {
    }

    protected Object[][] getContents()
    {
        return D;
    }

    static final Object D[][] = {
        {
            "addto.collection.label", "Add to Collection"
        }, {
            "notesandmarks.label", "Notes & Marks"
        }, {
            "goto.label", "Go To..."
        }, {
            "search.document.label", "Search This Document"
        }, {
            "delete.document.label", "Delete This Document"
        }, {
            "Areas.titleArea.font", FontCache.getInstance().get("Serif", 1, 23)
        }, {
            "Areas.titleArea.insets", new Insets(2, 0, 2, 0)
        }, {
            "Areas.titleArea.lines", new Integer(5)
        }, {
            "Areas.authorArea.font", FontCache.getInstance().get("Serif", 1, 19)
        }, {
            "Areas.authorArea.insets", new Insets(2, 0, 2, 0)
        }, {
            "areas.narratorarea.font", FontCache.getInstance().get("Serif", 1, 19)
        }, {
            "areas.narratorarea.insets", new Insets(2, 0, 2, 0)
        }, {
            "Areas.tagArea.font", FontCache.getInstance().get("Serif", 0, 12)
        }, {
            "Areas.tagArea.insets", new Insets(0, 0, 2, 0)
        }, {
            "Areas.progressArea.insets", new Insets(2, 0, 2, 0)
        }, {
            "Areas.inCollectionsArea.font", FontCache.getInstance().get("Serif", 1, 17)
        }, {
            "Areas.inCollectionsArea.insets", new Insets(2, 0, 0, 0)
        }, {
            "Areas.publicationDateArea.font", FontCache.getInstance().get("Serif", 1, 17)
        }, {
            "Areas.publicationDateArea.insets", new Insets(2, 0, 2, 0)
        }, {
            "areas.embeddedtitlearea.font", FontCache.getInstance().get("Serif", 1, 17)
        }, {
            "areas.embeddedtitlearea.insets", new Insets(2, 0, 0, 0)
        }, {
            "Areas.progressArea.insets", new Insets(2, 0, 2, 0)
        }
    };

}
rastik is offline   Reply With Quote
Old 01-17-2012, 08:43 AM   #6
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677559
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
You can only use .properties files to set String values (not Insets etc.). However, this is o problem, because you do not need to *replace* the file, you simply add another file "on top" of it.

This will work because of the way Java resource bundles work. They were designed to be used for localization. Suppose you are looking for a resource named R (in your case "remove.label") in resource bundle B (in your case AreasResources). If you're using en_US locale (as you do by default on the KT), resource lookup will be as follows:

1. does bundle B_en_US exist, and does it contain R?
2. does bundle B_en exist, and does it contain R?
3. does bundle B exist, and does it contain R?

In the above statements, a bundle can be a full-fledged class extending ResourceBundle, or it can simply be a .properties file (which will automagically be loaded using PropertyResourceBundle).

Thus, if you create a file named AreasResources_en.properties (or AreasResources_en_US.properties) at the correct directory (according to the bundle package name), and put ONLY the line "remove.label=ITSWORKING" in it, then your kindle will be using ITSWORKING for that particular entry of the resource bundle.

Hope this is clear enough.

UPDATE: (You may want to take a look at the KT localization thread; we're dealing with exactly such issues at the moment, albeit in a different context. However, getting the Localization tool from git and experimenting with it should hopefully help to understand how these resourcebundle things work).

Last edited by ixtab; 01-17-2012 at 08:47 AM.
ixtab is offline   Reply With Quote
Old 01-17-2012, 11:19 AM   #7
rastik
Connoisseur
rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.rastik is fluent in JavaScript as well as Klingon.
 
Posts: 65
Karma: 4662
Join Date: Feb 2011
Location: CZ
Device: Kindle Touch 3G, Kindle Keyboard
Thank you. It works.
What I've done (for others):
Create AreasResources_en.properties file containing:
Code:
remove.label=Move to Archived Items
Download /opt/amazon/ebook/lib/app_utilities.jar and add AreasResources_en.properties file to com/amazon/kindle/apps/util/resources folder within the archive. Any ZIP-compatible archiver should work.
Replace jar on Kindle and restart (framework or whole device). Or (RECOMMENDED) first try to store it somewhere else (e.g. /mnt/us) and in SSH enter:
Code:
mount --bind app_utilities.jar /opt/amazon/ebook/lib/app_utilities.jar
restart framework
This will keep it only until next reboot, so it is safe.
rastik is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleted Kindle Touch Documents folder contents Newf Amazon Kindle 2 12-28-2011 03:20 PM
Kindle 3, Nook Simple Touch, Kobo Touch and Libra Pro Touch jbcohen Which one should I buy? 4 06-18-2011 08:58 PM
Periodicals are not automatically deleted oecherprinte Amazon Kindle 3 03-15-2011 07:28 AM
News / periodicals date on the kindle prophet Calibre 3 12-04-2010 07:05 PM
Possible to treat periodicals as...periodicals? Spankypoo Calibre 1 01-23-2010 11:06 PM


All times are GMT -4. The time now is 07:40 AM.


MobileRead.com is a privately owned, operated and funded community.