Bläddra i källkod

work

pull/1/head
Burrit0z 4 år sedan
förälder
incheckning
b64f368720
3 ändrade filer med 74 tillägg och 49 borttagningar
  1. +10
    -9
      KAIBattery.mm
  2. +63
    -39
      Kai.xm
  3. +1
    -1
      control

+ 10
- 9
KAIBattery.mm Visa fil

@@ -7,11 +7,11 @@ KAIBattery *instance;
self = [super initWithFrame:arg1];
instance = self;
if (self) {
/*self.batteryLabel = [[UILabel alloc]initWithFrame:CGRectMake(25,-10,220,120)];
[self.batteryLabel setFont:[UIFont systemFontOfSize:13]];
[self.batteryLabel setTextColor:[UIColor whiteColor]];
self.batteryLabel.lineBreakMode = NSLineBreakByWordWrapping;
self.batteryLabel.numberOfLines = 0;*/
/*self.translatesAutoresizingMaskIntoConstraints = NO;
[self.leftAnchor constraintEqualToAnchor:self.leftAnchor constant:8].active = YES;
[self.topAnchor constraintEqualToAnchor:self.topAnchor constant:arg1.origin.y].active = YES;
[self.widthAnchor constraintEqualToConstant:UIScreen.mainScreen.bounds.size.width - 16].active = YES;
[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;*/
[self updateBattery];
[self darkLightMode];
self.userInteractionEnabled = NO;
@@ -46,7 +46,7 @@ long long lastPercentage;
BOOL charging = MSHookIvar<long long>(device, "_charging");
BOOL LPM = MSHookIvar<BOOL>(device, "_batterySaverModeActive");

if(charging) {
if(charging || !charging) {

UIVisualEffectView *blank;
if(@available(iOS 12.0, *)) {
@@ -58,7 +58,7 @@ long long lastPercentage;
} else {
blank = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
}
blank.frame = CGRectMake(0, 0 + y, self.frame.size.width, 80);
blank.frame = CGRectMake(0, 0 + y, UIScreen.mainScreen.bounds.size.width - 16, 80);
blank.layer.masksToBounds = YES;
blank.layer.cornerRadius = 13;
//[blank setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]];
@@ -95,8 +95,8 @@ long long lastPercentage;
glyphView.contentMode = UIViewContentModeScaleAspectFit;
[glyphView setImage:glyph];

label.frame = CGRectMake(57.5,27.5 + y,275,25);
glyphView.frame = CGRectMake(12.5,18.5 + y,40,40);
label.frame = CGRectMake(65.5,27.5 + y,275,25);
glyphView.frame = CGRectMake(20.5,18.5 + y,40,40);
battery.frame = CGRectMake(310,35 + y,20,10);
percentLabel.frame = CGRectMake(265,35 + y,36,12);

@@ -111,6 +111,7 @@ long long lastPercentage;
//blank.alpha = 0.8;
}
}
[self.heightAnchor constraintEqualToConstant:(self.number * 85)].active = YES;
self.isUpdating = NO;
[self darkLightMode];
}

+ 63
- 39
Kai.xm Visa fil

@@ -12,9 +12,11 @@
@end

@interface CSAdjunctListView : UIView
@property (nonatomic, strong) KAIBattery *battery;
@property (nonatomic, strong) KAIBattery *batteryView;
@property (nonatomic, assign) BOOL hasKai;
@property (nonatomic, assign) NSInteger previousKaiCount;
-(UIView *)stackView;
-(void)setStackView:(UIStackView *)arg1;
-(void)KaiUpdate;
@end

@@ -25,76 +27,98 @@
@interface _CSSingleBatteryChargingView : UIView
@end

/*
@interface NCNotificationListView : UIView
@property (nonatomic, assign) BOOL hasKai;
@property (nonatomic, assign) NSInteger previousKaiCount;
@end*/
@end

BOOL setFrame = NO;
CGRect original;
CGRect original = CGRectMake(0,0,0,0);
CGRect originalBattery;


%hook CSAdjunctListView
%property (nonatomic, strong) KAIBattery *battery;
%property (nonatomic, strong) KAIBattery *batteryView;
%property (nonatomic, assign) BOOL hasKai;
%property (nonatomic, assign) NSInteger previousKaiCount;

-(void)layoutSubviews {
-(void)_layoutStackView {
NSLog(@"Kai: Laying out stack view");
//%orig;

if(!self.hasKai) {
original = self.superview.superview.frame;
self.battery = [[KAIBattery alloc] initWithFrame:CGRectMake(8, 0, self.frame.size.width - 16, UIScreen.mainScreen.bounds.size.width)];
originalBattery = self.battery.frame;
[self addSubview:self.battery];
//original = self.superview.superview.frame;
self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
originalBattery = self.batteryView.frame;
//[[self stackView] addSubview:self.batteryView];
setFrame = YES;
self.previousKaiCount = 0;
self.hasKai = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(KaiUpdate)
selector:@selector(KaiInfo)
name:@"KaiInfoChanged"
object:nil];
[self.battery darkLightMode];
[self.batteryView darkLightMode];
//[self setStackView:self.batteryView];
}
[self KaiUpdate];

return %orig;
%orig;
}

-(void)setStackView:(UIStackView *)arg1 {
NSLog(@"Kai: Updating setting stack view");

if(!self.hasKai) {
//original = self.superview.superview.frame;
self.batteryView = [[KAIBattery alloc] initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
originalBattery = self.batteryView.frame;
//[[self stackView] addSubview:self.batteryView];
setFrame = YES;
self.previousKaiCount = 0;
self.hasKai = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(KaiInfo)
name:@"KaiInfoChanged"
object:nil];
[self.batteryView darkLightMode];
//[self setStackView:self.batteryView];
}

UIStackView *newView = arg1;

if(![arg1.subviews containsObject:self.batteryView]) {
//[newView addSubview:self.batteryView];
[newView addArrangedSubview:self.batteryView];
}
newView.frame = CGRectMake(newView.frame.origin.x, newView.frame.origin.y, newView.frame.size.width, newView.frame.size.height + self.batteryView.frame.size.height);
original = newView.frame;
%orig(newView);
}

%new
-(void)KaiUpdate {
if(self.battery) {
NSLog(@"Kai: Updating Pos.");

[self.battery updateBattery];

dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{

[UIView animateWithDuration:0.3 animations:^{
[UIView animateWithDuration:0.3 animations:^{

//self.translatesAutoresizingMaskIntoConstraints = NO;
// [self.topAnchor constraintEqualToAnchor:self.superview.topAnchor constant:(self.battery.number * 85)].active = YES;
self.batteryView.frame = CGRectMake(UIScreen.mainScreen.bounds.origin.x, 0, UIScreen.mainScreen.bounds.size.width, (self.batteryView.number * 85));
self.batteryView.hidden = YES;
self.batteryView.hidden = NO;
//self.batteryView.superview.frame = CGRectMake(original.origin.x, original.origin.y, original.size.width, original.size.height + (self.batteryView.number * 85));

self.superview.superview.frame = CGRectMake(
original.origin.x,
original.origin.y + (self.battery.number * 85),
original.size.width,
original.size.height
);
}];
[self.batteryView darkLightMode];
});

/*self.battery.frame = CGRectMake(
originalBattery.origin.x,
originalBattery.origin.y - (self.battery.number * 85),
originalBattery.size.width,
originalBattery.size.height
);*/
}];
[self.battery darkLightMode];
});
}

}
%new
-(void)KaiInfo {
NSLog(@"Kai: Updating Info");
[self.batteryView updateBattery];
[self KaiUpdate];
}
%end


+ 1
- 1
control Visa fil

@@ -1,6 +1,6 @@
Package: com.burritoz.kai
Name: Kai
Version: 0.0.1
Version: 0.0.2
Architecture: iphoneos-arm
Description: An awesome MobileSubstrate tweak!
Maintainer: burrit0z

Laddar…
Avbryt
Spara