Skip to content

Commit

Permalink
Fix update UI not displaying markdown correctly, make update button o…
Browse files Browse the repository at this point in the history
…pen TrollStore directly if possible
  • Loading branch information
opa334 committed Jun 12, 2024
1 parent 1335827 commit 535e263
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Application/Dopamine/UI/Update/DOUpdateViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "DODownloadViewController.h"
#import "DOUIManager.h"
#import "DOEnvironmentManager.h"
#import <CoreServices/LSApplicationProxy.h>

@interface DOUpdateViewController ()

Expand Down Expand Up @@ -111,6 +112,13 @@ - (void)viewDidLoad {

if (![DOEnvironmentManager sharedManager].isJailbroken || [[DOUIManager sharedInstance] launchedReleaseNeedsManualUpdate] || ![DOEnvironmentManager sharedManager].isInstalledThroughTrollStore)
{
if ([DOEnvironmentManager sharedManager].isInstalledThroughTrollStore) {
LSApplicationProxy *tsAppProxy = [LSApplicationProxy applicationProxyForIdentifier:@"com.opa334.TrollStore"];
if ([tsAppProxy.claimedURLSchemes containsObject:@"apple-magnifier"]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"apple-magnifier://install?url=" stringByAppendingString:self.lastestDownloadUrl]] options:@{} completionHandler:nil];
return;
}
}
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/opa334/Dopamine/releases"] options:@{} completionHandler:nil];
return;
}
Expand Down Expand Up @@ -166,7 +174,19 @@ - (void)updateChangelog
NSString *name = release[@"name"];
NSString *body = release[@"body"];
[changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n", name] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:18], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle}]];
[changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"\n%@\n\n\n", body] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle}]];
[changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];

NSAttributedStringMarkdownParsingOptions *parsingOptions = [[NSAttributedStringMarkdownParsingOptions alloc] init];
parsingOptions.allowsExtendedAttributes = YES;
parsingOptions.interpretedSyntax = NSAttributedStringMarkdownInterpretedSyntaxInlineOnlyPreservingWhitespace;

NSMutableAttributedString *markdownStringMut = [[NSAttributedString alloc] initWithMarkdownString:body options:parsingOptions baseURL:nil error:nil].mutableCopy;

[markdownStringMut addAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle} range:NSMakeRange(0, markdownStringMut.length)];

[changelogText appendAttributedString:markdownStringMut];

[changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n\n\n"]];
if (idx == 0)
{
NSArray *assets = release[@"assets"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
@interface LSApplicationProxy : LSBundleProxy
@property (getter=isInstalled,nonatomic,readonly) BOOL installed;
+ (instancetype)applicationProxyForIdentifier:(NSString *)identifier;
@property (nonatomic,readonly) NSSet * claimedURLSchemes;
@end

0 comments on commit 535e263

Please sign in to comment.