mirror of
https://github.com/Burrit0z/kai
synced 2025-07-01 10:56:47 +00:00
better placement options
This commit is contained in:
@ -58,3 +58,4 @@
|
|||||||
1.5.0:
|
1.5.0:
|
||||||
- Replace the code that handles hiding kai when media plays
|
- Replace the code that handles hiding kai when media plays
|
||||||
- Fix edge cases where battery info would not update completely until an update was called for again
|
- Fix edge cases where battery info would not update completely until an update was called for again
|
||||||
|
- There are now 3 placement options: Top, Below Media Player, and Bottom
|
||||||
|
@ -240,8 +240,8 @@ NSMutableArray *cellsForDeviceNames = [[NSMutableArray alloc] init];
|
|||||||
[s removeArrangedSubview:self];
|
[s removeArrangedSubview:self];
|
||||||
[self removeFromSuperview];
|
[self removeFromSuperview];
|
||||||
} else if (self.number != 0 && self.superview == nil && shouldBeAdded == YES) {
|
} else if (self.number != 0 && self.superview == nil && shouldBeAdded == YES) {
|
||||||
[[[[objc_getClass("CSAdjunctListView") class] sharedListViewForKai] stackView] addArrangedSubview:self];
|
Class cls = kCFCoreFoundationVersionNumber > 1600 ? ([objc_getClass("CSAdjunctListView") class]) : ([objc_getClass("SBDashBoardAdjunctListView") class]);
|
||||||
// [self performSelector:@selector(calculateHeight) withObject:self afterDelay:0.1];
|
[cls reorderKai];
|
||||||
}
|
}
|
||||||
|
|
||||||
[UIView animateWithDuration:0.3
|
[UIView animateWithDuration:0.3
|
||||||
|
6
Kai.h
6
Kai.h
@ -10,6 +10,8 @@
|
|||||||
- (UIStackView *)stackView;
|
- (UIStackView *)stackView;
|
||||||
- (void)_layoutStackView;
|
- (void)_layoutStackView;
|
||||||
- (void)setStackView:(UIStackView *)arg1;
|
- (void)setStackView:(UIStackView *)arg1;
|
||||||
|
- (NSInteger)getMediaIndexForClass:(Class)cls;
|
||||||
|
- (void)performReorder;
|
||||||
+ (id)sharedListViewForKai;
|
+ (id)sharedListViewForKai;
|
||||||
+ (void)reorderKai;
|
+ (void)reorderKai;
|
||||||
@end
|
@end
|
||||||
@ -45,7 +47,6 @@ BOOL enabled;
|
|||||||
BOOL disableGlyphs;
|
BOOL disableGlyphs;
|
||||||
BOOL hidePercent;
|
BOOL hidePercent;
|
||||||
BOOL showAll;
|
BOOL showAll;
|
||||||
BOOL belowMusic;
|
|
||||||
BOOL hideDeviceLabel;
|
BOOL hideDeviceLabel;
|
||||||
BOOL hideChargingAnimation;
|
BOOL hideChargingAnimation;
|
||||||
BOOL showAllMinusInternal;
|
BOOL showAllMinusInternal;
|
||||||
@ -57,6 +58,7 @@ BOOL extraPaddingAfter;
|
|||||||
NSInteger bannerStyle;
|
NSInteger bannerStyle;
|
||||||
NSInteger bannerAlign;
|
NSInteger bannerAlign;
|
||||||
NSInteger textColor;
|
NSInteger textColor;
|
||||||
|
NSInteger placement;
|
||||||
double spacing;
|
double spacing;
|
||||||
double glyphSize;
|
double glyphSize;
|
||||||
double bannerHeight;
|
double bannerHeight;
|
||||||
@ -123,7 +125,7 @@ static void preferencesChanged() {
|
|||||||
hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
|
hideDeviceLabel = boolValueForKey(@"hideDeviceLabel", NO);
|
||||||
bannerAlign = numberForValue(@"bannerAlign", 2);
|
bannerAlign = numberForValue(@"bannerAlign", 2);
|
||||||
horizontalOffset = numberForValue(@"horizontalOffset", 0);
|
horizontalOffset = numberForValue(@"horizontalOffset", 0);
|
||||||
belowMusic = boolValueForKey(@"belowMusic", NO);
|
placement = numberForValue(@"placement", 1);
|
||||||
hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
|
hideChargingAnimation = boolValueForKey(@"hideChargingAnimation", YES);
|
||||||
textColor = numberForValue(@"textColor", 0);
|
textColor = numberForValue(@"textColor", 0);
|
||||||
bannerAlpha = numberForValue(@"bannerAlpha", 1);
|
bannerAlpha = numberForValue(@"bannerAlpha", 1);
|
||||||
|
51
Kai.xm
51
Kai.xm
@ -63,7 +63,7 @@ CSAdjunctListView *list;
|
|||||||
|
|
||||||
if(![arg1.subviews containsObject:battery]) { // if not added
|
if(![arg1.subviews containsObject:battery]) { // if not added
|
||||||
// add kai to the stack view
|
// add kai to the stack view
|
||||||
[arg1 addArrangedSubview:battery];
|
[self performReorder];
|
||||||
}
|
}
|
||||||
[battery updateBattery];
|
[battery updateBattery];
|
||||||
|
|
||||||
@ -101,6 +101,46 @@ CSAdjunctListView *list;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
- (NSInteger)getMediaIndexForClass:(Class)cls {
|
||||||
|
UIView *mediaPlayer;
|
||||||
|
int index = 0;
|
||||||
|
for(UIView *subview in [self stackView].subviews) {
|
||||||
|
if([subview isKindOfClass:cls]) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return NSNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
- (void)performReorder {
|
||||||
|
UIStackView *stack = [self stackView];
|
||||||
|
if(placement == 1) { //top
|
||||||
|
BOOL isAperio = NO;
|
||||||
|
|
||||||
|
@try {
|
||||||
|
isAperio = [stack.subviews[0] isKindOfClass:%c(APEPlatter)];
|
||||||
|
// index 0 would be the platter, 1 would be placeholder
|
||||||
|
} @catch(NSException *exc) {}
|
||||||
|
|
||||||
|
[stack removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
||||||
|
[stack insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:isAperio];
|
||||||
|
// so, 0 if not aperio, 1 if aperio
|
||||||
|
} else if(placement == 2) { //after media
|
||||||
|
Class mediaClass = kCFCoreFoundationVersionNumber > 1600 ? %c(CSAdjunctItemView) : %c(SBDashBoardAdjunctItemView);
|
||||||
|
NSInteger mediaIndex = [self getMediaIndexForClass:mediaClass];
|
||||||
|
if(mediaIndex == NSNotFound) mediaIndex = 0;
|
||||||
|
|
||||||
|
[stack removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
||||||
|
[stack insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:mediaIndex];
|
||||||
|
} else if(placement == 3) { // bottom
|
||||||
|
[stack removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
||||||
|
[stack addArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%new
|
%new
|
||||||
+ (id)sharedListViewForKai {
|
+ (id)sharedListViewForKai {
|
||||||
return list;
|
return list;
|
||||||
@ -109,14 +149,7 @@ CSAdjunctListView *list;
|
|||||||
%new
|
%new
|
||||||
+ (void)reorderKai {
|
+ (void)reorderKai {
|
||||||
NSLog(@"[Kai]: Reordering kai");
|
NSLog(@"[Kai]: Reordering kai");
|
||||||
UIStackView *stack = [[self sharedListViewForKai] stackView];
|
[[self sharedListViewForKai] performReorder];
|
||||||
if(belowMusic) { // cursed
|
|
||||||
[stack removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
|
||||||
[stack addArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
|
||||||
} else {
|
|
||||||
[stack removeArrangedSubview:[KAIBatteryPlatter sharedInstance]];
|
|
||||||
[stack insertArrangedSubview:[KAIBatteryPlatter sharedInstance] atIndex:0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
@ -332,15 +332,31 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>cell</key>
|
<key>cell</key>
|
||||||
<string>PSSwitchCell</string>
|
<string>PSGroupCell</string>
|
||||||
<key>default</key>
|
<key>label</key>
|
||||||
<false/>
|
<string>Vertical Placement</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>cell</key>
|
||||||
|
<string>PSSegmentCell</string>
|
||||||
<key>defaults</key>
|
<key>defaults</key>
|
||||||
<string>com.burritoz.kaiprefs</string>
|
<string>com.burritoz.kaiprefs</string>
|
||||||
|
<key>default</key>
|
||||||
|
<string>1</string>
|
||||||
<key>key</key>
|
<key>key</key>
|
||||||
<string>belowMusic</string>
|
<string>placement</string>
|
||||||
<key>label</key>
|
<key>validValues</key>
|
||||||
<string>Show kai Below Music</string>
|
<array>
|
||||||
|
<string>1</string>
|
||||||
|
<string>2</string>
|
||||||
|
<string>3</string>
|
||||||
|
</array>
|
||||||
|
<key>validTitles</key>
|
||||||
|
<array>
|
||||||
|
<string>Top</string>
|
||||||
|
<string>Below Media Player</string>
|
||||||
|
<string>Bottom</string>
|
||||||
|
</array>
|
||||||
<key>PostNotification</key>
|
<key>PostNotification</key>
|
||||||
<string>com.burritoz.kaiprefs.apply</string>
|
<string>com.burritoz.kaiprefs.apply</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
Reference in New Issue
Block a user