AppList

From iPhone Development Wiki
Jump to: navigation, search
AppList
Cydia Package
Developer Ryan Petrich
Package ID applist
Latest Version 1.5.9


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/.

Include directive

#import <AppList/AppList.h>

Makefile

Add to your Makefile:

  • applist to the XXX_LIBRARIES variable.

Packaging

Add to your package's control file:

  • , mobilesubstrate (>= 0.9.5000), firmware (>= 3.0), com.rpetrich.rocketbootstrap (>= 1.0.3) | firmware (<< 7.0) to the Depends field.

PreferenceLoader

Simple Approach

The common way to use AppList is via its PreferenceLoader (preferences) integration, by putting entries in a PreferenceLoader plist: AppListSample.plist.

Key Type Description Default value
ALNavigationTitle string Navigation title. The specifier name
ALSingleEnabledMode bool Switch between single and multiple row selection. NO
ALSectionDescriptors array Array of PSSpecifier-style dictionaries. -
ALLocalizationBundle string Absolute path to a localization bundle. nil
ALSettingsDefaultValue object Default value. -
ALSettingsPath string Absolute file path to a settings file. -
ALSettingsKey string Key for the data to be saved. -
ALSettingsKeyPrefix string Key prefix for the key for the data to be saved. "ALValue-"
ALChangeNotification string Darwin notification string to be posted when a change happens. -
ALAllowsSelection bool Enable row selection. ALSingleEnabledMode value

To do: Add missing keys "listed" in the source code. Expand ALSectionDescriptors' usage like in Emphasize.

The following specifier presents a PSLinkCell for Cydia and iFile, which present a PSLinkListCell for a selection of options.

{
	bundle = AppList;
	cell = PSLinkCell;
	icon = "/Applications/Preferences.app/icon.png";
	isController = 1;
	label = "AppList Sample";
	ALAllowsSelection = 1;
	ALSectionDescriptors = (
		{
			title = "Supported Applications";
			predicate = "(displayIdentifier IN {'com.saurik.Cydia','eu.heinelt.ifile'})";
			"cell-class-name" = "ALDisclosureIndicatedCell";
			"icon-size" = 29;
			"suppress-hidden-apps" = 1;
			action = "showPreferences";
			"display-identifier-macro" = "@@DISPLAYIDENTIFIER@@";
			entry = {
				PostNotification = "com.rpetrich.applist.example.plist";
				cell = PSLinkListCell;
				default = 0;
				defaults = "com.rpetrich.applist.example";
				detail = PSListItemsController;
				key = "AppColor-@@DISPLAYIDENTIFIER@@";
				validTitles = ("Default", "iOS Standard");
				validValues = (0, 1);
				bundle = "AppList";
				isController = 1;
				overridePrincipalClass = 1;
			};
		}
	);
}

Retrieving Lists and Icons

To get an array of applications' bundle identifiers and their display names sorted in alphabetical order by their display name:

// sort the apps by display name. displayIdentifiers is an autoreleased object.
NSArray *sortedDisplayIdentifiers;
NSDictionary *applications = [[ALApplicationList sharedApplicationList] applicationsFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"isSystemApplication = TRUE"]
	onlyVisible:YES titleSortedIdentifiers:&sortedDisplayIdentifiers];

To get the display identifier and icon for a specific app at index idx, choose a size from this enum:

enum {
	ALApplicationIconSizeSmall = 29,
	ALApplicationIconSizeLarge = 59
};

And use the following snippet:

NSString *displayIdentifier = [displayIdentifiers objectAtIndex:idx];
UIImage *icon = [apps iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier];

As seen in ListLauncher7.

Retrieving Settings

As a filter, when using the simple selections (as single or switch options):

%ctor {
	NSString *identifier = [NSBundle mainBundle].bundleIdentifier;
	NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistpath];	
	if ([[plistDict objectForKey:[ALSettingsKeyPrefix stringByAppendingString:identifier]] boolValue]) {
		%init(someGroup);
	}
}

Usages in opensource projects

External links