diff --git a/Teslameter/Info.plist.xml b/Teslameter/Info.plist.xml index c2956aaf..cb717a37 100644 --- a/Teslameter/Info.plist.xml +++ b/Teslameter/Info.plist.xml @@ -24,6 +24,10 @@ ${app.build} LSRequiresIPhoneOS + UIMainStoryboardFile + Main + MinimumOSVersion + 8.0 UIDeviceFamily 1 @@ -36,42 +40,11 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - CFBundleIcons - - CFBundlePrimaryIcon - - CFBundleIconFiles - - Icon-Small - Icon-Small-40 - Icon - Icon-60 - Icon-72 - - - - CFBundleIcons~ipad - - CFBundlePrimaryIcon - - CFBundleIconFiles - - Icon-Small - Icon-Small-40 - Icon-72 - Icon-76 - - - diff --git a/Teslameter/resources/Base.lproj/Main.storyboard b/Teslameter/resources/Base.lproj/Main.storyboard new file mode 100644 index 00000000..63e41514 --- /dev/null +++ b/Teslameter/resources/Base.lproj/Main.storyboard @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Contents.json b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..ffa15158 --- /dev/null +++ b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,80 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@2x-1.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-Small-40@2x-1.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-Small-40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-Small-40.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-Small-40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Teslameter/resources/Icon-60@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png similarity index 100% rename from Teslameter/resources/Icon-60@2x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png diff --git a/Teslameter/resources/Icon-60@3x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png similarity index 100% rename from Teslameter/resources/Icon-60@3x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png diff --git a/Teslameter/resources/Icon-76.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png similarity index 100% rename from Teslameter/resources/Icon-76.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png diff --git a/Teslameter/resources/Icon-76@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png similarity index 100% rename from Teslameter/resources/Icon-76@2x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png diff --git a/Teslameter/resources/Icon-Small-40.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png similarity index 100% rename from Teslameter/resources/Icon-Small-40.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png diff --git a/Teslameter/resources/Icon-Small-40@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png similarity index 100% rename from Teslameter/resources/Icon-Small-40@2x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png diff --git a/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png new file mode 100644 index 00000000..8db82b0f Binary files /dev/null and b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png differ diff --git a/Teslameter/resources/Icon-Small-40@3x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png similarity index 100% rename from Teslameter/resources/Icon-Small-40@3x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png diff --git a/Teslameter/resources/Icon-Small.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small.png similarity index 100% rename from Teslameter/resources/Icon-Small.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small.png diff --git a/Teslameter/resources/Icon-Small@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png similarity index 100% rename from Teslameter/resources/Icon-Small@2x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png diff --git a/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png new file mode 100644 index 00000000..6f9e1565 Binary files /dev/null and b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png differ diff --git a/Teslameter/resources/Icon-Small@3x.png b/Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png similarity index 100% rename from Teslameter/resources/Icon-Small@3x.png rename to Teslameter/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png diff --git a/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Contents.json b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 00000000..5379aae6 --- /dev/null +++ b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,57 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Default@2x~iphone.png", + "scale" : "2x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "retina4", + "filename" : "Default-568h@2x~iphone.png", + "minimum-system-version" : "7.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Default-Portrait~ipad.png", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Default-Landscape~ipad.png", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Default-Portrait@2x~ipad.png", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Default-Landscape@2x~ipad.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Teslameter/resources/Default-568h@2x~iphone.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png similarity index 100% rename from Teslameter/resources/Default-568h@2x~iphone.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png diff --git a/Teslameter/resources/Default-Landscape@2x~ipad.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png similarity index 100% rename from Teslameter/resources/Default-Landscape@2x~ipad.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png diff --git a/Teslameter/resources/Default-Landscape~ipad.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png similarity index 100% rename from Teslameter/resources/Default-Landscape~ipad.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png diff --git a/Teslameter/resources/Default-Portrait@2x~ipad.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x~ipad.png similarity index 100% rename from Teslameter/resources/Default-Portrait@2x~ipad.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x~ipad.png diff --git a/Teslameter/resources/Default-Portrait~ipad.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png similarity index 100% rename from Teslameter/resources/Default-Portrait~ipad.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png diff --git a/Teslameter/resources/Default@2x~iphone.png b/Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png similarity index 100% rename from Teslameter/resources/Default@2x~iphone.png rename to Teslameter/resources/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png diff --git a/Teslameter/robovm.properties b/Teslameter/robovm.properties index a3dfeaf2..7218bcb3 100644 --- a/Teslameter/robovm.properties +++ b/Teslameter/robovm.properties @@ -1,6 +1,8 @@ +# +#Sun May 03 13:28:58 CEST 2015 app.version=1.0 app.id=org.robovm.samples.teslameter app.mainclass=org.robovm.samples.teslameter.Teslameter app.executable=Teslameter app.build=1 -app.name=Teslameter \ No newline at end of file +app.name=Teslameter diff --git a/Teslameter/robovm.xml b/Teslameter/robovm.xml index af5c5b33..88c5cf62 100644 --- a/Teslameter/robovm.xml +++ b/Teslameter/robovm.xml @@ -1,17 +1,13 @@ - ${app.executable} - ${app.mainclass} - ios - thumbv7 - - - resources - - - ios - Info.plist.xml - - CoreGraphics - CoreLocation - + ${app.executable} + ${app.mainclass} + ios + thumbv7 + + + resources + + + ios + Info.plist.xml \ No newline at end of file diff --git a/Teslameter/src/main/java/org/robovm/samples/teslameter/Teslameter.java b/Teslameter/src/main/java/org/robovm/samples/teslameter/Teslameter.java index b9da071a..95090b9f 100644 --- a/Teslameter/src/main/java/org/robovm/samples/teslameter/Teslameter.java +++ b/Teslameter/src/main/java/org/robovm/samples/teslameter/Teslameter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 RoboVM AB + * Copyright (C) 2013-2015 RoboVM AB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,45 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Portions of this code is based on Apple Inc's Teslameter sample (v1.3) - * which is copyright (C) 2009-2014 Apple Inc. + * Portions of this code is based on Apple Inc's PhotoPicker sample (v2.0) + * which is copyright (C) 2010-2013 Apple Inc. */ - package org.robovm.samples.teslameter; import org.robovm.apple.foundation.NSAutoreleasePool; import org.robovm.apple.uikit.UIApplication; import org.robovm.apple.uikit.UIApplicationDelegateAdapter; -import org.robovm.apple.uikit.UIScreen; -import org.robovm.apple.uikit.UIWindow; -import org.robovm.samples.teslameter.viewcontrollers.TeslameterViewController; +import org.robovm.apple.uikit.UIApplicationLaunchOptions; public class Teslameter extends UIApplicationDelegateAdapter { - private UIWindow window; - private TeslameterViewController viewController; @Override - public void didFinishLaunching (UIApplication application) { - // Set up the view controller. - viewController = new TeslameterViewController(); - - // Create a new window at screen size. - window = new UIWindow(UIScreen.getMainScreen().getBounds()); - // Set our viewcontroller as the root controller for the window. - window.setRootViewController(viewController); - // Make the window visible. - window.makeKeyAndVisible(); - - /* - * Retains the window object until the application is deallocated. Prevents Java GC from collecting the window object too - * early. - */ - addStrongRef(window); + public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) { + return true; } - public static void main (String[] args) { - NSAutoreleasePool pool = new NSAutoreleasePool(); - UIApplication.main(args, null, Teslameter.class); - pool.close(); + public static void main(String[] args) { + try (NSAutoreleasePool pool = new NSAutoreleasePool()) { + UIApplication.main(args, null, Teslameter.class); + } } } diff --git a/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/GraphView.java b/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/GraphView.java new file mode 100644 index 00000000..1c0af61f --- /dev/null +++ b/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/GraphView.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2013-2015 RoboVM AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Portions of this code is based on Apple Inc's PhotoPicker sample (v2.0) + * which is copyright (C) 2010-2013 Apple Inc. + */ +package org.robovm.samples.teslameter.ui; + +import org.robovm.apple.coregraphics.CGContext; +import org.robovm.apple.coregraphics.CGRect; +import org.robovm.apple.uikit.UIGraphics; +import org.robovm.apple.uikit.UIView; +import org.robovm.objc.annotation.CustomClass; + +@CustomClass("GraphView") +public class GraphView extends UIView { + private int nextIndex; + private double[][] history; + + public void updateHistory(double x, double y, double z) { + // Add to history. + history[nextIndex][0] = x; + history[nextIndex][1] = y; + history[nextIndex][2] = z; + + // Advance the index counter. + nextIndex = (nextIndex + 1) % 150; + + // Mark itself as needing to be redrawn. + setNeedsDisplay(); + } + + private void drawGraph(CGContext context, CGRect bounds) { + double value, temp; + + // Save any previous graphics state settings before setting the color + // and line width for the current draw. + context.saveGState(); + context.setLineWidth(1.0); + + // Draw the intermediate lines + context.setGrayStrokeColor(0.6, 1.0); + context.beginPath(); + for (value = -5 + 1.0; value <= 5 - 1.0; value += 1.0) { + if (value == 0.0) { + continue; + } + temp = 0.5 + Math.round(bounds.getOrigin().getY() + bounds.getSize().getHeight() / 2 + value / (2 * 5) + * bounds.getSize().getHeight()); + context.moveToPoint(bounds.getOrigin().getX(), temp); + context.addLineToPoint(bounds.getOrigin().getX() + bounds.getSize().getWidth(), temp); + } + context.strokePath(); + + // Draw the center line + context.setGrayStrokeColor(0.25, 1.0); + context.beginPath(); + temp = 0.5 + Math.round(bounds.getOrigin().getY() + bounds.getSize().getHeight() / 2); + context.moveToPoint(bounds.getOrigin().getX(), temp); + context.addLineToPoint(bounds.getOrigin().getX() + bounds.getSize().getWidth(), temp); + context.strokePath(); + + // Restore previous graphics state. + context.restoreGState(); + } + + private void drawHistory(int axis, int index, CGContext context, CGRect bounds) { + double value; + + context.beginPath(); + for (int counter = 0; counter < 150; ++counter) { + // UIView referential has the Y axis going down, so we need to draw + // upside-down. + value = history[(index + counter) % 150][axis] / -128; + if (counter > 0) { + context.addLineToPoint(bounds.getOrigin().getX() + (float) counter / (float) (150 - 1) + * bounds.getSize().getWidth(), bounds.getOrigin().getY() + bounds.getSize().getHeight() / 2 + + value + * bounds.getSize().getHeight() / 2); + } else { + context.moveToPoint(bounds.getOrigin().getX() + (float) counter / (float) (150 - 1) + * bounds.getSize().getWidth(), + bounds.getOrigin().getY() + bounds.getSize().getHeight() / 2 + value + * bounds.getSize().getHeight() / 2); + } + } + // Save any previous graphics state settings before setting the color + // and line width for the current draw. + context.saveGState(); + context.setRGBStrokeColor((axis == 0 ? 1.0 : 0.0), (axis == 1 ? 1.0 : 0.0), (axis == 2 ? 1.0 : 0.0), 1.0); + context.setLineWidth(2.0); + context.strokePath(); + // Restore previous graphics state. + context.restoreGState(); + } + + @Override + public void draw(CGRect rect) { + int index = nextIndex; + + if (history == null) { + // TODO move to constructor when #894 is fixed + history = new double[150][3]; + } + + CGContext context = UIGraphics.getCurrentContext(); + CGRect bounds = new CGRect(0, 0, getBounds().getSize().getWidth(), getBounds().getSize().getHeight()); + + // create the graph + drawGraph(context, bounds); + + // plot x,y,z with anti-aliasing turned off + context.setAllowsAntialiasing(false); + for (int i = 0; i < 3; ++i) { + drawHistory(i, index, context, bounds); + } + context.setAllowsAntialiasing(true); + } +} diff --git a/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/TeslameterViewController.java b/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/TeslameterViewController.java new file mode 100644 index 00000000..12d32dbc --- /dev/null +++ b/Teslameter/src/main/java/org/robovm/samples/teslameter/ui/TeslameterViewController.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2013-2015 RoboVM AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Portions of this code is based on Apple Inc's PhotoPicker sample (v2.0) + * which is copyright (C) 2010-2013 Apple Inc. + */ +package org.robovm.samples.teslameter.ui; + +import org.robovm.apple.corelocation.CLErrorCode; +import org.robovm.apple.corelocation.CLHeading; +import org.robovm.apple.corelocation.CLLocationManager; +import org.robovm.apple.corelocation.CLLocationManagerDelegateAdapter; +import org.robovm.apple.foundation.NSError; +import org.robovm.apple.uikit.UIAlertView; +import org.robovm.apple.uikit.UILabel; +import org.robovm.apple.uikit.UIStatusBarStyle; +import org.robovm.apple.uikit.UIViewController; +import org.robovm.objc.annotation.CustomClass; +import org.robovm.objc.annotation.IBOutlet; + +@CustomClass("TeslameterViewController") +public class TeslameterViewController extends UIViewController { + private UILabel magnitudeLabel; + private UILabel xLabel; + private UILabel yLabel; + private UILabel zLabel; + private GraphView graphView; + + private CLLocationManager locationManager; + + @Override + public void viewDidLoad() { + super.viewDidLoad(); + + // setup the location manager + locationManager = new CLLocationManager(); + + // check if the hardware has a compass + if (!CLLocationManager.isHeadingAvailable()) { + // No compass is available. This application cannot function without + // a compass, + // so a dialog will be displayed and no magnetic data will be + // measured. + locationManager = null; + UIAlertView noCompassAlert = new UIAlertView("No Compass!", + "This device does not have the ability to measure magnetic fields.", null, "OK"); + noCompassAlert.show(); + } else { + // heading service configuration + locationManager.setHeadingFilter(CLLocationManager.getHeadingFilterNone()); + + // setup delegate callbacks + locationManager.setDelegate(new CLLocationManagerDelegateAdapter() { + /** + * This delegate method is invoked when the location manager has + * heading data. + */ + @Override + public void didUpdateHeading(CLLocationManager manager, CLHeading newHeading) { + double x = newHeading.getX(); + double y = newHeading.getY(); + double z = newHeading.getZ(); + + // Update the labels with the raw x, y, and z values. + xLabel.setText(String.format("%.1f", x)); + yLabel.setText(String.format("%.1f", y)); + zLabel.setText(String.format("%.1f", z)); + + // Compute and display the magnitude (size or strength) of + // the vector. + // magnitude = sqrt(x^2 + y^2 + z^2) + double magnitute = Math.sqrt(x * x + y * y + z * z); + magnitudeLabel.setText(String.format("%.1f", magnitute)); + + // Update the graph with the new magnetic reading. + graphView.updateHistory(x, y, z); + } + + /** + * This delegate method is invoked when the location managed + * encounters an error condition. + */ + @Override + public void didFail(CLLocationManager manager, NSError error) { + if (error.getErrorCode() == CLErrorCode.Denied) { + // This error indicates that the user has denied the + // application's request to use location services. + manager.stopUpdatingHeading(); + } else if (error.getErrorCode() == CLErrorCode.HeadingFailure) { + // This error indicates that the heading could not be + // determined, most likely because of strong magnetic + // interference. + } + } + }); + + // start the compass + locationManager.startUpdatingHeading(); + } + } + + @Override + protected void dispose(boolean finalizing) { + // Stop the compass + locationManager.stopUpdatingHeading(); + super.dispose(finalizing); + } + + @Override + public UIStatusBarStyle getPreferredStatusBarStyle() { + // Status bar text should be white. + return UIStatusBarStyle.LightContent; + } + + @IBOutlet + private void setMagnitudeLabel(UILabel magnitudeLabel) { + this.magnitudeLabel = magnitudeLabel; + } + + @IBOutlet + private void setXLabel(UILabel xLabel) { + this.xLabel = xLabel; + } + + @IBOutlet + private void setYLabel(UILabel yLabel) { + this.yLabel = yLabel; + } + + @IBOutlet + private void setZLabel(UILabel zLabel) { + this.zLabel = zLabel; + } + + @IBOutlet + private void setGraphView(GraphView graphView) { + this.graphView = graphView; + } +} diff --git a/Teslameter2/Info.plist.xml b/Teslameter2/Info.plist.xml new file mode 100644 index 00000000..c2956aaf --- /dev/null +++ b/Teslameter2/Info.plist.xml @@ -0,0 +1,77 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${app.name} + CFBundleExecutable + ${app.executable} + CFBundleIdentifier + ${app.id} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${app.name} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${app.version} + CFBundleSignature + ???? + CFBundleVersion + ${app.build} + LSRequiresIPhoneOS + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon-Small + Icon-Small-40 + Icon + Icon-60 + Icon-72 + + + + CFBundleIcons~ipad + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon-Small + Icon-Small-40 + Icon-72 + Icon-76 + + + + + diff --git a/Teslameter/build.gradle b/Teslameter2/build.gradle similarity index 100% rename from Teslameter/build.gradle rename to Teslameter2/build.gradle diff --git a/Teslameter/pom.xml b/Teslameter2/pom.xml similarity index 100% rename from Teslameter/pom.xml rename to Teslameter2/pom.xml diff --git a/Teslameter2/resources/Background.png b/Teslameter2/resources/Background.png new file mode 100644 index 00000000..64827111 Binary files /dev/null and b/Teslameter2/resources/Background.png differ diff --git a/Teslameter2/resources/Default-568h@2x~iphone.png b/Teslameter2/resources/Default-568h@2x~iphone.png new file mode 100644 index 00000000..fb1d4236 Binary files /dev/null and b/Teslameter2/resources/Default-568h@2x~iphone.png differ diff --git a/Teslameter/resources/Default-667h@2x~iphone.png b/Teslameter2/resources/Default-667h@2x~iphone.png similarity index 100% rename from Teslameter/resources/Default-667h@2x~iphone.png rename to Teslameter2/resources/Default-667h@2x~iphone.png diff --git a/Teslameter/resources/Default-736h@3x~iphone.png b/Teslameter2/resources/Default-736h@3x~iphone.png similarity index 100% rename from Teslameter/resources/Default-736h@3x~iphone.png rename to Teslameter2/resources/Default-736h@3x~iphone.png diff --git a/Teslameter2/resources/Default-Landscape@2x~ipad.png b/Teslameter2/resources/Default-Landscape@2x~ipad.png new file mode 100644 index 00000000..e17e1121 Binary files /dev/null and b/Teslameter2/resources/Default-Landscape@2x~ipad.png differ diff --git a/Teslameter2/resources/Default-Landscape~ipad.png b/Teslameter2/resources/Default-Landscape~ipad.png new file mode 100644 index 00000000..71b5a2b3 Binary files /dev/null and b/Teslameter2/resources/Default-Landscape~ipad.png differ diff --git a/Teslameter2/resources/Default-Portrait@2x~ipad.png b/Teslameter2/resources/Default-Portrait@2x~ipad.png new file mode 100644 index 00000000..7e9edb2c Binary files /dev/null and b/Teslameter2/resources/Default-Portrait@2x~ipad.png differ diff --git a/Teslameter2/resources/Default-Portrait~ipad.png b/Teslameter2/resources/Default-Portrait~ipad.png new file mode 100644 index 00000000..c1b70744 Binary files /dev/null and b/Teslameter2/resources/Default-Portrait~ipad.png differ diff --git a/Teslameter2/resources/Default@2x~iphone.png b/Teslameter2/resources/Default@2x~iphone.png new file mode 100644 index 00000000..c43b69c9 Binary files /dev/null and b/Teslameter2/resources/Default@2x~iphone.png differ diff --git a/Teslameter2/resources/Icon-60@2x.png b/Teslameter2/resources/Icon-60@2x.png new file mode 100644 index 00000000..dc692891 Binary files /dev/null and b/Teslameter2/resources/Icon-60@2x.png differ diff --git a/Teslameter2/resources/Icon-60@3x.png b/Teslameter2/resources/Icon-60@3x.png new file mode 100644 index 00000000..a0e7f3d2 Binary files /dev/null and b/Teslameter2/resources/Icon-60@3x.png differ diff --git a/Teslameter/resources/Icon-72.png b/Teslameter2/resources/Icon-72.png similarity index 100% rename from Teslameter/resources/Icon-72.png rename to Teslameter2/resources/Icon-72.png diff --git a/Teslameter/resources/Icon-72@2x.png b/Teslameter2/resources/Icon-72@2x.png similarity index 100% rename from Teslameter/resources/Icon-72@2x.png rename to Teslameter2/resources/Icon-72@2x.png diff --git a/Teslameter2/resources/Icon-76.png b/Teslameter2/resources/Icon-76.png new file mode 100644 index 00000000..1353f4e8 Binary files /dev/null and b/Teslameter2/resources/Icon-76.png differ diff --git a/Teslameter2/resources/Icon-76@2x.png b/Teslameter2/resources/Icon-76@2x.png new file mode 100644 index 00000000..02186449 Binary files /dev/null and b/Teslameter2/resources/Icon-76@2x.png differ diff --git a/Teslameter2/resources/Icon-Small-40.png b/Teslameter2/resources/Icon-Small-40.png new file mode 100644 index 00000000..868d80b9 Binary files /dev/null and b/Teslameter2/resources/Icon-Small-40.png differ diff --git a/Teslameter2/resources/Icon-Small-40@2x.png b/Teslameter2/resources/Icon-Small-40@2x.png new file mode 100644 index 00000000..8db82b0f Binary files /dev/null and b/Teslameter2/resources/Icon-Small-40@2x.png differ diff --git a/Teslameter2/resources/Icon-Small-40@3x.png b/Teslameter2/resources/Icon-Small-40@3x.png new file mode 100644 index 00000000..dc692891 Binary files /dev/null and b/Teslameter2/resources/Icon-Small-40@3x.png differ diff --git a/Teslameter2/resources/Icon-Small.png b/Teslameter2/resources/Icon-Small.png new file mode 100644 index 00000000..595c460d Binary files /dev/null and b/Teslameter2/resources/Icon-Small.png differ diff --git a/Teslameter2/resources/Icon-Small@2x.png b/Teslameter2/resources/Icon-Small@2x.png new file mode 100644 index 00000000..6f9e1565 Binary files /dev/null and b/Teslameter2/resources/Icon-Small@2x.png differ diff --git a/Teslameter2/resources/Icon-Small@3x.png b/Teslameter2/resources/Icon-Small@3x.png new file mode 100644 index 00000000..8219640c Binary files /dev/null and b/Teslameter2/resources/Icon-Small@3x.png differ diff --git a/Teslameter/resources/Icon.png b/Teslameter2/resources/Icon.png similarity index 100% rename from Teslameter/resources/Icon.png rename to Teslameter2/resources/Icon.png diff --git a/Teslameter2/robovm.properties b/Teslameter2/robovm.properties new file mode 100644 index 00000000..a3dfeaf2 --- /dev/null +++ b/Teslameter2/robovm.properties @@ -0,0 +1,6 @@ +app.version=1.0 +app.id=org.robovm.samples.teslameter +app.mainclass=org.robovm.samples.teslameter.Teslameter +app.executable=Teslameter +app.build=1 +app.name=Teslameter \ No newline at end of file diff --git a/Teslameter2/robovm.xml b/Teslameter2/robovm.xml new file mode 100644 index 00000000..af5c5b33 --- /dev/null +++ b/Teslameter2/robovm.xml @@ -0,0 +1,17 @@ + + ${app.executable} + ${app.mainclass} + ios + thumbv7 + + + resources + + + ios + Info.plist.xml + + CoreGraphics + CoreLocation + + \ No newline at end of file diff --git a/Teslameter2/src/main/java/org/robovm/samples/teslameter/Teslameter.java b/Teslameter2/src/main/java/org/robovm/samples/teslameter/Teslameter.java new file mode 100644 index 00000000..b9da071a --- /dev/null +++ b/Teslameter2/src/main/java/org/robovm/samples/teslameter/Teslameter.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 RoboVM AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Portions of this code is based on Apple Inc's Teslameter sample (v1.3) + * which is copyright (C) 2009-2014 Apple Inc. + */ + +package org.robovm.samples.teslameter; + +import org.robovm.apple.foundation.NSAutoreleasePool; +import org.robovm.apple.uikit.UIApplication; +import org.robovm.apple.uikit.UIApplicationDelegateAdapter; +import org.robovm.apple.uikit.UIScreen; +import org.robovm.apple.uikit.UIWindow; +import org.robovm.samples.teslameter.viewcontrollers.TeslameterViewController; + +public class Teslameter extends UIApplicationDelegateAdapter { + private UIWindow window; + private TeslameterViewController viewController; + + @Override + public void didFinishLaunching (UIApplication application) { + // Set up the view controller. + viewController = new TeslameterViewController(); + + // Create a new window at screen size. + window = new UIWindow(UIScreen.getMainScreen().getBounds()); + // Set our viewcontroller as the root controller for the window. + window.setRootViewController(viewController); + // Make the window visible. + window.makeKeyAndVisible(); + + /* + * Retains the window object until the application is deallocated. Prevents Java GC from collecting the window object too + * early. + */ + addStrongRef(window); + } + + public static void main (String[] args) { + NSAutoreleasePool pool = new NSAutoreleasePool(); + UIApplication.main(args, null, Teslameter.class); + pool.close(); + } +} diff --git a/Teslameter/src/main/java/org/robovm/samples/teslameter/viewcontrollers/TeslameterViewController.java b/Teslameter2/src/main/java/org/robovm/samples/teslameter/viewcontrollers/TeslameterViewController.java similarity index 100% rename from Teslameter/src/main/java/org/robovm/samples/teslameter/viewcontrollers/TeslameterViewController.java rename to Teslameter2/src/main/java/org/robovm/samples/teslameter/viewcontrollers/TeslameterViewController.java diff --git a/Teslameter/src/main/java/org/robovm/samples/teslameter/views/GraphView.java b/Teslameter2/src/main/java/org/robovm/samples/teslameter/views/GraphView.java similarity index 100% rename from Teslameter/src/main/java/org/robovm/samples/teslameter/views/GraphView.java rename to Teslameter2/src/main/java/org/robovm/samples/teslameter/views/GraphView.java