Coder Social home page Coder Social logo

weepreferenceloader's Introduction

WeePreferenceLoader

A tool to load and insert preferences in the iOS Notification Center settings. Inspired heavily by Dustin Howett's PreferenceLoader.

Essentially, this allows you to very easily add preferences for Notification Center widgets (WeeApps) and even for per-app notification settings (BulletinBoard). It supports:

  • Adding preferences dynamically via plists
  • Loading bundles to add custom code and localization
  • Picking up plist files directly from WeeAppPlugin bundles

Why Use It?

  • Familiar - designed to be used similarly to PreferenceLoader
  • Logical - Notification Center widgets shouldn't add their preferences to an already-crowded main list, but to the actual Notifications settings
  • Ease of use - It's as simple as adding your preferences plist file to your widget's bundle

Usage

There are several ways to use WeePreferenceLoader, depending on your use case. This does require knowledge of how plists are formatted to work with the Settings app. For more information on this, see http://iphonedevwiki.net/index.php/Preferences_specifier_plist.

Simple WeeApp Settings

To add a basic set of preferences to your Notification Center widget, it's as easy as this:

  1. Create a plist file containing your settings. Your plist file requires only an items property, containing all of your preference items (formatted identically to a PreferenceLoader plist).
    • A title property is optional - if you specify a title, it will be used as a section header at the beginning of your group of preferences (if your specifiers do not begin with a group cell).
  2. Name your plist file Preferences.plist, or give it a custom name and specify it in your WeeApp's Info.plist file using the PreferencesPlistName key.
  3. Add the plist file to your WeeApp's bundle, in the root directory (don't place it in a subdirectory).
  4. You're done! WeePreferenceLoader will automatically pick up your plist file and display your preferences in the Notifications settings for your WeeApp.

To add localizations to your plist file, you can either use the same localization files as your WeeApp, or use a custom bundle with separate localizations. Which brings us to...

Using a custom bundle

A custom bundle allows you to add custom actions and code to your preferences, as well as localizations. Bundles created for WeePreferenceLoader should have their name specified using the bundle key in the root level of your plist file. Bundles can be added one of the following ways:

  • Adding the bundle within your WeeApp's bundle
  • Adding the bundle to /Library/WeePreferenceLoader/Preferences/
  • Specifying a custom bundle path in your plist file, using the bundlePath key (just like PreferenceLoader), and adding your bundle there

If you choose to add an executable with custom code to your bundle, the process for this is a bit different from PreferenceLoader. Most notably, your bundle's principal class should not be a PSListController. The principal class can only be used for adding custom actions for your existing specifiers, as well as modifying those specifiers at runtime (more on that later). It will not be used as a view controller. However, any additional classes you choose to add (ie. custom cell classes, detail view controllers, etc.) will work normally.

Your bundle's principal class can implement a couple of methods that make customization of the view controller and your specifiers at runtime possible. The first is -(id)initWithListController:(PSListController *)controller, which will be used as the default initializer should your class implement it. This will be called before your bundle's specifiers have been added, so it is important not to modify the specifiers in this method. You also must not retain the list controller, or you will cause a retain cycle and leak memory.

To modify your primary specifiers, you can also choose to implement the method -(void)configureSpecifiers:(NSMutableArray *)specifiers. Here you can modify, add to, or remove your specifiers as needed. Note that your bundle will receive only the specifiers contained in your plist, not those from any other plist.

Adding settings to multiple sections

If you wish to add settings to multiple sections in the Notifications settings - for WeeApps, and / or for per-app notification (BulletinBoard) - you can add them by placing your plist in /Library/WeePreferenceLoader/Preferences.

You will also need to specify a sections key in the root level of your plist with an array of section IDs you want your preferences to appear in - the section IDs being the bundle IDs of the WeeApps and / or apps that are set up to display BulletinBoard notifications. If you do not specify this key, or if the array is empty, WeePreferenceLoader will show your preferences in all sections. Support for filtering sections will be coming in a future update (but send me an email if you want it done sooner!).

Bundles are loaded the same way for these plists as for plists in WeeApp bundles, so the above instructions still apply.

weepreferenceloader's People

Contributors

aricha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

weepreferenceloader's Issues

Settings for individual e-mail accounts not working

According to David Ashman, the following is due to a bug in WeePreferenceLoader. Please let me know what information I can help gather to get this resolved. Thanks!

The option "View in Status Bar" is not working properly for mail accounts that do not have "View in Lock Screen" enabled. This is important so a user can quickly glance at the status bar when their phone vibrates to see that the vibration was for a new mail.

Custom bundle crashes Preferences

This custom bundle works - it adds the Test button to the Phone and Messages views, and the button calls the testButton method in the bundle's principal class:

https://gist.github.com/joedj/5537700

However, if I remove the sections = ("N/A"); entry from Info.plist, it crashes the Preferences app:

May  8 12:04:28 iJoe Preferences[88074]: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0

Last Exception Backtrace:
0       CoreFoundation                  0x3435e29e 0x3429c000 + 0xc229e         // ___exceptionPreprocess + 0x9e
1       libobjc.A.dylib                 0x3bff897a 0x3bff0000 + 0x897a          // _objc_exception_throw + 0x1a
2       CoreFoundation                  0x342a9b70 0x3429c000 + 0xdb70          // -[__NSArrayM objectAtIndex:] + 0xa0
3     + WeePreferenceLoader.dylib       0x00c68684 0x00c66000 + 0x2684          // -[WeePreferenceLoaderModel loadSpecifiersForListController:sectionInfo:] + 0x710
4     + WeePreferenceLoader.dylib       0x00c674a4 0x00c66000 + 0x14a4          // $_ungrouped$BulletinBoardAppDetailController$specifiers(BulletinBoardAppDetailController*, objc_selector*) + 0xfc
5       Preferences                     0x39671d7c 0x3966b000 + 0x6d7c          // -[PSListController viewDidLoad] + 0x6c
6       UIKit                           0x36185590 0x36163000 + 0x22590         // -[UIViewController loadViewIfRequired] + 0x168

Can't find the .deb online

Hello i know this is a long shot but i cant manage to find the compile version of this repo online . Can ypu share the .deb please. Happy Cristmas

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.