-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add generated profile picture with initials if no picture was found - Add dedicated error message for secret conversations - Improve .gitignore - Other improvements
- Loading branch information
1 parent
3858f82
commit fa0c423
Showing
12 changed files
with
132 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
# gitignore for Theos | ||
|
||
*.deb | ||
_/ | ||
theos/ | ||
theos | ||
.theos | ||
.vscode/ | ||
.theos/ | ||
packages/ | ||
./packages/ | ||
obj/ | ||
./obj/ | ||
obj | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "ShortLook-API"] | ||
path = ShortLook-API | ||
url = https://github.com/dynastic/ShortLook-API |
This file was deleted.
Oops, something went wrong.
Submodule ShortLook-API
added at
856139
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface TGSFolderFinder : NSObject | ||
+ (NSString *)findSharedFolder:(NSString *)appName; | ||
+ (NSString *)findFolder:(NSString *)appName folder:(NSString *)dir; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface TGSInitialsPictureGenerator : NSObject | ||
+ (UIImage *)generatePictureWithFirstLetter:(unichar)firstLetter secondLetter:(unichar)secondLetter; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#import "TGSInitialsPictureGenerator.h" | ||
|
||
@implementation TGSInitialsPictureGenerator | ||
|
||
// https://github.com/bachonk/UIImageView-Letters/blob/master/UIImageView%2BLetters/UIImageView%2BLetters.m#L137-L187 | ||
+ (UIImage *)generatePictureWithFirstLetter:(unichar)firstLetter secondLetter:(unichar)secondLetter { | ||
// Initial variables | ||
static NSInteger imageDimension = 300; | ||
CGFloat fontSize = imageDimension * .5f; | ||
|
||
// Assemble letters | ||
NSString *content = [NSString stringWithFormat:@"%C%C", firstLetter, secondLetter]; | ||
UIFont *textFont = [UIFont systemFontOfSize:fontSize weight:UIFontWeightBold]; | ||
if (@available(iOS 13.0, *)) { // round the font to look like Telegram | ||
textFont = [UIFont fontWithDescriptor:[textFont.fontDescriptor fontDescriptorWithDesign:UIFontDescriptorSystemDesignRounded] size:fontSize]; | ||
} | ||
NSDictionary *attributes = @{ | ||
NSFontAttributeName : textFont, | ||
NSForegroundColorAttributeName : [UIColor whiteColor] | ||
}; | ||
|
||
// Generate background | ||
NSArray<UIColor *> *colors = @[ // official colors from Telegram (https://github.com/TelegramMessenger/Telegram-iOS/blob/master/submodules/LocationResources/Sources/VenueIconResources.swift#L116) | ||
[UIColor colorWithRed:.9 green:.42 blue:.84 alpha:1.], // Pink | ||
[UIColor colorWithRed:.97 green:.58 blue:.25 alpha:1.], // Orange | ||
[UIColor colorWithRed:.6 green:.53 blue:1. alpha:1.], // Magenta | ||
[UIColor colorWithRed:.27 green:.7 blue:.96 alpha:1.], // Light Blue | ||
[UIColor colorWithRed:.43 green:.76 blue:.22 alpha:1.], // Green | ||
[UIColor colorWithRed:1. green:.36 blue:.35 alpha:1.], // Red | ||
[UIColor colorWithRed:.97 green:.48 blue:.68 alpha:1.], // Another pink | ||
[UIColor colorWithRed:.43 green:.51 blue:.7 alpha:1.], // Dark blue | ||
[UIColor colorWithRed:.96 green:.73 blue:.13 alpha:1.] // Yellow | ||
]; | ||
CGSize imageSize = CGSizeMake(imageDimension, imageDimension); | ||
CGRect imageRect = {CGPointZero, imageSize}; | ||
// 1. Image basis | ||
UIGraphicsBeginImageContextWithOptions(imageSize, NO, [UIScreen mainScreen].scale); | ||
CGContextRef context = UIGraphicsGetCurrentContext(); | ||
// 2. Circular shape | ||
CGPathRef path = CGPathCreateWithEllipseInRect(imageRect, NULL); | ||
CGContextAddPath(context, path); | ||
CGContextClip(context); | ||
CGPathRelease(path); | ||
// 3. Fill color | ||
CGContextSetFillColorWithColor(context, colors[arc4random_uniform(colors.count)].CGColor); | ||
CGContextFillRect(context, imageRect); | ||
|
||
// Add letters in it | ||
CGSize textSize = [content sizeWithAttributes:attributes]; | ||
[content drawInRect:CGRectMake(imageSize.width / 2 - textSize.width / 2, | ||
imageSize.height / 2 - textSize.height / 2, | ||
textSize.width, | ||
textSize.height) | ||
withAttributes:attributes]; | ||
|
||
// Extract it | ||
UIImage *generatedPicture = UIGraphicsGetImageFromCurrentImageContext(); | ||
UIGraphicsEndImageContext(); | ||
|
||
// Return it | ||
return generatedPicture; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters