Skip to content

Commit

Permalink
much stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TorutheRedFox committed Nov 5, 2023
1 parent 69af018 commit 0d84fee
Show file tree
Hide file tree
Showing 15 changed files with 1,064 additions and 25 deletions.
9 changes: 6 additions & 3 deletions DCChatVideoAttachment.xib
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<string key="NSFrameSize">{266, 123}</string>
<reference key="NSSuperview" ref="1069778560"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1054416182"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBUIContentMode">1</int>
Expand All @@ -53,6 +54,7 @@
<string key="NSFrame">{{0, 1}, {266, 123}}</string>
<reference key="NSSuperview" ref="1069778560"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBUIContentMode">4</int>
Expand All @@ -64,13 +66,14 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">Video-play-button.png</string>
<string key="NSResourceName">PLVideoOverlayPlay.png</string>
</object>
</object>
</array>
<string key="NSFrameSize">{266, 123}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="606199461"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
Expand Down Expand Up @@ -209,8 +212,8 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">Video-play-button.png</string>
<string key="NS.object.0">{38, 38}</string>
<string key="NS.key.0">PLVideoOverlayPlay.png</string>
<string key="NS.object.0">{72, 72}</string>
</object>
<string key="IBCocoaTouchPluginVersion">3733</string>
</data>
Expand Down
44 changes: 36 additions & 8 deletions Discord Classic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@
2C0EBB952ADB175E00A23EB8 /* DCChatReplyTableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C0EBB942ADB175E00A23EB8 /* DCChatReplyTableCell.xib */; };
2C11B41E2AEAF91600BE66F6 /* UIImage+animatedGIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C11B41D2AEAF91600BE66F6 /* UIImage+animatedGIF.m */; };
2C11B4202AEAFA5000BE66F6 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C11B41F2AEAFA5000BE66F6 /* ImageIO.framework */; };
2C571D1F2AEF138900B7A97C /* Video-play-button.png in Resources */ = {isa = PBXBuildFile; fileRef = 2C571D1D2AEF138900B7A97C /* Video-play-button.png */; };
2C571D202AEF138900B7A97C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 2C571D1E2AEF138900B7A97C /* [email protected] */; };
2C87A3D62AE99BA400DA6C21 /* DCChatVideoAttachment.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C87A3D52AE99BA400DA6C21 /* DCChatVideoAttachment.xib */; };
2C87A3D92AE99C3A00DA6C21 /* DCChatVideoAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C87A3D82AE99C3A00DA6C21 /* DCChatVideoAttachment.m */; };
2CBB33A52AD97F0700D28976 /* DCChatGroupedTableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2CBB33A42AD97F0700D28976 /* DCChatGroupedTableCell.xib */; };
2CEBF2982AE2FE2500EC7812 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEBF2972AE2FE2500EC7812 /* AVFoundation.framework */; };
2CEBF29A2AE2FE4500EC7812 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEBF2992AE2FE4500EC7812 /* MediaPlayer.framework */; };
2CF9200F2AF7E2D100249D6A /* NSString+Emojize.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CF9200E2AF7E2D100249D6A /* NSString+Emojize.m */; };
2CF920112AF7F17B00249D6A /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CF920102AF7F17B00249D6A /* QuickLook.framework */; };
2CF920162AF7F36300249D6A /* PLVideoOverlayPlay.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CF920122AF7F36300249D6A /* PLVideoOverlayPlay.png */; };
2CF920172AF7F36300249D6A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 2CF920132AF7F36300249D6A /* [email protected] */; };
2CF920182AF7F36300249D6A /* PLVideoOverlayPlayDown.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CF920142AF7F36300249D6A /* PLVideoOverlayPlayDown.png */; };
2CF920192AF7F36300249D6A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 2CF920152AF7F36300249D6A /* [email protected] */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -162,21 +166,28 @@
2C11B41C2AEAF91600BE66F6 /* UIImage+animatedGIF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+animatedGIF.h"; path = "Discord Classic/UIImage+animatedGIF.h"; sourceTree = "<group>"; };
2C11B41D2AEAF91600BE66F6 /* UIImage+animatedGIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+animatedGIF.m"; path = "Discord Classic/UIImage+animatedGIF.m"; sourceTree = "<group>"; };
2C11B41F2AEAFA5000BE66F6 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
2C571D1D2AEF138900B7A97C /* Video-play-button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Video-play-button.png"; sourceTree = "<group>"; };
2C571D1E2AEF138900B7A97C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
2C87A3D52AE99BA400DA6C21 /* DCChatVideoAttachment.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DCChatVideoAttachment.xib; sourceTree = SOURCE_ROOT; };
2C87A3D72AE99C3A00DA6C21 /* DCChatVideoAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCChatVideoAttachment.h; sourceTree = "<group>"; };
2C87A3D82AE99C3A00DA6C21 /* DCChatVideoAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCChatVideoAttachment.m; sourceTree = "<group>"; };
2CBB33A42AD97F0700D28976 /* DCChatGroupedTableCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DCChatGroupedTableCell.xib; sourceTree = SOURCE_ROOT; };
2CEBF2972AE2FE2500EC7812 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
2CEBF2992AE2FE4500EC7812 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
2CF9200C2AF7E2D100249D6A /* emojis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = emojis.h; sourceTree = "<group>"; };
2CF9200D2AF7E2D100249D6A /* NSString+Emojize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Emojize.h"; sourceTree = "<group>"; };
2CF9200E2AF7E2D100249D6A /* NSString+Emojize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Emojize.m"; sourceTree = "<group>"; };
2CF920102AF7F17B00249D6A /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; };
2CF920122AF7F36300249D6A /* PLVideoOverlayPlay.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PLVideoOverlayPlay.png; sourceTree = "<group>"; };
2CF920132AF7F36300249D6A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
2CF920142AF7F36300249D6A /* PLVideoOverlayPlayDown.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PLVideoOverlayPlayDown.png; sourceTree = "<group>"; };
2CF920152AF7F36300249D6A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
09C6B91D204A0F54007EAC26 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2CF920112AF7F17B00249D6A /* QuickLook.framework in Frameworks */,
2C11B4202AEAFA5000BE66F6 /* ImageIO.framework in Frameworks */,
2CEBF29A2AE2FE4500EC7812 /* MediaPlayer.framework in Frameworks */,
2CEBF2982AE2FE2500EC7812 /* AVFoundation.framework in Frameworks */,
Expand All @@ -194,6 +205,7 @@
095284622055EFDA00760073 /* Etc */ = {
isa = PBXGroup;
children = (
2CF9200B2AF7E2C400249D6A /* Emojize */,
2C4C757A2AF28480007E0E53 /* GIF */,
096DD77621A6EB1800C7A3B1 /* UI */,
09C6B97D204A1782007EAC26 /* Websocket */,
Expand Down Expand Up @@ -226,6 +238,7 @@
09C6B923204A0F54007EAC26 /* Frameworks */ = {
isa = PBXGroup;
children = (
2CF920102AF7F17B00249D6A /* QuickLook.framework */,
2C11B41F2AEAFA5000BE66F6 /* ImageIO.framework */,
2CEBF2992AE2FE4500EC7812 /* MediaPlayer.framework */,
2CEBF2972AE2FE2500EC7812 /* AVFoundation.framework */,
Expand Down Expand Up @@ -399,8 +412,10 @@
2C11B4172AEA546F00BE66F6 /* Video Player */ = {
isa = PBXGroup;
children = (
2C571D1D2AEF138900B7A97C /* Video-play-button.png */,
2C571D1E2AEF138900B7A97C /* [email protected] */,
2CF920122AF7F36300249D6A /* PLVideoOverlayPlay.png */,
2CF920132AF7F36300249D6A /* [email protected] */,
2CF920142AF7F36300249D6A /* PLVideoOverlayPlayDown.png */,
2CF920152AF7F36300249D6A /* [email protected] */,
);
name = "Video Player";
sourceTree = "<group>";
Expand All @@ -421,6 +436,16 @@
name = iPad;
sourceTree = "<group>";
};
2CF9200B2AF7E2C400249D6A /* Emojize */ = {
isa = PBXGroup;
children = (
2CF9200C2AF7E2D100249D6A /* emojis.h */,
2CF9200D2AF7E2D100249D6A /* NSString+Emojize.h */,
2CF9200E2AF7E2D100249D6A /* NSString+Emojize.m */,
);
name = Emojize;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -478,11 +503,11 @@
09C6B92F204A0F54007EAC26 /* InfoPlist.strings in Resources */,
09C8E2ED204C3B64006A1422 /* Storyboard.storyboard in Resources */,
2C0EBB8C2ADB16FB00A23EB8 /* DefaultAvatar3.png in Resources */,
2C571D1F2AEF138900B7A97C /* Video-play-button.png in Resources */,
2C0EBB712ADB15DC00A23EB8 /* [email protected] in Resources */,
2C0EBB8E2ADB16FB00A23EB8 /* DefaultAvatar4.png in Resources */,
2C0EBB952ADB175E00A23EB8 /* DCChatReplyTableCell.xib in Resources */,
2CBB33A52AD97F0700D28976 /* DCChatGroupedTableCell.xib in Resources */,
2CF920182AF7F36300249D6A /* PLVideoOverlayPlayDown.png in Resources */,
2C0EBB882ADB16FB00A23EB8 /* DefaultAvatar1.png in Resources */,
09FF0301205EFB8800BCBA8D /* [email protected] in Resources */,
09A2A3122072674000F3D98C /* [email protected] in Resources */,
Expand All @@ -491,6 +516,8 @@
2C0EBB912ADB16FB00A23EB8 /* [email protected] in Resources */,
2C0EBB892ADB16FB00A23EB8 /* [email protected] in Resources */,
2C0EBB762ADB165400A23EB8 /* UINavigationBarTexture.png in Resources */,
2CF920162AF7F36300249D6A /* PLVideoOverlayPlay.png in Resources */,
2CF920172AF7F36300249D6A /* [email protected] in Resources */,
2C87A3D62AE99BA400DA6C21 /* DCChatVideoAttachment.xib in Resources */,
09A2A3142072674500F3D98C /* Icon.png in Resources */,
2C0EBB702ADB15DC00A23EB8 /* DirectMessages.png in Resources */,
Expand All @@ -499,8 +526,8 @@
2C0EBB8B2ADB16FB00A23EB8 /* [email protected] in Resources */,
2C0EBB772ADB165400A23EB8 /* [email protected] in Resources */,
2C0EBB872ADB16FB00A23EB8 /* [email protected] in Resources */,
2C571D202AEF138900B7A97C /* [email protected] in Resources */,
2C0EBB862ADB16FB00A23EB8 /* DefaultAvatar0.png in Resources */,
2CF920192AF7F36300249D6A /* [email protected] in Resources */,
09A4EA672079220E00DECFD6 /* DCChatTableCell.xib in Resources */,
09F4C6F121A6EBD40018F312 /* FontAwesome.ttf in Resources */,
);
Expand Down Expand Up @@ -558,6 +585,7 @@
2C11B41E2AEAF91600BE66F6 /* UIImage+animatedGIF.m in Sources */,
09FF02F7205EF9DD00BCBA8D /* DCGuildListViewController.m in Sources */,
2C87A3D92AE99C3A00DA6C21 /* DCChatVideoAttachment.m in Sources */,
2CF9200F2AF7E2D100249D6A /* NSString+Emojize.m in Sources */,
09FF02F8205EF9DF00BCBA8D /* DCViewController.m in Sources */,
09D84D0C205F36B90070020A /* DCSettingsViewController.m in Sources */,
09E3ED262069F21200E90DA1 /* DCTools.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion Discord Classic/DCChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "DCChannel.h"
#import "DCServerCommunicator.h"
#import "DCTools.h"
#import "NSString+Emojize.h"

@interface DCChannel()

Expand Down Expand Up @@ -56,7 +57,7 @@ - (void)sendMessage:(NSString*)message {
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:channelURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
[urlRequest setValue:@"no-store" forHTTPHeaderField:@"Cache-Control"];

NSString* escapedMessage = [message mutableCopy];
NSString* escapedMessage = [[message mutableCopy] emojizedString];

CFStringRef transform = CFSTR("Any-Hex/Java");
CFStringTransform((__bridge CFMutableStringRef)escapedMessage, NULL, transform, NO);
Expand Down
5 changes: 5 additions & 0 deletions Discord Classic/DCChannelListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ - (void)viewDidLoad{
-(void)viewWillAppear:(BOOL)animated{
[self.navigationItem setTitle:self.selectedGuild.name];
[DCServerCommunicator.sharedInstance setSelectedChannel:nil];
if ([self.navigationItem.title isEqualToString:@"Direct Messages"]) {
// Sort the DMs list by most recent...
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastMessageId" ascending:NO selector:@selector(localizedStandardCompare:)];
[self.selectedGuild.channels sortUsingDescriptors:@[sortDescriptor]];
}
}


Expand Down
28 changes: 27 additions & 1 deletion Discord Classic/DCChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#import "DCImageViewController.h"
#import "TRMalleableFrameView.h"
#import "DCChatVideoAttachment.h"
#import "NSString+Emojize.h"
#import "QuickLook/QuickLook.h"

@interface DCChatViewController()
@property int numberOfMessagesLoaded;
Expand Down Expand Up @@ -234,7 +236,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell.timestampLabel setFrame:CGRectMake(messageAtRowIndex.authorNameWidth, cell.timestampLabel.y, self.chatTableView.width-messageAtRowIndex.authorNameWidth, cell.timestampLabel.height)];
}

[cell.contentTextView setText:messageAtRowIndex.content];
[cell.contentTextView setText:[messageAtRowIndex.content emojizedString]];

[cell.contentTextView setHeight:[cell.contentTextView sizeThatFits:CGSizeMake(cell.contentTextView.width, MAXFLOAT)].height];

Expand Down Expand Up @@ -263,6 +265,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
if ([subView isKindOfClass:[DCChatVideoAttachment class]]) {
[subView removeFromSuperview];
}
if ([subView isKindOfClass:[QLPreviewController class]]) {
[subView removeFromSuperview];
}
}
//dispatch_async(dispatch_get_main_queue(), ^{
int imageViewOffset = cell.contentTextView.height + (messageAtRowIndex.isGrouped ? 12 : 36);
Expand Down Expand Up @@ -315,6 +320,27 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
imageViewOffset += 210;

[cell addSubview:video];
} else if ([attachment isKindOfClass:[QLPreviewController class]]) {
NSLog(@"Add QuickLook!");
QLPreviewController *preview = attachment;

/*UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tappedVideo:)];
singleTap.numberOfTapsRequired = 1;
[video.playButton addGestureRecognizer:singleTap];
video.playButton.userInteractionEnabled = YES;
CGFloat aspectRatio = video.thumbnail.image.size.width / video.thumbnail.image.size.height;
int newWidth = 200 * aspectRatio;
int newHeight = 200;
if (newWidth > self.chatTableView.width - 66) {
newWidth = self.chatTableView.width - 66;
newHeight = newWidth / aspectRatio;
}
[video setFrame:CGRectMake(55, imageViewOffset, newWidth, newHeight)];*/

imageViewOffset += 210;

[cell addSubview:preview.view];
}

}
Expand Down
10 changes: 9 additions & 1 deletion Discord Classic/DCGuildListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

DCChannelListViewController *channelListViewController = [segue destinationViewController];

if ([channelListViewController isKindOfClass:DCChannelListViewController.class])
if ([channelListViewController isKindOfClass:DCChannelListViewController.class]) {
//Assign selected guild for the channel list we are transitioning to.
channelListViewController.selectedGuild = DCServerCommunicator.sharedInstance.selectedGuild;

// sort DMs by most recent
if ([channelListViewController.navigationItem.title isEqualToString:@"Direct Messages"]) {
// Sort the DMs list by most recent...
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastMessageId" ascending:NO selector:@selector(localizedStandardCompare:)];
[channelListViewController.selectedGuild.channels sortUsingDescriptors:@[sortDescriptor]];
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Discord Classic/DCTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "DCUser.h"
#import "DCServerCommunicator.h"
#import "DCChatVideoAttachment.h"
#import "QuickLook/QuickLook.h"
#import "UIImage+animatedGIF.h"

//https://discord.gg/X4NSsMC
Expand Down Expand Up @@ -518,6 +519,7 @@ + (DCMessage*)convertJsonMessage:(NSDictionary*)jsonMessage{
});
} else {
NSLog(@"unknown attachment type %@", fileType);
newMessage.content = [NSString stringWithFormat:@"%@\n%@", newMessage.content, [attachment valueForKey:@"url"]];
continue;
}
}
Expand Down
18 changes: 18 additions & 0 deletions NSString+Emojize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// NSString+Emojize.h
// Field Recorder
//
// Created by Jonathan Beilin on 11/5/12.
// Copyright (c) 2014 DIY. All rights reserved.
//
// Inspired by https://github.com/larsschwegmann/Emoticonizer

#import <Foundation/Foundation.h>

@interface NSString (Emojize)

- (NSString *)emojizedString;
+ (NSString *)emojizedStringWithString:(NSString *)text;
+ (NSDictionary *)emojiAliases;

@end
Loading

0 comments on commit 0d84fee

Please sign in to comment.