string - Android, retrieve additional information about a resource -
i doing instrumented unit tests check resources requirements, there no duplicate texts, or pictures used once.
i not want hardcode list of strings or pictures.
i know how retrieve drawable or string resources , id or key name, missing important information like:
- is string translatable? how translatable="false" flag?
- is drawable file? (or drawable injected android starting "abc_")
- in files comes string from? (strings.xml or custom name)
if have clue please tell me :) thanks!
@runwith(androidjunit4.class) public class resourcestest { @test public void duplicatedtexts() throws exception { final class<r.string> c = r.string.class; final field[] fields = c.getdeclaredfields(); (field field : fields) { int resid = field.getint(field); // string resource id string keyname = field.getname(); // string key name // how skip non translatable strings? if (!istranslatable(resid, field)) { continue; } // check } } }
Comments
Post a Comment