Tweak disappearing messages indicator.
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer00_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer00_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer00_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 217 B |
After Width: | Height: | Size: 318 B |
After Width: | Height: | Size: 656 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer05_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer05_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer05_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 758 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer10_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer10_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer10_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 255 B |
After Width: | Height: | Size: 433 B |
After Width: | Height: | Size: 759 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer15_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer15_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer15_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 398 B |
After Width: | Height: | Size: 685 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer20_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer20_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer20_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 268 B |
After Width: | Height: | Size: 486 B |
After Width: | Height: | Size: 815 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer25_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer25_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer25_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 272 B |
After Width: | Height: | Size: 504 B |
After Width: | Height: | Size: 860 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer30_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer30_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer30_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 267 B |
After Width: | Height: | Size: 446 B |
After Width: | Height: | Size: 782 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer35_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer35_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer35_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 282 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 862 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer40_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer40_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer40_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 900 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer45_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer45_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer45_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 251 B |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 759 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer50_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer50_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer50_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 599 B |
After Width: | Height: | Size: 932 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer55_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer55_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer55_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 312 B |
After Width: | Height: | Size: 621 B |
After Width: | Height: | Size: 962 B |
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer60_12@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer60_12@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "timer60_12@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 272 B |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 864 B |
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSMessageTimerView : UIView
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithExpiration:(uint64_t)expirationTimestamp
|
||||
initialDurationSeconds:(uint32_t)initialDurationSeconds NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (CGSize)measureSize;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,169 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSMessageTimerView.h"
|
||||
#import "ConversationViewController.h"
|
||||
#import "NSDate+OWS.h"
|
||||
#import "OWSMath.h"
|
||||
#import "UIColor+OWS.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <SignalServiceKit/NSTimer+OWS.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
const CGFloat kDisappearingMessageIconSize = 12.f;
|
||||
|
||||
@interface OWSMessageTimerView ()
|
||||
|
||||
@property (nonatomic) uint32_t initialDurationSeconds;
|
||||
@property (nonatomic) uint64_t expirationTimestamp;
|
||||
@property (nonatomic) UIColor *tintColor;
|
||||
|
||||
@property (nonatomic) UIImageView *imageView;
|
||||
|
||||
@property (nonatomic, nullable) NSTimer *animationTimer;
|
||||
|
||||
@property (nonatomic) NSInteger progress12;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSMessageTimerView
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self.animationTimer invalidate];
|
||||
self.animationTimer = nil;
|
||||
}
|
||||
|
||||
- (instancetype)initWithExpiration:(uint64_t)expirationTimestamp
|
||||
initialDurationSeconds:(uint32_t)initialDurationSeconds
|
||||
tintColor:(UIColor *)tintColor;
|
||||
{
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
self.expirationTimestamp = expirationTimestamp;
|
||||
self.initialDurationSeconds = initialDurationSeconds;
|
||||
self.tintColor = tintColor;
|
||||
|
||||
[self commonInit];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)commonInit
|
||||
{
|
||||
self.imageView = [UIImageView new];
|
||||
[self addSubview:self.imageView];
|
||||
[self.imageView autoPinToSuperviewEdges];
|
||||
[self.imageView autoSetDimension:ALDimensionWidth toSize:kDisappearingMessageIconSize];
|
||||
[self.imageView autoSetDimension:ALDimensionHeight toSize:kDisappearingMessageIconSize];
|
||||
|
||||
[self updateProgress12];
|
||||
[self updateIcon];
|
||||
|
||||
self.animationTimer = [NSTimer weakScheduledTimerWithTimeInterval:1.f
|
||||
target:self
|
||||
selector:@selector(updateProgress12)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
- (void)updateProgress12
|
||||
{
|
||||
CGFloat secondsLeft = MAX(0, (self.expirationTimestamp - [NSDate ows_millisecondTimeStamp]) / 1000.f);
|
||||
CGFloat progress = 0.f;
|
||||
if (self.initialDurationSeconds > 0) {
|
||||
progress = CGFloatClamp(1.f - (secondsLeft / self.initialDurationSeconds), 0.f, 1.f);
|
||||
}
|
||||
OWSAssert(progress >= 0.f);
|
||||
OWSAssert(progress <= 1.f);
|
||||
|
||||
self.progress12 = (NSInteger)round(CGFloatClamp(progress, 0.f, 1.f) * 12);
|
||||
}
|
||||
|
||||
- (void)setProgress12:(NSInteger)progress12
|
||||
{
|
||||
if (_progress12 == progress12) {
|
||||
return;
|
||||
}
|
||||
_progress12 = progress12;
|
||||
|
||||
[self updateIcon];
|
||||
}
|
||||
|
||||
- (void)updateIcon
|
||||
{
|
||||
self.imageView.image = [[self progressIcon] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
self.imageView.tintColor = self.tintColor;
|
||||
}
|
||||
|
||||
- (UIImage *)progressIcon
|
||||
{
|
||||
OWSAssert(self.progress12 >= 0);
|
||||
OWSAssert(self.progress12 <= 12);
|
||||
|
||||
UIImage *_Nullable image;
|
||||
switch (self.progress12) {
|
||||
default:
|
||||
case 0:
|
||||
image = [UIImage imageNamed:@"disappearing_message_00"];
|
||||
break;
|
||||
case 1:
|
||||
image = [UIImage imageNamed:@"disappearing_message_05"];
|
||||
break;
|
||||
case 2:
|
||||
image = [UIImage imageNamed:@"disappearing_message_10"];
|
||||
break;
|
||||
case 3:
|
||||
image = [UIImage imageNamed:@"disappearing_message_15"];
|
||||
break;
|
||||
case 4:
|
||||
image = [UIImage imageNamed:@"disappearing_message_20"];
|
||||
break;
|
||||
case 5:
|
||||
image = [UIImage imageNamed:@"disappearing_message_25"];
|
||||
break;
|
||||
case 6:
|
||||
image = [UIImage imageNamed:@"disappearing_message_30"];
|
||||
break;
|
||||
case 7:
|
||||
image = [UIImage imageNamed:@"disappearing_message_35"];
|
||||
break;
|
||||
case 8:
|
||||
image = [UIImage imageNamed:@"disappearing_message_40"];
|
||||
break;
|
||||
case 9:
|
||||
image = [UIImage imageNamed:@"disappearing_message_45"];
|
||||
break;
|
||||
case 10:
|
||||
image = [UIImage imageNamed:@"disappearing_message_50"];
|
||||
break;
|
||||
case 11:
|
||||
image = [UIImage imageNamed:@"disappearing_message_55"];
|
||||
break;
|
||||
case 12:
|
||||
image = [UIImage imageNamed:@"disappearing_message_60"];
|
||||
break;
|
||||
}
|
||||
OWSAssert(image);
|
||||
OWSAssert(image.size.width == kDisappearingMessageIconSize);
|
||||
OWSAssert(image.size.height == kDisappearingMessageIconSize);
|
||||
return image;
|
||||
}
|
||||
|
||||
+ (CGSize)measureSize
|
||||
{
|
||||
return CGSizeMake(kDisappearingMessageIconSize, kDisappearingMessageIconSize);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|