diff --git a/Wearable/ReverseGeocoding/.gitignore b/Wearable/ReverseGeocoding/.gitignore new file mode 100644 index 000000000..d056bb5d6 --- /dev/null +++ b/Wearable/ReverseGeocoding/.gitignore @@ -0,0 +1,183 @@ +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates +*.DotSettings + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# .NET Core +*.project.lock.json +*.project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + + +### Android START ### +# Built application files +*.apk +*.ap_ + +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +### Android Patch ### +gen-external-apklibs + + +### Java ### +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ +/captures + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties + +### Android END ### + +### Resharper ### + +_Resharper* + +# StyleCop +StyleCop.Cache diff --git a/Wearable/ReverseGeocoding/LICENSE b/Wearable/ReverseGeocoding/LICENSE new file mode 100644 index 000000000..03f3cf37d --- /dev/null +++ b/Wearable/ReverseGeocoding/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2019 Samsung + + 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. diff --git a/Wearable/ReverseGeocoding/README.md b/Wearable/ReverseGeocoding/README.md new file mode 100644 index 000000000..632ee49b6 --- /dev/null +++ b/Wearable/ReverseGeocoding/README.md @@ -0,0 +1,17 @@ +# Reverse Geocoding +Reverse Geocoding is a sample application that shows how to get address of selected geographical location using [Tizen Maps API](https://developer.tizen.org/dev-guide/csapi/api/Tizen.Maps.html). + +![WelcomePage](./Screenshots/reverse_geocoding_welcome_page.png) +![MainPage](./Screenshots/reverse_geocoding_main_page.png) +![ResultsPage](./Screenshots/reverse_geocoding_results_page.png) + +### Features +* Translating geographical location selected on the map to address. + +### Prerequisites +* [Visual Studio](https://www.visualstudio.com/) - Buildtool, IDE +* [Visual Studio Tools for Tizen](https://developer.tizen.org/development/visual-studio-tools-tizen/installing-visual-studio-tools-tizen) - Visual Studio plugin for Tizen .NET application development +* [HERE Maps API Key](https://developer.here.com/plans) - API key from HERE maps is required to use the application + +### Author +* Michal Lesniak \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_main_page.png b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_main_page.png new file mode 100644 index 000000000..972285ba3 Binary files /dev/null and b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_main_page.png differ diff --git a/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_results_page.png b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_results_page.png new file mode 100644 index 000000000..adf71b620 Binary files /dev/null and b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_results_page.png differ diff --git a/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_welcome_page.png b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_welcome_page.png new file mode 100644 index 000000000..ebed853e3 Binary files /dev/null and b/Wearable/ReverseGeocoding/Screenshots/reverse_geocoding_welcome_page.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding.sln b/Wearable/ReverseGeocoding/src/ReverseGeocoding.sln new file mode 100644 index 000000000..f6fdd925b --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2046 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseGeocoding", "ReverseGeocoding\ReverseGeocoding\ReverseGeocoding.csproj", "{5AC6DE97-44E4-47E2-A91F-6286A7F3D5B4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseGeocoding.Tizen.Wearable", "ReverseGeocoding\ReverseGeocoding.Tizen.Wearable\ReverseGeocoding.Tizen.Wearable.csproj", "{386C0DF6-3D16-4AE0-A2F9-CA1E191EE0CF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5AC6DE97-44E4-47E2-A91F-6286A7F3D5B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5AC6DE97-44E4-47E2-A91F-6286A7F3D5B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AC6DE97-44E4-47E2-A91F-6286A7F3D5B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5AC6DE97-44E4-47E2-A91F-6286A7F3D5B4}.Release|Any CPU.Build.0 = Release|Any CPU + {386C0DF6-3D16-4AE0-A2F9-CA1E191EE0CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {386C0DF6-3D16-4AE0-A2F9-CA1E191EE0CF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {386C0DF6-3D16-4AE0-A2F9-CA1E191EE0CF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {386C0DF6-3D16-4AE0-A2F9-CA1E191EE0CF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {221C5101-6FE9-4E80-BC18-4B65E77643A0} + EndGlobalSection +EndGlobal diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Controls/TizenMapView.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Controls/TizenMapView.cs new file mode 100644 index 000000000..7e769b807 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Controls/TizenMapView.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 Tizen.Maps; +using Xamarin.Forms; + +namespace ReverseGeocoding.Tizen.Wearable.Controls +{ + /// + /// TizenMapView control class. + /// Provides base functionality of the TizenMapView. + /// + public class TizenMapView : View + { + #region fields + + /// + /// Backing field of the Map property. + /// + private MapView _map; + + #endregion + + #region properties + + /// + /// Notifies about map view initialization success. + /// + public event EventHandler MapViewSet; + + /// + /// Control width. + /// + public int ControlWidth { get; set; } + + /// + /// Control height. + /// + public int ControlHeight { get; set; } + + /// + /// An instance of the Tizen MapService class. + /// + public MapService Service { get; set; } + + /// + /// An instance of the Tizen MapView class. + /// + public MapView Map + { + get => _map; + set + { + _map = value; + MapViewSet?.Invoke(this, null); + } + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Renderers/TizenMapViewRenderer.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Renderers/TizenMapViewRenderer.cs new file mode 100644 index 000000000..4fc0ce1db --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Renderers/TizenMapViewRenderer.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Tizen.Wearable.Controls; +using ReverseGeocoding.Tizen.Wearable.Renderers; +using Tizen.Maps; +using Xamarin.Forms.Platform.Tizen; + +[assembly: ExportRenderer(typeof(TizenMapView), typeof(TizenMapViewRenderer))] +namespace ReverseGeocoding.Tizen.Wearable.Renderers +{ + /// + /// Tizen map view renderer. + /// + public class TizenMapViewRenderer : ViewRenderer + { + #region fields + + /// + /// MapView class instance used for interacting with the map view. + /// + MapView _mapView; + + #endregion + + #region methods + + /// + /// Overridden OnElementChanged method which initializes new control as a Tizen map view. + /// + /// Event arguments. + protected override void OnElementChanged(ElementChangedEventArgs e) + { + if (Control == null) + { + _mapView = new MapView(Forms.NativeParent, Element.Service); + + _mapView.ViewReady += OnViewReady; + + SetNativeControl(_mapView); + Control.Resize(Element.ControlWidth, Element.ControlHeight); + Control.Show(); + } + + base.OnElementChanged(e); + } + + /// + /// Handles "ViewReady" event of the MapView class. + /// + /// Object firing the event. + /// Event arguments. + private void OnViewReady(object sender, EventArgs e) + { + Element.Map = Control; + _mapView.ViewReady -= OnViewReady; + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.cs new file mode 100644 index 000000000..3cbf01165 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding +{ + /// + /// ReverseGeocoding Xamarin.Forms application class for Tizen wearable profile. + /// + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + #region methods + + /// + /// Handles creation phase of the application. + /// Loads Xamarin application. + /// + protected override void OnCreate() + { + base.OnCreate(); + LoadApplication(new App()); + } + + /// + /// Entry method of the program/application. + /// + /// Launch arguments. + static void Main(string[] args) + { + var app = new Program(); + global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); + global::Tizen.Wearable.CircularUI.Forms.Renderer.FormsCircularUI.Init(); + app.Run(args); + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.csproj b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.csproj new file mode 100644 index 000000000..31ea22bb8 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/ReverseGeocoding.Tizen.Wearable.csproj @@ -0,0 +1,39 @@ + + + + + Exe + tizen50 + + + + portable + + + None + + + + + + + + + + + + Runtime + + + + + + + MSBuild:UpdateDesignTimeXaml + + + MSBuild:UpdateDesignTimeXaml + + + + diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/IMapServiceProvider.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/IMapServiceProvider.cs new file mode 100644 index 000000000..9f4b9b80f --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/IMapServiceProvider.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 Tizen.Maps; + +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Provides methods to get map service. + /// + public interface IMapServiceProvider + { + #region methods + + /// + /// Gets MapService class instance. + /// + /// MapService class instance. + MapService GetService(); + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/InformationPopupService.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/InformationPopupService.cs new file mode 100644 index 000000000..b6a54f59c --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/InformationPopupService.cs @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Interfaces; +using ReverseGeocoding.Tizen.Wearable.Services; +using Tizen.Wearable.CircularUI.Forms; +using Xamarin.Forms; +using Command = Xamarin.Forms.Command; + +[assembly: Xamarin.Forms.Dependency(typeof(InformationPopupService))] +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Provides methods to use the information popup service. + /// + class InformationPopupService : IInformationPopupService + { + #region fields + + /// + /// Information popup class instance. + /// + InformationPopup _informationPopup; + + #endregion + + #region properties + + /// + /// Gets or sets text displayed on the loading popup. + /// + public string LoadingText { get; set; } + + /// + /// Gets or sets text displayed on the error popup. + /// + public string ErrorPopupText { get; set; } + + /// + /// Gets or sets text displayed on the error popup button. + /// + public string ErrorPopupButtonText { get; set; } + + #endregion + + #region methods + + /// + /// Displays loading popup. + /// + public void ShowLoadingPopup() + { + _informationPopup = new InformationPopup(); + _informationPopup.Title = LoadingText; + _informationPopup.Text = LoadingText; + _informationPopup.IsProgressRunning = true; + + _informationPopup.Show(); + } + + /// + /// Dismisses the popup. + /// + public void Dismiss() + { + _informationPopup.Dismiss(); + } + + /// + /// Shows error popup with action button. + /// + public void ShowErrorPopup() + { + InformationPopup informationPopup = new InformationPopup(); + MenuItem bottomButton = new MenuItem() + { + Text = ErrorPopupButtonText, + Command = new Command(() => + { + informationPopup.Dismiss(); + }) + }; + + informationPopup.Text = ErrorPopupText; + informationPopup.BottomButton = bottomButton; + + informationPopup.Show(); + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/MapServiceProvider.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/MapServiceProvider.cs new file mode 100644 index 000000000..9cc15cf1b --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/MapServiceProvider.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Tizen.Wearable.Services; +using Tizen.Maps; + +[assembly: Xamarin.Forms.Dependency(typeof(MapServiceProvider))] + +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Manages map service. + /// + public class MapServiceProvider : IMapServiceProvider + { + #region fields + + /// + /// MapService class instance. + /// + private readonly MapService _mapService; + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + public MapServiceProvider() + { + _mapService = new MapService(Config.ProviderName, Config.AuthenticationToken); + } + + /// + /// Gets MapService class instance. + /// + /// MapService instance. + public MapService GetService() + { + return _mapService; + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingResponseArgs.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingResponseArgs.cs new file mode 100644 index 000000000..022d95fea --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingResponseArgs.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Interfaces; +using System; + +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Defines properties that are used for the service response. + /// + class ReverseGeocodingResponseArgs : EventArgs, IReverseGeocodingResponseArgs + { + #region properties + + /// + /// Determines if response was successful. + /// + public bool Success { get; } + + /// + /// Response result. + /// + public string Result { get; } + + #endregion + + #region methods + + /// + /// Initializes class. + /// + /// Defines if the request was successful. + /// Defines response result. + public ReverseGeocodingResponseArgs(bool success, string result = "") + { + Success = success; + Result = result; + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingService.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingService.cs new file mode 100644 index 000000000..21289075f --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingService.cs @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Interfaces; +using ReverseGeocoding.Common; +using ReverseGeocoding.Tizen.Wearable.Services; +using ReverseGeocoding.ViewModels; +using System; +using Tizen.Maps; +using Xamarin.Forms; + +[assembly: Xamarin.Forms.Dependency(typeof(ReverseGeocodingService))] + +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Provides methods to use the maps and their services. + /// + public class ReverseGeocodingService : IReverseGeocodingService + { + #region fields + + /// + /// MapService class instance used for getting the map service data. + /// + private MapService _mapService; + + #endregion + + #region properties + + /// + /// Notifies about user consent. + /// + public event EventHandler UserConsent; + + /// + /// Notifies about receiving response. + /// + public event EventHandler ResponseReceived; + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + public ReverseGeocodingService() + { + _mapService = DependencyService.Get().GetService(); + } + + /// + /// Requests to check user consent. + /// + public async void RequestUserConsent() + { + bool consent = await _mapService.RequestUserConsent(); + UserConsent?.Invoke(this, new ReverseGeocodingUserConsentArgs(consent)); + } + + /// + /// Creates and sends request to reverse geocode service. + /// + /// Coordinates of the point. + public async void CreateReverseGeocodeRequest(PointGeocoordinates pointGeocoordinates) + { + try + { + var request = _mapService.CreateReverseGeocodeRequest(pointGeocoordinates.Latitude, pointGeocoordinates.Longitude); + var response = await request.GetResponseAsync(); + + foreach (var result in response) + { + ResponseReceived?.Invoke(this, new ReverseGeocodingResponseArgs(true, result.ToString())); + } + } + catch (Exception) + { + ResponseReceived?.Invoke(this, new ReverseGeocodingResponseArgs(false)); + } + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingUserConsentArgs.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingUserConsentArgs.cs new file mode 100644 index 000000000..5fe499711 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Services/ReverseGeocodingUserConsentArgs.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.ViewModels; +using System; + +namespace ReverseGeocoding.Tizen.Wearable.Services +{ + /// + /// Event arguments providing information about user consent. + /// + public class ReverseGeocodingUserConsentArgs : EventArgs, IReverseGeocodingUserConsentArgs + { + #region properties + + /// + /// Consent status value. + /// + public bool Consent { get; } + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + /// Consent status value. + public ReverseGeocodingUserConsentArgs(bool consent) + { + Consent = consent; + } + + #endregion + } +} \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml new file mode 100644 index 000000000..ee1d52baf --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml.cs new file mode 100644 index 000000000..987d2a9a2 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/MainPage.xaml.cs @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Tizen.Wearable.Services; +using Tizen.Maps; +using Tizen.Wearable.CircularUI.Forms; +using Xamarin.Forms; +using Xamarin.Forms.Platform.Tizen; +using Xamarin.Forms.Xaml; +using ReverseGeocoding.Common; +using ElmSharp.Wearable; +using ReverseGeocoding.Tizen.Wearable.Controls; + +namespace ReverseGeocoding.Tizen.Wearable.Views +{ + /// + /// Main page of the application displaying the map. + /// + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class MainPage : CirclePage + { + #region fields + + /// + /// Initial map latitude. + /// + private const double MAP_CENTER_LATITUDE = 52.229676; + + /// + /// Initial map longitude. + /// + private const double MAP_CENTER_LONGITUDE = 21.012229; + + /// + /// Default zoom level. + /// + private const int DEFAULT_ZOOM_LEVEL = 14; + + /// + /// Device screen size. + /// + private const int SCREEN_SIZE = 360; + + /// + /// Represents the pin on the map. + /// + private Pin _pin; + + /// + /// MapService class instance used for getting the map service data. + /// + private MapService _mapService; + + /// + /// TizenMapView class instance used for interacting with the map view. + /// + private TizenMapView _mapView; + + /// + /// Indicates if map was displayed. + /// + private bool _mapAppeared; + + #endregion + + #region properties + + /// + /// Bindable property definition for pin selected. + /// + public static readonly BindableProperty PinPlacedProperty = BindableProperty.Create( + nameof(PinPlaced), + typeof(bool), + typeof(MainPage), + false); + + /// + /// Gets or sets information if pin is placed. + /// + public bool PinPlaced + { + get => (bool)GetValue(PinPlacedProperty); + set => SetValue(PinPlacedProperty, value); + } + + /// + /// Bindable property definition for point coordinates. + /// + public static readonly BindableProperty PointProperty = BindableProperty.Create( + nameof(Point), + typeof(PointGeocoordinates), + typeof(MainPage), + null); + + /// + /// Gets or sets information about current coordinates of the pin. + /// + public PointGeocoordinates Point + { + get => (PointGeocoordinates)GetValue(PointProperty); + set => SetValue(PointProperty, value); + } + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + public MainPage() + { + InitializeComponent(); + + _mapService = DependencyService.Get().GetService(); + + PinPlaced = false; + + _mapAppeared = false; + + _mapView = new TizenMapView + { + Service = _mapService, + ControlWidth = SCREEN_SIZE, + ControlHeight = SCREEN_SIZE + }; + + Content = _mapView; + } + + /// + /// Handles the long pressed event of the MapView object. + /// + /// Object firing the event. + /// Event arguments. + private void OnMapLongPressed(object sender, MapGestureEventArgs e) + { + if (_pin == null) + { + _pin = new Pin(new Geocoordinates(MAP_CENTER_LATITUDE, MAP_CENTER_LONGITUDE), + ResourcePath.GetPath("images/indicator.png")); + _mapView.Map.Add(_pin); + Point = new PointGeocoordinates(MAP_CENTER_LATITUDE, MAP_CENTER_LONGITUDE); + } + + PinPlaced = true; + _pin.Coordinates = e.Geocoordinates; + Point.Latitude = e.Geocoordinates.Latitude; + Point.Longitude = e.Geocoordinates.Longitude; + } + + /// + /// Zooms in/out map on rotary event. + /// + /// Rotary arguments. + private void OnRotaryChange(ElmSharp.Wearable.RotaryEventArgs args) + { + if (args.IsClockwise) + { + _mapView.Map.ZoomLevel++; + } + else + { + _mapView.Map.ZoomLevel--; + } + } + + /// + /// Overrides OnAppearing method. + /// Registers event handlers and sets map properties. + /// + protected override void OnAppearing() + { + if (!_mapAppeared) + { + _mapView.Map.MapType = MapTypes.Normal; + _mapView.Map.ZoomLevel = DEFAULT_ZOOM_LEVEL; + _mapView.Map.Center = new Geocoordinates(MAP_CENTER_LATITUDE, MAP_CENTER_LONGITUDE); + _mapAppeared = true; + } + + RotaryEventManager.Rotated += OnRotaryChange; + _mapView.Map.LongPressed += OnMapLongPressed; + } + + /// + /// Overrides OnDisappearing method. + /// Unregisters event handlers. + /// + protected override void OnDisappearing() + { + RotaryEventManager.Rotated -= OnRotaryChange; + _mapView.Map.LongPressed -= OnMapLongPressed; + } + + #endregion + } +} \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/PageNavigation.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/PageNavigation.cs new file mode 100644 index 000000000..1b7296e79 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/PageNavigation.cs @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Tizen.Wearable.Views; +using ReverseGeocoding.Views; +using System; +using Xamarin.Forms; + +[assembly: Dependency(typeof(PageNavigation))] + +namespace ReverseGeocoding.Tizen.Wearable.Views +{ + /// + /// Provides methods which allow to navigate between pages. + /// + public class PageNavigation : IPageNavigation + { + #region methods + + /// + /// Creates welcome page and sets it as active. + /// + public void CreateWelcomePage() + { + Application.Current.MainPage = new WelcomePage(); + } + + /// + /// Creates main page and sets it as active. + /// + public void CreateMainPage() + { + Application.Current.MainPage = new NavigationPage(new MainPage()); + } + + /// + /// Closes the application. + /// + public void Close() + { + try + { + global::Tizen.Applications.Application.Current.Exit(); + } + catch (Exception) + { + global::Tizen.Log.Error("ReverseGeocoding", "Unable to close the application"); + } + } + + /// + /// Creates results page and sets it as active. + /// + public void CreateResultsPage() + { + Application.Current.MainPage?.Navigation.PushAsync(new ResultsPage()); + } + + /// + /// Navigates to previous page. + /// + public void GoBack() + { + Application.Current.MainPage?.Navigation.PopAsync(); + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml new file mode 100644 index 000000000..dde4165f3 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml.cs new file mode 100644 index 000000000..b9518def5 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/ResultsPage.xaml.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 Tizen.Wearable.CircularUI.Forms; +using Xamarin.Forms.Xaml; + +namespace ReverseGeocoding.Tizen.Wearable.Views +{ + /// + /// Presents the information about the previously selected point on map. + /// + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class ResultsPage : CirclePage + { + #region methods + + /// + /// Initializes class instance. + /// + public ResultsPage() + { + InitializeComponent(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml new file mode 100644 index 000000000..7564e253b --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml.cs new file mode 100644 index 000000000..856bb17fd --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/Views/WelcomePage.xaml.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 Xamarin.Forms.Xaml; +using Tizen.Wearable.CircularUI.Forms; + +namespace ReverseGeocoding.Tizen.Wearable.Views +{ + /// + /// Welcome page. + /// + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class WelcomePage : CirclePage + { + #region methods + + /// + /// Initializes class instance. + /// + public WelcomePage() + { + InitializeComponent(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/bg.png b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/bg.png new file mode 100644 index 000000000..ae81d06ff Binary files /dev/null and b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/bg.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/indicator.png b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/indicator.png new file mode 100644 index 000000000..43b339f79 Binary files /dev/null and b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/indicator.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding.png b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding.png new file mode 100644 index 000000000..d06975503 Binary files /dev/null and b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding_76.png b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding_76.png new file mode 100644 index 000000000..56c5d912a Binary files /dev/null and b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/res/images/reverse_geocoding_76.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/shared/res/ReverseGeocoding.Tizen.Wearable.png b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/shared/res/ReverseGeocoding.Tizen.Wearable.png new file mode 100644 index 000000000..d06975503 Binary files /dev/null and b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/shared/res/ReverseGeocoding.Tizen.Wearable.png differ diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/tizen-manifest.xml b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/tizen-manifest.xml new file mode 100644 index 000000000..a7db69a5e --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding.Tizen.Wearable/tizen-manifest.xml @@ -0,0 +1,17 @@ + + + + + + ReverseGeocoding.Tizen.Wearable.png + + + + + + http://tizen.org/privilege/mapservice + http://tizen.org/privilege/network.get + http://tizen.org/privilege/internet + + + diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Common/PointGeocoordinates.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Common/PointGeocoordinates.cs new file mode 100644 index 000000000..c85a373fe --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Common/PointGeocoordinates.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding.Common +{ + /// + /// Stores information about geocoordinates. + /// + public class PointGeocoordinates + { + #region properties + + /// + /// Gets or sets latitude. + /// + public double Latitude { get; set; } + + /// + /// Gets or sets longitude. + /// + public double Longitude { get; set; } + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + /// Latitude value. + /// Longitude value. + public PointGeocoordinates(double latitude, double longitude) + { + Latitude = latitude; + Longitude = longitude; + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Config/Config.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Config/Config.cs new file mode 100644 index 000000000..1e8e77f8c --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Config/Config.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding +{ + /// + /// Provides application settings. + /// + public static class Config + { + #region fields + + /// + /// Map provider's name. + /// + private const string PROVIDER_NAME = "HERE"; + + /// + /// ID registered with provider. + /// Please visit http://developer.here.com to obtain application id. + /// + private const string APP_ID = "hgTt8y5V91b7gWydK2df"; + + /// + /// Key assigned with application ID. + /// Please visit http://developer.here.com to obtain application key. + /// + private const string APP_KEY = "YwiXR-_JkJ4R1yWz4eMjbw"; + + #endregion + + #region properties + + /// + /// Provider name. + /// + public static string ProviderName => PROVIDER_NAME; + + /// + /// Authentication token used to initialize map library. + /// + public static string AuthenticationToken => APP_ID + "/" + APP_KEY; + + /// + /// Map credentials indicator. + /// True if map application ID and key are not empty. + /// + /// True if both fields are not empty. + public static bool IsMapProviderConfigured() => APP_ID.Length > 0 && APP_KEY.Length > 0; + + #endregion + } +} \ No newline at end of file diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IInformationPopupService.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IInformationPopupService.cs new file mode 100644 index 000000000..44f3c3a70 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IInformationPopupService.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding.Interfaces +{ + /// + /// Provides methods to use the information popup service. + /// + public interface IInformationPopupService + { + #region properties + + /// + /// Gets or sets text displayed on the loading popup. + /// + string LoadingText { get; set; } + + /// + /// Gets or sets text displayed on the error popup. + /// + string ErrorPopupText { get; set; } + + /// + /// Gets or sets text displayed on the error popup button. + /// + string ErrorPopupButtonText { get; set; } + + #endregion + + #region methods + + /// + /// Displays loading popup. + /// + void ShowLoadingPopup(); + + /// + /// Dismisses the popup. + /// + void Dismiss(); + + /// + /// Shows error popup with action button. + /// + void ShowErrorPopup(); + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingResponseArgs.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingResponseArgs.cs new file mode 100644 index 000000000..5d8169bab --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingResponseArgs.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding.Interfaces +{ + /// + /// Defines properties that are used for the service response. + /// + public interface IReverseGeocodingResponseArgs + { + #region properties + + /// + /// Determines if response was successful. + /// + bool Success { get; } + + /// + /// Response result. + /// + string Result { get; } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingService.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingService.cs new file mode 100644 index 000000000..0808e2af3 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingService.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Common; +using ReverseGeocoding.ViewModels; +using System; + +namespace ReverseGeocoding.Interfaces +{ + /// + /// Provides methods to use the maps and their services. + /// + public interface IReverseGeocodingService + { + #region properties + + /// + /// Notifies about user consent. + /// + event EventHandler UserConsent; + + /// + /// Notifies about receiving response. + /// + event EventHandler ResponseReceived; + + #endregion + + #region methods + + /// + /// Requests to check user consent. + /// + void RequestUserConsent(); + + /// + /// Creates and sends request to reverse geocode service. + /// + /// Coordinates of the point. + void CreateReverseGeocodeRequest(PointGeocoordinates pointGeocoordinates); + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingUserConsentArgs.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingUserConsentArgs.cs new file mode 100644 index 000000000..cde2d68cd --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Interfaces/IReverseGeocodingUserConsentArgs.cs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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. + */ +namespace ReverseGeocoding.ViewModels +{ + /// + /// Defines properties that should be implemented by class used to notifying about the user consent status. + /// + public interface IReverseGeocodingUserConsentArgs + { + #region properties + + /// + /// Consent status value. + /// + bool Consent { get; } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.csproj b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.csproj new file mode 100644 index 000000000..05dca2aff --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + + + + + + + + diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml new file mode 100644 index 000000000..15d41989f --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml.cs new file mode 100644 index 000000000..1d1412a55 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ReverseGeocoding.xaml.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Interfaces; +using ReverseGeocoding.Views; +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace ReverseGeocoding +{ + /// + /// Main application class. + /// + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class App : Application + { + #region methods + + /// + /// Initializes application. + /// + public App() + { + InitializeComponent(); + + DependencyService.Get().CreateWelcomePage(); + + IInformationPopupService popupService = DependencyService.Get(); + popupService.LoadingText = "Loading"; + popupService.ErrorPopupText = "Connection failed."; + popupService.ErrorPopupButtonText = "OK"; + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/MainViewModel.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/MainViewModel.cs new file mode 100644 index 000000000..efdee8c94 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/MainViewModel.cs @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 Xamarin.Forms; +using ReverseGeocoding.Views; +using System.Windows.Input; +using ReverseGeocoding.Interfaces; +using ReverseGeocoding.Common; + +namespace ReverseGeocoding.ViewModels +{ + /// + /// The application's main view model class (abstraction of the view). + /// + public class MainViewModel : ViewModelBase + { + #region fields + + /// + /// Reference to object handling navigation between pages obtained in constructor using DependencyService. + /// + private readonly IPageNavigation _navigation; + + /// + /// Reference to object handling reverse geocoding services obtained in constructor using DependencyService. + /// + private readonly IReverseGeocodingService _reverseGeocodingService; + + /// + /// Reference to object handling information popup obtained in constructor using DependencyService. + /// + private readonly IInformationPopupService _informationPopupService; + + /// + /// Represents the data about the place which was selected. + /// + private string _place; + + #endregion + + #region properties + + /// + /// Navigates to main page. + /// + public ICommand GoToMainPageCommand { get; private set; } + + /// + /// Navigates to results page. + /// + public ICommand GoToResultsPageCommand { get; private set; } + + /// + /// Navigates to previous page. + /// + public ICommand GoToPreviousPageCommand { get; private set; } + + /// + /// Gets or sets data about the place which was selected. + /// + public string Place + { + get => _place; + set => SetProperty(ref _place, value); + } + + #endregion + + #region methods + + /// + /// Initializes class instance. + /// + public MainViewModel() + { + _navigation = DependencyService.Get(); + _reverseGeocodingService = DependencyService.Get(); + _informationPopupService = DependencyService.Get(); + + _reverseGeocodingService.UserConsent += ServiceOnUserConsented; + _reverseGeocodingService.ResponseReceived += OnResponseReceived; + + Place = ""; + + InitCommands(); + } + + /// + /// Initializes commands. + /// + private void InitCommands() + { + GoToMainPageCommand = new Command(ExecuteGoToMainPage); + GoToResultsPageCommand = new Command(ExecuteGoToResultsPage); + GoToPreviousPageCommand = new Command(ExecuteGoToPreviousPage); + } + + /// + /// Handles execution of "GoToResultsPageCommand". + /// + /// Geocoordinates of the selected point. + private void ExecuteGoToResultsPage(PointGeocoordinates geocoordinates) + { + _informationPopupService.ShowLoadingPopup(); + _reverseGeocodingService.CreateReverseGeocodeRequest(geocoordinates); + } + + /// + /// Handles execution of "GoToMainPageCommand". + /// + private void ExecuteGoToMainPage() + { + _reverseGeocodingService.RequestUserConsent(); + } + + /// + /// Handles "UserConsent" event of the geocoding service. + /// + /// Object firing the event. + /// Event arguments. + private void ServiceOnUserConsented(object sender, IReverseGeocodingUserConsentArgs e) + { + if (e.Consent) + { + _navigation.CreateMainPage(); + } + else + { + _navigation.Close(); + } + } + + /// + /// Handles the execution of "GoToPreviousPageCommand". + /// + private void ExecuteGoToPreviousPage() + { + _navigation.GoBack(); + } + + /// + /// Handles "ResponseReceived" event of the geocoding service. + /// + /// Object firing the event. + /// Event arguments. + private void OnResponseReceived(object sender, IReverseGeocodingResponseArgs e) + { + if (e.Success) + { + Place = e.Result; + _navigation.CreateResultsPage(); + _informationPopupService.Dismiss(); + } + else + { + _informationPopupService.Dismiss(); + _informationPopupService.ShowErrorPopup(); + } + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/ViewModelBase.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/ViewModelBase.cs new file mode 100644 index 000000000..3a0fc9d76 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/ViewModels/ViewModelBase.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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.ComponentModel; +using System.Runtime.CompilerServices; + +namespace ReverseGeocoding.ViewModels +{ + /// + /// Class that provides basic functionality for view models. + /// Implements INotifyPropertyChanged interface. + /// + public class ViewModelBase : INotifyPropertyChanged + { + #region properties + + /// + /// PropertyChanged event handler. + /// + public event PropertyChangedEventHandler PropertyChanged; + + #endregion + + #region methods + + /// + /// Updates value of the "storage" argument with value given by the second argument. + /// Notifies the application about update of the property which has executed this method. + /// + /// Type of storage field. + /// Field reference. + /// New value. + /// Name of property triggered change. + /// Returns true if storage is successfully updated, false otherwise. + protected bool SetProperty(ref T storage, T value, + [CallerMemberName] string propertyName = null) + { + if (Equals(storage, value)) + { + return false; + } + + storage = value; + OnPropertyChanged(propertyName); + return true; + } + + /// + /// Notifies the application about update of the property with name given as a parameter. + /// + /// Property name. + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + } +} diff --git a/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Views/IPageNavigation.cs b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Views/IPageNavigation.cs new file mode 100644 index 000000000..5cbdb9ae9 --- /dev/null +++ b/Wearable/ReverseGeocoding/src/ReverseGeocoding/ReverseGeocoding/Views/IPageNavigation.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 ReverseGeocoding.Interfaces; + +namespace ReverseGeocoding.Views +{ + /// + /// Provides methods which allow to navigate between pages. + /// + public interface IPageNavigation + { + #region methods + + /// + /// Creates welcome page and sets it as active. + /// + void CreateWelcomePage(); + + /// + /// Creates main page and sets it as active. + /// + void CreateMainPage(); + + /// + /// Closes the application. + /// + void Close(); + + /// + /// Creates welcome page and sets it as active. + /// + void CreateResultsPage(); + + /// + /// Navigates to previous page. + /// + void GoBack(); + + #endregion + } +}