From 82cfbabbab8968bb60072fa81b5e7208c451a5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Tue, 17 Jan 2017 14:05:49 +0100 Subject: [PATCH] Remove wp8 and comment out windows platform --- plugin.xml | 4 +- src/wp8/BackgroundMode.cs | 199 -------------------------------------- 2 files changed, 2 insertions(+), 201 deletions(-) delete mode 100644 src/wp8/BackgroundMode.cs diff --git a/plugin.xml b/plugin.xml index a21a4c2..137113a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -84,7 +84,7 @@ target-dir="src/de/appplant/cordova/plugin/background" /> - + diff --git a/src/wp8/BackgroundMode.cs b/src/wp8/BackgroundMode.cs deleted file mode 100644 index 9ff039f..0000000 --- a/src/wp8/BackgroundMode.cs +++ /dev/null @@ -1,199 +0,0 @@ -/* - Copyright 2013-2017 appPlant GmbH - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. -*/ - -using WPCordovaClassLib.Cordova.Commands; -using Windows.Devices.Geolocation; -using Microsoft.Phone.Shell; -using System; -using WPCordovaClassLib.Cordova; - -namespace Cordova.Extension.Commands -{ - /// - /// Ermöglicht, dass eine Anwendung im Hintergrund läuft ohne pausiert zu werden - /// - public class BackgroundMode : BaseCommand - { - /// - /// Event types for callbacks - /// - enum Event { - ACTIVATE, DEACTIVATE, FAILURE - } - - #region Instance variables - - /// - /// Flag indicates if the plugin is enabled or disabled - /// - private bool IsDisabled = true; - - /// - /// Geolocator to monitor location changes - /// - private static Geolocator Geolocator { get; set; } - - #endregion - - #region Interface methods - - /// - /// Enable the mode to stay awake when switching - /// to background for the next time. - /// - public void enable (string args) - { - IsDisabled = false; - } - - /// - /// Disable the background mode and stop - /// being active in background. - /// - public void disable (string args) - { - IsDisabled = true; - - Deactivate(); - } - - #endregion - - #region Core methods - - /// - /// Keep the app awake by tracking - /// for position changes. - /// - private void Activate() - { - if (IsDisabled || Geolocator != null) - return; - - if (!IsServiceAvailable()) - { - FireEvent(Event.FAILURE, null); - return; - } - - Geolocator = new Geolocator(); - - Geolocator.DesiredAccuracy = PositionAccuracy.Default; - Geolocator.MovementThreshold = 100000; - Geolocator.PositionChanged += geolocator_PositionChanged; - - FireEvent(Event.ACTIVATE, null); - } - - /// - /// Let the app going to sleep. - /// - private void Deactivate () - { - if (Geolocator == null) - return; - - FireEvent(Event.DEACTIVATE, null); - - Geolocator.PositionChanged -= geolocator_PositionChanged; - Geolocator = null; - } - - #endregion - - #region Helper methods - - /// - /// Determine if location service is available and enabled. - /// - private bool IsServiceAvailable() - { - Geolocator geolocator = (Geolocator == null) ? new Geolocator() : Geolocator; - - PositionStatus status = geolocator.LocationStatus; - - if (status == PositionStatus.Disabled) - return false; - - if (status == PositionStatus.NotAvailable) - return false; - - return true; - } - - /// - /// Fires the given event. - /// - private void FireEvent(Event Event, string Param) - { - string EventName; - - switch (Event) { - case Event.ACTIVATE: - EventName = "activate"; break; - case Event.DEACTIVATE: - EventName = "deactivate"; break; - default: - EventName = "failure"; break; - } - - string js = String.Format("cordova.plugins.backgroundMode.on{0}({1})", EventName, Param); - - PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, js); - - pluginResult.KeepCallback = true; - - DispatchCommandResult(pluginResult); - } - - #endregion - - #region Delegate methods - - private void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) - { - // Nothing to do here - } - - #endregion - - #region Lifecycle methods - - /// - /// Occurs when the application is being deactivated. - /// - public override void OnPause(object sender, DeactivatedEventArgs e) - { - Activate(); - } - - /// - /// Occurs when the application is being made active after previously being put - /// into a dormant state or tombstoned. - /// - public override void OnResume(object sender, ActivatedEventArgs e) - { - Deactivate(); - } - - #endregion - } -}