├── .gitattributes ├── .gitignore ├── AppColorClose.plist ├── LICENSE ├── Makefile ├── README.md ├── Resources ├── AppColorClose.plist ├── AppColorClose.png ├── AppColorClose@2x.png └── AppColorClose@3x.png ├── SS.PNG ├── Tweak.x └── control /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .theos 2 | packages 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /AppColorClose.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PoomSmart/AppColorClose/261bfeeab3c8d842c29d6a1ca7a099961ccf89ba/AppColorClose.plist -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 - 2023 PoomSmart 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PACKAGE_VERSION = 1.2.1 2 | 3 | ifeq ($(SIMULATOR),1) 4 | TARGET = simulator:clang:latest:8.0 5 | ARCHS = x86_64 i386 6 | else 7 | TARGET = iphone:clang:latest:12.0 8 | endif 9 | 10 | include $(THEOS)/makefiles/common.mk 11 | TWEAK_NAME = AppColorClose 12 | $(TWEAK_NAME)_FILES = Tweak.x 13 | $(TWEAK_NAME)_CFLAGS = -fobjc-arc 14 | $(TWEAK_NAME)_USE_SUBSTRATE = 1 15 | 16 | include $(THEOS_MAKE_PATH)/tweak.mk 17 | 18 | internal-stage:: 19 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 20 | $(ECHO_NOTHING)cp -R Resources $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/$(TWEAK_NAME)$(ECHO_END) 21 | 22 | all:: 23 | ifeq ($(SIMULATOR),1) 24 | @rm -f /opt/simject/$(TWEAK_NAME).dylib 25 | @cp -v $(THEOS_OBJ_DIR)/$(TWEAK_NAME).dylib /opt/simject 26 | @cp -v $(PWD)/$(TWEAK_NAME).plist /opt/simject 27 | endif 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AppColorClose 2 | =========== 3 | 4 | App's close box based on app icon. 5 | 6 | Requires iOS 12+ 7 | 8 | ![alt tag](https://raw.github.com/PoomSmart/AppColorClose/master/SS.PNG) 9 | 10 | -------------------------------------------------------------------------------- /Resources/AppColorClose.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | title 6 | AppColorClose 7 | entry 8 | 9 | cell 10 | PSLinkCell 11 | icon 12 | AppColorClose.png 13 | label 14 | AppColorClose 15 | 16 | items 17 | 18 | 19 | cell 20 | PSGroupCell 21 | label 22 | Tint Opacity 23 | footerText 24 | Tint color opacity of app close box. 25 | 26 | 27 | cell 28 | PSSliderCell 29 | default 30 | 0.65 31 | defaults 32 | com.apple.springboard 33 | key 34 | SBCloseBoxTintAlpha 35 | max 36 | 1.0 37 | min 38 | 0.0 39 | showValue 40 | 41 | 42 | 43 | cell 44 | PSGroupCell 45 | label 46 | Border Width 47 | footerText 48 | Border width of app close box. 49 | 50 | 51 | cell 52 | PSSliderCell 53 | default 54 | 0.0 55 | defaults 56 | com.apple.springboard 57 | key 58 | SBCloseBoxBorderWidth 59 | max 60 | 2.5 61 | min 62 | 0.0 63 | showValue 64 | 65 | 66 | 67 | cell 68 | PSGroupCell 69 | footerText 70 | © 2021 - 2023 PoomSmart 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Resources/AppColorClose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PoomSmart/AppColorClose/261bfeeab3c8d842c29d6a1ca7a099961ccf89ba/Resources/AppColorClose.png -------------------------------------------------------------------------------- /Resources/AppColorClose@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PoomSmart/AppColorClose/261bfeeab3c8d842c29d6a1ca7a099961ccf89ba/Resources/AppColorClose@2x.png -------------------------------------------------------------------------------- /Resources/AppColorClose@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PoomSmart/AppColorClose/261bfeeab3c8d842c29d6a1ca7a099961ccf89ba/Resources/AppColorClose@3x.png -------------------------------------------------------------------------------- /SS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PoomSmart/AppColorClose/261bfeeab3c8d842c29d6a1ca7a099961ccf89ba/SS.PNG -------------------------------------------------------------------------------- /Tweak.x: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import 6 | 7 | @interface SBIconView (AppColorClose) 8 | @property(retain, nonatomic) UIColor *dominantColor; 9 | @end 10 | 11 | @interface SBHomeScreenMaterialView : UIView 12 | @end 13 | 14 | @interface SBHomeScreenButton : UIView 15 | - (SBHomeScreenMaterialView *)materialView; 16 | @end 17 | 18 | @interface SBCloseBoxView : SBHomeScreenButton 19 | @end 20 | 21 | @interface SBIconBlurryBackgroundView : UIView 22 | @end 23 | 24 | struct pixel { 25 | unsigned char r, g, b, a; 26 | }; 27 | 28 | static UIColor *dominantColorFromIcon(SBIcon *icon) { 29 | UIImage *iconImage = nil; 30 | if (@available(iOS 13.0, *)) 31 | iconImage = [icon generateIconImageWithInfo:(SBIconImageInfo) { .size = CGSizeMake(48, 48), .scale = 1, .continuousCornerRadius = 12 }]; 32 | else 33 | iconImage = [icon getIconImage:2]; 34 | if (iconImage == nil) 35 | return [UIColor blackColor]; 36 | NSUInteger red = 0, green = 0, blue = 0; 37 | CGImageRef iconCGImage = iconImage.CGImage; 38 | struct pixel *pixels = (struct pixel *)calloc(1, iconImage.size.width * iconImage.size.height * sizeof(struct pixel)); 39 | if (pixels != nil) { 40 | CGContextRef context = CGBitmapContextCreate((void *)pixels, iconImage.size.width, iconImage.size.height, 8, iconImage.size.width * 4, CGImageGetColorSpace(iconCGImage), kCGImageAlphaPremultipliedLast); 41 | if (context != NULL) { 42 | CGContextDrawImage(context, CGRectMake(0.0, 0.0, iconImage.size.width, iconImage.size.height), iconCGImage); 43 | NSUInteger numberOfPixels = iconImage.size.width * iconImage.size.height; 44 | for (int i = 0; i < numberOfPixels; ++i) { 45 | red += pixels[i].r; 46 | green += pixels[i].g; 47 | blue += pixels[i].b; 48 | } 49 | red /= numberOfPixels; 50 | green /= numberOfPixels; 51 | blue /= numberOfPixels; 52 | CGContextRelease(context); 53 | } 54 | free(pixels); 55 | } 56 | return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1.0]; 57 | } 58 | 59 | static CGFloat readValue(NSString *key, CGFloat defaultValue) { 60 | id r = [[NSUserDefaults standardUserDefaults] objectForKey:key]; 61 | return r ? [r doubleValue] : defaultValue; 62 | } 63 | 64 | static void setColor(SBIconView *self, SBIcon *icon) { 65 | SBCloseBoxView *closeBox = [self valueForKey:@"_closeBox"]; 66 | if (closeBox && !closeBox.hidden) { 67 | // if (self.dominantColor == nil) 68 | self.dominantColor = dominantColorFromIcon(self.icon); 69 | SBHomeScreenMaterialView *materialView = [closeBox materialView]; 70 | UIView *tintView = [materialView valueForKey:@"_whiteTintView"]; 71 | tintView.backgroundColor = self.dominantColor; 72 | CGFloat tintAlpha = readValue(@"SBCloseBoxTintAlpha", 0.85); 73 | tintView.alpha = tintAlpha; 74 | CGFloat borderWidth = readValue(@"SBCloseBoxBorderWidth", 0.0); 75 | tintView.layer.borderWidth = borderWidth; 76 | if (borderWidth > 0.0) 77 | tintView.layer.borderColor = self.dominantColor.CGColor; 78 | UIImageView *xView = [materialView valueForKey:@"_xPlusDView"]; 79 | xView.image = [xView.image _flatImageWithColor:self.dominantColor]; 80 | xView.alpha = tintAlpha; 81 | } 82 | } 83 | 84 | %hook SBIconView 85 | 86 | %property(retain, nonatomic) UIColor *dominantColor; 87 | 88 | - (void)_updateCloseBoxAnimated:(BOOL)animated { 89 | %orig; 90 | setColor(self, self.icon); 91 | } 92 | 93 | // - (void)prepareForReuse { 94 | // self.dominantColor = nil; 95 | // %orig; 96 | // } 97 | 98 | %end 99 | 100 | #ifdef TARGET_OS_SIMULATOR 101 | 102 | %hook SBIconColorSettings 103 | 104 | - (BOOL)closeBoxesEverywhere { 105 | return YES; 106 | } 107 | 108 | %end 109 | 110 | %hook SBIconView 111 | 112 | - (BOOL)iconViewDisplaysCloseBox:(id)arg1 { 113 | return YES; 114 | } 115 | 116 | %end 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Name: AppColorClose (iOS 12+) 2 | Package: com.ps.appcolorclose 3 | Author: PoomSmart 4 | Maintainer: PoomSmart 5 | Depends: firmware (>= 12.0), mobilesubstrate, preferenceloader 6 | Conflicts: org.thebigboss.appcolorclose, com.spicat.appcolorclose 7 | Section: Tweaks 8 | Version: 1.0.0 9 | Architecture: iphoneos-arm 10 | Description: Tint app close box based on app icon color. 11 | --------------------------------------------------------------------------------