Code Monkey home page Code Monkey logo

kbapplist's Introduction

KBAppList

Framework for access to lists of installed apps and cool app selection preference panes!

The preferences, unlike all other iOS preference panes makes use of a UICollectionView with a fresh but iOS like look rather then the standard UITableView. It comes with drag and drop, quick edit, and search capabillities to improve user experience within your tweaks.

Requires a unique ID for saving the list in preferences, which can be retrieved in a number of ways. The recommended method is NSUserDefaults. Can also use Post Notification, to allow you to instantly retrieve the new listed of selected apps whenever a change to the selected apps is made.

| Downloads: | Latest Release | Headers | Example Use | Package | Framework |

How To Use?

First, You have to install the latest deb. when the installation process is complete, you have to add the latest KBAppList framework to /theos/lib/.

Now we can move onto the tweak's folder. First you would need to add KBAppList as a dependancy, this can be done by add it to the control file like Depends: mobilesubstrate, com.kaneb.kbapplist. Next You would need to add TWEAKSNAME_EXTRA_FRAMEWORKS += KBAppList in the makefile in the Preferences folder.

It is really easy to add a tab to view the applist inside your preferences, all you need to do is add this inside your root.plist

    <dict>
       <key>key</key>
       <string>UNIQUEID</string> <!-- your unique prefs key, for retrieving selected apps in your tweak -->
       <key>defaults</key>
       <string>com.example.tweak</string> <!-- The pref's bundleID -->
       <key>default</key>
       <string></string> <!-- This will default to all apps being unselected -->
       <key>appList</key>
       <string>allApps</string> <!-- Choose which apps should be displayed for selection -->
       <key>label</key>
       <string>DISPLAYNAME</string> <!-- What the tab will be called in the settings app -->
       <key>postNotification</key> <!-- This is if you want to use system notifications for real time preference changes -->
       <string>com.example.tweak-prefsreload</string>
       <key>cell</key>
       <string>PSLinkCell</string>
       <key>detail</key>
       <string>ALViewController</string>
       <key>icon</key>
       <string>iconpath.png</string>
       <key>isController</key>
       <true/>
     </dict>

Finally retrieving the values from the Tweak.xm file can be easily done like such.

  NSUserDefaults *preferences = [[NSUserDefaults alloc] initWithSuiteName:@"com.example.tweak"];
  NSArray *apps = [preferences objectForKey:@"UNIQUEID"];
  NSArray *appsName = [apps valueForKey:@"name"];
  NSArray *appsID = [apps valueForKey:@"bundleID"];

If you are going to use postNotifcation you can use this outside the %hook.

static void loadPrefs() {
     NSUserDefaults *preferences = [[NSUserDefaults alloc] initWithSuiteName:@"com.example.tweak"];
     NSArray *apps = [preferences objectForKey:@"UNIQUEID"];
     NSArray *appsName = [apps valueForKey:@"name"];
     NSArray *appsID = [apps valueForKey:@"bundleID"];
}

%ctor {
    CFNotificationCenterAddObserver(
    CFNotificationCenterGetDarwinNotifyCenter(), NULL,
    (CFNotificationCallback)loadPrefs,
    CFSTR("com.example.tweak-prefsreload"), NULL,
    CFNotificationSuspensionBehaviorDeliverImmediately);
    loadPrefs();
}

Information

Preferences

Keys Option 1 Option 2 Option 3 Option 4
key UNIQUE STRING
defaults UNIQUE bundleID
default "selected" "unselected" or nil
postNotification UNIQUE BUNDLEID nil
appList "userApps" "systemApps" "allApps" "audioApps"
label STRING nil
selectionAllowance INTEGER nil

KBAppList KBAppList


License

Please dont steel code!

This software is licensed under the BSD 4 License, detailed in the file LICENSE.md If you do wish to use this code in your project then in addition to the License agreement you must also provide a link to my twitter @IndieDevKB. If for any reason you do not wish to include my twitter in your project, then please contact me so we can discuss another agreement.

kbapplist's People

Contributors

kanebuckthorpe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.