Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 161D9200B2B for ; Mon, 23 May 2016 15:42:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 152D1160A3A; Mon, 23 May 2016 13:42:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EA997160A2B for ; Mon, 23 May 2016 15:42:06 +0200 (CEST) Received: (qmail 10467 invoked by uid 500); 23 May 2016 13:42:00 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 10311 invoked by uid 99); 23 May 2016 13:42:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 May 2016 13:42:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 215D2E571F; Mon, 23 May 2016 13:42:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tony--@apache.org To: commits@cordova.apache.org Date: Mon, 23 May 2016 13:42:14 -0000 Message-Id: In-Reply-To: <910fe92b604043af969dc81a33dd8155@git.apache.org> References: <910fe92b604043af969dc81a33dd8155@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/50] cordova-plugin-screen-orientation git commit: Added WP8 support archived-at: Mon, 23 May 2016 13:42:08 -0000 Added WP8 support Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/865c81a0 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/865c81a0 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/865c81a0 Branch: refs/heads/master Commit: 865c81a09effa5a4176de8882bcbfbb1b7f11d25 Parents: b3aadac Author: EddyVerbruggen Authored: Wed May 13 20:30:41 2015 +0200 Committer: EddyVerbruggen Committed: Wed May 13 20:30:41 2015 +0200 ---------------------------------------------------------------------- plugin.xml | 14 +++- src/wp/YoikScreenOrientation.cs | 133 +++++++++++++++++++++++++++++++++++ www/screenorientation.wp8.js | 8 +++ 3 files changed, 154 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/865c81a0/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index 07a9b5d..874d7da 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.3.3"> Screen Orientation Adds Screen Orientation API lock and unlock functions to the global screen object in android, iOS and BB10. @@ -52,4 +52,16 @@ + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/865c81a0/src/wp/YoikScreenOrientation.cs ---------------------------------------------------------------------- diff --git a/src/wp/YoikScreenOrientation.cs b/src/wp/YoikScreenOrientation.cs new file mode 100644 index 0000000..00545e3 --- /dev/null +++ b/src/wp/YoikScreenOrientation.cs @@ -0,0 +1,133 @@ +/* + 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. +*/ + +using System; +using System.Net; +using System.IO; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Notification; +using Microsoft.Phone.Shell; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using System.Windows.Threading; +using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Threading; + +using WPCordovaClassLib.Cordova; +using WPCordovaClassLib.Cordova.Commands; +using WPCordovaClassLib.Cordova.JSON; + + +namespace WPCordovaClassLib.Cordova.Commands +{ + public class YoikScreenOrientation : BaseCommand + { + #region Static members + private const string UNLOCKED = "unlocked"; + + private const string PORTRAIT = "portrait"; + private const string PORTRAIT_PRIMARY = "portrait-primary"; + private const string PORTRAIT_SECONDARY = "portrait-secondary"; + + private const string LANDSCAPE = "landscape"; + private const string LANDSCAPE_PRIMARY = "landscape-primary"; + private const string LANDSCAPE_SECONDARY = "landscape-secondary"; + + #endregion + + /// + /// Current orientation + /// + private string currentOrientation; + + public YoikScreenOrientation() + { + + } + + /// + /// Changes the orientation + /// + + public void screenOrientation(string options) + { + string orientation = null; + try + { + orientation = JSON.JsonHelper.Deserialize(options)[0]; + } + catch (Exception ex) + { + this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); + return; + } + + if (string.IsNullOrEmpty(orientation)) + { + this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); + return; + } + + if (this.currentOrientation != orientation) // Might prevent flickering + { + + Deployment.Current.Dispatcher.BeginInvoke(() => + { + PhoneApplicationFrame frame; + PhoneApplicationPage page; + if (TryCast(Application.Current.RootVisual, out frame) && + TryCast(frame.Content, out page)) + { + if (orientation == PORTRAIT || orientation == PORTRAIT_PRIMARY || orientation == PORTRAIT_SECONDARY) + { + page.SupportedOrientations = SupportedPageOrientation.Portrait; + } + + else if (orientation == LANDSCAPE || orientation == LANDSCAPE_PRIMARY || orientation == LANDSCAPE_SECONDARY) + { + page.SupportedOrientations = SupportedPageOrientation.Landscape; + } + else if (orientation == UNLOCKED) + { + page.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; + } + else + { + this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Screen orientation not detected.")); + return; + } + this.currentOrientation = orientation; + } + }); + + this.DispatchCommandResult(); + } + } + + static bool TryCast(object obj, out T result) where T : class + { + result = obj as T; + return result != null; + } + } +} http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/865c81a0/www/screenorientation.wp8.js ---------------------------------------------------------------------- diff --git a/www/screenorientation.wp8.js b/www/screenorientation.wp8.js new file mode 100644 index 0000000..9dd64ae --- /dev/null +++ b/www/screenorientation.wp8.js @@ -0,0 +1,8 @@ +var exec = require('cordova/exec'), + screenOrientation = {}; + +screenOrientation.setOrientation = function(orientation) { + exec(null, null, "YoikScreenOrientation", "screenOrientation", [orientation]); +}; + +module.exports = screenOrientation; \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org