Merge branch 'dev' into server-deletion

This commit is contained in:
Mikunj 2019-08-29 15:14:37 +10:00
commit be1def6dfc
8 changed files with 40 additions and 42 deletions

View File

@ -1500,7 +1500,7 @@ static NSTimeInterval launchStartedAt;
- (LKRSSFeed *)lokiMessengerUpdatesFeed
{
return [[LKRSSFeed alloc] initWithId:@"loki.network.messenger-updates" server:@"https://loki.network/category/messenger-updates/feed/" displayName:NSLocalizedString(@"Loki Messenger Updates", @"") isDeletable:false];
return [[LKRSSFeed alloc] initWithId:@"loki.network.messenger-updates.feed" server:@"https://loki.network/category/messenger-updates/feed/" displayName:NSLocalizedString(@"Loki Messenger Updates", @"") isDeletable:false];
}
- (void)createGroupChatsIfNeeded

View File

@ -35,7 +35,7 @@ public final class LokiRSSFeedPoller : NSObject {
guard let title = item.title, let description = item.description, let date = item.pubDate else { return }
let timestamp = UInt64(date.timeIntervalSince1970 * 1000)
let urlRegex = try! NSRegularExpression(pattern: "<a\\s+(?:[^>]*?\\s+)?href=\"([^\"]*)\".*?>(.*?)<.*?\\/a>")
var bodyAsHTML = "\(title)<br>\(description)"
var bodyAsHTML = "\(title)<br><br>\(description)".replacingOccurrences(of: "</p>", with: "</p><br>")
while true {
guard let match = urlRegex.firstMatch(in: bodyAsHTML, options: [], range: NSRange(location: 0, length: bodyAsHTML.utf16.count)) else { break }
let matchRange = match.range(at: 0)

View File

@ -44,7 +44,7 @@ final class NewConversationViewController : OWSViewController, OWSQRScannerDeleg
// Next button
let nextButtonFont = UIFont.ows_dynamicTypeBodyClamped.ows_mediumWeight()
let nextButtonHeight = nextButtonFont.pointSize * 48 / 17
let nextButton = OWSFlatButton.button(title: NSLocalizedString("Next", comment: ""), font: nextButtonFont, titleColor: .white, backgroundColor: .lokiGreen(), target: self, selector: #selector(startNewConversationIfPossible))
let nextButton = OWSFlatButton.button(title: NSLocalizedString("Next", comment: ""), font: nextButtonFont, titleColor: .white, backgroundColor: .lokiGreen(), target: self, selector: #selector(handleNextButtonTapped))
nextButton.autoSetDimension(.height, toSize: nextButtonHeight)
// Stack view
let stackView = UIStackView(arrangedSubviews: [
@ -95,12 +95,12 @@ final class NewConversationViewController : OWSViewController, OWSQRScannerDeleg
startNewConversationIfPossible(with: hexEncodedPublicKey)
}
private func handleNextButtonTapped() {
@objc private func handleNextButtonTapped() {
let hexEncodedPublicKey = publicKeyTextField.text?.trimmingCharacters(in: .whitespaces) ?? ""
startNewConversationIfPossible(with: hexEncodedPublicKey)
}
@objc private func startNewConversationIfPossible(with hexEncodedPublicKey: String) {
private func startNewConversationIfPossible(with hexEncodedPublicKey: String) {
if !ECKeyPair.isValidHexEncodedPublicKey(candidate: hexEncodedPublicKey) {
let alert = UIAlertController(title: NSLocalizedString("Invalid Public Key", comment: ""), message: NSLocalizedString("Please check the public key you entered and try again.", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: nil))

View File

@ -564,14 +564,11 @@ typedef enum : NSUInteger {
return !groupThread.isLocalUserInGroup;
}
- (BOOL)isRSSGroup
- (BOOL)isRSSFeed
{
if (![_thread isKindOfClass:[TSGroupThread class]]) {
return NO;
}
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
return groupThread.isRSS;
if (![_thread isKindOfClass:[TSGroupThread class]]) { return NO; }
TSGroupThread *thread = (TSGroupThread *)self.thread;
return thread.isRSSFeed;
}
- (void)hideInputIfNeeded
@ -582,7 +579,7 @@ typedef enum : NSUInteger {
return;
}
if (self.userLeftGroup || self.isRSSGroup) {
if (self.userLeftGroup || self.isRSSFeed) {
self.inputToolbar.hidden = YES; // user has requested they leave the group. further sends disallowed
[self dismissKeyBoard];
} else {

View File

@ -14,41 +14,41 @@ public class OnboardingSplashViewController: OnboardingBaseViewController {
view.backgroundColor = Theme.backgroundColor
view.layoutMargins = .zero
let heroImage = UIImage(named: "onboarding_splash_hero")
let heroImageView = UIImageView(image: heroImage)
heroImageView.contentMode = .scaleAspectFit
heroImageView.layer.minificationFilter = .trilinear
heroImageView.layer.magnificationFilter = .trilinear
heroImageView.setCompressionResistanceLow()
heroImageView.setContentHuggingVerticalLow()
heroImageView.accessibilityIdentifier = "onboarding.splash." + "heroImageView"
let titleLabel = self.createTitleLabel(text: NSLocalizedString("Loki Messenger", comment: ""))
view.addSubview(titleLabel)
titleLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .bottom)
titleLabel.accessibilityIdentifier = "onboarding.splash." + "titleLabel"
let explanationLabel = UILabel()
explanationLabel.text = NSLocalizedString("Privacy Policy", comment: "")
explanationLabel.textColor = .ows_materialBlue
explanationLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped
explanationLabel.numberOfLines = 0
explanationLabel.textAlignment = .center
explanationLabel.lineBreakMode = .byWordWrapping
explanationLabel.isUserInteractionEnabled = true
explanationLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(explanationLabelTapped)))
explanationLabel.accessibilityIdentifier = "onboarding.splash." + "explanationLabel"
let lokiLogo = UIImage(named: "LokiLogo")
let lokiLogoImageView = UIImageView(image: lokiLogo)
lokiLogoImageView.accessibilityIdentifier = "onboarding.splash." + "lokiLogoImageView"
lokiLogoImageView.autoSetDimension(.height, toSize: 71)
lokiLogoImageView.contentMode = .scaleAspectFit
let lokiLogoContainer = UIView()
view.setContentHuggingVerticalLow()
view.setCompressionResistanceVerticalLow()
lokiLogoContainer.addSubview(lokiLogoImageView)
let privacyPolicyLabel = UILabel()
privacyPolicyLabel.text = NSLocalizedString("Privacy Policy", comment: "")
privacyPolicyLabel.textColor = .ows_materialBlue
privacyPolicyLabel.font = UIFont.ows_dynamicTypeSubheadlineClamped
privacyPolicyLabel.numberOfLines = 0
privacyPolicyLabel.textAlignment = .center
privacyPolicyLabel.lineBreakMode = .byWordWrapping
privacyPolicyLabel.isUserInteractionEnabled = true
privacyPolicyLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(explanationLabelTapped)))
privacyPolicyLabel.accessibilityIdentifier = "onboarding.splash." + "explanationLabel"
let continueButton = self.createButton(title: NSLocalizedString("BUTTON_CONTINUE",
comment: "Label for 'continue' button."),
selector: #selector(continuePressed))
let continueButton = self.createButton(title: NSLocalizedString("BUTTON_CONTINUE", comment: "Label for 'continue' button."), selector: #selector(continuePressed))
view.addSubview(continueButton)
continueButton.accessibilityIdentifier = "onboarding.splash." + "continueButton"
let stackView = UIStackView(arrangedSubviews: [
titleLabel,
UIView.vStretchingSpacer(),
explanationLabel,
lokiLogoContainer,
privacyPolicyLabel,
UIView.spacer(withHeight: 24),
continueButton
])
@ -60,6 +60,7 @@ public class OnboardingSplashViewController: OnboardingBaseViewController {
stackView.autoPinWidthToSuperview()
stackView.autoPin(toTopLayoutGuideOf: self, withInset: 0)
stackView.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
lokiLogoImageView.autoCenterInSuperview()
}
// MARK: - Events

View File

@ -16,7 +16,7 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
@interface TSGroupThread : TSThread
@property (nonatomic, strong) TSGroupModel *groupModel;
@property (nonatomic, readonly) BOOL isRSS;
@property (nonatomic, readonly) BOOL isRSSFeed;
+ (instancetype)getOrCreateThreadWithGroupModel:(TSGroupModel *)groupModel;
+ (instancetype)getOrCreateThreadWithGroupModel:(TSGroupModel *)groupModel

View File

@ -266,10 +266,10 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
return [self.class stableColorNameForNewConversationWithString:[self threadIdFromGroupId:groupId]];
}
- (BOOL)isRSS
- (BOOL)isRSSFeed
{
NSString *groupID = [[NSString alloc] initWithData:self.groupModel.groupId encoding:NSUTF8StringEncoding];
return groupID != nil && [groupID containsString:@"rss:"];
return groupID != nil && [groupID hasPrefix:@"rss://"];
}
@end

View File

@ -12,7 +12,7 @@ public final class LokiAPI : NSObject {
private static let defaultTimeout: TimeInterval = 20
private static let longPollingTimeout: TimeInterval = 40
public static let defaultMessageTTL: UInt64 = 24 * 60 * 60 * 1000
internal static var powDifficulty: UInt = 100
internal static var powDifficulty: UInt = 40
// MARK: Types
public typealias RawResponse = Any