("How to use this library" standardization) |
('Usage' is now PreferenceLoader usage and settings retrieval) |
||
Line 10: | Line 10: | ||
Headers are available from [https://github.com/rpetrich/AppList/tree/master/public Applist's GitHub project] and the library can be found at <code>/usr/lib/libapplist.dylib</code> on a device where Applist is installed. If using Theos, place the headers in <code>$THEOS/include/Applist</code>, the library in <code>$THEOS/lib/</code> and add <code>applist</code> to the <code>XXX_LIBRARIES</code> Makefile variable. | Headers are available from [https://github.com/rpetrich/AppList/tree/master/public Applist's GitHub project] and the library can be found at <code>/usr/lib/libapplist.dylib</code> on a device where Applist is installed. If using Theos, place the headers in <code>$THEOS/include/Applist</code>, the library in <code>$THEOS/lib/</code> and add <code>applist</code> to the <code>XXX_LIBRARIES</code> Makefile variable. | ||
== | == PreferenceLoader == | ||
=== | === Simple Approach === | ||
The common way to use AppList is via its [[PreferenceLoader]] (preferences) integration, by putting entries in a PreferenceLoader plist: [https://github.com/rpetrich/AppList/blob/master/sample/layout/Library/PreferenceLoader/Preferences/AppListSample.plist AppListSample.plist]. | The common way to use AppList is via its [[PreferenceLoader]] (preferences) integration, by putting entries in a PreferenceLoader plist: [https://github.com/rpetrich/AppList/blob/master/sample/layout/Library/PreferenceLoader/Preferences/AppListSample.plist AppListSample.plist]. | ||
To | ''To-Do: Add explanation of keys in the plist'' | ||
=== | === PreferenceBundle Approach === | ||
To get an array of applications and their display | To get an array of applications' bundle identifiers and their display names sorted in alphabetical order by their display name: | ||
<source lang=objc> | <source lang=objc> | ||
ALApplicationList *apps = [ALApplicationList sharedApplicationList]; //list all the apps | ALApplicationList *apps = [ALApplicationList sharedApplicationList]; //list all the apps | ||
NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { | NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { | ||
return [[apps.applications objectForKey:obj1] caseInsensitiveCompare:[apps.applications objectForKey:obj2]];}]; //sort the apps by display name | |||
[displayIdentifiers retain]; //make sure it doesn't disappear when you actually need to use it, if you only use it once, release it | [displayIdentifiers retain]; //make sure it doesn't disappear when you actually need to use it, if you only use it once, release it | ||
</source> | </source> | ||
To get the display identifier and icon for a specific app at index <code>{X}</code> | To get the display identifier and icon for a specific app at index <code>{X}</code>, choose a size from this enum: | ||
<source lang=objc> | <source lang=objc> | ||
Line 52: | Line 36: | ||
ALApplicationIconSizeLarge = 59 | ALApplicationIconSizeLarge = 59 | ||
}; | }; | ||
</source> | |||
And use the following snippet: | |||
<source lang=objc> | |||
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:{X}]; | |||
UIImage *icon = [apps iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier]; | |||
</source> | </source> | ||
As seen in https://github.com/twodayslate/ListLauncher7 | As seen in https://github.com/twodayslate/ListLauncher7 | ||
== Retrieving Settings == | |||
To access the list of applications use the following, filtered by enabled apps: | |||
''This should be revised'' | |||
<source lang=objc> | |||
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistpath]; | |||
[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"]; | |||
</source> | |||
As seen in https://github.com/iceNuts/DisableNC-Switch | |||
== External links == | == External links == |
Revision as of 13:50, 11 June 2014
AppList | |
Cydia Package | |
---|---|
Developer | Ryan Petrich |
Package ID | applist |
Latest Version | 1.5.7 |
AppList is a library for fetching app information. As described on its package page in Cydia: "Allows developers to query the list of installed apps and provide a preferences pane based on that information. Exports displayIdentifier, displayName, icon and smallIcon via a remote messaging center so that it's easy to write a prefs pane that presents a list of apps."
How to use this library
Headers are available from Applist's GitHub project and the library can be found at /usr/lib/libapplist.dylib
on a device where Applist is installed. If using Theos, place the headers in $THEOS/include/Applist
, the library in $THEOS/lib/
and add applist
to the XXX_LIBRARIES
Makefile variable.
PreferenceLoader
Simple Approach
The common way to use AppList is via its PreferenceLoader (preferences) integration, by putting entries in a PreferenceLoader plist: AppListSample.plist.
To-Do: Add explanation of keys in the plist
PreferenceBundle Approach
To get an array of applications' bundle identifiers and their display names sorted in alphabetical order by their display name:
ALApplicationList *apps = [ALApplicationList sharedApplicationList]; //list all the apps
NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [[apps.applications objectForKey:obj1] caseInsensitiveCompare:[apps.applications objectForKey:obj2]];}]; //sort the apps by display name
[displayIdentifiers retain]; //make sure it doesn't disappear when you actually need to use it, if you only use it once, release it
To get the display identifier and icon for a specific app at index {X}
, choose a size from this enum:
enum {
ALApplicationIconSizeSmall = 29,
ALApplicationIconSizeLarge = 59
};
And use the following snippet:
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:{X}];
UIImage *icon = [apps iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier];
As seen in https://github.com/twodayslate/ListLauncher7
Retrieving Settings
To access the list of applications use the following, filtered by enabled apps:
This should be revised
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistpath];
[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"];
As seen in https://github.com/iceNuts/DisableNC-Switch