Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
AppList: Difference between revisions - iPhone Development Wiki

AppList: Difference between revisions

From iPhone Development Wiki
(preferenceloader integration)
(Fixed/removed dead link and minor updates)
 
(23 intermediate revisions by 5 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."


== Usage ==
== How to use this library ==


=== With PreferenceLoader ===
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 ==
 
=== 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].


=== Without PreferenceLoader ===
{| class="wikitable"
! 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 <tt>ALSingleEnabledMode</tt> is true. || -
|-
| 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. || -
|-
| ALAllowsSelection || bool || Enable row selection. || ALSingleEnabledMode value
|}


To get an array of applications and their display identifiers, do the following:
''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].''
<source lang=objc>
ALApplicationList *apps = [ALApplicationList sharedApplicationList];


NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
The following specifier presents a <code>PSLinkCell</code> for Cydia and iFile, which present a <code>PSLinkListCell</code> for a selection of options.
    return [[apps.applications objectForKey:obj1] caseInsensitiveCompare:[apps.applications objectForKey:obj2]];}];
<source lang="xml">
[displayIdentifiers retain];
{
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>
</source>
This gives you a list of all the apps in alphabetical order by their display name.


To get the display identifier and icon for a specific app at index <code>{X}</code> do the following:
== Retrieving Lists and Icons ==
 
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>
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:{X}];
// sort the apps by display name. displayIdentifiers is an autoreleased object.
UIImage *icon = [apps iconOfSize:{size here - see enums} forDisplayIdentifier:displayIdentifier];
NSArray *sortedDisplayIdentifiers;
NSDictionary *applications = [[ALApplicationList sharedApplicationList] applicationsFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"isSystemApplication = TRUE"]
onlyVisible:YES titleSortedIdentifiers:&sortedDisplayIdentifiers];
</source>
</source>
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 37: Line 115:
};
};
</source>
</source>
And use the following snippet:
<source lang=objc>
NSString *displayIdentifier = [displayIdentifiers objectAtIndex:idx];
UIImage *icon = [apps iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier];
</source>
As seen in [https://github.com/twodayslate/ListLauncher7 ListLauncher7].
== Retrieving Settings ==
As a filter, when using the simple selections (as single or switch options):
<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>
== Usages in opensource projects ==
* 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