AppList: Difference between revisions

From iPhone Development Wiki
(→‎Simple Approach: Edited keys table)
(Fixed/removed dead link and minor updates)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Infobox Package
{{Infobox Package
|developer=[[User:Rpetrich|Ryan Petrich]]
|developer=[[User:Rpetrich|Ryan Petrich]]
|version=1.5.7
|version=1.5.9
|package=applist
|package=applist
}}
}}


'''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."
'''AppList''' is a library for fetching app information. As described on its package page: "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 ==
== How to use this library ==
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>.
 
=== Include directive ===
 
<source lang="objc">
#import <AppList/AppList.h>
</source>
 
=== Makefile ===
 
Add to your Makefile:
 
* <code>applist</code> to the <code>XXX_LIBRARIES</code> variable.
 
=== Packaging ===
 
Add to your package's control file:
 
* <code>, mobilesubstrate (>= 0.9.5000), firmware (>= 3.0), com.rpetrich.rocketbootstrap (>= 1.0.3) | firmware (<< 7.0)</code> to the <code>Depends</code> field.


== PreferenceLoader ==
== PreferenceLoader ==
Line 31: Line 50:
| ALSettingsPath || string || Absolute file path to a settings file. || -
| ALSettingsPath || string || Absolute file path to a settings file. || -
|-
|-
| ALSettingsKey || string || Key for the data to be saved. || -
| ALSettingsKey || string || Key for the data to be saved when <tt>ALSingleEnabledMode</tt> is true. || -
|-
|-
| ALSettingsKeyPrefix || string || Key prefix for the key for the data to be saved. || "ALValue-"
| ALSettingsKeyPrefix || string || Key prefix for the key for the data to be saved when <tt>ALSingleEnabledMode</tt> is false. || "ALValue-"
|-
|-
| ALChangeNotification || string || Darwin notification string to be posted when a change happens. || -
| ALChangeNotification || string || Darwin notification string to be posted when a change happens. || -
Line 40: Line 59:
|}
|}


''To do: Add missing keys "listed" in the [https://github.com/rpetrich/AppList/blob/master/ALApplicationTableDataSource.m source code].''
''To do: Add missing keys "listed" in the [https://github.com/rpetrich/AppList/blob/master/ALApplicationTableDataSource.m source code]. Expand ALSectionDescriptors' usage like in [https://github.com/rpetrich/Emphasize/blob/master/layout/Library/PreferenceLoader/Preferences/Emphasize/Emphasize.plist Emphasize].''


=== PreferenceBundle Approach ===
The following specifier presents a <code>PSLinkCell</code> for Cydia and iFile, which present a <code>PSLinkListCell</code> for a selection of options.
<source lang="xml">
{
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;
};
}
);
}
</source>
 
== Retrieving Lists and Icons ==


To get an array of applications' bundle identifiers and their display names sorted in alphabetical order by their display name:
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
// sort the apps by display name. displayIdentifiers is an autoreleased object.
 
NSArray *sortedDisplayIdentifiers;
NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
NSDictionary *applications = [[ALApplicationList sharedApplicationList] applicationsFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"isSystemApplication = TRUE"]
return [[apps.applications objectForKey:obj1] caseInsensitiveCompare:[apps.applications objectForKey:obj2]];}]; //sort the apps by display name
onlyVisible:YES titleSortedIdentifiers:&sortedDisplayIdentifiers];
[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>, choose a size from this enum:
To get the display identifier and icon for a specific app at index <code>idx</code>, choose a size from this enum:


<source lang=objc>
<source lang=objc>
Line 65: Line 119:


<source lang=objc>
<source lang=objc>
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:{X}];
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:idx];
UIImage *icon = [apps iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier];
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 ListLauncher7].


== Retrieving Settings ==
== Retrieving Settings ==


To access the list of applications use the following, filtered by enabled apps:
As a filter, when using the simple selections (as single or switch options):


''This should be revised''
<source lang=logos>
%ctor {
NSString *identifier = [NSBundle mainBundle].bundleIdentifier;
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistpath];
if ([[plistDict objectForKey:[ALSettingsKeyPrefix stringByAppendingString:identifier]] boolValue]) {
%init(someGroup);
}
}
</source>


<source lang=objc>
== Usages in opensource projects ==
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistpath];
[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"];
</source>


As seen in https://github.com/iceNuts/DisableNC-Switch
* https://github.com/iceNuts/DisableNC-Switch
* https://github.com/PoomSmart/AppPad


== External links ==
== External links ==


* [https://github.com/rpetrich/AppList AppList on GitHub]
* [https://github.com/rpetrich/AppList AppList on GitHub]
{{Navbox Library}}


[[Category:Cydia packages]]
[[Category:Cydia packages]]
[[Category:Directories in /Library]]

Latest revision as of 04:20, 8 May 2021

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: "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 when ALSingleEnabledMode is true. -
ALSettingsKeyPrefix string Key prefix for the key for the data to be saved when ALSingleEnabledMode is false. "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