summaryrefslogtreecommitdiffstats
path: root/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension')
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json18
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json28
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json18
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json18
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json18
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.h8
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.m48
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Info.plist36
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.h21
-rw-r--r--tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.m146
10 files changed, 359 insertions, 0 deletions
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
new file mode 100644
index 000000000..9be9adbf7
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
@@ -0,0 +1,18 @@
+{
+ "images" : [
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{130,145}",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{146,165}",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json
new file mode 100644
index 000000000..2eca9a1f4
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json
@@ -0,0 +1,28 @@
+{
+ "assets" : [
+ {
+ "idiom" : "watch",
+ "filename" : "Circular.imageset",
+ "role" : "circular"
+ },
+ {
+ "idiom" : "watch",
+ "filename" : "Extra Large.imageset",
+ "role" : "extra-large"
+ },
+ {
+ "idiom" : "watch",
+ "filename" : "Modular.imageset",
+ "role" : "modular"
+ },
+ {
+ "idiom" : "watch",
+ "filename" : "Utilitarian.imageset",
+ "role" : "utilitarian"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json
new file mode 100644
index 000000000..9be9adbf7
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json
@@ -0,0 +1,18 @@
+{
+ "images" : [
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{130,145}",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{146,165}",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json
new file mode 100644
index 000000000..9be9adbf7
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json
@@ -0,0 +1,18 @@
+{
+ "images" : [
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{130,145}",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{146,165}",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json
new file mode 100644
index 000000000..9be9adbf7
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json
@@ -0,0 +1,18 @@
+{
+ "images" : [
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{130,145}",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "watch",
+ "screenWidth" : "{146,165}",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.h b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.h
new file mode 100644
index 000000000..dfd9b7fde
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.h
@@ -0,0 +1,8 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#import <WatchKit/WatchKit.h>
+
+@interface ExtensionDelegate : NSObject <WKExtensionDelegate>
+
+@end
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.m b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.m
new file mode 100644
index 000000000..014c5fa40
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/ExtensionDelegate.m
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#import "ExtensionDelegate.h"
+
+@implementation ExtensionDelegate
+
+- (void)applicationDidFinishLaunching {
+ // Perform any final initialization of your application.
+}
+
+- (void)applicationDidBecomeActive {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillResignActive {
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, etc.
+}
+
+- (void)handleBackgroundTasks:(NSSet<WKRefreshBackgroundTask *> *)backgroundTasks {
+ // Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one.
+ for (WKRefreshBackgroundTask * task in backgroundTasks) {
+ // Check the Class of each task to decide how to process it
+ if ([task isKindOfClass:[WKApplicationRefreshBackgroundTask class]]) {
+ // Be sure to complete the background task once you’re done.
+ WKApplicationRefreshBackgroundTask *backgroundTask = (WKApplicationRefreshBackgroundTask*)task;
+ [backgroundTask setTaskCompleted];
+ } else if ([task isKindOfClass:[WKSnapshotRefreshBackgroundTask class]]) {
+ // Snapshot tasks have a unique completion call, make sure to set your expiration date
+ WKSnapshotRefreshBackgroundTask *snapshotTask = (WKSnapshotRefreshBackgroundTask*)task;
+ [snapshotTask setTaskCompletedWithDefaultStateRestored:YES estimatedSnapshotExpiration:[NSDate distantFuture] userInfo:nil];
+ } else if ([task isKindOfClass:[WKWatchConnectivityRefreshBackgroundTask class]]) {
+ // Be sure to complete the background task once you’re done.
+ WKWatchConnectivityRefreshBackgroundTask *backgroundTask = (WKWatchConnectivityRefreshBackgroundTask*)task;
+ [backgroundTask setTaskCompleted];
+ } else if ([task isKindOfClass:[WKURLSessionRefreshBackgroundTask class]]) {
+ // Be sure to complete the background task once you’re done.
+ WKURLSessionRefreshBackgroundTask *backgroundTask = (WKURLSessionRefreshBackgroundTask*)task;
+ [backgroundTask setTaskCompleted];
+ } else {
+ // make sure to complete unhandled task types
+ [task setTaskCompleted];
+ }
+ }
+}
+
+@end
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Info.plist b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Info.plist
new file mode 100644
index 000000000..ece2677b1
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/Info.plist
@@ -0,0 +1,36 @@
+<?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>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>PlanetsClient WatchKit Extension</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>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSExtension</key>
+ <dict>
+ <key>NSExtensionAttributes</key>
+ <dict>
+ <key>WKAppBundleIdentifier</key>
+ <string>Qt.PlanetsClient.watchkitapp</string>
+ </dict>
+ <key>NSExtensionPointIdentifier</key>
+ <string>com.apple.watchkit</string>
+ </dict>
+ <key>WKExtensionDelegateClassName</key>
+ <string>ExtensionDelegate</string>
+</dict>
+</plist>
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.h b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.h
new file mode 100644
index 000000000..0e11fa23d
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#import <WatchKit/WatchKit.h>
+#import <Foundation/Foundation.h>
+#import <WatchConnectivity/WatchConnectivity.h>
+
+@interface InterfaceController : WKInterfaceController
+
+@property (nonatomic, copy) NSString *host;
+@property (nonatomic, copy) NSNumber *port;
+@property (nonatomic, copy) NSArray *planets;
+@property (nonatomic, assign) float minimumValue;
+@property (nonatomic, assign) float maximumValue;
+@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceLabel *hostLabel;
+@property (unsafe_unretained, nonatomic) IBOutlet WKInterfacePicker *planetPicker;
+@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceSlider *rotationSpeedSlider;
+@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceSlider *viewingDistanceSlider;
+@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceSlider *planetSizeSlider;
+
+@end
diff --git a/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.m b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.m
new file mode 100644
index 000000000..77f052002
--- /dev/null
+++ b/tests/manual/planets-qml/planets-watchos/PlanetsClient WatchKit Extension/InterfaceController.m
@@ -0,0 +1,146 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#import "InterfaceController.h"
+
+@interface InterfaceController() <WCSessionDelegate>
+
+@end
+
+@implementation InterfaceController
+
+- (id)init {
+ if ((self = [super init])) {
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSString *host = [defaults stringForKey:@"host"];
+ int port = [defaults integerForKey:@"port"];
+
+ if (host == nil) {
+ self.host = @"127.0.0.1";
+ } else {
+ self.host = host;
+ }
+
+ if (port == 0) {
+ self.port = [NSNumber numberWithInt:8080];
+ } else {
+ self.port = [NSNumber numberWithInt:port];
+ }
+
+ self.planets = @[@"Sun",
+ @"Mercury",
+ @"Venus",
+ @"Earth",
+ @"Mars",
+ @"Jupiter",
+ @"Saturn",
+ @"Uranus",
+ @"Neptune",
+ @"Solar System"];
+
+ self.minimumValue = 1.0f;
+ self.maximumValue = 10.0f;
+ }
+
+ return self;
+}
+
+- (void)awakeWithContext:(id)context {
+ [super awakeWithContext:context];
+
+ int planetsCount = [self.planets count];
+
+ NSMutableArray *pickerItems = [[NSMutableArray alloc] init];
+
+ for (int i = 0; i < planetsCount; i++) {
+ WKPickerItem *item = [WKPickerItem alloc];
+ item.title = self.planets[i];
+ [pickerItems addObject:item];
+ }
+
+ [self.planetPicker setItems:pickerItems];
+
+ [self.hostLabel setText:[NSString stringWithFormat:@"%@:%@", self.host, [NSString stringWithFormat:@"%d", [self.port intValue]]]];
+}
+
+- (void)willActivate {
+ [super willActivate];
+
+ if ([WCSession isSupported]) {
+ WCSession *session = [WCSession defaultSession];
+ session.delegate = self;
+ [session activateSession];
+ }
+}
+
+- (IBAction)selectedPlanetChanged:(NSInteger)value {
+ NSString *command = [@[@"selectPlanet", self.planets[value]] componentsJoinedByString:@"/"];
+
+ [self sendCommand:command];
+}
+
+- (IBAction)rotationSpeedChanged:(float)value {
+ NSString* formattedValue = [NSString stringWithFormat:@"%.02f", (value - self.minimumValue) /
+ (self.maximumValue - self.minimumValue)];
+ NSString *command = [@[@"setRotationSpeed", formattedValue] componentsJoinedByString:@"/"];
+
+ [self sendCommand:command];
+}
+
+- (IBAction)viewingDistanceChanged:(float)value {
+ NSString* formattedValue = [NSString stringWithFormat:@"%.02f", (value - self.minimumValue) /
+ (self.maximumValue - self.minimumValue)];
+ NSString *command = [@[@"setViewingDistance", formattedValue] componentsJoinedByString:@"/"];
+
+ [self sendCommand:command];
+}
+
+- (IBAction)planetSizeChanged:(float)value {
+ NSString* formattedValue = [NSString stringWithFormat:@"%.02f", (value - self.minimumValue) /
+ (self.maximumValue - self.minimumValue)];
+ NSString *command = [@[@"setPlanetSize", formattedValue] componentsJoinedByString:@"/"];
+
+ [self sendCommand:command];
+}
+
+
+- (void)sendCommand:(NSString *)command {
+ NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
+
+ NSURLComponents *urlComponents = [[NSURLComponents alloc] init];
+ urlComponents.scheme = @"http";
+ urlComponents.host = self.host;
+ urlComponents.port = self.port;
+ urlComponents.path = [NSString stringWithFormat:@"/%@", command];
+
+ [request setURL:urlComponents.URL];
+ [request setHTTPMethod:@"GET"];
+
+ NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+ [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response,
+ NSError *error) {}] resume];
+}
+
+- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary *)message replyHandler:(nonnull void (^)(NSDictionary<NSString *,id> *))replyHandler {
+ NSString *host = [message objectForKey:@"host"];
+ NSString *port = [message objectForKey:@"port"];
+
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
+ numberFormatter.numberStyle = NSNumberFormatterNoStyle;
+
+ self.host = host;
+ self.port = [numberFormatter numberFromString:port];
+
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [defaults setObject:host forKey:@"host"];
+ [defaults setInteger:[self.port integerValue] forKey:@"port"];
+ [defaults synchronize];
+
+ [self.hostLabel setText:[NSString stringWithFormat:@"%@:%@", host, port]];
+}
+
+- (void)session:(WCSession *)session activationDidCompleteWithState:(WCSessionActivationState)activationState error:(NSError *)error {
+
+}
+
+@end