Browse Source

Add Reddit 2020.41.0 support

master
lint 3 years ago
parent
commit
dd6539cc3c
2 changed files with 44 additions and 26 deletions
  1. +5
    -0
      tweak/Reddit.h
  2. +39
    -26
      tweak/Reddit.xm

+ 5
- 0
tweak/Reddit.h View File

@@ -164,7 +164,12 @@
@property(strong, nonatomic) id dayTheme;
@property(strong, nonatomic) id nightTheme;
- (id)initWithTraitCollection:(id)arg1 appSettings:(id)arg2;
@end
// >= 2020.41.0
@interface RUIThemeGuidance : NSObject
@property(strong, nonatomic) RUITheme *currentTheme;
+ (id)sharedGuidance;
@end
@interface AppSettings

+ 39
- 26
tweak/Reddit.xm View File

@@ -102,33 +102,38 @@ int secondVersionPart = 0;
id textColor;
if (firstVersionPart == 2020) {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
AppSettings *appSettings = [%c(AppSettings) sharedSettings];
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:appSettings];
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
if (secondVersionPart <= 40) {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
AppSettings *appSettings = [%c(AppSettings) sharedSettings];
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:appSettings];
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) {
NSInteger sysInterfaceStyle = [[UITraitCollection _currentTraitCollection] userInterfaceStyle];
NSInteger sysInterfaceStyle = [[UITraitCollection _currentTraitCollection] userInterfaceStyle];
if (sysInterfaceStyle == UIUserInterfaceStyleDark){
textColor = [[themeManager darkTheme] bodyTextColor];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
}
if (sysInterfaceStyle == UIUserInterfaceStyleDark){
textColor = [[themeManager darkTheme] bodyTextColor];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
}
}
[themeManager release];
} else {
if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
}
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
textColor = [[themeGuidance currentTheme] bodyTextColor];
}
[themeManager release];
} else {
if (secondVersionPart >= 45) {
@@ -263,18 +268,26 @@ int secondVersionPart = 0;
id textColor;
if (firstVersionPart == 2020) {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor];
if (secondVersionPart <= 40) {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
AccountManager *accountManager = secondVersionPart >= 29 ? [appDelegate accountManager] : [%c(AccountManager) sharedManager];
themeManager = [[%c(ThemeManager) alloc] initWithAppSettings:[%c(AppSettings) sharedSettings]];
isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"];
if (isNightMode) {
textColor = [[themeManager darkTheme] bodyTextColor];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
}
[themeManager release];
} else {
textColor = [[themeManager lightTheme] bodyTextColor];
RUIThemeGuidance *themeGuidance = [%c(RUIThemeGuidance) sharedGuidance];
textColor = [[themeGuidance currentTheme] bodyTextColor];
}
[themeManager release];
} else {
if (secondVersionPart >= 45) {

Loading…
Cancel
Save