Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'paste without formatting' to the context menu on desktop #7959

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import kotlinx.serialization.json.*
@Serializable
data class MobilePlanPrice(
val name: String,
val monthlyPerMonth: String,
val yearlyPerYear: String,
val yearlyPerMonth: String,
val rawMonthlyPerMonth: String,
val rawYearlyPerYear: String,
val rawYearlyPerMonth: String,
val displayMonthlyPerMonth: String,
val displayYearlyPerYear: String,
val displayYearlyPerMonth: String,
)
27 changes: 18 additions & 9 deletions app-ios/TutanotaSharedFramework/GeneratedIpc/MobilePlanPrice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
public struct MobilePlanPrice : Codable {
public init(
name: String,
monthlyPerMonth: String,
yearlyPerYear: String,
yearlyPerMonth: String
rawMonthlyPerMonth: String,
rawYearlyPerYear: String,
rawYearlyPerMonth: String,
displayMonthlyPerMonth: String,
displayYearlyPerYear: String,
displayYearlyPerMonth: String
) {
self.name = name
self.monthlyPerMonth = monthlyPerMonth
self.yearlyPerYear = yearlyPerYear
self.yearlyPerMonth = yearlyPerMonth
self.rawMonthlyPerMonth = rawMonthlyPerMonth
self.rawYearlyPerYear = rawYearlyPerYear
self.rawYearlyPerMonth = rawYearlyPerMonth
self.displayMonthlyPerMonth = displayMonthlyPerMonth
self.displayYearlyPerYear = displayYearlyPerYear
self.displayYearlyPerMonth = displayYearlyPerMonth
}
public let name: String
public let monthlyPerMonth: String
public let yearlyPerYear: String
public let yearlyPerMonth: String
public let rawMonthlyPerMonth: String
public let rawYearlyPerYear: String
public let rawYearlyPerMonth: String
public let displayMonthlyPerMonth: String
public let displayYearlyPerYear: String
public let displayYearlyPerMonth: String
}
91 changes: 58 additions & 33 deletions app-ios/calendar/Sources/Payment/IosMobilePaymentsFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,64 @@ public class IosMobilePaymentsFacade: MobilePaymentsFacade {
return currentResult
}

public func getPlanPrices() async throws -> [MobilePlanPrice] {
struct TempMobilePlanPrice {
var monthlyPerMonth: String?
var yearlyPerYear: String?
var yearlyPerMonth: String?
}
let plans: [String] = ALL_PURCHASEABLE_PLANS.flatMap { plan in
[self.formatPlanType(plan, withInterval: 1), self.formatPlanType(plan, withInterval: 12)]
}
let products: [Product] = try await Product.products(for: plans)
var result = [String: TempMobilePlanPrice]()
for product in products {
let productName = String(product.id.split(separator: ".")[2])
var plan = result[productName] ?? TempMobilePlanPrice(monthlyPerMonth: nil, yearlyPerYear: nil, yearlyPerMonth: nil)

let unit = product.subscription!.subscriptionPeriod.unit
switch unit {
case .year:
let formatStyle = product.priceFormatStyle
let priceDivided = product.price / 12
let yearlyPerMonthPrice = priceDivided.formatted(formatStyle)
let yearlyPerYearPrice = product.displayPrice
plan.yearlyPerYear = yearlyPerYearPrice
plan.yearlyPerMonth = yearlyPerMonthPrice
case .month: plan.monthlyPerMonth = product.displayPrice
default: fatalError("unexpected subscription period unit \(unit)")
}
result[productName] = plan
}
return result.map { name, prices in
MobilePlanPrice(name: name, monthlyPerMonth: prices.monthlyPerMonth!, yearlyPerYear: prices.yearlyPerYear!, yearlyPerMonth: prices.yearlyPerMonth!)
}
}
public func getPlanPrices() async throws -> [MobilePlanPrice] {
// TODO: Handle promotions (first year discount etc.)
struct TempMobilePlanPrice {
var rawMonthlyPerMonth: String?
var rawYearlyPerYear: String?
var rawYearlyPerMonth: String?
var displayMonthlyPerMonth: String?
var displayYearlyPerYear: String?
var displayYearlyPerMonth: String?
}
let plans: [String] = ALL_PURCHASEABLE_PLANS.flatMap { plan in
[self.formatPlanType(plan, withInterval: 1), self.formatPlanType(plan, withInterval: 12)]
}
let products: [Product] = try await Product.products(for: plans)
var result = [String: TempMobilePlanPrice]()
for product in products {
let productName = String(product.id.split(separator: ".")[2])
var plan =
result[productName]
?? TempMobilePlanPrice(
rawMonthlyPerMonth: nil,
rawYearlyPerYear: nil,
rawYearlyPerMonth: nil,
displayMonthlyPerMonth: nil,
displayYearlyPerYear: nil,
displayYearlyPerMonth: nil
)

let unit = product.subscription!.subscriptionPeriod.unit
switch unit {
case .year:
let formatStyle = product.priceFormatStyle
let priceDivided = product.price / 12
let yearlyPerMonthPrice = priceDivided.formatted(formatStyle)
let yearlyPerYearPrice = product.displayPrice
plan.rawYearlyPerYear = String(describing: product.price)
plan.rawYearlyPerMonth = String(describing: priceDivided)
plan.displayYearlyPerYear = yearlyPerYearPrice
plan.displayYearlyPerMonth = yearlyPerMonthPrice
case .month:
plan.rawMonthlyPerMonth = String(describing: product.price)
plan.displayMonthlyPerMonth = product.displayPrice
default: fatalError("unexpected subscription period unit \(unit)")
}
result[productName] = plan
}
return result.map { name, prices in
MobilePlanPrice(
name: name,
rawMonthlyPerMonth: prices.rawMonthlyPerMonth!,
rawYearlyPerYear: prices.rawYearlyPerYear!,
rawYearlyPerMonth: prices.rawYearlyPerMonth!,
displayMonthlyPerMonth: prices.displayMonthlyPerMonth!,
displayYearlyPerYear: prices.displayYearlyPerYear!,
displayYearlyPerMonth: prices.displayYearlyPerMonth!
)
}
}
public func showSubscriptionConfigView() async throws {
let window = await UIApplication.shared.connectedScenes.first
try await AppStore.showManageSubscriptions(in: window as! UIWindowScene)
Expand Down
41 changes: 33 additions & 8 deletions app-ios/tutanota/Sources/Payment/IosMobilePaymentsFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ public class IosMobilePaymentsFacade: MobilePaymentsFacade {
}

public func getPlanPrices() async throws -> [MobilePlanPrice] {
// TODO: Handle promotions (first year discount etc.)
struct TempMobilePlanPrice {
var monthlyPerMonth: String?
var yearlyPerYear: String?
var yearlyPerMonth: String?
var rawMonthlyPerMonth: String?
var rawYearlyPerYear: String?
var rawYearlyPerMonth: String?
var displayMonthlyPerMonth: String?
var displayYearlyPerYear: String?
var displayYearlyPerMonth: String?
}
let plans: [String] = ALL_PURCHASEABLE_PLANS.flatMap { plan in
[self.formatPlanType(plan, withInterval: 1), self.formatPlanType(plan, withInterval: 12)]
Expand All @@ -40,7 +44,16 @@ public class IosMobilePaymentsFacade: MobilePaymentsFacade {
var result = [String: TempMobilePlanPrice]()
for product in products {
let productName = String(product.id.split(separator: ".")[1])
var plan = result[productName] ?? TempMobilePlanPrice(monthlyPerMonth: nil, yearlyPerYear: nil, yearlyPerMonth: nil)
var plan =
result[productName]
?? TempMobilePlanPrice(
rawMonthlyPerMonth: nil,
rawYearlyPerYear: nil,
rawYearlyPerMonth: nil,
displayMonthlyPerMonth: nil,
displayYearlyPerYear: nil,
displayYearlyPerMonth: nil
)

let unit = product.subscription!.subscriptionPeriod.unit
switch unit {
Expand All @@ -49,15 +62,27 @@ public class IosMobilePaymentsFacade: MobilePaymentsFacade {
let priceDivided = product.price / 12
let yearlyPerMonthPrice = priceDivided.formatted(formatStyle)
let yearlyPerYearPrice = product.displayPrice
plan.yearlyPerYear = yearlyPerYearPrice
plan.yearlyPerMonth = yearlyPerMonthPrice
case .month: plan.monthlyPerMonth = product.displayPrice
plan.rawYearlyPerYear = String(describing: product.price)
plan.rawYearlyPerMonth = String(describing: priceDivided)
plan.displayYearlyPerYear = yearlyPerYearPrice
plan.displayYearlyPerMonth = yearlyPerMonthPrice
case .month:
plan.rawMonthlyPerMonth = String(describing: product.price)
plan.displayMonthlyPerMonth = product.displayPrice
default: fatalError("unexpected subscription period unit \(unit)")
}
result[productName] = plan
}
return result.map { name, prices in
MobilePlanPrice(name: name, monthlyPerMonth: prices.monthlyPerMonth!, yearlyPerYear: prices.yearlyPerYear!, yearlyPerMonth: prices.yearlyPerMonth!)
MobilePlanPrice(
name: name,
rawMonthlyPerMonth: prices.rawMonthlyPerMonth!,
rawYearlyPerYear: prices.rawYearlyPerYear!,
rawYearlyPerMonth: prices.rawYearlyPerMonth!,
displayMonthlyPerMonth: prices.displayMonthlyPerMonth!,
displayYearlyPerYear: prices.displayYearlyPerYear!,
displayYearlyPerMonth: prices.displayYearlyPerMonth!
)
}
}
public func showSubscriptionConfigView() async throws {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/LaunchHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function renderHtml(scripts, env) {
<meta itemprop="name" content="Turn ON Privacy">
<meta itemprop="description" content="Get a free email account with quantum-safe encryption and best privacy on all your devices. Green, secure &amp; no ads!">
<meta itemprop="image" content="https://tuta.com/images/share_image.png">
<meta name="apple-itunes-app" content="app-id=id922429609, affiliate-data=10lSfb">
<meta name="apple-itunes-app" content="app-id=922429609, app-argument=https://app.tuta.com">
</head>
<body style="background-color:transparent">
<noscript>This site requires javascript to be enabled. Please activate it in the settings of your browser.</noscript>
Expand Down
9 changes: 6 additions & 3 deletions ipc-schema/types/MobilePlanPrice.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"type": "struct",
"fields": {
"name": "string",
"monthlyPerMonth": "string",
"yearlyPerYear": "string",
"yearlyPerMonth": "string"
"rawMonthlyPerMonth": "string",
"rawYearlyPerYear": "string",
"rawYearlyPerMonth": "string",
"displayMonthlyPerMonth": "string",
"displayYearlyPerYear": "string",
"displayYearlyPerMonth": "string"
}
}
Loading
Loading