From 7e1db92b2f3d07c2dab47f6480b427692476cd54 Mon Sep 17 00:00:00 2001 From: lint <47455468+lint@users.noreply.github.com> Date: Sun, 23 Aug 2020 14:39:37 -0400 Subject: [PATCH] Add Reddit 2020.29.0 support --- tweak/Reddit.h | 5 ++++- tweak/Reddit.xm | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) mode change 100644 => 100755 tweak/Reddit.h mode change 100644 => 100755 tweak/Reddit.xm diff --git a/tweak/Reddit.h b/tweak/Reddit.h old mode 100644 new mode 100755 index abb18c2..a3268fa --- a/tweak/Reddit.h +++ b/tweak/Reddit.h @@ -176,8 +176,11 @@ @interface AccountManager @property(assign, nonatomic) id defaults; + (id)sharedManager; -@end +@end +@interface AppDelegate : UIResponder +@property(strong, nonatomic) AccountManager *accountManager; +@end /* ---- Reddit v3 ---- */ diff --git a/tweak/Reddit.xm b/tweak/Reddit.xm old mode 100644 new mode 100755 index b8f3fce..da59bd6 --- a/tweak/Reddit.xm +++ b/tweak/Reddit.xm @@ -102,9 +102,11 @@ 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 = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; + isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"]; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"13.0") && [appSettings isAutoDarkModeEnabled]) { @@ -258,8 +260,10 @@ 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 = [[[%c(AccountManager) sharedManager] defaults] objectForKey:@"kUseNightKey"]; + isNightMode = [[accountManager defaults] objectForKey:@"kUseNightKey"]; if (isNightMode) { textColor = [[themeManager darkTheme] bodyTextColor];