Commit e4e6dbb5 authored by Jose Blaya's avatar Jose Blaya
Browse files

Show specific label when IPSec for UsageTile

parent 5db88612
This diff is collapsed.
......@@ -524,6 +524,10 @@ internal enum L10n {
internal static let title = L10n.tr("Localizable", "tiles.usage.title")
/// Upload
internal static let upload = L10n.tr("Localizable", "tiles.usage.upload")
internal enum Ipsec {
/// USAGE (Disabled unless using OpenVPN)
internal static let title = L10n.tr("Localizable", "tiles.usage.ipsec.title")
}
}
}
......
......@@ -29,7 +29,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xR4-ef-XuZ">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="xR4-ef-XuZ">
<rect key="frame" x="25" y="43" width="142.5" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
......@@ -44,7 +44,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Eay-Yz-Xzw">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="Eay-Yz-Xzw">
<rect key="frame" x="212.5" y="43" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
......
......@@ -60,18 +60,37 @@ class UsageTile: UIView, Tileable {
}
@objc private func displayUsageInformation() {
Client.providers.vpnProvider.dataUsage { (usage, error) in
var uploaded = Int64(0)
var downloaded = Int64(0)
if error == nil,
let usage = usage {
uploaded = Int64(usage.uploaded)
downloaded = Int64(usage.downloaded)
updateStyleForVPNType(Client.providers.vpnProvider.currentVPNType)
if Client.providers.vpnProvider.currentVPNType != IPSecProfile.vpnType {
Client.providers.vpnProvider.dataUsage { (usage, error) in
var uploaded = Int64(0)
var downloaded = Int64(0)
if error == nil,
let usage = usage {
uploaded = Int64(usage.uploaded)
downloaded = Int64(usage.downloaded)
}
self.uploadValue.text = ByteCountFormatter.string(fromByteCount: uploaded,
countStyle: .file)
self.downloadValue.text = ByteCountFormatter.string(fromByteCount: downloaded,
countStyle: .file)
}
self.uploadValue.text = ByteCountFormatter.string(fromByteCount: uploaded,
}
}
private func updateStyleForVPNType(_ vpnType: String) {
if vpnType == IPSecProfile.vpnType {
self.uploadValue.text = ByteCountFormatter.string(fromByteCount: Int64(0),
countStyle: .file)
self.downloadValue.text = ByteCountFormatter.string(fromByteCount: downloaded,
self.downloadValue.text = ByteCountFormatter.string(fromByteCount: Int64(0),
countStyle: .file)
self.uploadValue.alpha = 0.2
self.downloadValue.alpha = 0.2
self.usageTitle.text = L10n.Tiles.Usage.Ipsec.title
} else {
self.usageTitle.text = L10n.Tiles.Usage.title.uppercased()
self.uploadValue.alpha = 1
self.downloadValue.alpha = 1
}
}
}
......@@ -24,7 +24,7 @@
<rect key="frame" x="0.0" y="0.0" width="561" height="286"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3hN-bp-xD7">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="3hN-bp-xD7">
<rect key="frame" x="25" y="15" width="511" height="40.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
......
......@@ -217,5 +217,6 @@
"tiles.subscription.yearly" = "Yearly";
"tiles.subscription.days.left" = "(%d days left)";
"tiles.usage.title" = "Usage";
"tiles.usage.ipsec.title" = "USAGE (Disabled unless using OpenVPN)";
"tiles.usage.upload" = "Upload";
"tiles.usage.download" = "Download";
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment