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

Merge branch '287-today-extension-connect-and-disconnect-vpn' into 'release/3.0.0'

Resolve "Today Extension: Connect and Disconnect VPN"

See merge request ios/vpn-ios!397
parents c8226491 7c46e2cd
This diff is collapsed.
......@@ -56,6 +56,16 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0EE2D77F1CB40A98000DEC4D"
BuildableName = "PIA VPNUITests.xctest"
BlueprintName = "PIA VPNUITests"
ReferencedContainer = "container:PIA VPN.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
......
......@@ -123,4 +123,10 @@ struct AppConstants {
return typeface
}()
}
struct VPNWidget {
static let vpnStatus = "vpn.status"
static let vpnButtonDescription = "vpn.button.description"
}
}
......@@ -86,6 +86,15 @@ class AppDelegate: NSObject, UIApplicationDelegate {
// in case it's too early for notification delivery (vc not loaded)
TransientState.shouldDisplayRegionPicker = true
case VPNStatus.connected.rawValue:
if Client.providers.vpnProvider.isVPNConnected {
disconnectAfter(milliseconds: 200)
}
case VPNStatus.disconnected.rawValue:
if !Client.providers.vpnProvider.isVPNConnected {
connectAfter(milliseconds: 200)
}
default:
return false
}
......@@ -165,9 +174,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
case .connect:
if !Client.providers.vpnProvider.isVPNConnected {
// this time delay seems to fix a strange issue of the VPN connecting from a fresh launch
Macros.dispatch(after: .milliseconds(200)) {
Client.providers.vpnProvider.connect(nil)
}
connectAfter(milliseconds: 200)
}
case .disconnect:
......@@ -175,9 +182,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
// this time delay seems to fix a strange issue of the VPN disconnecting and
// then automatically reconnecting when it's done from a fresh launch
Macros.dispatch(after: .milliseconds(200)) {
Client.providers.vpnProvider.disconnect(nil)
}
disconnectAfter(milliseconds: 200)
}
case .selectRegion:
......@@ -195,20 +200,28 @@ class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if userActivity.activityType == AppConstants.SiriShortcuts.shortcutConnect {
if AppPreferences.shared.useConnectSiriShortcuts {
Macros.dispatch(after: .milliseconds(200)) {
Client.providers.vpnProvider.connect(nil)
}
connectAfter(milliseconds: 200)
}
return AppPreferences.shared.useConnectSiriShortcuts
} else {
if AppPreferences.shared.useDisconnectSiriShortcuts {
Macros.dispatch(after: .milliseconds(200)) {
Client.providers.vpnProvider.disconnect(nil)
}
disconnectAfter(milliseconds: 200)
}
return AppPreferences.shared.useDisconnectSiriShortcuts
}
}
private func connectAfter(milliseconds: Int) {
Macros.dispatch(after: .milliseconds(milliseconds)) {
Client.providers.vpnProvider.connect(nil)
}
}
private func disconnectAfter(milliseconds: Int) {
Macros.dispatch(after: .milliseconds(milliseconds)) {
Client.providers.vpnProvider.disconnect(nil)
}
}
}
......@@ -41,6 +41,9 @@ class AppPreferences {
static let useDisconnectSiriShortcuts = "UseDisconnectSiriShortcuts"
static let disconnectShortcut = "disconnectShortcut"
static let todayWidgetVpnStatus = "vpn.status"
static let todayWidgetButtonTitle = "vpn.button.description"
}
static let shared = AppPreferences()
......@@ -159,6 +162,24 @@ class AppPreferences {
}
}
var todayWidgetVpnStatus: String? {
get {
return defaults.string(forKey: Entries.todayWidgetVpnStatus) ?? L10n.Today.Widget.login
}
set {
defaults.set(newValue, forKey: Entries.todayWidgetVpnStatus)
}
}
var todayWidgetButtonTitle: String? {
get {
return defaults.string(forKey: Entries.todayWidgetButtonTitle) ?? nil
}
set {
defaults.set(newValue, forKey: Entries.todayWidgetButtonTitle)
}
}
@available(iOS 12.0, *)
var connectShortcut: INVoiceShortcut? {
get {
......@@ -208,6 +229,7 @@ class AppPreferences {
Entries.themeCode: ThemeCode.light.rawValue,
Entries.useConnectSiriShortcuts: false,
Entries.useDisconnectSiriShortcuts: false,
Entries.todayWidgetButtonTitle: L10n.Today.Widget.login
])
}
......@@ -313,6 +335,8 @@ class AppPreferences {
connectShortcut = nil
disconnectShortcut = nil
}
todayWidgetVpnStatus = L10n.Today.Widget.login
todayWidgetButtonTitle = L10n.Today.Widget.login
}
// + (void)eraseForTesting;
......
......@@ -124,11 +124,21 @@ class DashboardViewController: AutolayoutViewController {
showWalkthrough()
return
}
guard Client.providers.accountProvider.isLoggedIn else {
presentLogin()
AppPreferences.shared.todayWidgetVpnStatus = L10n.Today.Widget.login
AppPreferences.shared.todayWidgetButtonTitle = L10n.Today.Widget.login
return
}
AppPreferences.shared.todayWidgetVpnStatus = Client.providers.vpnProvider.vpnStatus.rawValue
if Client.providers.vpnProvider.vpnStatus == .disconnected {
AppPreferences.shared.todayWidgetButtonTitle = L10n.Shortcuts.connect
} else {
AppPreferences.shared.todayWidgetButtonTitle = L10n.Shortcuts.disconnect
}
viewContent.isHidden = false
viewRows.isHidden = false
......@@ -427,6 +437,8 @@ class DashboardViewController: AutolayoutViewController {
}
@objc private func accountDidLogout(notification: Notification) {
AppPreferences.shared.todayWidgetVpnStatus = nil
AppPreferences.shared.todayWidgetButtonTitle = L10n.Today.Widget.login
presentLogin()
}
......@@ -469,6 +481,11 @@ class DashboardViewController: AutolayoutViewController {
}
@objc private func updateCurrentStatusWithUserInfo(_ userInfo: [AnyHashable: Any]?) {
guard Client.providers.accountProvider.isLoggedIn else {
return
}
currentStatus = Client.providers.vpnProvider.vpnStatus
switch currentStatus {
......@@ -486,6 +503,8 @@ class DashboardViewController: AutolayoutViewController {
UIColor.piaGreenDark20])
navigationItem.titleView = titleLabelView
setNeedsStatusBarAppearanceUpdate()
AppPreferences.shared.todayWidgetVpnStatus = VPNStatus.connected.rawValue
AppPreferences.shared.todayWidgetButtonTitle = L10n.Shortcuts.disconnect
case .disconnected:
toggleConnection.isOn = false
......@@ -493,6 +512,8 @@ class DashboardViewController: AutolayoutViewController {
toggleConnection.stopButtonAnimation()
AppPreferences.shared.lastVPNConnectionStatus = .disconnected
resetNavigationBar()
AppPreferences.shared.todayWidgetVpnStatus = VPNStatus.disconnected.rawValue
AppPreferences.shared.todayWidgetButtonTitle = L10n.Shortcuts.connect
case .connecting:
Macros.postNotification(.PIADaemonsDidUpdateConnectivity)
......
......@@ -627,6 +627,13 @@ internal enum L10n {
}
}
internal enum Today {
internal enum Widget {
/// Login
internal static let login = L10n.tr("Localizable", "today.widget.login")
}
}
internal enum VpnPermission {
/// PIA
internal static let title = L10n.tr("Localizable", "vpn_permission.title")
......@@ -663,9 +670,9 @@ internal enum L10n {
}
internal enum Page {
internal enum _1 {
/// Protect yourself on up to 5 devices at a time.
/// Protect yourself on up to 10 devices at a time.
internal static let description = L10n.tr("Localizable", "walkthrough.page.1.description")
/// Support 5 devices at once
/// Support 10 devices at once
internal static let title = L10n.tr("Localizable", "walkthrough.page.1.title")
}
internal enum _2 {
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "تم";
"walkthrough.action.next" = "التالي";
"walkthrough.action.skip" = "تخطي";
"walkthrough.page.1.description" = "احمي نفسك على ما يصل إلى 5 أجهزة في وقت واحد.";
"walkthrough.page.1.title" = "يدعم 5 أجهزة في المرة الواحدة";
"walkthrough.page.1.description" = "احمي نفسك على ما يصل إلى 10 أجهزة في وقت واحد.";
"walkthrough.page.1.title" = "يدعم 10 أجهزة في المرة الواحدة";
"walkthrough.page.2.description" = "مع خوادم في جميع أنحاء العالم، أنت دائما تحت الحماية.";
"walkthrough.page.2.title" = "اتصل بأي منطقة بسهولة";
"walkthrough.page.3.description" = "تمكين ميزة حظر المحتوى يمنع الإعلانات من الظهور في Safari.";
......
......@@ -157,8 +157,8 @@
"walkthrough.action.done" = "UDFØRT";
"walkthrough.action.next" = "NÆSTE";
"walkthrough.action.skip" = "SPRING OVER";
"walkthrough.page.1.description" = "Beskyt dig selv på op til 5 enheder ad gangen.";
"walkthrough.page.1.title" = "Understøt 5 enheder på en gang";
"walkthrough.page.1.description" = "Beskyt dig selv på op til 10 enheder ad gangen.";
"walkthrough.page.1.title" = "Understøt 10 enheder på en gang";
"walkthrough.page.2.description" = "Med servere rundt om i verden er du altid beskyttet.";
"walkthrough.page.2.title" = "Forbind nemt til en hvilken som helst region";
"walkthrough.page.3.description" = "Aktivering af vores Indholdsblokering forhindrer reklamer i at blive vist i Safari.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "FERTIG";
"walkthrough.action.next" = "WEITER";
"walkthrough.action.skip" = "ÜBERSPRINGEN";
"walkthrough.page.1.description" = "Schütze dich auf bis zu 5 Geräten gleichzeitig.";
"walkthrough.page.1.title" = "Unterstützt 5 Geräte auf einmal";
"walkthrough.page.1.description" = "Schütze dich auf bis zu 10 Geräten gleichzeitig.";
"walkthrough.page.1.title" = "Unterstützt 10 Geräte auf einmal";
"walkthrough.page.2.description" = "Mit Servern auf der ganzen Welt bist du immer geschützt.";
"walkthrough.page.2.title" = "Bequem mit jeder beliebigen Region verbinden";
"walkthrough.page.3.description" = "Mit der Aktivierung unseres Inhalts-Blockers sehen Sie keine Anzeigen in Safari mehr.";
......
......@@ -35,8 +35,8 @@
"walkthrough.action.done" = "DONE";
"walkthrough.action.skip" = "SKIP";
"walkthrough.page.1.title" = "Support 5 devices at once";
"walkthrough.page.1.description" = "Protect yourself on up to 5 devices at a time.";
"walkthrough.page.1.title" = "Support 10 devices at once";
"walkthrough.page.1.description" = "Protect yourself on up to 10 devices at a time.";
"walkthrough.page.2.title" = "Connect to any region easily";
"walkthrough.page.2.description" = "With servers around the globe, you are always under protection.";
"walkthrough.page.3.title" = "Protect yourself from ads";
......@@ -250,3 +250,6 @@
"siri.shortcuts.connect.title" = "Connect PIA VPN";
"siri.shortcuts.disconnect.title" = "Disconnect PIA VPN";
"siri.shortcuts.add.error" = "There was an error adding the Siri shortcut. Please, try it again.";
//TODAY WIDGET
"today.widget.login" = "Login";
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "TERMINADO";
"walkthrough.action.next" = "SIGUIENTE";
"walkthrough.action.skip" = "OMITIR";
"walkthrough.page.1.description" = "Protégete en hasta 5 dispositivos a la vez.";
"walkthrough.page.1.title" = "Admite 5 dispositivos a la vez";
"walkthrough.page.1.description" = "Protégete en hasta 10 dispositivos a la vez.";
"walkthrough.page.1.title" = "Admite 10 dispositivos a la vez";
"walkthrough.page.2.description" = "Con servidores en todo el mundo, siempre estarás protegido.";
"walkthrough.page.2.title" = "Conéctate a cualquier región con facilidad";
"walkthrough.page.3.description" = "Habilita nuestro Bloqueador de contenido para impedir que aparezca publicidad en Safari.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "TERMINÉ";
"walkthrough.action.next" = "SUIVANT";
"walkthrough.action.skip" = "PASSER";
"walkthrough.page.1.description" = "Protégez-vous sur jusqu'à 5 appareils à la fois.";
"walkthrough.page.1.title" = "Prend en charge 5 appareils en même temps";
"walkthrough.page.1.description" = "Protégez-vous sur jusqu'à 10 appareils à la fois.";
"walkthrough.page.1.title" = "Prend en charge 10 appareils en même temps";
"walkthrough.page.2.description" = "Avec des serveurs partout dans le monde, vous êtes toujours sous protection.";
"walkthrough.page.2.title" = "Connectez-vous facilement à n'importe quelle région";
"walkthrough.page.3.description" = "Activer notre bloqueur de contenu empêche les publicités de s'afficher dans Safari.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "FATTO";
"walkthrough.action.next" = "AVANTI";
"walkthrough.action.skip" = "SALTA";
"walkthrough.page.1.description" = "Proteggi te stesso su un massimo di 5 dispositivi alla volta.";
"walkthrough.page.1.title" = "Supporta 5 dispositivi alla volta";
"walkthrough.page.1.description" = "Proteggi te stesso su un massimo di 10 dispositivi alla volta.";
"walkthrough.page.1.title" = "Supporta 10 dispositivi alla volta";
"walkthrough.page.2.description" = "Con server in tutto il mondo, sei sempre protetto.";
"walkthrough.page.2.title" = "Connettiti facilmente a qualsiasi regione";
"walkthrough.page.3.description" = "Abilitando il nostro Blocco dei contenuti non visualizzerai la pubblicità mentre navighi con Safari.";
......
......@@ -157,8 +157,8 @@
"walkthrough.action.done" = "GOTOWE";
"walkthrough.action.next" = "DALEJ";
"walkthrough.action.skip" = "POMIŃ";
"walkthrough.page.1.description" = "Ochrona na maksymalnie 5 urządzeniach jednocześnie.";
"walkthrough.page.1.title" = "Obsługa 5 urządzeń jednocześnie";
"walkthrough.page.1.description" = "Ochrona na maksymalnie 10 urządzeniach jednocześnie.";
"walkthrough.page.1.title" = "Obsługa 10 urządzeń jednocześnie";
"walkthrough.page.2.description" = "Dzięki serwerom na całym świecie zawsze jesteś pod ochroną.";
"walkthrough.page.2.title" = "Łatwo połączysz się z dowolnym regionem";
"walkthrough.page.3.description" = "Włączenie naszej Blokady zawartości chroni Cię przed wyświetlaniem reklam w Safari.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "CONCLUÍDO";
"walkthrough.action.next" = "AVANÇAR";
"walkthrough.action.skip" = "PULAR";
"walkthrough.page.1.description" = "Proteja-se em até 5 dispositivos ao mesmo tempo.";
"walkthrough.page.1.title" = "Suporte para 5 dispositivos ao mesmo tempo";
"walkthrough.page.1.description" = "Proteja-se em até 10 dispositivos ao mesmo tempo.";
"walkthrough.page.1.title" = "Suporte para 10 dispositivos ao mesmo tempo";
"walkthrough.page.2.description" = "Com servidores ao redor do mundo, você está sempre protegido.";
"walkthrough.page.2.title" = "Conecte-se a qualquer região facilmente";
"walkthrough.page.3.description" = "A ativação do nosso Bloqueador de Conteúdo impede que anúncios sejam exibidos no Safari.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "ГОТОВО";
"walkthrough.action.next" = "ДАЛЕЕ";
"walkthrough.action.skip" = "ПРОПУСК";
"walkthrough.page.1.description" = "Защищайте себя на нескольких устройствах одновременно (до 5).";
"walkthrough.page.1.title" = "Поддержка 5 устройств одновременно";
"walkthrough.page.1.description" = "Защищайте себя на нескольких устройствах одновременно (до 10).";
"walkthrough.page.1.title" = "Поддержка 10 устройств одновременно";
"walkthrough.page.2.description" = "У нас есть серверы по всему миру, так что вы всегда будете под защитой.";
"walkthrough.page.2.title" = "Простое подключение к любому региону";
"walkthrough.page.3.description" = "Активация нашего правила блокирования контента препятствует отображению рекламы в Safari.";
......
......@@ -157,8 +157,8 @@
"walkthrough.action.done" = "เสร็จสิ้น";
"walkthrough.action.next" = "ถัดไป";
"walkthrough.action.skip" = "ข้าม";
"walkthrough.page.1.description" = "ปกป้องตัวคุณบนอุปกรณ์ถึง 5 เครื่องในเวลาเดียวกัน";
"walkthrough.page.1.title" = "รับรองอุปกรณ์ 5 เครื่องในคราวเดียว";
"walkthrough.page.1.description" = "ปกป้องตัวคุณบนอุปกรณ์ถึง 10 เครื่องในเวลาเดียวกัน";
"walkthrough.page.1.title" = "รับรองอุปกรณ์ 10 เครื่องในคราวเดียว";
"walkthrough.page.2.description" = "ด้วยเซิร์ฟเวอร์ที่มีอยู่ทั่วโลก คุณจะได้รับความคุ้มครองตลอดเวลา";
"walkthrough.page.2.title" = "เชื่อมต่อไปยังภูมิภาคใดก็ตามได้อย่างง่ายดาย";
"walkthrough.page.3.description" = "การเปิดใช้งานตัวปิดกั้นเนื้อหาของเราจะเป็นการป้องกันไม่ให้แสดงโฆษณาใน Safari";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "BİTTİ";
"walkthrough.action.next" = "İLERİ";
"walkthrough.action.skip" = "ATLA";
"walkthrough.page.1.description" = "Aynı anda 5 cihazda koruma sağlayın.";
"walkthrough.page.1.title" = "Aynı anda 5 cihazı destekle";
"walkthrough.page.1.description" = "Aynı anda 10 cihazda koruma sağlayın.";
"walkthrough.page.1.title" = "Aynı anda 10 cihazı destekle";
"walkthrough.page.2.description" = "Dünya çapındaki sunucularla daima koruma altındasınız.";
"walkthrough.page.2.title" = "Herhangi bir bölgeye kolayca bağlanın";
"walkthrough.page.3.description" = "İçerik Engelleyicimizi etkinleştirdiğinizde Safari'de reklamların gösterilmesi engellenir.";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "完成";
"walkthrough.action.next" = "下一个";
"walkthrough.action.skip" = "跳过";
"walkthrough.page.1.description" = "一次在多达 5 台设备上保护自己。";
"walkthrough.page.1.title" = "一次支持 5 台设备";
"walkthrough.page.1.description" = "一次在多达 10 台设备上保护自己。";
"walkthrough.page.1.title" = "一次支持 10 台设备";
"walkthrough.page.2.description" = "服务器遍布世界各地,您始终受到保护。";
"walkthrough.page.2.title" = "轻松连接到任何地区";
"walkthrough.page.3.description" = "启用内容拦截器以防止 Safari 中出现广告。";
......
......@@ -156,8 +156,8 @@
"walkthrough.action.done" = "完成";
"walkthrough.action.next" = "下一步";
"walkthrough.action.skip" = "跳過";
"walkthrough.page.1.description" = "同時為多達 5 台裝置提供保護";
"walkthrough.page.1.title" = "同時支援 5 台裝置";
"walkthrough.page.1.description" = "同時為多達 10 台裝置提供保護";
"walkthrough.page.1.title" = "同時支援 10 台裝置";
"walkthrough.page.2.description" = "我們的伺服器遍佈全球,能為您提供全面保護。";
"walkthrough.page.2.title" = "輕易就能連線到任何地區";
"walkthrough.page.3.description" = "只要啟用我們的內容阻擋器,使用 Safari 瀏覽器時就再也不會看到廣告。";
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Today View Controller-->
<scene sceneID="cwh-vc-ff4">
<objects>
<viewController id="M4Y-Lb-cyx" customClass="TodayViewController" customModule="PIAWidget" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LCJ-5k-KoW">
<rect key="frame" x="19" y="-6.5" width="282" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="CnC-rS-rIA"/>
</constraints>
<state key="normal" title="Button"/>
<connections>
<action selector="widgetButtonClicked:" destination="M4Y-Lb-cyx" eventType="touchUpInside" id="slV-Cz-c3O"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="LCJ-5k-KoW" firstAttribute="leading" secondItem="ssy-KU-ocm" secondAttribute="leading" constant="19" id="OKJ-2O-hZe"/>
<constraint firstItem="ssy-KU-ocm" firstAttribute="trailing" secondItem="LCJ-5k-KoW" secondAttribute="trailing" constant="19" id="WKB-Fn-zJA"/>
<constraint firstItem="LCJ-5k-KoW" firstAttribute="centerY" secondItem="S3S-Oj-5AN" secondAttribute="centerY" id="klG-o6-2QE"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ssy-KU-ocm"/>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="37"/>
<connections>
<outlet property="widgetConnectButton" destination="LCJ-5k-KoW" id="hKH-gq-WRm"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>PIA VPN</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widget-extension</string>
</dict>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.privateinternetaccess</string>
</array>
</dict>
</plist>
//
// TodayViewController.swift
// PIAWidget
//
// Created by Jose Antonio Blaya Garcia on 18/03/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import NotificationCenter
class TodayViewController: UIViewController, NCWidgetProviding {
private let vpnStatus = "vpn.status"
private let vpnButtonDescription = "vpn.button.description"
private let appGroup = "group.com.privateinternetaccess"
private let urlSchema = "privateinternetaccess://"
@IBOutlet weak var widgetConnectButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
if let sharedDefaults = UserDefaults(suiteName: appGroup),
let buttonTitle = sharedDefaults.string(forKey: vpnButtonDescription) {
widgetConnectButton.setTitle(buttonTitle.uppercased(), for: [])
}
widgetConnectButton.layer.cornerRadius = 6.0
widgetConnectButton.clipsToBounds = true
widgetConnectButton.titleLabel?.font = UIFont.systemFont(ofSize: 14.0)
widgetConnectButton.setTitleColor(UIColor.white, for: [])
widgetConnectButton.backgroundColor = UIColor(red: 76.0 / 255.0, green: 182.0 / 255.0, blue: 73.0 / 255.0, alpha: 1.0)
widgetConnectButton.layer.borderWidth = 0
widgetConnectButton.layer.borderColor = UIColor.clear.cgColor
}
@IBAction func widgetButtonClicked(_ sender: Any) {
if let sharedDefaults = UserDefaults(suiteName: appGroup),
let status = sharedDefaults.string(forKey: vpnStatus),
let appURL = URL(string: urlSchema+status) {
extensionContext?.open(appURL, completionHandler: nil)
}
}
}
......@@ -14,7 +14,8 @@ app_identifier [
"com.privateinternetaccess.ios.PIA-VPN",
"com.privateinternetaccess.ios.PIA-VPN.Tunnel",
"com.privateinternetaccess.ios.PIA-VPN.Widget",
"com.privateinternetaccess.ios.PIA-VPN.AdBlocker"
"com.privateinternetaccess.ios.PIA-VPN.AdBlocker",
"com.privateinternetaccess.ios.PIA-VPN.PIAWidget"
]
# For all available options run `fastlane match --help`
......
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