Libstatusbar: Difference between revisions

From iPhone Development Wiki
(such a great troll)
Tag: Undo
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Infobox Package
{{Infobox Package
|developer=phoenix3200
|developer=phoenix3200
|version=0.9.7.0
|version=0.9.8-1
|package=libstatusbar
|package=libstatusbar
}}
}}
Line 7: Line 7:
'''libstatusbar''' is a library supporting status bar modifications.
'''libstatusbar''' is a library supporting status bar modifications.


The readme explaining iOS 7.x support is at http://phoenix-dev.com/Drop/README (also viewable [https://github.com/phoenix3200/libstatusbar on the project page on Github]).
The readme explaining iOS 7.x support is viewable [https://github.com/phoenix3200/libstatusbar on the project page on Github].


== How to use within a SpringBoard tweak ==
== How to use within a tweak ==
First download the [https://raw2.github.com/phoenix3200/libstatusbar/master/LSStatusBarItem.h LSStatusBarItem.h] header file. To compile it needs the following modification to the enum:
First download the [https://github.com/phoenix3200/libstatusbar/blob/master/LSStatusBarItem.h LSStatusBarItem.h] header file. To compile on modern toolchains, the first line must be edited to instead be the following:


typedef NS_ENUM(NSInteger, StatusBarAlignment)
<source lang="objc">
typedef NS_ENUM(NSInteger, StatusBarAlignment)
</source>


Create a singleton class in your tweak. In your tweak initializer, you need to call the shared singleton. Then, in its init method, perform a delayed init method by using:
Create a constructor function in your tweak. You need to first ensure libstatusbar is loaded, otherwise the following code most likely won’t work (depending on whether your tweak is loaded after libstatusbar by Substrate, and whether another tweak loaded before yours has already done this).


[self performSelector:@selector(delayedInit) withObject:nil afterDelay:0];
<source lang="objc">
dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY);
</source>


The reason for this is when your tweak is initialized into the SpringBoard, chances are libstatusbar.dylib, which contains the LSStatusBarItem, hasn't been loaded in yet, hence it would be null in the init method. So by delaying a run loop event, it will be loaded and the instance can be successfully created.
Use of dlopen() will require you to also <code>#include <dlfcn.h></code>.


-(void)delayedInit{
After this, you can proceed to create a status bar item. Here is an example:
  self.statusBarItem = [[NSClassFromString(@"LSStatusBarItem") alloc] initWithIdentifier: @"com.malcolmhall.InsomniaPro" alignment: StatusBarAlignmentRight];
 
  _statusBarItem.imageName = @"InsomniaPro";
<source lang="logos">
}
statusBarItem = [[%c(LSStatusBarItem) alloc] initWithIdentifier:@"com.malcolmhall.InsomniaPro" alignment:StatusBarAlignmentRight];
statusBarItem.imageName = @"InsomniaPro";
</source>


The imageName defines what image to look for. See below for naming conventions.
The imageName defines what image to look for. See below for naming conventions.


Then when you want to make the status bar item appear, do this:
The item will be visible by default. You can control this by setting the <code>visible</code> property:
self.statusBarItem.visible = YES;
 
<source lang="objc">
statusBarItem.visible = NO;
</source>
 
The last thing you need to do is add a dependency on libstatusbar in your package’s control file. Obviously none of this will work if it’s not installed. That might look something like:


I would usually check a setting inside the delayedInit and show it the first time if necessary. The last thing you need to do is add a dependency on libstatusbar in your control file so that when your deb is installed it also installs the dependency so that the NSClassFromString can successfully find the LSStatusBarItem class.
<source lang="text">
Depends: mobilesubstrate, libstatusbar
</source>


== Icon sizes ==
It’s also worth noting that the libstatusbar API is usable from pretty much any process that has permission to do inter-process communication. This includes apps, daemons, and command line tools.


My iOS 6 icon sizes were 12x20 for 1x and 20x40 for 2x
== Icons ==


iOS 7 uses a height of 20 normal and 24 on the lock screen. Some example sizes from the built-in icons are:
{| class="wikitable"
! iOS Version
! Image Name
! Status Bar Color
! Glyph Color
! Height (Points)
! Location
! Notes
|-
| rowspan="2" | 2.0 – 3.2
| Default_''Name''.png
| Silver
| Colored
| rowspan="8" | 20
| rowspan="2" | [[SpringBoard.app]]
| rowspan="2" | Supported by libstatusbar on newer iOS versions for backwards compatibility. Retina is not supported, even on iOS 4 and newer.
|-
| FSO_''Name''.png
| Black
| Gray
|-
| 4.0 – 5.1
| Silver_''Name''.png
| Silver
| Colored
| rowspan="10" | [[UIKit.framework]]
| Silver status bar was removed in iOS 6.
|-
| 4.0 – 6.1
| Black_''Name''.png
| Black
| Gray
|
|-
| 5.0 – 5.1
| ColorOnGrayShadow_''Name''.png
| Silver
| Colored
| Silver status bar was removed in iOS 6.
|-
| rowspan="2" | 5.0 – 6.1
| WhiteOnBlackEtch_''Name''.png
| Black
| Gray
|
|-
| WhiteOnBlackShadow_''Name''.png
| Linen
| White
| Used in the notification center.
|-
| rowspan="5" | 7.0 –
| Black_''Name''.png
| rowspan="5" | None
| rowspan="2" | Varies
| rowspan="2" | The original glyph should be black. The status bar tints it accordingly.
|-
| LockScreen_''Name''.png
| 24
|-
| Black_''Name''_Color.png
| rowspan="3" | Colored
| rowspan="2" | 20
| rowspan="3" | Custom style supported by libstatusbar. It disables the glyph tinting and allows you to use color. Be aware that this may clash with colors in the background (e.g., album art in Music).
|-
| White_''Name''_Color.png
|-
| LockScreen_''Name''_Color.png
| 24
|}


Black_Airplane~iphone.png 12x20
Images can be as wide (or thin) as desired. In all status bar styles listed above, there is usually some margin above and below the glyph. The dimensions you should use really depend on what looks best for the glyph. Take a look at the built in status bar icons, and possibly some from other tweaks, in your favorite image editor to see how they have been designed.
<br>
Black_Airplane~iphone@2x.png 26x40
<br>
LockScreen_Airplane~iphone.png 14x24
<br>
LockScreen_Airplane~iphone@2x.png 28x48


Black_Alarm~iphone.png 9x20
Some example sizes from the built-in icons are:
<br>
<br>
LockScreen_Alarm~iphone.png 11x24
<br>


== Icon Locations and Naming ==
{| class="wikitable"
! iOS Version
! Image Name
! Size (Points)
|-
| rowspan="4" | 7.0
| Black_Airplane~iphone.png
| 12×20
|-
| LockScreen_Airplane~iphone.png
| 14×24
|-
| Black_Alarm~iphone.png
| 9×20
|-
| LockScreen_Alarm~iphone.png
| 11×24
|}


Check out https://github.com/phoenix3200/libstatusbar for info on where to put images for different devices, and how to name them.
== Video Tutorials ==
To see a full tutorial on how to use this library in your tweak, check out [https://www.youtube.com/watch?v=sH60TbYkyYs this video] by Sassoty


[[Category:Cydia packages]]
[[Category:Cydia packages]]

Latest revision as of 03:05, 3 November 2018

Libstatusbar
Cydia Package
Developer phoenix3200
Package ID libstatusbar
Latest Version 0.9.8-1


libstatusbar is a library supporting status bar modifications.

The readme explaining iOS 7.x support is viewable on the project page on Github.

How to use within a tweak

First download the LSStatusBarItem.h header file. To compile on modern toolchains, the first line must be edited to instead be the following:

typedef NS_ENUM(NSInteger, StatusBarAlignment)

Create a constructor function in your tweak. You need to first ensure libstatusbar is loaded, otherwise the following code most likely won’t work (depending on whether your tweak is loaded after libstatusbar by Substrate, and whether another tweak loaded before yours has already done this).

dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY);

Use of dlopen() will require you to also #include <dlfcn.h>.

After this, you can proceed to create a status bar item. Here is an example:

statusBarItem = [[%c(LSStatusBarItem) alloc] initWithIdentifier:@"com.malcolmhall.InsomniaPro" alignment:StatusBarAlignmentRight];
statusBarItem.imageName = @"InsomniaPro";

The imageName defines what image to look for. See below for naming conventions.

The item will be visible by default. You can control this by setting the visible property:

statusBarItem.visible = NO;

The last thing you need to do is add a dependency on libstatusbar in your package’s control file. Obviously none of this will work if it’s not installed. That might look something like:

Depends: mobilesubstrate, libstatusbar

It’s also worth noting that the libstatusbar API is usable from pretty much any process that has permission to do inter-process communication. This includes apps, daemons, and command line tools.

Icons

iOS Version Image Name Status Bar Color Glyph Color Height (Points) Location Notes
2.0 – 3.2 Default_Name.png Silver Colored 20 SpringBoard.app Supported by libstatusbar on newer iOS versions for backwards compatibility. Retina is not supported, even on iOS 4 and newer.
FSO_Name.png Black Gray
4.0 – 5.1 Silver_Name.png Silver Colored UIKit.framework Silver status bar was removed in iOS 6.
4.0 – 6.1 Black_Name.png Black Gray
5.0 – 5.1 ColorOnGrayShadow_Name.png Silver Colored Silver status bar was removed in iOS 6.
5.0 – 6.1 WhiteOnBlackEtch_Name.png Black Gray
WhiteOnBlackShadow_Name.png Linen White Used in the notification center.
7.0 – Black_Name.png None Varies The original glyph should be black. The status bar tints it accordingly.
LockScreen_Name.png 24
Black_Name_Color.png Colored 20 Custom style supported by libstatusbar. It disables the glyph tinting and allows you to use color. Be aware that this may clash with colors in the background (e.g., album art in Music).
White_Name_Color.png
LockScreen_Name_Color.png 24

Images can be as wide (or thin) as desired. In all status bar styles listed above, there is usually some margin above and below the glyph. The dimensions you should use really depend on what looks best for the glyph. Take a look at the built in status bar icons, and possibly some from other tweaks, in your favorite image editor to see how they have been designed.

Some example sizes from the built-in icons are:

iOS Version Image Name Size (Points)
7.0 Black_Airplane~iphone.png 12×20
LockScreen_Airplane~iphone.png 14×24
Black_Alarm~iphone.png 9×20
LockScreen_Alarm~iphone.png 11×24

Video Tutorials

To see a full tutorial on how to use this library in your tweak, check out this video by Sassoty