Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NightwindDev committed Jul 25, 2024
0 parents commit fadeefe
Show file tree
Hide file tree
Showing 17 changed files with 931 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.theos/
packages/
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Nightwind

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export TARGET = iphone:clang:latest:16.0
export ARCHS = arm64 arm64e

INSTALL_TARGET_PROCESSES = SpringBoard MediaRemoteUI

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = MusicPlayerControlsColor

MusicPlayerControlsColor_FILES = Tweak.x Utils.m
MusicPlayerControlsColor_LIBRARIES = gcuniversal
MusicPlayerControlsColor_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk
SUBPROJECTS += musicplayercontrolscolorsettings
include $(THEOS_MAKE_PATH)/aggregate.mk
61 changes: 61 additions & 0 deletions MediaRemoteUI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Copyright (c) 2024 Nightwind
*/

#import <UIKit/UIView.h>
#import <UIKit/UIColor.h>

API_AVAILABLE(ios(12.0))
@interface MPRouteLabel : UIView
@property (nonatomic, strong, readwrite) UIColor *textColor;
@end

API_AVAILABLE(ios(16.0))
@interface MRUMarqueeLabel : UIView
@property (nonatomic, strong, readwrite) UIColor *textColor;
@end

API_AVAILABLE(ios(14.0))
@interface MRUNowPlayingLabelView : UIView
@property (nonatomic, strong, readwrite) MPRouteLabel *routeLabel;
@property (nonatomic, strong, readwrite) MRUMarqueeLabel *titleMarqueeView;
@property (nonatomic, strong, readwrite) MRUMarqueeLabel *subtitleMarqueeView;
@property (nonatomic, strong, readwrite) MRUMarqueeLabel *placeholderMarqueeView API_AVAILABLE(ios(16.0));
@end

API_AVAILABLE(ios(16.0))
@interface MRUCAPackageView : UIView
@property (nonatomic, assign, readwrite) CATransform3D permanentTransform;
@property (nonatomic, strong, readwrite) CALayer *packageLayer;
@property (nonatomic, strong, readonly) NSString *packageName;
- (void)mru_applyVisualStylingWithColor:(UIColor *)color alpha:(CGFloat)alpha blendMode:(CGBlendMode)blendMode;
@end

API_AVAILABLE(ios(14.0))
@interface MRUTransportButton : UIView
@end

API_AVAILABLE(ios(16.0))
@interface MRUSlider : UIView
@property (nonatomic, strong, readwrite) UIView *minTrack __attribute__((availability(ios, introduced=16.0, obsoleted=17.0)));
@property (nonatomic, strong, readwrite) UIView *maxTrack __attribute__((availability(ios, introduced=16.0, obsoleted=17.0)));
@end

API_AVAILABLE(ios(14.0))
@interface MRUNowPlayingTimeControlsView : UIView
@property (nonatomic, strong, readwrite) MRUSlider *slider API_AVAILABLE(ios(16.0));
@property (nonatomic, strong, readwrite) UILabel *elapsedTimeLabel;
@property (nonatomic, strong, readwrite) UILabel *remainingTimeLabel;
@end

API_AVAILABLE(ios(14.0))
@interface MRUNowPlayingVolumeControlsView : UIView
@property (nonatomic, strong, readwrite) MRUSlider *slider;
@property (nonatomic, strong, readwrite) UIImageView *minImageView API_AVAILABLE(ios(16.0));
@property (nonatomic, strong, readwrite) UIImageView *maxImageView API_AVAILABLE(ios(16.0));
@end

API_AVAILABLE(ios(16.0))
@interface MRUWaveformView : UIView
@property (nonatomic, retain) NSArray<UIView *> *bars;
@end
1 change: 1 addition & 0 deletions MusicPlayerControlsColor.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ Filter = { Bundles = ( "com.apple.springboard", "com.apple.MediaRemoteUI" ); }; }
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<img width="70" src="musicplayercontrolscolorsettings/Resources/icon@3.png">

# MusicPlayerControlsColor
### Compatible with iOS 16.
Colorize the various elements of the music player on iOS 16!

#### Bounty
This tweak was made as a private tweak bounty. Separate from [MusicPlayerColor](https://github.com/NightwindDev/MusicPlayerColor) as per the person's request.

#### License
This project is licensed under [MIT](LICENSE).

###### Copyright (c) 2024 Nightwind
216 changes: 216 additions & 0 deletions Tweak.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/**
* Copyright (c) 2024 Nightwind
*/


#import <UIKit/UIKit.h>
#import "MediaRemoteUI.h"


extern UIColor *const colorForKey(NSString *const key);


%group NowPlayingHeaderSection
%hook MRUNowPlayingLabelView

- (void)updateVisualStyling {}

- (void)didMoveToSuperview {
%orig;

self.routeLabel.textColor = colorForKey(@"RouteLabelColor");
self.titleMarqueeView.textColor = colorForKey(@"TitleColor");
self.subtitleMarqueeView.textColor = colorForKey(@"SubtitleColor");
self.placeholderMarqueeView.textColor = colorForKey(@"PlaceholderColor");
}

%end
%end // NowPlayingHeaderSection


%group NowPlayingButtonsSection
%hook MRUCAPackageView

- (void)layoutSubviews {
%orig;

NSString *const packageName = [self packageName];
if (!packageName) return;

UIColor *const playButtonColor = colorForKey(@"PlayButtonColor");
UIColor *const backwardsButtonColor = colorForKey(@"BackwardsButtonColor");
UIColor *const forwardsButtonColor = colorForKey(@"ForwardsButtonColor");

if ([packageName isEqualToString:@"PlayPauseStop"]) {
[self mru_applyVisualStylingWithColor:playButtonColor alpha:1.0f blendMode:kCGBlendModeNormal];
} else if ([packageName isEqualToString:@"ForwardBackward"]) {
const BOOL isBackwardsImage = self.permanentTransform.m11 == -1;

if (isBackwardsImage) {
[self mru_applyVisualStylingWithColor:backwardsButtonColor alpha:1.0f blendMode:kCGBlendModeNormal];
} else {
[self mru_applyVisualStylingWithColor:forwardsButtonColor alpha:1.0f blendMode:kCGBlendModeNormal];
}
}
}

%end
%end // NowPlayingButtonsSection


%group TransportButtonSection
%hook MRUTransportButton

- (void)updateVisualStyling {}

%end
%end // TransportButtonSection


%group RoutingButtonSection
%hook MRUNowPlayingTransportControlsView

- (void)updateVisualStyling {}
- (void)updateVisibility {}

- (MRUTransportButton *)routingButton {
MRUTransportButton *const routingButton = %orig;
routingButton.tintColor = colorForKey(@"RoutingButtonColor");
routingButton.alpha = 1.0f;
return routingButton;
}

%end

%hook MRUControlCenterView

- (MRUTransportButton *)routingButton {
MRUTransportButton *const routingButton = %orig;
routingButton.tintColor = colorForKey(@"RoutingButtonColor");
routingButton.alpha = 1.0f;
return routingButton;
}

%end
%end // RoutingButtonSection


%group WaveformSection
%hook MRUWaveformView

- (void)updateVisualStyle {}

- (void)didMoveToSuperview {
%orig;

for (UIView *bar in [self bars]) {
bar.backgroundColor = colorForKey(@"WaveformColor");
bar.alpha = 1.0f;
}
}

- (void)applyContext:(NSUInteger)context {
/**
* 0 = dynamic island (color depends on artwork)
* 1 = music player (custom color)
*/
%orig(1);
}

%end
%end // WaveformSection


%group SlidersSection
%hook MRUSlider

- (void)updateVisualStyling {}

%end
%end


%group TimeControlsSection
%hook MRUNowPlayingTimeControlsView

- (void)updateVisualStyling {}

- (void)didMoveToSuperview {
%orig;

self.slider.minTrack.backgroundColor = colorForKey(@"TimeMinTrackColor");
self.slider.maxTrack.backgroundColor = colorForKey(@"TimeMaxTrackColor");
self.elapsedTimeLabel.textColor = colorForKey(@"ElapsedTimeTextColor");
self.remainingTimeLabel.textColor = colorForKey(@"RemainingTimeTextColor");
}

%end
%end // TimeControlsSection


%group VolumeControlsSection
%hook MRUNowPlayingVolumeControlsView

- (void)updateVisualStyling {}

- (void)didMoveToSuperview {
%orig;

self.slider.minTrack.backgroundColor = colorForKey(@"VolumeMinTrackColor");
self.slider.maxTrack.backgroundColor = colorForKey(@"VolumeMaxTrackColor");
self.maxImageView.tintColor = colorForKey(@"MinVolumeIconColor");
self.minImageView.tintColor = colorForKey(@"MaxVolumeIconColor");
}

%end
%end // VolumeControlsSection


%ctor {
NSDictionary *const prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.nightwind.musicplayercontrolscolorsettings.plist"];

const BOOL (^boolForKey)(NSString *) = ^BOOL(NSString *key) {
return [prefs objectForKey:key] ? [[prefs objectForKey:key] boolValue] : YES;
};

if (!boolForKey(@"TweakEnabled")) return;

const BOOL nowPlayingHeaderSectionEnabled = boolForKey(@"NowPlayingHeaderSectionEnabled");
const BOOL nowPlayingButtonsSectionEnabled = boolForKey(@"NowPlayingButtonsSectionEnabled");
const BOOL routingButtonSectionEnabled = boolForKey(@"RoutingButtonSectionEnabled");
const BOOL waveformSectionEnabled = boolForKey(@"WaveformSectionEnabled");
const BOOL timeControlsSectionEnabled = boolForKey(@"TimeControlsSectionEnabled");
const BOOL volumeControlsSectionEnabled = boolForKey(@"VolumeControlsSectionEnabled");

if (nowPlayingHeaderSectionEnabled || nowPlayingButtonsSectionEnabled || routingButtonSectionEnabled) {
%init(TransportButtonSection);
}

if (timeControlsSectionEnabled || volumeControlsSectionEnabled) {
%init(SlidersSection);
}

if (nowPlayingHeaderSectionEnabled) {
%init(NowPlayingHeaderSection);
}

if (nowPlayingButtonsSectionEnabled) {
%init(NowPlayingButtonsSection);
}

if (routingButtonSectionEnabled) {
%init(RoutingButtonSection);
}

if (waveformSectionEnabled) {
%init(WaveformSection);
}

if (timeControlsSectionEnabled) {
%init(TimeControlsSection);
}

if (volumeControlsSectionEnabled) {
%init(VolumeControlsSection);
}
}
27 changes: 27 additions & 0 deletions Utils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2024 Nightwind
*/

#import <UIKit/UIColor.h>
#import <GcUniversal/GcColorPickerUtils.h>

UIColor *const colorForKey(NSString *const key) {
NSDictionary *const prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.nightwind.musicplayercontrolscolorsettings.plist"];
NSString *const hexString = [prefs objectForKey:key];

if (!hexString) return [UIColor whiteColor];

unsigned rgbValue = 0;
NSScanner *const scanner = [NSScanner scannerWithString:hexString];
if ([hexString hasPrefix:@"#"]) {
scanner.scanLocation = 1;
}
[scanner scanHexInt:&rgbValue];

return [UIColor
colorWithRed:((rgbValue >> 24) & 0xFF) / 255.0
green:((rgbValue >> 16) & 0xFF) / 255.0
blue:((rgbValue >> 8) & 0xFF) / 255.0
alpha:(rgbValue & 0xFF) / 255.0
];
}
10 changes: 10 additions & 0 deletions control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: com.nightwind.musicplayercontrolscolor
Name: MusicPlayerControlsColor
Version: 0.0.1
Architecture: iphoneos-arm
Description: Colorize the various elements of the music player on iOS 16!
Maintainer: Nightwind
Author: Nightwind
Section: Tweaks
Depends: mobilesubstrate (>= 0.9.5000), firmware (>= 16.0), firmware (<< 17.0), com.mrgcgamer.libgcuniversal, preferenceloader
Icon: https://github.com/NightwindDev/MusicPlayerControlsColor/blob/main/icon.png?raw=true
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions musicplayercontrolscolorsettings/MPCCRootListController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2024 Nightwind
*/

#import <Preferences/PSListController.h>

@interface MPCCRootListController : PSListController
@end
Loading

0 comments on commit fadeefe

Please sign in to comment.