org.robovm.apple.uikit.UIDevice Java Examples
The following examples show how to use
org.robovm.apple.uikit.UIDevice.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IOSLauncher.java From graphicsfuzz with Apache License 2.0 | 6 votes |
@Override protected IOSApplication createApplication() { JsonObject platformInfoJson = new JsonObject(); platformInfoJson.addProperty("device.name", UIDevice.getCurrentDevice().getName()); platformInfoJson.addProperty("device.model", UIDevice.getCurrentDevice().getModel()); platformInfoJson.addProperty("device.localized_model", UIDevice.getCurrentDevice().getLocalizedModel()); platformInfoJson.addProperty("device.system_name", UIDevice.getCurrentDevice().getSystemName()); platformInfoJson.addProperty("device.system_version", UIDevice.getCurrentDevice().getSystemVersion()); platformInfoJson.addProperty("device.identifier_for_vendor", UIDevice.getCurrentDevice().getIdentifierForVendor().toString()); Main main = new Main(); main.persistentData = new PersistentData(); main.setPlatformInfoJson(platformInfoJson); IOSApplicationConfiguration config = new IOSApplicationConfiguration(); config.orientationPortrait = false; // config.preferredFramesPerSecond = 10; config.useAccelerometer = false; config.useCompass = false; config.allowIpod = true; config.useGL30 = true; return new IOSApplication(main, config); }
Example #2
Source File: BatStatViewController.java From robovm-samples with Apache License 2.0 | 6 votes |
private void updateBatteryLevel() { float batteryLevel = UIDevice.getCurrentDevice().getBatteryLevel(); if (batteryLevel < 0) { // -1.0 means battery state is UIDeviceBatteryState.Unknown levelLabel.setText(NSString.getLocalizedString("Unknown")); } else { NSNumberFormatter numberFormatter = null; if (numberFormatter == null) { numberFormatter = new NSNumberFormatter(); numberFormatter.setNumberStyle(NSNumberFormatterStyle.Percent); numberFormatter.setMaximumFractionDigits(1); } NSNumber levelObj = NSNumber.valueOf(batteryLevel); levelLabel.setText(numberFormatter.format(levelObj)); } }
Example #3
Source File: BatStatViewController.java From robovm-samples with Apache License 2.0 | 6 votes |
private void updateBatteryState() { UITableViewCell[] batteryStateCells = new UITableViewCell[] { unknownCell, unpluggedCell, chargingCell, fullCell }; UIDeviceBatteryState currentState = UIDevice.getCurrentDevice().getBatteryState(); for (int i = 0; i < batteryStateCells.length; i++) { UITableViewCell cell = batteryStateCells[i]; if (i + UIDeviceBatteryState.Unknown.value() == currentState.value()) { cell.setAccessoryType(UITableViewCellAccessoryType.Checkmark); } else { cell.setAccessoryType(UITableViewCellAccessoryType.None); } } }
Example #4
Source File: BatStatViewController.java From robovm-samples with Apache License 2.0 | 6 votes |
@Override public void viewDidLoad() { super.viewDidLoad(); // Register for battery level and state change notifications. UIDevice.Notifications.observeBatteryLevelDidChange(new Runnable() { @Override public void run() { updateBatteryLevel(); } }); UIDevice.Notifications.observeBatteryStateDidChange(new Runnable() { @Override public void run() { updateBatteryLevel(); updateBatteryState(); } }); }
Example #5
Source File: BatStatViewController.java From robovm-samples with Apache License 2.0 | 5 votes |
@Override public void viewDidLayoutSubviews() { // Enable battery monitoring. UIDevice.getCurrentDevice().setBatteryMonitoringEnabled(true); updateBatteryLevel(); updateBatteryState(); }
Example #6
Source File: MyMovieViewController.java From robovm-samples with Apache License 2.0 | 5 votes |
public MyMovieViewController() { movieBackgroundImageView = new UIImageView(UIImage.getImage("images/movieBackground.jpg")); movieBackgroundImageView.setFrame(new CGRect(0, 0, 240, 128)); backgroundView = new UIView(new CGRect(0, 0, 320, 460)); backgroundView.setBackgroundColor(UIColor.fromWhiteAlpha(0.66, 1)); overlayController = new MyOverlayViewController(this); if (Integer.valueOf(UIDevice.getCurrentDevice().getSystemVersion().substring(0, 1)) >= 7) { setEdgesForExtendedLayout(UIRectEdge.None); } }
Example #7
Source File: IOSMini2DxInput.java From mini2Dx with Apache License 2.0 | 5 votes |
void setupPeripherals() { // motionManager = new CMMotionManager(); setupAccelerometer(); setupCompass(); UIDevice device = UIDevice.getCurrentDevice(); if (device.getModel().equalsIgnoreCase("iphone")) hasVibrator = true; }
Example #8
Source File: BatStatViewController.java From robovm-samples with Apache License 2.0 | 4 votes |
@IBAction private void switchAction(UISwitch sender) { UIDevice.getCurrentDevice().setBatteryMonitoringEnabled(sender.isOn()); updateBatteryLevel(); updateBatteryState(); }
Example #9
Source File: APAViewController.java From robovm-samples with Apache License 2.0 | 4 votes |
@Override public void viewWillAppear (boolean animated) { // Start the progress indicator animation. loadingProgressIndicator.startAnimating(); CGSize viewSize = getView().getBounds().getSize(); // On iPhone/iPod touch we want to see a similar amount of the scene as on iPad. // So, we set the size of the scene to be double the size of the view, which is // the whole screen, 3.5- or 4- inch. This effectively scales the scene to 50%. if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Phone) { viewSize.setHeight(viewSize.getHeight() * 2); viewSize.setWidth(viewSize.getWidth() * 2); } scene = new APAAdventureScene(viewSize); // Load the shared assets of the scene. scene.loadSceneAssets(new Runnable() { @Override public void run () { scene.setup(); scene.setScaleMode(SKSceneScaleMode.AspectFill); scene.configureGameControllers(); loadingProgressIndicator.stopAnimating(); loadingProgressIndicator.setHidden(true); skView.presentScene(scene); UIView.animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, new Runnable() { @Override public void run () { archerButton.setAlpha(1); warriorButton.setAlpha(1); } }, null); } }); if (SHOW_DEBUG_INFO) { // Show debug information. skView.setShowsFPS(true); skView.setShowsDrawCount(true); skView.setShowsNodeCount(true); } }