mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-26 14:01:24 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -296,13 +296,13 @@
|
||||
"Weekday.Today" = "Today";
|
||||
"Weekday.Yesterday" = "Yesterday";
|
||||
|
||||
"Calendar.ShortMonday" = "M";
|
||||
"Calendar.ShortTuesday" = "T";
|
||||
"Calendar.ShortWednesday" = "W";
|
||||
"Calendar.ShortThursday" = "T";
|
||||
"Calendar.ShortFriday" = "F";
|
||||
"Calendar.ShortSaturday" = "S";
|
||||
"Calendar.ShortSunday" = "S";
|
||||
"Calendar.ShortMon" = "M";
|
||||
"Calendar.ShortTue" = "T";
|
||||
"Calendar.ShortWed" = "W";
|
||||
"Calendar.ShortThu" = "T";
|
||||
"Calendar.ShortFri" = "F";
|
||||
"Calendar.ShortSat" = "S";
|
||||
"Calendar.ShortSun" = "S";
|
||||
|
||||
"Time.TodayAt" = "today at %@";
|
||||
"Time.YesterdayAt" = "yesterday at %@";
|
||||
|
||||
@@ -120,22 +120,51 @@ private final class MediaPreviewView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
private func dayName(index: Int, strings: PresentationStrings) -> String {
|
||||
private func normalizeDayIndex(index: Int) -> Int {
|
||||
switch index {
|
||||
case 0:
|
||||
return strings.Calendar_ShortMonday
|
||||
case 1:
|
||||
return strings.Calendar_ShortTuesday
|
||||
return 6
|
||||
case 2:
|
||||
return strings.Calendar_ShortWednesday
|
||||
return 0
|
||||
case 3:
|
||||
return strings.Calendar_ShortThursday
|
||||
return 1
|
||||
case 4:
|
||||
return strings.Calendar_ShortFriday
|
||||
return 2
|
||||
case 5:
|
||||
return strings.Calendar_ShortSaturday
|
||||
return 3
|
||||
case 6:
|
||||
return strings.Calendar_ShortSunday
|
||||
return 4
|
||||
case 7:
|
||||
return 5
|
||||
default:
|
||||
preconditionFailure()
|
||||
}
|
||||
}
|
||||
|
||||
private func gridDayOffset(firstDayOfWeek: Int, firstWeekdayOfMonth: Int) -> Int {
|
||||
let monthStartsWithDay = normalizeDayIndex(index: firstWeekdayOfMonth)
|
||||
let weekStartsWithDay = normalizeDayIndex(index: firstDayOfWeek)
|
||||
|
||||
return (monthStartsWithDay - weekStartsWithDay + 7) % 7
|
||||
}
|
||||
|
||||
private func gridDayName(index: Int, firstDayOfWeek: Int, strings: PresentationStrings) -> String {
|
||||
let adjustedIndex = (index + firstDayOfWeek) % 7
|
||||
switch adjustedIndex {
|
||||
case 1:
|
||||
return strings.Calendar_ShortSun
|
||||
case 2:
|
||||
return strings.Calendar_ShortMon
|
||||
case 3:
|
||||
return strings.Calendar_ShortTue
|
||||
case 4:
|
||||
return strings.Calendar_ShortWed
|
||||
case 5:
|
||||
return strings.Calendar_ShortThu
|
||||
case 6:
|
||||
return strings.Calendar_ShortFri
|
||||
case 0:
|
||||
return strings.Calendar_ShortSat
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@@ -670,7 +699,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
let updatedWeekdayTitles = (0 ..< 7).map { index in
|
||||
return weekdayTitles[index].update(
|
||||
component: AnyComponent(Text(
|
||||
text: dayName(index: index, strings: context.component.strings),
|
||||
text: gridDayName(index: index, firstDayOfWeek: context.component.model.firstWeekday, strings: context.component.strings),
|
||||
font: Font.regular(10.0),
|
||||
color: context.component.foregroundColor
|
||||
)),
|
||||
@@ -761,7 +790,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
var selectionsByLine: [Int: LineSelection] = [:]
|
||||
|
||||
for i in 0 ..< updatedDays.count {
|
||||
let gridIndex = (context.component.model.firstDayWeekday - 1) + i
|
||||
let gridIndex = gridDayOffset(firstDayOfWeek: context.component.model.firstWeekday, firstWeekdayOfMonth: context.component.model.firstDayWeekday) + i
|
||||
let rowIndex = gridIndex % 7
|
||||
let lineIndex = gridIndex / 7
|
||||
|
||||
@@ -828,7 +857,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
}
|
||||
|
||||
for i in 0 ..< updatedDays.count {
|
||||
let gridIndex = (context.component.model.firstDayWeekday - 1) + i
|
||||
let gridIndex = gridDayOffset(firstDayOfWeek: context.component.model.firstWeekday, firstWeekdayOfMonth: context.component.model.firstDayWeekday) + i
|
||||
let rowIndex = gridIndex % 7
|
||||
let lineIndex = gridIndex / 7
|
||||
|
||||
@@ -865,6 +894,7 @@ private struct MonthModel: Equatable {
|
||||
var numberOfDays: Int
|
||||
var firstDay: Date
|
||||
var firstDayWeekday: Int
|
||||
var firstWeekday: Int
|
||||
var currentYear: Int
|
||||
var currentMonth: Int
|
||||
var currentDayOfMonth: Int
|
||||
@@ -876,6 +906,7 @@ private struct MonthModel: Equatable {
|
||||
numberOfDays: Int,
|
||||
firstDay: Date,
|
||||
firstDayWeekday: Int,
|
||||
firstWeekday: Int,
|
||||
currentYear: Int,
|
||||
currentMonth: Int,
|
||||
currentDayOfMonth: Int,
|
||||
@@ -886,6 +917,7 @@ private struct MonthModel: Equatable {
|
||||
self.numberOfDays = numberOfDays
|
||||
self.firstDay = firstDay
|
||||
self.firstDayWeekday = firstDayWeekday
|
||||
self.firstWeekday = firstWeekday
|
||||
self.currentYear = currentYear
|
||||
self.currentMonth = currentMonth
|
||||
self.currentDayOfMonth = currentDayOfMonth
|
||||
@@ -901,6 +933,7 @@ private func monthMetadata(calendar: Calendar, for baseDate: Date, currentYear:
|
||||
let year = calendar.component(.year, from: firstDayOfMonth)
|
||||
let month = calendar.component(.month, from: firstDayOfMonth)
|
||||
let firstDayWeekday = calendar.component(.weekday, from: firstDayOfMonth)
|
||||
let firstWeekday = calendar.firstWeekday
|
||||
|
||||
return MonthModel(
|
||||
year: year,
|
||||
@@ -908,6 +941,7 @@ private func monthMetadata(calendar: Calendar, for baseDate: Date, currentYear:
|
||||
numberOfDays: numberOfDaysInMonth,
|
||||
firstDay: firstDayOfMonth,
|
||||
firstDayWeekday: firstDayWeekday,
|
||||
firstWeekday: firstWeekday,
|
||||
currentYear: currentYear,
|
||||
currentMonth: currentMonth,
|
||||
currentDayOfMonth: currentDayOfMonth,
|
||||
@@ -1057,7 +1091,7 @@ public final class CalendarMessageScreen: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
let calendar = Calendar(identifier: .gregorian)
|
||||
let calendar = Calendar.current
|
||||
|
||||
let baseDate = Date()
|
||||
let currentYear = calendar.component(.year, from: baseDate)
|
||||
|
||||
@@ -244,7 +244,7 @@ public final class DirectMediaImageCache {
|
||||
let progressiveSizes = representation.progressiveSizes
|
||||
if progressiveSizes.count > 0 && width <= 64 {
|
||||
selectedSize = progressiveSizes[0]
|
||||
} else if progressiveSizes.count > 1 && width <= 160 {
|
||||
} else if progressiveSizes.count > 2 && width <= 160 {
|
||||
selectedSize = progressiveSizes[2]
|
||||
} else if progressiveSizes.count > 4 && width <= 400 {
|
||||
selectedSize = progressiveSizes[4]
|
||||
|
||||
@@ -263,7 +263,9 @@ UIImage * _Nullable decompressImage(NSData * _Nonnull sourceData) {
|
||||
|
||||
tjhandle _jpegDecompressor = tjInitDecompress();
|
||||
|
||||
tjDecompressHeader2(_jpegDecompressor, _compressedImage, jpegSize, &width, &height, &jpegSubsamp);
|
||||
if (tjDecompressHeader2(_jpegDecompressor, _compressedImage, jpegSize, &width, &height, &jpegSubsamp) != 0) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
int sourceBytesPerRow = (3 * width + 31) & ~0x1F;
|
||||
int targetBytesPerRow = (4 * width + 31) & ~0x1F;
|
||||
|
||||
@@ -1015,6 +1015,10 @@ public final class SparseItemGrid: ASDisplayNode {
|
||||
guard let strongSelf = self else {
|
||||
return nil
|
||||
}
|
||||
if let decelerationAnimator = strongSelf.decelerationAnimator {
|
||||
strongSelf.decelerationAnimator = nil
|
||||
decelerationAnimator.invalidate()
|
||||
}
|
||||
strongSelf.items?.itemBinding.onBeginFastScrolling()
|
||||
return strongSelf.scrollView
|
||||
}
|
||||
|
||||
@@ -1067,7 +1067,7 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
|
||||
|
||||
//#if DEBUG
|
||||
//#else
|
||||
Queue.mainQueue().after(2.0, { [weak self] in
|
||||
Queue.mainQueue().after(5.0, { [weak self] in
|
||||
self?.dismissLineTooltip()
|
||||
})
|
||||
//#endif
|
||||
|
||||
@@ -1394,15 +1394,15 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}
|
||||
|
||||
Logger.shared.log("App \(self.episodeId)", "remoteNotification: \(redactedPayload)")
|
||||
|
||||
|
||||
if userInfo["p"] == nil {
|
||||
completionHandler(.noData)
|
||||
return
|
||||
}
|
||||
|
||||
let _ = (self.sharedContextPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { sharedApplicationContext in
|
||||
|
||||
sharedApplicationContext.wakeupManager.replaceCurrentExtensionWithExternalTime(completion: {
|
||||
completionHandler(.newData)
|
||||
}, timeout: 29.0)
|
||||
|
||||
Reference in New Issue
Block a user