+++ /dev/null
-
- 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 [yyyy] [name of copyright owner]
-
- 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.
-
+++ /dev/null
-# Legal information
-
-## WeatherInformation
-
-**WeatherInformation** is licensed under the Apache License, Version 2.0. The full text
-of the license can be found in:
-
- - LICENSE
-
-This license applies to the whole project with the exception of third party libraries
-and files, which may be licensed under different licenses, as noted below.
-
-
-## [Jackson](http://wiki.fasterxml.com/JacksonHome)
-
-WeatherInformation uses **jackson-core-2.3.3.jar** library, which is licensed under the
-Apache License, Version 2.0. The license is located in the following path:
-
- - app/src/main/assets/jackson-license.txt
-
-
-## [GNOME Project](http://www.gnome.org)
-
-WeatherInformation makes use of [gnome-icon-theme-symbolic](https://github.com/GNOME/gnome-icon-theme-symbolic) that
-was licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. This license
-can be found in the following path:
-
- - app/src/main/assets/gnome-icon-license.txt
-
-It applies to the following files:
-
- * weather-clear-night-symbolic.svg
- * weather-clear-symbolic.svg
- * weather-few-clouds-night-symbolic.svg
- * weather-few-clouds-symbolic.svg
- * weather-fog-symbolic.svg
- * weather-overcast-symbolic.svg
- * weather-severe-alert-symbolic.svg
- * weather-showers-symbolic.svg
- * weather_showers_scattered-symbolic.svg
- * weather-snow-symbolic.svg
- * weather-storm-symbolic.svg
-
-
-## Java code from [Apache HttpClient 3.X](http://hc.apache.org/httpclient-3.x/)
-
-This application is using code from **Apache HttpClient 3.X**. We include the license in:
-
- - app/src/main/assets/apache-http-client-license.txt
-
-It applies to the following files:
-
- * Consts.java
- * ContentType.java
-
-
-## Files from The Android Open Source Project
-
-This application makes use of **appwidget_dark_bg.9.png** file, which comes from
-The Android Open Source Project. The license can be found in this path:
-
- - app/src/main/assets/google-widget-dark-license.txt
-
-
-## [Google Play Services](https://developer.android.com/google/play-services/index.html)
-
-WeatherInformation uses the Google Play Services API and libraries.
+++ /dev/null
-# WeatherInformation
-
-This project, application and its source code is licensed under the
-Apache License, Version 2.0 (the "License");
-See the License for details about distribution rights, and the
-specific rights regarding derivate works.
-
-You may obtain a copy of the License at:
-
-http://www.apache.org/licenses/LICENSE-2.0
+++ /dev/null
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 18
- buildToolsVersion "20.0.0"
-
- defaultConfig {
- applicationId "name.gumartinm.weather.information"
- minSdkVersion 18
- targetSdkVersion 18
-
- testApplicationId "name.gumartinm.weather.information.test"
- testInstrumentationRunner "android.test.InstrumentationTestRunner"
- }
-
- buildTypes {
- release {
- runProguard false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- }
- }
-}
-
-dependencies {
- compile 'com.android.support:support-v4:+'
- compile 'com.google.android.gms:play-services:+'
- compile files('libs/jackson-core-2.3.3.jar')
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<lint>
-</lint>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <string name="app_name">Weather Information Test</string>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="name.gumartinm.weather.information"
- android:installLocation="auto"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:maxSdkVersion="18"
- android:minSdkVersion="18"
- android:targetSdkVersion="18" />
-
- <uses-feature
- android:glEsVersion="0x00020000"
- android:required="true" />
-
- <!-- TODO: http://developer.android.com/guide/topics/manifest/supports-screens-element.html -->
- <!-- TODO: supporting multiple layouts/languages http://developer.android.com/guide/practices/screens_support.html -->
- <compatible-screens>
- <screen
- android:screenDensity="xhdpi"
- android:screenSize="normal" />
- </compatible-screens>
-
- <supports-screens android:smallScreens="false" />
-
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <!--
- The following two permissions are not required to use
- Google Maps Android API v2, but are recommended.
- -->
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:logo="@drawable/ic_launcher"
- android:supportsRtl="false"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".activity.MainTabsActivity"
- android:hardwareAccelerated="false"
- android:launchMode="singleTop"
- android:uiOptions="splitActionBarWhenNarrow" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".activity.PreferencesActivity"
- android:parentActivityName=".activity.MainTabsActivity" >
- <intent-filter>
- <action android:name="android.intent.action.WEATHERINFORMATIONSETTINGS" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
-
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- <activity
- android:name=".activity.MapActivity"
- android:parentActivityName=".activity.MainTabsActivity" >
- <intent-filter>
- <action android:name="android.intent.action.WEATHERINFORMATIONMAP" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".activity.SpecificActivity"
- android:exported="false"
- android:parentActivityName=".activity.MainTabsActivity" >
- <intent-filter>
- <action android:name="android.intent.action.WEATHERINFORMATIONSPECIFICDATA" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".widget.WidgetConfigure"
- android:excludeFromRecents="true"
- android:taskAffinity="" >
- <intent-filter>
- <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
- </intent-filter>
- </activity>
- <activity
- android:name=".activity.AboutActivity"
- android:label="@string/title_activity_about"
- android:parentActivityName=".activity.MainTabsActivity" >
- <intent-filter>
- <action android:name="android.intent.action.WEATHERINFORMATIONABOUT" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".activity.LicensesActivity"
- android:parentActivityName=".activity.AboutActivity" >
- <intent-filter>
- <action android:name="android.intent.action.WEATHERINFORMATIONLICENSES" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <receiver
- android:name=".boot.BootReceiver"
- android:enabled="true" >
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- <receiver android:name=".widget.WidgetProvider" >
- <intent-filter>
- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
- </intent-filter>
-
- <meta-data
- android:name="android.appwidget.provider"
- android:resource="@xml/appwidget_provider" />
- </receiver>
-
- <!-- Service to update Notification -->
- <service
- android:name=".notification.NotificationIntentService"
- android:enabled="true"
- android:exported="false" />
-
- <!-- Service to update Widget -->
- <service
- android:name=".widget.WidgetIntentService"
- android:enabled="true"
- android:exported="false" />
-
- <meta-data
- android:name="com.google.android.maps.v2.API_KEY"
- android:value="" />
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version" />
-
- </application>
-
-</manifest>
+++ /dev/null
-
- 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 [yyyy] [name of copyright owner]
-
- 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.
-
+++ /dev/null
-# WeatherInformation
-
-This project, application and its source code is licensed under the
-Apache License, Version 2.0 (the "License");
-See the License for details about distribution rights, and the
-specific rights regarding derivate works.
-
-You may obtain a copy of the License at:
-
-http://www.apache.org/licenses/LICENSE-2.0
+++ /dev/null
-
- 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 [yyyy] [name of copyright owner]
-
- 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.
-
+++ /dev/null
-This work is licenced under the Creative Commons Attribution-Share Alike 3.0
-United States License. To view a copy of this licence, visit
-http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
-Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
-
-When attributing the artwork, using "GNOME Project" is enough.
-Please link to http://www.gnome.org where available.
+++ /dev/null
- Copyright (c) 2005-2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- 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.
-
-
- 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
-
+++ /dev/null
-
- 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 [yyyy] [name of copyright owner]
-
- 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.
-
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.View;
-
-import name.gumartinm.weather.information.R;
-
-public class AboutActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.weather_about);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
- actionBar.setTitle(this.getString(R.string.weather_about_action));
- }
-
- public void onClickLegalInformation(final View view) {
- final Intent intent = new Intent("name.gumartinm.weather.information.WEATHERINFO")
- .setComponent(new ComponentName("name.gumartinm.weather.information",
- "name.gumartinm.weather.information.activity.LicensesActivity"));
- this.startActivity(intent);
- }
-
- public void onClickSourceCode(final View view) {
- final String url = this.getString(R.string.application_source_code_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
- }
-
- public void onClickRemoteData(final View view) {
- final String url = this.getString(R.string.openweathermap_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
- }
-
- public void onClickMyWeb(final View view) {
- final String url = this.getString(R.string.my_url);
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.webkit.WebView;
-
-import com.google.android.gms.common.GooglePlayServicesUtil;
-import name.gumartinm.weather.information.R;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-public class LicensesActivity extends Activity {
- private static final String TAG = "LicensesActivity";
- private WebView mWebView;
-
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.weather_licenses);
-
- mWebView = (WebView) this.findViewById(R.id.weather_licenses);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
- actionBar.setTitle(this.getString(R.string.weather_licenses_title));
-
- final String googlePlayServices = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this.getApplicationContext());
- try {
- final StringBuilder stringBuilder = this.loadData();
- stringBuilder.append(googlePlayServices).append("</pre>").append("</body>").append("</html>");
- mWebView.loadDataWithBaseURL(null, stringBuilder.toString(), "text/html", "UTF-8", null);
- } catch (final UnsupportedEncodingException e) {
- Log.e(TAG, "Load data error", e);
- } catch (final IOException e) {
- Log.e(TAG, "Load data error", e);
- }
- }
-
- private StringBuilder loadData() throws UnsupportedEncodingException, IOException {
- final InputStream inputStream = this.getResources().openRawResource(R.raw.licenses);
- try {
- final InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
- try {
- final BufferedReader reader = new BufferedReader(inputStreamReader);
- try {
- final StringBuilder stringBuilder = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- stringBuilder.append(line);
- stringBuilder.append("\n");
- }
- return stringBuilder;
- } finally {
- reader.close();
- }
- } finally {
- inputStreamReader.close();
- }
- } finally {
- inputStream.close();
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.app.ActionBar.Tab;
-import android.app.FragmentTransaction;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.fragment.current.CurrentFragment;
-import name.gumartinm.weather.information.fragment.overview.OverviewFragment;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-
-
-public class MainTabsActivity extends FragmentActivity {
- private static final int NUM_ITEMS = 2;
- private ViewPager mPager;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.setContentView(R.layout.fragment_pager);
-
- this.mPager = (ViewPager)this.findViewById(R.id.pager);
- this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager()));
-
-
- this.mPager.setOnPageChangeListener(
- new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(final int position) {
- MainTabsActivity.this.getActionBar().setSelectedNavigationItem(position);
- }
- });
-
-
- final ActionBar actionBar = this.getActionBar();
-
- PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false);
-
- // Specify that tabs should be displayed in the action bar.
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
- actionBar.setDisplayHomeAsUpEnabled(true);
-
- // Create a tab listener that is called when the user changes tabs.
- final ActionBar.TabListener tabListener = new ActionBar.TabListener() {
-
- @Override
- public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
- MainTabsActivity.this.mPager.setCurrentItem(tab.getPosition());
-
- }
-
- @Override
- public void onTabUnselected(final Tab tab, final FragmentTransaction ft) {
-
- }
-
- @Override
- public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
-
- }
-
- };
-
- actionBar.addTab(actionBar.newTab().setText("CURRENTLY").setTabListener(tabListener));
- actionBar.addTab(actionBar.newTab().setText("FORECAST").setTabListener(tabListener));
- }
-
- @Override
- public boolean onCreateOptionsMenu(final Menu menu) {
-
- this.getMenuInflater().inflate(R.menu.weather_main_menu, menu);
-
- return super.onCreateOptionsMenu(menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(final MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- super.onOptionsItemSelected(item);
-
- Intent intent;
- final int itemId = item.getItemId();
- if (itemId == R.id.weather_menu_settings) {
- intent = new Intent("name.gumartinm.weather.information.WEATHERINFO")
- .setComponent(new ComponentName("name.gumartinm.weather.information",
- "name.gumartinm.weather.information.activity.PreferencesActivity"));
- this.startActivity(intent);
- return true;
- } else if (itemId == R.id.weather_menu_map) {
- intent = new Intent("name.gumartinm.weather.information.WEATHERINFO").
- setComponent(new ComponentName("name.gumartinm.weather.information",
- "name.gumartinm.weather.information.activity.MapActivity"));
- this.startActivity(intent);
- return true;
- } else if (itemId == R.id.weather_menu_about) {
- intent = new Intent("name.gumartinm.weather.information.WEATHERINFO").
- setComponent(new ComponentName("name.gumartinm.weather.information",
- "name.gumartinm.weather.information.activity.AboutActivity"));
- this.startActivity(intent);
- return true;
- } else {
- }
-
- // TODO: calling again super method?
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onRestoreInstanceState(final Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- }
-
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
-
- // 1. Update title.
- final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- if (weatherLocation != null) {
- final String[] array = new String[2];
- array[0] = weatherLocation.getCity();
- array[1] = weatherLocation.getCountry();
- final MessageFormat message = new MessageFormat("{0},{1}", Locale.US);
- final String cityCountry = message.format(array);
- actionBar.setTitle(cityCountry);
- } else {
- actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location));
- }
-
- // 2. Update forecast tab text.
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(this.getApplicationContext());
- final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key);
- final String value = sharedPreferences.getString(keyPreference, "");
- String humanValue = "";
- if (value.equals("5")) {
- humanValue = this.getString(R.string.text_tab_five_days_forecast);
- } else if (value.equals("10")) {
- humanValue = this.getString(R.string.text_tab_ten_days_forecast);
- } else if (value.equals("14")) {
- humanValue = this.getString(R.string.text_tab_fourteen_days_forecast);
- }
- actionBar.getTabAt(1).setText(humanValue);
- }
-
- @Override
- public void onSaveInstanceState(final Bundle savedInstanceState) {
- super.onSaveInstanceState(savedInstanceState);
- }
-
- private class TabsAdapter extends FragmentPagerAdapter {
- public TabsAdapter(final FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public int getCount() {
- return NUM_ITEMS;
- }
-
- @Override
- public Fragment getItem(final int position) {
- if (position == 0) {
- return new CurrentFragment();
- } else {
- return new OverviewFragment();
- }
-
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.content.Context;
-import android.location.Criteria;
-import android.location.Geocoder;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.os.Build;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
-import com.google.android.gms.maps.MapFragment;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.Marker;
-import com.google.android.gms.maps.model.MarkerOptions;
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.fragment.map.MapButtonsFragment;
-import name.gumartinm.weather.information.fragment.map.MapProgressFragment;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-
-
-public class MapActivity extends FragmentActivity implements
- LocationListener,
- MapProgressFragment.TaskCallbacks {
- private static final String PROGRESS_FRAGMENT_TAG = "PROGRESS_FRAGMENT";
- private static final String BUTTONS_FRAGMENT_TAG = "BUTTONS_FRAGMENT";
- private WeatherLocation mRestoreUI;
-
- // Google Play Services Map
- private GoogleMap mMap;
- private Marker mMarker;
-
- private LocationManager mLocationManager;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.setContentView(R.layout.weather_map);
-
- // Acquire a reference to the system Location Manager
- this.mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
-
- // Google Play Services Map
- final MapFragment mapFragment = (MapFragment) this.getFragmentManager()
- .findFragmentById(R.id.weather_map_fragment_map);
- this.mMap = mapFragment.getMap();
- this.mMap.setMyLocationEnabled(false);
- this.mMap.getUiSettings().setMyLocationButtonEnabled(false);
- this.mMap.getUiSettings().setZoomControlsEnabled(true);
- this.mMap.getUiSettings().setCompassEnabled(true);
- this.mMap.setOnMapLongClickListener(new MapActivityOnMapLongClickListener(this));
- }
-
- @Override
- protected void onRestoreInstanceState(final Bundle savedInstanceState) {
- // Instead of restoring the state during onCreate() you may choose to
- // implement onRestoreInstanceState(), which the system calls after the
- // onStart() method. The system calls onRestoreInstanceState() only if
- // there is a saved state to restore, so you do not need to check whether
- // the Bundle is null:
- super.onRestoreInstanceState(savedInstanceState);
-
- // Restore UI state
- this.mRestoreUI = (WeatherLocation) savedInstanceState.getSerializable("WeatherLocation");
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
- actionBar.setTitle(this.getString(R.string.weather_map_mark_location));
-
- WeatherLocation weatherLocation;
- if (this.mRestoreUI != null) {
- // Restore UI state
- weatherLocation = this.mRestoreUI;
- // just once
- this.mRestoreUI = null;
- } else if (this.mMarker != null ) {
- final TextView city = (TextView) this.findViewById(R.id.weather_map_city);
- final TextView country = (TextView) this.findViewById(R.id.weather_map_country);
- final String cityString = city.getText().toString();
- final String countryString = country.getText().toString();
-
- final LatLng point = this.mMarker.getPosition();
- double latitude = point.latitude;
- double longitude = point.longitude;
-
- weatherLocation = new WeatherLocation()
- .setCity(cityString)
- .setCountry(countryString)
- .setLatitude(latitude)
- .setLongitude(longitude);
- } else {
- final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
- weatherLocation = query.queryDataBase();
- }
-
- if (weatherLocation != null) {
- this.updateUI(weatherLocation);
- }
- }
-
- /**
- * I am not using fragment transactions in the right way. But I do not know other way for doing what I am doing.
- *
- * {@link http://stackoverflow.com/questions/16265733/failure-delivering-result-onactivityforresult}
- */
- @Override
- public void onPostResume() {
- super.onPostResume();
-
- final FragmentManager fm = getSupportFragmentManager();
- final Fragment progressFragment = fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG);
- if (progressFragment == null) {
- this.addButtonsFragment();
- } else {
- this.removeProgressFragment();
- final Bundle bundle = progressFragment.getArguments();
- double latitude = bundle.getDouble("latitude");
- double longitude = bundle.getDouble("longitude");
- this.addProgressFragment(latitude, longitude);
- }
- }
-
- @Override
- public void onSaveInstanceState(final Bundle savedInstanceState) {
- // Save UI state
- // Save Google Maps Marker
- if (this.mMarker != null) {
- final TextView city = (TextView) this.findViewById(R.id.weather_map_city);
- final TextView country = (TextView) this.findViewById(R.id.weather_map_country);
- final String cityString = city.getText().toString();
- final String countryString = country.getText().toString();
-
- final LatLng point = this.mMarker.getPosition();
- double latitude = point.latitude;
- double longitude = point.longitude;
-
- final WeatherLocation location = new WeatherLocation()
- .setCity(cityString)
- .setCountry(countryString)
- .setLatitude(latitude)
- .setLongitude(longitude);
- savedInstanceState.putSerializable("WeatherLocation", location);
- }
-
- super.onSaveInstanceState(savedInstanceState);
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- this.mLocationManager.removeUpdates(this);
- }
-
- public void onClickSaveLocation(final View v) {
- if (this.mMarker != null) {
- final LatLng position = this.mMarker.getPosition();
-
- final TextView city = (TextView) this.findViewById(R.id.weather_map_city);
- final TextView country = (TextView) this.findViewById(R.id.weather_map_country);
- final String cityString = city.getText().toString();
- final String countryString = country.getText().toString();
-
- final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- if (weatherLocation != null) {
- weatherLocation
- .setCity(cityString)
- .setCountry(countryString)
- .setLatitude(position.latitude)
- .setLongitude(position.longitude)
- .setLastCurrentUIUpdate(null)
- .setLastForecastUIUpdate(null)
- .setIsNew(true);
- query.updateDataBase(weatherLocation);
- } else {
- final WeatherLocation location = new WeatherLocation()
- .setCity(cityString)
- .setCountry(countryString)
- .setIsSelected(true)
- .setLatitude(position.latitude)
- .setLongitude(position.longitude)
- .setIsNew(true);
- query.insertIntoDataBase(location);
- }
- }
- }
-
- public void onClickGetLocation(final View v) {
- // TODO: Somehow I should show a progress dialog.
- // If Google Play Services is available
- if (this.mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
- // TODO: Hopefully there will be results even if location did not change...
- final Criteria criteria = new Criteria();
- criteria.setAccuracy(Criteria.ACCURACY_FINE);
- criteria.setAltitudeRequired(false);
- criteria.setBearingAccuracy(Criteria.NO_REQUIREMENT);
- criteria.setBearingRequired(false);
- criteria.setCostAllowed(false);
- criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
- criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
- criteria.setSpeedAccuracy(Criteria.NO_REQUIREMENT);
- criteria.setSpeedRequired(false);
- criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
-
- this.mLocationManager.requestSingleUpdate(criteria, this, null);
- } else {
- Toast.makeText(this, this.getString(R.string.weather_map_not_enabled_location), Toast.LENGTH_LONG).show();
- }
- // Trying to use the synchronous calls. Problems: mGoogleApiClient read/store from different threads.
- // new GetLocationTask(this).execute();
- }
-
- private void updateUI(final WeatherLocation weatherLocation) {
-
- final TextView city = (TextView) this.findViewById(R.id.weather_map_city);
- final TextView country = (TextView) this.findViewById(R.id.weather_map_country);
- city.setText(weatherLocation.getCity());
- country.setText(weatherLocation.getCountry());
-
- final LatLng point = new LatLng(weatherLocation.getLatitude(), weatherLocation.getLongitude());
- if (this.mMarker != null) {
- // Just one marker on map
- this.mMarker.remove();
- }
- this.mMarker = this.mMap.addMarker(new MarkerOptions().position(point).draggable(true));
- this.mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 5));
- this.mMap.animateCamera(CameraUpdateFactory.zoomIn());
- this.mMap.animateCamera(CameraUpdateFactory.zoomTo(8), 2000, null);
- }
-
- private class MapActivityOnMapLongClickListener implements OnMapLongClickListener {
- // Store the context passed to the AsyncTask when the system instantiates it.
- private final Context localContext;
-
- private MapActivityOnMapLongClickListener(final Context context) {
- this.localContext = context;
- }
-
- @Override
- public void onMapLongClick(final LatLng point) {
- final MapActivity activity = (MapActivity) this.localContext;
- activity.getAddressAndUpdateUI(point.latitude, point.longitude);
- }
-
- }
-
- /**
- * Getting the address of the current location, using reverse geocoding only works if
- * a geocoding service is available.
- *
- */
- private void getAddressAndUpdateUI(final double latitude, final double longitude) {
- // In Gingerbread and later, use Geocoder.isPresent() to see if a geocoder is available.
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent()) {
- this.removeButtonsFragment();
- this.removeProgressFragment();
- this.addProgressFragment(latitude, longitude);
- } else {
- this.removeProgressFragment();
- this.addButtonsFragment();
- // No geocoder is present. Issue an error message.
- Toast.makeText(this, this.getString(R.string.weather_map_no_geocoder_available), Toast.LENGTH_LONG).show();
-
- // Default values
- final String city = this.getString(R.string.city_not_found);
- final String country = this.getString(R.string.country_not_found);
- final WeatherLocation weatherLocation = new WeatherLocation()
- .setLatitude(latitude)
- .setLongitude(longitude)
- .setCity(city)
- .setCountry(country);
-
- updateUI(weatherLocation);
- }
- }
-
- /*****************************************************************************************************
- *
- * MapProgressFragment.TaskCallbacks
- *
- *****************************************************************************************************/
- @Override
- public void onPostExecute(WeatherLocation weatherLocation) {
-
- this.updateUI(weatherLocation);
- this.removeProgressFragment();
-
- this.addButtonsFragment();
- }
-
- /*****************************************************************************************************
- *
- * MapProgressFragment
- * I am not using fragment transactions in the right way. But I do not know other way for doing what I am doing.
- * Android sucks.
- *
- * "Avoid performing transactions inside asynchronous callback methods." :(
- * see: http://stackoverflow.com/questions/16265733/failure-delivering-result-onactivityforresult
- * see: http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html
- * How do you do what I am doing in a different way without using fragments?
- *****************************************************************************************************/
-
- private void addProgressFragment(final double latitude, final double longitude) {
- final Fragment progressFragment = new MapProgressFragment();
- progressFragment.setRetainInstance(true);
- final Bundle args = new Bundle();
- args.putDouble("latitude", latitude);
- args.putDouble("longitude", longitude);
- progressFragment.setArguments(args);
-
- final FragmentManager fm = this.getSupportFragmentManager();
- final FragmentTransaction fragmentTransaction = fm.beginTransaction();
- fragmentTransaction.setCustomAnimations(R.anim.weather_map_enter_progress, R.anim.weather_map_exit_progress);
- fragmentTransaction.add(R.id.weather_map_buttons_container, progressFragment, PROGRESS_FRAGMENT_TAG).commit();
- fm.executePendingTransactions();
- }
-
- private void removeProgressFragment() {
- final FragmentManager fm = this.getSupportFragmentManager();
- final Fragment progressFragment = fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG);
- if (progressFragment != null) {
- final FragmentTransaction fragmentTransaction = fm.beginTransaction();
- fragmentTransaction.remove(progressFragment).commit();
- fm.executePendingTransactions();
- }
- }
-
- private void addButtonsFragment() {
- final FragmentManager fm = this.getSupportFragmentManager();
- Fragment buttonsFragment = fm.findFragmentByTag(BUTTONS_FRAGMENT_TAG);
- if (buttonsFragment == null) {
- buttonsFragment = new MapButtonsFragment();
- buttonsFragment.setRetainInstance(true);
- final FragmentTransaction fragmentTransaction = fm.beginTransaction();
- fragmentTransaction.setCustomAnimations(R.anim.weather_map_enter_progress, R.anim.weather_map_exit_progress);
- fragmentTransaction.add(R.id.weather_map_buttons_container, buttonsFragment, BUTTONS_FRAGMENT_TAG).commit();
- fm.executePendingTransactions();
- }
-
- if (this.mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
- final Button getLocationButton = (Button) this.findViewById(R.id.weather_map_button_getlocation);
- getLocationButton.setEnabled(true);
- }
- }
-
- private void removeButtonsFragment() {
- final FragmentManager fm = this.getSupportFragmentManager();
- final Fragment buttonsFragment = fm.findFragmentByTag(BUTTONS_FRAGMENT_TAG);
- if (buttonsFragment != null) {
- final FragmentTransaction fragmentTransaction = fm.beginTransaction();
- fragmentTransaction.remove(buttonsFragment).commit();
- fm.executePendingTransactions();
- }
- }
-
- /*****************************************************************************************************
- *
- * android.location.LocationListener
- *
- *****************************************************************************************************/
-
- @Override
- public void onLocationChanged(final Location location) {
- // It was called from onClickGetLocation (UI thread) This method will run in the same thread (the UI thread)
-
- // Display the current location in the UI
- // TODO: May location not be null?
- this.getAddressAndUpdateUI(location.getLatitude(), location.getLongitude());
- }
-
- @Override
- public void onStatusChanged(String provider, int status, Bundle extras) {}
-
- @Override
- public void onProviderEnabled(String provider) {}
-
- @Override
- public void onProviderDisabled(String provider) {}
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.os.Bundle;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.fragment.preferences.PreferencesFragment;
-
-public class PreferencesActivity extends Activity {
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- this.getFragmentManager()
- .beginTransaction()
- .replace(android.R.id.content,
- new PreferencesFragment()).commit();
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
- actionBar.setTitle(this.getString(R.string.weather_preferences_action_settings));
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.activity;
-
-import android.app.ActionBar;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-
-public class SpecificActivity extends FragmentActivity {
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.setContentView(R.layout.weather_specific);
-
- final ActionBar actionBar = this.getActionBar();
-
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
- actionBar.setDisplayHomeAsUpEnabled(true);
-
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // 1. Update title.
- final DatabaseQueries query = new DatabaseQueries(this);
- final WeatherLocation weatherLocation = query.queryDataBase();
- if (weatherLocation != null) {
- final ActionBar actionBar = this.getActionBar();
- final String[] array = new String[2];
- array[0] = weatherLocation.getCity();
- array[1] = weatherLocation.getCountry();
- final MessageFormat message = new MessageFormat("{0},{1}", Locale.US);
- final String cityCountry = message.format(array);
- actionBar.setTitle(cityCountry);
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.boot;
-
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.SystemClock;
-import android.preference.PreferenceManager;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.notification.NotificationIntentService;
-
-public class BootReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(final Context context, final Intent intent) {
-
- if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
-
- // Update Time Rate
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(context);
- final String keyPreference = context
- .getString(R.string.weather_preferences_update_time_rate_key);
- final String updateTimeRate = sharedPreferences.getString(keyPreference, "");
- long chosenInterval = 0;
- if (updateTimeRate.equals("900")) {
- chosenInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
- } else if (updateTimeRate.equals("1800")) {
- chosenInterval = AlarmManager.INTERVAL_HALF_HOUR;
- } else if (updateTimeRate.equals("3600")) {
- chosenInterval = AlarmManager.INTERVAL_HOUR;
- } else if (updateTimeRate.equals("43200")) {
- chosenInterval = AlarmManager.INTERVAL_HALF_DAY;
- } else if (updateTimeRate.equals("86400")) {
- chosenInterval = AlarmManager.INTERVAL_DAY;
- }
-
- if (chosenInterval != 0) {
- final AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- // TODO: better use some string instead of .class? In case I change the service class
- // this could be a problem (I guess)
- final Intent serviceIntent = new Intent(context, NotificationIntentService.class);
- final PendingIntent alarmIntent = PendingIntent.getService(
- context,
- 0,
- serviceIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- alarmMgr.setInexactRepeating(
- AlarmManager.ELAPSED_REALTIME,
- SystemClock.elapsedRealtime() + chosenInterval,
- chosenInterval,
- alarmIntent);
- }
- }
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-
-public class ErrorDialogFragment extends DialogFragment {
-
- public static ErrorDialogFragment newInstance(final int title) {
- final ErrorDialogFragment frag = new ErrorDialogFragment();
- final Bundle args = new Bundle();
-
- args.putInt("title", title);
- frag.setArguments(args);
-
- return frag;
- }
-
- @Override
- public Dialog onCreateDialog(final Bundle savedInstanceState) {
- final int title = this.getArguments().getInt("title");
-
- return new AlertDialog.Builder(this.getActivity())
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setTitle(title)
- .setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(final DialogInterface dialog,
- final int whichButton) {
-
- }
- }).create();
- }
-
- @Override
- public void onDestroyView() {
- if (getDialog() != null && getRetainInstance()) {
- getDialog().setDismissMessage(null);
- }
- super.onDestroyView();
- }
-}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.current;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import org.apache.http.client.ClientProtocolException;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.http.AndroidHttpClient;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.LocalBroadcastManager;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.httpclient.CustomHTTPClient;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.parser.JPOSCurrentParser;
-import name.gumartinm.weather.information.service.IconsList;
-import name.gumartinm.weather.information.service.PermanentStorage;
-import name.gumartinm.weather.information.service.ServiceCurrentParser;
-import name.gumartinm.weather.information.widget.WidgetProvider;
-
-public class CurrentFragment extends Fragment {
- private static final String TAG = "CurrentFragment";
- private BroadcastReceiver mReceiver;
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.weather_current_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(final Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- if (savedInstanceState != null) {
- // Restore UI state
- final Current current = (Current) savedInstanceState.getSerializable("Current");
-
- if (current != null) {
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- store.saveCurrent(current);
- }
- }
-
- this.setHasOptionsMenu(false);
-
- this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE);
- this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE);
- this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
-
- this.mReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(final Context context, final Intent intent) {
- final String action = intent.getAction();
- if (action.equals("name.gumartinm.weather.information.UPDATECURRENT")) {
- final Current currentRemote = (Current) intent.getSerializableExtra("current");
-
- if (currentRemote != null) {
-
- // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask.
- final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- final PermanentStorage store = new PermanentStorage(context.getApplicationContext());
- final Current current = store.getCurrent();
-
- if (current == null || !CurrentFragment.this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) {
- // 2. Update UI.
- CurrentFragment.this.updateUI(currentRemote);
-
- // 3. Update current data.
- store.saveCurrent(currentRemote);
-
- // 4. Update location data.
- weatherLocation.setLastCurrentUIUpdate(new Date());
- query.updateDataBase(weatherLocation);
- }
-
- } else {
- // Empty UI and show error message
- CurrentFragment.this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE);
- CurrentFragment.this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.GONE);
- CurrentFragment.this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.VISIBLE);
- }
- }
- }
- };
-
- // Register receiver
- final IntentFilter filter = new IntentFilter();
- filter.addAction("name.gumartinm.weather.information.UPDATECURRENT");
- LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
- .registerReceiver(this.mReceiver, filter);
-
- // Empty UI
- this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE);
-
- final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- if (weatherLocation == null) {
- // Nothing to do.
- // Show error message
- final ProgressBar progress = (ProgressBar) getActivity().findViewById(R.id.weather_current_progressbar);
- progress.setVisibility(View.GONE);
- final TextView errorMessage = (TextView) getActivity().findViewById(R.id.weather_current_error_message);
- errorMessage.setVisibility(View.VISIBLE);
- return;
- }
-
- // If is new location update widgets.
- if (weatherLocation.getIsNew()) {
- WidgetProvider.refreshAllAppWidgets(this.getActivity().getApplicationContext());
- // Update location data.
- weatherLocation.setIsNew(false);
- query.updateDataBase(weatherLocation);
- }
-
-
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Current current = store.getCurrent();
-
- if (current != null && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) {
- this.updateUI(current);
- } else {
- // Load remote data (aynchronous)
- // Gets the data from the web.
- this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE);
- this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
- final CurrentTask task = new CurrentTask(
- this.getActivity().getApplicationContext(),
- new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))),
- new ServiceCurrentParser(new JPOSCurrentParser()));
-
- task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude());
- }
- }
-
- @Override
- public void onSaveInstanceState(final Bundle savedInstanceState) {
-
- // Save UI state
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Current current = store.getCurrent();
-
- if (current != null) {
- savedInstanceState.putSerializable("Current", current);
- }
-
- super.onSaveInstanceState(savedInstanceState);
- }
-
- @Override
- public void onPause() {
- LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()).unregisterReceiver(this.mReceiver);
-
- super.onPause();
- }
-
- private interface UnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private void updateUI(final Current current) {
-
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(this.getActivity().getApplicationContext());
-
- // TODO: repeating the same code in Overview, Specific and Current!!!
- // 1. Update units of measurement.
- // 1.1 Temperature
- String tempSymbol;
- UnitsConversor tempUnitsConversor;
- String keyPreference = this.getResources().getString(R.string.weather_preferences_temperature_key);
- String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- String unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- if (unitsPreferenceValue.equals(values[0])) {
- tempSymbol = values[0];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value - 273.15;
- }
-
- };
- } else if (unitsPreferenceValue.equals(values[1])) {
- tempSymbol = values[1];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return (value * 1.8) - 459.67;
- }
-
- };
- } else {
- tempSymbol = values[2];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value;
- }
-
- };
- }
-
- // 1.2 Wind
- String windSymbol;
- UnitsConversor windUnitsConversor;
- keyPreference = this.getResources().getString(R.string.weather_preferences_wind_key);
- values = this.getResources().getStringArray(R.array.weather_preferences_wind);
- unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_wind_meters));
- if (unitsPreferenceValue.equals(values[0])) {
- windSymbol = values[0];
- windUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value;
- }
- };
- } else {
- windSymbol = values[1];
- windUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value * 2.237;
- }
- };
- }
-
- // 1.3 Pressure
- String pressureSymbol;
- UnitsConversor pressureUnitsConversor;
- keyPreference = this.getResources().getString(R.string.weather_preferences_pressure_key);
- values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
- unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_pressure_pascal));
- if (unitsPreferenceValue.equals(values[0])) {
- pressureSymbol = values[0];
- pressureUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value;
- }
- };
- } else {
- pressureSymbol = values[1];
- pressureUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value / 113.25d;
- }
- };
- }
-
-
- // 2. Formatters
- final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
- tempFormatter.applyPattern("#####.#####");
- final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.US);
-
-
- // 3. Prepare data for UI.
- String tempMax = "";
- if (current.getMain().getTemp_max() != null) {
- double conversion = (Double) current.getMain().getTemp_max();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMax = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempMin = "";
- if (current.getMain().getTemp_min() != null) {
- double conversion = (Double) current.getMain().getTemp_min();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMin = tempFormatter.format(conversion) + tempSymbol;
- }
- Bitmap picture;
- if ((current.getWeather().size() > 0)
- && (current.getWeather().get(0).getIcon() != null)
- && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) {
- final String icon = current.getWeather().get(0).getIcon();
- picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
- .getResourceDrawable());
- } else {
- picture = BitmapFactory.decodeResource(this.getResources(),
- R.drawable.weather_severe_alert);
- }
-
- String description = this.getString(R.string.text_field_description_when_error);
- if (current.getWeather().size() > 0) {
- description = current.getWeather().get(0).getDescription();
- }
-
- String humidityValue = "";
- if ((current.getMain() != null)
- && (current.getMain().getHumidity() != null)) {
- final double conversion = (Double) current.getMain().getHumidity();
- humidityValue = tempFormatter.format(conversion);
- }
- String pressureValue = "";
- if ((current.getMain() != null)
- && (current.getMain().getPressure() != null)) {
- double conversion = (Double) current.getMain().getPressure();
- conversion = pressureUnitsConversor.doConversion(conversion);
- pressureValue = tempFormatter.format(conversion);
- }
- String windValue = "";
- if ((current.getWind() != null)
- && (current.getWind().getSpeed() != null)) {
- double conversion = (Double) current.getWind().getSpeed();
- conversion = windUnitsConversor.doConversion(conversion);
- windValue = tempFormatter.format(conversion);
- }
- String rainValue = "";
- if ((current.getRain() != null)
- && (current.getRain().get3h() != null)) {
- final double conversion = (Double) current.getRain().get3h();
- rainValue = tempFormatter.format(conversion);
- }
- String cloudsValue = "";
- if ((current.getClouds() != null)
- && (current.getClouds().getAll() != null)) {
- final double conversion = (Double) current.getClouds().getAll();
- cloudsValue = tempFormatter.format(conversion);
- }
- String snowValue = "";
- if ((current.getSnow() != null)
- && (current.getSnow().get3h() != null)) {
- final double conversion = (Double) current.getSnow().get3h();
- snowValue = tempFormatter.format(conversion);
- }
- String feelsLike = "";
- if (current.getMain().getTemp() != null) {
- double conversion = (Double) current.getMain().getTemp();
- conversion = tempUnitsConversor.doConversion(conversion);
- feelsLike = tempFormatter.format(conversion);
- }
- String sunRiseTime = "";
- if (current.getSys().getSunrise() != null) {
- final long unixTime = (Long) current.getSys().getSunrise();
- final Date unixDate = new Date(unixTime * 1000L);
- sunRiseTime = dateFormat.format(unixDate);
- }
- String sunSetTime = "";
- if (current.getSys().getSunset() != null) {
- final long unixTime = (Long) current.getSys().getSunset();
- final Date unixDate = new Date(unixTime * 1000L);
- sunSetTime = dateFormat.format(unixDate);
- }
-
-
- // 4. Update UI.
- final TextView tempMaxView = (TextView) getActivity().findViewById(R.id.weather_current_temp_max);
- tempMaxView.setText(tempMax);
- final TextView tempMinView = (TextView) getActivity().findViewById(R.id.weather_current_temp_min);
- tempMinView.setText(tempMin);
- final ImageView pictureView = (ImageView) getActivity().findViewById(R.id.weather_current_picture);
- pictureView.setImageBitmap(picture);
-
- final TextView descriptionView = (TextView) getActivity().findViewById(R.id.weather_current_description);
- descriptionView.setText(description);
-
- ((TextView) getActivity().findViewById(R.id.weather_current_humidity_value)).setText(humidityValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_humidity_units)).setText(
- this.getActivity().getApplicationContext().getString(R.string.text_units_percent));
-
- ((TextView) getActivity().findViewById(R.id.weather_current_pressure_value)).setText(pressureValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_pressure_units)).setText(pressureSymbol);
-
- ((TextView) getActivity().findViewById(R.id.weather_current_wind_value)).setText(windValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_wind_units)).setText(windSymbol);
-
- ((TextView) getActivity().findViewById(R.id.weather_current_rain_value)).setText(rainValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_rain_units)).setText(
- this.getActivity().getApplicationContext().getString(R.string.text_units_mm3h));
-
- ((TextView) getActivity().findViewById(R.id.weather_current_clouds_value)).setText(cloudsValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_clouds_units)).setText(
- this.getActivity().getApplicationContext().getString(R.string.text_units_percent));
-
- ((TextView) getActivity().findViewById(R.id.weather_current_snow_value)).setText(snowValue);
- ((TextView) getActivity().findViewById(R.id.weather_current_snow_units)).setText(
- this.getActivity().getApplicationContext().getString(R.string.text_units_mm3h));
-
- ((TextView) getActivity().findViewById(R.id.weather_current_feelslike_value)).setText(feelsLike);
- ((TextView) getActivity().findViewById(R.id.weather_current_feelslike_units)).setText(tempSymbol);
-
- ((TextView) getActivity().findViewById(R.id.weather_current_sunrise_value)).setText(sunRiseTime);
-
- ((TextView) getActivity().findViewById(R.id.weather_current_sunset_value)).setText(sunSetTime);
-
- this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.VISIBLE);
- this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.GONE);
- this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE);
- }
-
- private boolean isDataFresh(final Date lastUpdate) {
- if (lastUpdate == null) {
- return false;
- }
-
- final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
- this.getActivity().getApplicationContext());
- final String keyPreference = this.getString(R.string.weather_preferences_refresh_interval_key);
- final String refresh = sharedPreferences.getString(
- keyPreference,
- this.getResources().getStringArray(R.array.weather_preferences_refresh_interval)[0]);
- final Date currentTime = new Date();
- if (((currentTime.getTime() - lastUpdate.getTime())) < Long.valueOf(refresh)) {
- return true;
- }
-
- return false;
- }
-
- private class CurrentTask extends AsyncTask<Object, Void, Current> {
- // Store the context passed to the AsyncTask when the system instantiates it.
- private final Context localContext;
- final CustomHTTPClient HTTPClient;
- final ServiceCurrentParser weatherService;
-
- public CurrentTask(final Context context, final CustomHTTPClient HTTPClient,
- final ServiceCurrentParser weatherService) {
- this.localContext = context;
- this.HTTPClient = HTTPClient;
- this.weatherService = weatherService;
- }
-
- @Override
- protected Current doInBackground(final Object... params) {
- final double latitude = (Double) params[0];
- final double longitude = (Double) params[1];
-
- Current current = null;
- try {
- current = this.doInBackgroundThrowable(latitude, longitude);
- } catch (final JsonParseException e) {
- Log.e(TAG, "CurrentTask doInBackground exception: ", e);
- } catch (final ClientProtocolException e) {
- Log.e(TAG, "CurrentTask doInBackground exception: ", e);
- } catch (final MalformedURLException e) {
- Log.e(TAG, "CurrentTask doInBackground exception: ", e);
- } catch (final URISyntaxException e) {
- Log.e(TAG, "CurrentTask doInBackground exception: ", e);
- } catch (final IOException e) {
- // logger infrastructure swallows UnknownHostException :/
- Log.e(TAG, "CurrentTask doInBackground exception: " + e.getMessage(), e);
- } finally {
- HTTPClient.close();
- }
-
- return current;
- }
-
- private Current doInBackgroundThrowable(final double latitude, final double longitude)
- throws URISyntaxException, ClientProtocolException, JsonParseException, IOException {
-
- final String APIVersion = localContext.getResources().getString(R.string.api_version);
- final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_today);
- final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion, latitude, longitude);
- final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis());
- final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache));
-
- return weatherService.retrieveCurrentFromJPOS(jsonData);
- }
-
- @Override
- protected void onPostExecute(final Current current) {
-
- // Call updateUI on the UI thread.
- final Intent currentData = new Intent("name.gumartinm.weather.information.UPDATECURRENT");
- currentData.putExtra("current", current);
- LocalBroadcastManager.getInstance(this.localContext).sendBroadcastSync(currentData);
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.map;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import name.gumartinm.weather.information.R;
-
-public class MapButtonsFragment extends Fragment {
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
-
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.weather_map_buttons, container, false);
- }
-
- /**
- * This method will only be called once when the retained
- * Fragment is first created.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Retain this fragment across configuration changes.
- this.setRetainInstance(true);
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.map;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Locale;
-
-import android.app.Activity;
-import android.content.Context;
-import android.location.Address;
-import android.location.Geocoder;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.model.WeatherLocation;
-
-/**
- * {@link http://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html}
- *
- */
-public class MapProgressFragment extends Fragment {
-
- /**
- *
- * Callback interface through which the fragment will report the
- * task's progress and results back to the Activity.
- */
- public static interface TaskCallbacks {
- void onPostExecute(final WeatherLocation weatherLocation);
- }
-
- private TaskCallbacks mCallbacks;
-
- @Override
- public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
- final Bundle savedInstanceState) {
-
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.weather_map_progress, container, false);
- }
-
- /**
- * This method will only be called once when the retained
- * Fragment is first created.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Retain this fragment across configuration changes.
- this.setRetainInstance(true);
-
- final Bundle bundle = this.getArguments();
- double latitude = bundle.getDouble("latitude");
- double longitude = bundle.getDouble("longitude");
-
- // Create and execute the background task.
- new GetAddressTask(this.getActivity().getApplicationContext()).execute(latitude, longitude);
- }
-
- /**
- * Hold a reference to the parent Activity so we can report the
- * task's current progress and results. The Android framework
- * will pass us a reference to the newly created Activity after
- * each configuration change.
- */
- @Override
- public void onAttach(final Activity activity) {
- super.onAttach(activity);
- mCallbacks = (TaskCallbacks) activity;
- }
-
- /**
- * Set the callback to null so we don't accidentally leak the
- * Activity instance.
- */
-// @Override
-// public void onDetach() {
-// super.onDetach();
-// mCallbacks = null;
-// }
-
- /**
- * I am not using onDetach because there are problems when my activity goes to background.
- *
- * {@link http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html}
- */
- @Override
- public void onPause() {
- super.onPause();
- mCallbacks = null;
- }
-
- private class GetAddressTask extends AsyncTask<Object, Void, WeatherLocation> {
- private static final String TAG = "GetAddressTask";
- // Store the context passed to the AsyncTask when the system instantiates it.
- private final Context localContext;
-
- private GetAddressTask(final Context context) {
- this.localContext = context;
- }
-
- @Override
- protected WeatherLocation doInBackground(final Object... params) {
- final double latitude = (Double) params[0];
- final double longitude = (Double) params[1];
-
- WeatherLocation weatherLocation = this.doDefaultLocation(latitude, longitude);
- try {
- weatherLocation = this.getLocation(latitude, longitude);
- } catch (final Throwable e) { // Hopefully nothing goes wrong because of catching Throwable.
- Log.e(TAG, "GetAddressTask doInBackground exception: ", e);
- }
-
- return weatherLocation;
- }
-
- @Override
- protected void onPostExecute(final WeatherLocation weatherLocation) {
-
- // Call updateUI on the UI thread.
- if (mCallbacks != null) {
- mCallbacks.onPostExecute(weatherLocation);
- }
- }
-
- private WeatherLocation getLocation(final double latitude, final double longitude) throws IOException {
- // TODO: i18n Locale.getDefault()
- final Geocoder geocoder = new Geocoder(this.localContext, Locale.US);
- final List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
-
- // Default values
- WeatherLocation weatherLocation = this.doDefaultLocation(latitude, longitude);
-
- if (addresses != null && addresses.size() > 0) {
- if (addresses.get(0).getLocality() != null) {
- weatherLocation.setCity(addresses.get(0).getLocality());
- }
- if(addresses.get(0).getCountryName() != null) {
- weatherLocation.setCountry(addresses.get(0).getCountryName());
- }
- }
-
- return weatherLocation;
- }
-
- private WeatherLocation doDefaultLocation(final double latitude, final double longitude) {
- // Default values
- String city = this.localContext.getString(R.string.city_not_found);
- String country = this.localContext.getString(R.string.country_not_found);
-
- return new WeatherLocation()
- .setLatitude(latitude)
- .setLongitude(longitude)
- .setCity(city)
- .setCountry(country);
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.overview;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import name.gumartinm.weather.information.R;
-
-public class OverviewAdapter extends ArrayAdapter<OverviewEntry> {
- private final int resource;
-
- public OverviewAdapter(final Context context, final int resource) {
- super(context, 0);
-
- this.resource = resource;
- }
-
- @Override
- public View getView(final int position, final View convertView,
- final ViewGroup parent) {
-
- // We need to get the best view (re-used if possible) and then
- // retrieve its corresponding ViewHolder, which optimizes lookup
- // efficiency
- final View view = this.getWorkingView(convertView);
- final ViewHolder viewHolder = this.getViewHolder(view);
- final OverviewEntry entry = this.getItem(position);
-
-
- // Setting date
- viewHolder.dateNameView.setText(entry.getDateName());
- viewHolder.dateNumberView.setText(entry.getDateNumber());
-
- // Setting temperature max/min
- viewHolder.temperatureMaxView.setText(entry.getMaxTemp());
- viewHolder.temperatureMinView.setText(entry.getMinTemp());
-
- // Set image view
- viewHolder.pictureView.setImageBitmap(entry.getPicture());
-
-
- return view;
- }
-
- private View getWorkingView(final View convertView) {
- // The workingView is basically just the convertView re-used if possible
- // or inflated new if not possible
- View workingView = null;
-
- if(null == convertView) {
- final Context context = this.getContext();
- final LayoutInflater inflater = (LayoutInflater)context.getSystemService
- (Context.LAYOUT_INFLATER_SERVICE);
-
- workingView = inflater.inflate(this.resource, null);
- } else {
- workingView = convertView;
- }
-
- return workingView;
- }
-
- private ViewHolder getViewHolder(final View workingView) {
- // The viewHolder allows us to avoid re-looking up view references
- // Since views are recycled, these references will never change
- final Object tag = workingView.getTag();
- ViewHolder viewHolder = null;
-
-
- if((null == tag) || !(tag instanceof ViewHolder)) {
- viewHolder = new ViewHolder();
-
- viewHolder.dateNameView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_date_name);
- viewHolder.dateNumberView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_date_number);
- viewHolder.temperatureMaxView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_temperature_max);
- viewHolder.temperatureMinView = (TextView) workingView
- .findViewById(R.id.weather_main_entry_temperature_min);
- viewHolder.pictureView = (ImageView) workingView
- .findViewById(R.id.weather_main_entry_image);
-
- workingView.setTag(viewHolder);
-
- } else {
- viewHolder = (ViewHolder) tag;
- }
-
- return viewHolder;
- }
-
- /**
- * ViewHolder allows us to avoid re-looking up view references
- * Since views are recycled, these references will never change
- */
- private static class ViewHolder {
- public TextView dateNameView;
- public TextView dateNumberView;
- public TextView temperatureMaxView;
- public TextView temperatureMinView;
- public ImageView pictureView;
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.overview;
-
-import android.graphics.Bitmap;
-
-public class OverviewEntry {
- private final String dateName;
- private final String dateNumber;
- private final String maxTemp;
- private final String minTemp;
- private final Bitmap picture;
-
- public OverviewEntry(final String dateName, final String dateNumber,
- final String maxTemp, final String minTemp,
- final Bitmap picture) {
- this.dateName = dateName;
- this.dateNumber = dateNumber;
- this.maxTemp = maxTemp;
- this.minTemp = minTemp;
- this.picture = picture;
- }
-
- public String getDateName() {
- return this.dateName;
- }
-
- public String getDateNumber() {
- return this.dateNumber;
- }
-
- public String getMaxTemp() {
- return this.maxTemp;
- }
-
- public String getMinTemp() {
- return this.minTemp;
- }
-
- public Bitmap getPicture() {
- return this.picture;
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.overview;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.http.client.ClientProtocolException;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.http.AndroidHttpClient;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.ListFragment;
-import android.support.v4.content.LocalBroadcastManager;
-import android.util.Log;
-import android.view.View;
-import android.widget.ListView;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.fragment.specific.SpecificFragment;
-import name.gumartinm.weather.information.httpclient.CustomHTTPClient;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-import name.gumartinm.weather.information.model.forecastweather.Forecast;
-import name.gumartinm.weather.information.parser.JPOSForecastParser;
-import name.gumartinm.weather.information.service.IconsList;
-import name.gumartinm.weather.information.service.PermanentStorage;
-import name.gumartinm.weather.information.service.ServiceForecastParser;
-
-public class OverviewFragment extends ListFragment {
- private static final String TAG = "OverviewFragment";
- private BroadcastReceiver mReceiver;
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public void onActivityCreated(final Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final ListView listWeatherView = this.getListView();
- listWeatherView.setChoiceMode(ListView.CHOICE_MODE_NONE);
-
- if (savedInstanceState != null) {
- // Restore UI state
- final Forecast forecast = (Forecast) savedInstanceState.getSerializable("Forecast");
-
- if (forecast != null) {
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- store.saveForecast(forecast);
- }
- }
-
- this.setHasOptionsMenu(false);
-
- this.setEmptyText(this.getString(R.string.text_field_remote_error));
- this.setListShownNoAnimation(false);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- this.mReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(final Context context, final Intent intent) {
- final String action = intent.getAction();
- if (action.equals("name.gumartinm.weather.information.UPDATEFORECAST")) {
- final Forecast forecastRemote = (Forecast) intent.getSerializableExtra("forecast");
-
- if (forecastRemote != null) {
-
- // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask.
- final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- final PermanentStorage store = new PermanentStorage(context.getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast == null || !OverviewFragment.this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {
- // 2. Update UI.
- OverviewFragment.this.updateUI(forecastRemote);
-
- // 3. Update Data.
- store.saveForecast(forecastRemote);
- weatherLocation.setLastForecastUIUpdate(new Date());
- query.updateDataBase(weatherLocation);
-
- // 4. Show list.
- OverviewFragment.this.setListShownNoAnimation(true);
- }
-
- } else {
- // Empty list and show error message (see setEmptyText in onCreate)
- OverviewFragment.this.setListAdapter(null);
- OverviewFragment.this.setListShownNoAnimation(true);
- }
- }
- }
- };
-
- // Register receiver
- final IntentFilter filter = new IntentFilter();
- filter.addAction("name.gumartinm.weather.information.UPDATEFORECAST");
- LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
- .registerReceiver(this.mReceiver, filter);
-
- final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
- if (weatherLocation == null) {
- // Nothing to do.
- // Empty list and show error message (see setEmptyText in onCreate)
- this.setListAdapter(null);
- this.setListShownNoAnimation(true);
- return;
- }
-
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast != null && this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {
- this.updateUI(forecast);
- } else {
- // Load remote data (aynchronous)
- // Gets the data from the web.
- this.setListShownNoAnimation(false);
- final OverviewTask task = new OverviewTask(
- this.getActivity().getApplicationContext(),
- new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))),
- new ServiceForecastParser(new JPOSForecastParser()));
-
- task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude());
- }
- }
-
- @Override
- public void onSaveInstanceState(final Bundle savedInstanceState) {
-
- // Save UI state
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast != null) {
- savedInstanceState.putSerializable("Forecast", forecast);
- }
-
- super.onSaveInstanceState(savedInstanceState);
- }
-
- @Override
- public void onPause() {
- LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()).unregisterReceiver(this.mReceiver);
-
- super.onPause();
- }
-
- @Override
- public void onListItemClick(final ListView l, final View v, final int position, final long id) {
- final SpecificFragment fragment = (SpecificFragment) this
- .getFragmentManager().findFragmentById(R.id.weather_specific_fragment);
- if (fragment == null) {
- // handset layout
- final Intent intent = new Intent("name.gumartinm.weather.information.WEATHERINFO")
- .setComponent(new ComponentName("name.gumartinm.weather.information",
- "name.gumartinm.weather.information.activity.SpecificActivity"));
- intent.putExtra("CHOSEN_DAY", (int) id);
- OverviewFragment.this.getActivity().startActivity(intent);
- } else {
- // tablet layout
- fragment.updateUIByChosenDay((int) id);
- }
- }
-
- private interface UnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private void updateUI(final Forecast forecastWeatherData) {
-
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(this.getActivity().getApplicationContext());
-
- // TODO: repeating the same code in Overview, Specific and Current!!!
- // 1. Update units of measurement.
- String symbol;
- UnitsConversor unitsConversor;
- String keyPreference = this.getResources().getString(
- R.string.weather_preferences_temperature_key);
- final String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- final String unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- if (unitsPreferenceValue.equals(values[0])) {
- symbol = values[0];
- unitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value - 273.15;
- }
-
- };
- } else if (unitsPreferenceValue.equals(values[1])) {
- symbol = values[1];
- unitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return (value * 1.8) - 459.67;
- }
-
- };
- } else {
- symbol = values[2];
- unitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value;
- }
-
- };
- }
-
-
- // 2. Update number day forecast.
- keyPreference = this.getResources().getString(R.string.weather_preferences_day_forecast_key);
- final String dayForecast = sharedPreferences.getString(keyPreference, "5");
- final int mDayForecast = Integer.valueOf(dayForecast);
-
-
- // 3. Formatters
- final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
- tempFormatter.applyPattern("#####.##");
- final SimpleDateFormat dayNameFormatter = new SimpleDateFormat("EEE", Locale.US);
- final SimpleDateFormat monthAndDayNumberormatter = new SimpleDateFormat("MMM d", Locale.US);
-
-
- // 4. Prepare data for UI.
- final List<OverviewEntry> entries = new ArrayList<OverviewEntry>();
- final OverviewAdapter adapter = new OverviewAdapter(this.getActivity(),
- R.layout.weather_main_entry_list);
- final Calendar calendar = Calendar.getInstance();
- int count = mDayForecast;
- for (final name.gumartinm.weather.information.model.forecastweather.List forecast : forecastWeatherData
- .getList()) {
-
- Bitmap picture;
-
- if ((forecast.getWeather().size() > 0) &&
- (forecast.getWeather().get(0).getIcon() != null) &&
- (IconsList.getIcon(forecast.getWeather().get(0).getIcon()) != null)) {
- final String icon = forecast.getWeather().get(0).getIcon();
- picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
- .getResourceDrawable());
- } else {
- picture = BitmapFactory.decodeResource(this.getResources(),
- R.drawable.weather_severe_alert);
- }
-
- final Long forecastUNIXDate = (Long) forecast.getDt();
- calendar.setTimeInMillis(forecastUNIXDate * 1000L);
- final Date dayTime = calendar.getTime();
- final String dayTextName = dayNameFormatter.format(dayTime);
- final String monthAndDayNumberText = monthAndDayNumberormatter.format(dayTime);
-
- Double maxTemp = null;
- if (forecast.getTemp().getMax() != null) {
- maxTemp = (Double) forecast.getTemp().getMax();
- maxTemp = unitsConversor.doConversion(maxTemp);
- }
-
- Double minTemp = null;
- if (forecast.getTemp().getMin() != null) {
- minTemp = (Double) forecast.getTemp().getMin();
- minTemp = unitsConversor.doConversion(minTemp);
- }
-
- if ((maxTemp != null) && (minTemp != null)) {
- entries.add(new OverviewEntry(dayTextName, monthAndDayNumberText,
- tempFormatter.format(maxTemp) + symbol, tempFormatter.format(minTemp) + symbol,
- picture));
- }
-
- count = count - 1;
- if (count == 0) {
- break;
- }
- }
-
-
- // 5. Update UI.
- adapter.addAll(entries);
- this.setListAdapter(adapter);
- }
-
- private boolean isDataFresh(final Date lastUpdate) {
- if (lastUpdate == null) {
- return false;
- }
-
- final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
- this.getActivity().getApplicationContext());
- final String keyPreference = this.getString(R.string.weather_preferences_refresh_interval_key);
- final String refresh = sharedPreferences.getString(
- keyPreference,
- this.getResources().getStringArray(R.array.weather_preferences_refresh_interval)[0]);
- final Date currentTime = new Date();
- if (((currentTime.getTime() - lastUpdate.getTime())) < Long.valueOf(refresh)) {
- return true;
- }
-
- return false;
- }
-
- private class OverviewTask extends AsyncTask<Object, Void, Forecast> {
- // Store the context passed to the AsyncTask when the system instantiates it.
- private final Context localContext;
- private final CustomHTTPClient HTTPClient;
- private final ServiceForecastParser weatherService;
-
- public OverviewTask(final Context context, final CustomHTTPClient HTTPClient,
- final ServiceForecastParser weatherService) {
- this.localContext = context;
- this.HTTPClient = HTTPClient;
- this.weatherService = weatherService;
- }
-
- @Override
- protected Forecast doInBackground(final Object... params) {
- final double latitude = (Double) params[0];
- final double longitude = (Double) params[1];
-
- Forecast forecast = null;
-
- try {
- forecast = this.doInBackgroundThrowable(latitude, longitude);
- } catch (final JsonParseException e) {
- Log.e(TAG, "OverviewTask doInBackground exception: ", e);
- } catch (final ClientProtocolException e) {
- Log.e(TAG, "OverviewTask doInBackground exception: ", e);
- } catch (final MalformedURLException e) {
- Log.e(TAG, "OverviewTask doInBackground exception: ", e);
- } catch (final URISyntaxException e) {
- Log.e(TAG, "OverviewTask doInBackground exception: ", e);
- } catch (final IOException e) {
- // logger infrastructure swallows UnknownHostException :/
- Log.e(TAG, "OverviewTask doInBackground exception: " + e.getMessage(), e);
- } finally {
- HTTPClient.close();
- }
-
- return forecast;
- }
-
- private Forecast doInBackgroundThrowable(final double latitude, final double longitude)
- throws URISyntaxException, ClientProtocolException, JsonParseException, IOException {
-
- final String APIVersion = localContext.getResources().getString(R.string.api_version);
- final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_forecast);
- // TODO: number as resource
- final String url = weatherService.createURIAPIForecast(urlAPI, APIVersion, latitude, longitude, "14");
- final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis());
- final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache));
-
- return weatherService.retrieveForecastFromJPOS(jsonData);
- }
-
- @Override
- protected void onPostExecute(final Forecast forecast) {
-
- // Call updateUI on the UI thread.
- final Intent forecastData = new Intent("name.gumartinm.weather.information.UPDATEFORECAST");
- forecastData.putExtra("forecast", forecast);
- LocalBroadcastManager.getInstance(this.localContext).sendBroadcastSync(forecastData);
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.fragment.preferences;
-
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.preference.SwitchPreference;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.notification.NotificationIntentService;
-
-public class PreferencesFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener {
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- this.addPreferencesFromResource(R.xml.weather_preferences);
-
-
- // Temperature units
- String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_temperature_human_value);
- String keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_temperature_key);
- Preference connectionPref = this.findPreference(keyPreference);
- String value = this.getPreferenceManager().getSharedPreferences()
- .getString(keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
- connectionPref.setSummary(humanValue);
-
- // Wind
- values = this.getResources().getStringArray(R.array.weather_preferences_wind);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_wind_human_value);
- keyPreference = this.getString(R.string.weather_preferences_wind_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences()
- .getString(keyPreference, this.getString(R.string.weather_preferences_wind_meters));
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- }
- connectionPref.setSummary(humanValue);
-
- // Pressure
- values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_pressure_human_value);
- keyPreference = this.getString(R.string.weather_preferences_pressure_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences()
- .getString(keyPreference, this.getString(R.string.weather_preferences_pressure_pascal));
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- }
- connectionPref.setSummary(humanValue);
-
- // Forecast days number
- values = this.getResources().getStringArray(R.array.weather_preferences_day_forecast);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_day_forecast_human_value);
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_day_forecast_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences().getString(keyPreference, values[0]);
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
- connectionPref.setSummary(humanValue);
-
- // Refresh interval
- values = this.getResources().getStringArray(R.array.weather_preferences_refresh_interval);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_refresh_interval_human_value);
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_refresh_interval_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences().getString(keyPreference, values[0]);
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- } else if (value.equals(values[3])) {
- humanValue = humanValues[3];
- } else if (value.equals(values[4])) {
- humanValue = humanValues[4];
- } else if (value.equals(values[5])) {
- humanValue = humanValues[5];
- } else if (value.equals(values[6])) {
- humanValue = humanValues[6];
- }
- connectionPref.setSummary(humanValue);
-
- // Update Time Rate
- values = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate_human_value);
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_update_time_rate_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences()
- .getString(keyPreference, values[0]);
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- } else if (value.equals(values[3])) {
- humanValue = humanValues[3];
- } else if (value.equals(values[4])) {
- humanValue = humanValues[4];
- }
- connectionPref.setSummary(humanValue);
-
- // Notifications temperature units
- values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_temperature_human_value);
- keyPreference = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_notifications_temperature_key);
- connectionPref = this.findPreference(keyPreference);
- value = this.getPreferenceManager().getSharedPreferences()
- .getString(keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
- connectionPref.setSummary(humanValue);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- this.getPreferenceManager().getSharedPreferences()
- .registerOnSharedPreferenceChangeListener(this);
-
- }
-
- @Override
- public void onPause() {
- super.onPause();
- this.getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onSharedPreferenceChanged(
- final SharedPreferences sharedPreferences, final String key) {
-
- // Temperature units
- String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- String[] humanValues = this.getResources().getStringArray(R.array.weather_preferences_temperature_human_value);
- String keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_temperature_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
-
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Wind
- values = this.getResources().getStringArray(R.array.weather_preferences_wind);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_wind_human_value);
- keyValue = this.getString(R.string.weather_preferences_wind_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- }
-
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Pressure
- values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_pressure_human_value);
- keyValue = this.getString(R.string.weather_preferences_pressure_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- }
-
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Forecast days number
- values = this.getResources().getStringArray(R.array.weather_preferences_day_forecast);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_day_forecast_human_value);
- keyValue = this.getActivity().getString(
- R.string.weather_preferences_day_forecast_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Refresh interval
- values = this.getResources().getStringArray(R.array.weather_preferences_refresh_interval);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_refresh_interval_human_value);
- keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_refresh_interval_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- } else if (value.equals(values[3])) {
- humanValue = humanValues[3];
- } else if (value.equals(values[4])) {
- humanValue = humanValues[4];
- } else if (value.equals(values[5])) {
- humanValue = humanValues[5];
- } else if (value.equals(values[6])) {
- humanValue = humanValues[6];
- }
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Notification switch
- values = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate);
- keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_notifications_switch_key);
- if (key.equals(keyValue)) {
- final SwitchPreference preference = (SwitchPreference)this.findPreference(key);
- if (preference.isChecked())
- {
- keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_update_time_rate_key);
- final String value = sharedPreferences.getString(keyValue, values[0]);
- this.updateNotification(value);
- } else {
- this.cancelNotification();
- }
- }
- // Update Time Rate
- values = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate_human_value);
- keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_update_time_rate_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- } else if (value.equals(values[3])) {
- humanValue = humanValues[3];
- } else if (value.equals(values[4])) {
- humanValue = humanValues[4];
- }
-
- this.updateNotification(value);
- connectionPref.setSummary(humanValue);
- return;
- }
-
- // Temperature units
- values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- humanValues = this.getResources().getStringArray(R.array.weather_preferences_temperature_human_value);
- keyValue = this.getActivity().getApplicationContext().getString(
- R.string.weather_preferences_notifications_temperature_key);
- if (key.equals(keyValue)) {
- final Preference connectionPref = this.findPreference(key);
- final String value = sharedPreferences.getString(key, values[0]);
- String humanValue = "";
- if (value.equals(values[0])) {
- humanValue = humanValues[0];
- } else if (value.equals(values[1])) {
- humanValue = humanValues[1];
- } else if (value.equals(values[2])) {
- humanValue = humanValues[2];
- }
-
- connectionPref.setSummary(humanValue);
- return;
- }
- }
-
- private void updateNotification(final String updateTimeRate) {
- final String[] values = this.getResources().getStringArray(R.array.weather_preferences_update_time_rate);
- long chosenInterval = 0;
- if (updateTimeRate.equals(values[0])) {
- chosenInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
- } else if (updateTimeRate.equals(values[1])) {
- chosenInterval = AlarmManager.INTERVAL_HALF_HOUR;
- } else if (updateTimeRate.equals(values[2])) {
- chosenInterval = AlarmManager.INTERVAL_HOUR;
- } else if (updateTimeRate.equals(values[3])) {
- chosenInterval = AlarmManager.INTERVAL_HALF_DAY;
- } else if (updateTimeRate.equals(values[4])) {
- chosenInterval = AlarmManager.INTERVAL_DAY;
- }
-
- final AlarmManager alarmMgr =
- (AlarmManager) this.getActivity().getApplicationContext().getSystemService(Context.ALARM_SERVICE);
- // TODO: better use some string instead of .class? In case I change the service class
- // this could be a problem (I guess)
- final Intent serviceIntent =
- new Intent(this.getActivity().getApplicationContext(), NotificationIntentService.class);
- final PendingIntent alarmIntent =
- PendingIntent.getService(
- this.getActivity().getApplicationContext(),
- 0,
- serviceIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- if (chosenInterval != 0) {
- alarmMgr.setInexactRepeating(
- AlarmManager.ELAPSED_REALTIME,
- SystemClock.elapsedRealtime(),
- chosenInterval,
- alarmIntent);
- }
- }
-
- private void cancelNotification() {
- final AlarmManager alarmMgr =
- (AlarmManager) this.getActivity().getApplicationContext().getSystemService(Context.ALARM_SERVICE);
- final Intent serviceIntent =
- new Intent(this.getActivity().getApplicationContext(), NotificationIntentService.class);
- final PendingIntent alarmIntent =
- PendingIntent.getService(
- this.getActivity().getApplicationContext(),
- 0,
- serviceIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- alarmMgr.cancel(alarmIntent);
- }
-}
+++ /dev/null
-package name.gumartinm.weather.information.fragment.specific;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.model.forecastweather.Forecast;
-import name.gumartinm.weather.information.service.IconsList;
-import name.gumartinm.weather.information.service.PermanentStorage;
-
-
-public class SpecificFragment extends Fragment {
- private int mChosenDay;
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- final Bundle extras = this.getActivity().getIntent().getExtras();
-
- if (extras != null) {
- // handset layout
- this.mChosenDay = extras.getInt("CHOSEN_DAY", 0);
- } else {
- // tablet layout
- // Always 0 when tablet layout (by default shows the first day)
- this.mChosenDay = 0;
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.weather_specific_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(final Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- if (savedInstanceState != null) {
- // Restore UI state
- final Forecast forecast = (Forecast) savedInstanceState.getSerializable("Forecast");
-
- if (forecast != null) {
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- store.saveForecast(forecast);
- }
-
- this.mChosenDay = savedInstanceState.getInt("mChosenDay");
- }
-
- this.setHasOptionsMenu(false);
- }
-
- @Override
- public void onSaveInstanceState(final Bundle savedInstanceState) {
-
- // Save UI state
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast != null) {
- savedInstanceState.putSerializable("Forecast", forecast);
- }
-
- savedInstanceState.putInt("mChosenDay", this.mChosenDay);
-
- super.onSaveInstanceState(savedInstanceState);
- }
-
- /**
- * This method is used by tablet layout.
- *
- * @param chosenDay
- */
- public void updateUIByChosenDay(final int chosenDay) {
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast != null) {
- this.updateUI(forecast, chosenDay);
- }
- }
-
- private interface UnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private void updateUI(final Forecast forecastWeatherData, final int chosenDay) {
-
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(this.getActivity());
-
- // TODO: repeating the same code in Overview, Specific and Current!!!
- // 1. Update units of measurement.
- // 1.1 Temperature
- String tempSymbol;
- UnitsConversor tempUnitsConversor;
- String keyPreference = this.getResources().getString(
- R.string.weather_preferences_temperature_key);
- String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- String unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- if (unitsPreferenceValue.equals(values[0])) {
- tempSymbol = values[0];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value - 273.15;
- }
-
- };
- } else if (unitsPreferenceValue.equals(values[1])) {
- tempSymbol = values[1];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return (value * 1.8) - 459.67;
- }
-
- };
- } else {
- tempSymbol = values[2];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value;
- }
-
- };
- }
-
- // 1.2 Wind
- String windSymbol;
- UnitsConversor windUnitsConversor;
- keyPreference = this.getResources().getString(R.string.weather_preferences_wind_key);
- values = this.getResources().getStringArray(R.array.weather_preferences_wind);
- unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_wind_meters));
- if (unitsPreferenceValue.equals(values[0])) {
- windSymbol = values[0];
- windUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value;
- }
- };
- } else {
- windSymbol = values[1];
- windUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value * 2.237;
- }
- };
- }
-
- // 1.3 Pressure
- String pressureSymbol;
- UnitsConversor pressureUnitsConversor;
- keyPreference = this.getResources().getString(R.string.weather_preferences_pressure_key);
- values = this.getResources().getStringArray(R.array.weather_preferences_pressure);
- unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_pressure_pascal));
- if (unitsPreferenceValue.equals(values[0])) {
- pressureSymbol = values[0];
- pressureUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value;
- }
- };
- } else {
- pressureSymbol = values[1];
- pressureUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(double value) {
- return value / 113.25d;
- }
- };
- }
-
-
- // 2. Formatters
- final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
- tempFormatter.applyPattern("#####.#####");
-
-
- // 3. Prepare data for UI.
- final name.gumartinm.weather.information.model.forecastweather.List forecast = forecastWeatherData
- .getList().get((chosenDay));
-
- final SimpleDateFormat dayFormatter = new SimpleDateFormat("EEEE - MMM d", Locale.US);
- final Calendar calendar = Calendar.getInstance();
- final Long forecastUNIXDate = (Long) forecast.getDt();
- calendar.setTimeInMillis(forecastUNIXDate * 1000L);
- final Date date = calendar.getTime();
-
- String tempMax = "";
- if (forecast.getTemp().getMax() != null) {
- double conversion = (Double) forecast.getTemp().getMax();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMax = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempMin = "";
- if (forecast.getTemp().getMin() != null) {
- double conversion = (Double) forecast.getTemp().getMin();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMin = tempFormatter.format(conversion) + tempSymbol;
- }
- Bitmap picture;
- if ((forecast.getWeather().size() > 0) && (forecast.getWeather().get(0).getIcon() != null)
- && (IconsList.getIcon(forecast.getWeather().get(0).getIcon()) != null)) {
- final String icon = forecast.getWeather().get(0).getIcon();
- picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
- .getResourceDrawable());
- } else {
- picture = BitmapFactory.decodeResource(this.getResources(),
- R.drawable.weather_severe_alert);
- }
-
- String description = this.getString(R.string.text_field_description_when_error);
- if (forecast.getWeather().size() > 0) {
- description = forecast.getWeather().get(0).getDescription();
- }
-
- String humidityValue = "";
- if (forecast.getHumidity() != null) {
- final double conversion = (Double) forecast.getHumidity();
- humidityValue = tempFormatter.format(conversion);
- }
- String pressureValue = "";
- if (forecast.getPressure() != null) {
- double conversion = (Double) forecast.getPressure();
- conversion = pressureUnitsConversor.doConversion(conversion);
- pressureValue = tempFormatter.format(conversion);
- }
- String windValue = "";
- if (forecast.getSpeed() != null) {
- double conversion = (Double) forecast.getSpeed();
- conversion = windUnitsConversor.doConversion(conversion);
- windValue = tempFormatter.format(conversion);
- }
- String rainValue = "";
- if (forecast.getRain() != null) {
- final double conversion = (Double) forecast.getRain();
- rainValue = tempFormatter.format(conversion);
- }
- String cloudsValue = "";
- if (forecast.getRain() != null) {
- final double conversion = (Double) forecast.getClouds();
- cloudsValue = tempFormatter.format(conversion);
- }
-
- String tempDay = "";
- if (forecast.getTemp().getDay() != null) {
- double conversion = (Double) forecast.getTemp().getDay();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempDay = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempMorn = "";
- if (forecast.getTemp().getMorn() != null) {
- double conversion = (Double) forecast.getTemp().getMorn();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMorn = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempEve = "";
- if (forecast.getTemp().getEve() != null) {
- double conversion = (Double) forecast.getTemp().getEve();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempEve = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempNight = "";
- if (forecast.getTemp().getNight() != null) {
- double conversion = (Double) forecast.getTemp().getNight();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempNight = tempFormatter.format(conversion) + tempSymbol;
- }
-
-
- // 4. Update UI.
- this.getActivity().getActionBar().setSubtitle(dayFormatter.format(date).toUpperCase());
-
- final TextView tempMaxView = (TextView) getActivity().findViewById(R.id.weather_specific_temp_max);
- tempMaxView.setText(tempMax);
- final TextView tempMinView = (TextView) getActivity().findViewById(R.id.weather_specific_temp_min);
- tempMinView.setText(tempMin);
- final ImageView pictureView = (ImageView) getActivity().findViewById(R.id.weather_specific_picture);
- pictureView.setImageBitmap(picture);
-
- final TextView descriptionView = (TextView) getActivity().findViewById(R.id.weather_specific_description);
- descriptionView.setText(description);
-
- final TextView humidityValueView = (TextView) getActivity().findViewById(R.id.weather_specific_humidity_value);
- humidityValueView.setText(humidityValue);
- ((TextView) getActivity().findViewById(R.id.weather_specific_pressure_value)).setText(pressureValue);
- ((TextView) getActivity().findViewById(R.id.weather_specific_pressure_units)).setText(pressureSymbol);
- ((TextView) getActivity().findViewById(R.id.weather_specific_wind_value)).setText(windValue);
- ((TextView) getActivity().findViewById(R.id.weather_specific_wind_units)).setText(windSymbol);
- final TextView rainValueView = (TextView) getActivity().findViewById(R.id.weather_specific_rain_value);
- rainValueView.setText(rainValue);
- final TextView cloudsValueView = (TextView) getActivity().findViewById(R.id.weather_specific_clouds_value);
- cloudsValueView.setText(cloudsValue);
-
- final TextView tempDayView = (TextView) getActivity().findViewById(R.id.weather_specific_day_temperature);
- tempDayView.setText(tempDay);
- final TextView tempMornView = (TextView) getActivity().findViewById(R.id.weather_specific_morn_temperature);
- tempMornView.setText(tempMorn);
- final TextView tempEveView = (TextView) getActivity().findViewById(R.id.weather_specific_eve_temperature);
- tempEveView.setText(tempEve);
- final TextView tempNightView = (TextView) getActivity().findViewById(R.id.weather_specific_night_temperature);
- tempNightView.setText(tempNight);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
- final Forecast forecast = store.getForecast();
-
- if (forecast != null) {
- this.updateUI(forecast, this.mChosenDay);
- }
- }
-}
+++ /dev/null
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package name.gumartinm.weather.information.httpclient;
-
-import java.nio.charset.Charset;
-
-/**
- * Commons constants.
- *
- * @since 4.2
- */
-public final class Consts {
-
- public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
- public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
- public static final int SP = 32; // <US-ASCII SP, space (32)>
- public static final int HT = 9; // <US-ASCII HT, horizontal-tab (9)>
-
- public static final Charset UTF_8 = Charset.forName("UTF-8");
- public static final Charset ASCII = Charset.forName("US-ASCII");
- public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
-
- private Consts() {
- }
-
-}
+++ /dev/null
-/*
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package name.gumartinm.weather.information.httpclient;
-
-import java.nio.charset.Charset;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.Locale;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
-import org.apache.http.message.BasicHeaderValueParser;
-
-/**
- * Content type information consisting of a MIME type and an optional charset.
- * <p/>
- * This class makes no attempts to verify validity of the MIME type.
- * The input parameters of the {@link #create(String, String)} method, however, may not
- * contain characters <">, <;>, <,> reserved by the HTTP specification.
- *
- * @since 4.2
- */
-
-public final class ContentType {
-
- // constants
- public static final ContentType APPLICATION_ATOM_XML = create(
- "application/atom+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_FORM_URLENCODED = create(
- "application/x-www-form-urlencoded", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_JSON = create(
- "application/json", Consts.UTF_8);
- public static final ContentType APPLICATION_OCTET_STREAM = create(
- "application/octet-stream", (Charset) null);
- public static final ContentType APPLICATION_SVG_XML = create(
- "application/svg+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_XHTML_XML = create(
- "application/xhtml+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_XML = create(
- "application/xml", Consts.ISO_8859_1);
- public static final ContentType MULTIPART_FORM_DATA = create(
- "multipart/form-data", Consts.ISO_8859_1);
- public static final ContentType TEXT_HTML = create(
- "text/html", Consts.ISO_8859_1);
- public static final ContentType TEXT_PLAIN = create(
- "text/plain", Consts.ISO_8859_1);
- public static final ContentType TEXT_XML = create(
- "text/xml", Consts.ISO_8859_1);
- public static final ContentType WILDCARD = create(
- "*/*", (Charset) null);
-
- // defaults
- public static final ContentType DEFAULT_TEXT = TEXT_PLAIN;
- public static final ContentType DEFAULT_BINARY = APPLICATION_OCTET_STREAM;
-
- private final String mimeType;
- private final Charset charset;
-
- /**
- * Given a MIME type and a character set, constructs a ContentType.
- * @param mimeType The MIME type to use for the ContentType header.
- * @param charset The optional character set to use with the ContentType header.
- * @throws UnsupportedCharsetException
- * If no support for the named charset is available in this Java virtual machine
- */
- ContentType(final String mimeType, final Charset charset) {
- this.mimeType = mimeType;
- this.charset = charset;
- }
-
- public String getMimeType() {
- return this.mimeType;
- }
-
- public Charset getCharset() {
- return this.charset;
- }
-
- /**
- * Converts a ContentType to a string which can be used as a ContentType header.
- * If a charset is provided by the ContentType, it will be included in the string.
- */
- @Override
- public String toString() {
- final StringBuilder buf = new StringBuilder();
- buf.append(this.mimeType);
- if (this.charset != null) {
- buf.append("; charset=");
- buf.append(this.charset);
- }
- return buf.toString();
- }
-
- private static boolean valid(final String s) {
- for (int i = 0; i < s.length(); i++) {
- final char ch = s.charAt(i);
- if ((ch == '"') || (ch == ',') || (ch == ';')) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Creates a new instance of {@link ContentType}.
- *
- * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @param charset charset.
- * @return content type
- */
- public static ContentType create(final String mimeType, final Charset charset) {
- if (mimeType == null) {
- throw new IllegalArgumentException("MIME type may not be null");
- }
- final String type = mimeType.trim().toLowerCase(Locale.US);
- if (type.length() == 0) {
- throw new IllegalArgumentException("MIME type may not be empty");
- }
- if (!valid(type)) {
- throw new IllegalArgumentException("MIME type may not contain reserved characters");
- }
- return new ContentType(type, charset);
- }
-
- /**
- * Creates a new instance of {@link ContentType} without a charset.
- *
- * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @return content type
- */
- public static ContentType create(final String mimeType) {
- return new ContentType(mimeType, (Charset) null);
- }
-
- /**
- * Creates a new instance of {@link ContentType}.
- *
- * @param mimeType MIME type. It may not be <code>null</code> or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @param charset charset. It may not contain characters <">, <;>, <,> reserved by the HTTP
- * specification. This parameter is optional.
- * @return content type
- */
- public static ContentType create(
- final String mimeType, final String charset) throws UnsupportedCharsetException {
- return create(mimeType, charset != null ? Charset.forName(charset) : null);
- }
-
- private static ContentType create(final HeaderElement helem) {
- final String mimeType = helem.getName();
- String charset = null;
- final NameValuePair param = helem.getParameterByName("charset");
- if (param != null) {
- charset = param.getValue();
- }
- return create(mimeType, charset);
- }
-
- /**
- * Parses textual representation of <code>Content-Type</code> value.
- *
- * @param s text
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * <code>Content-Type</code> value.
- */
- public static ContentType parse(
- final String s) throws ParseException, UnsupportedCharsetException {
- if (s == null) {
- throw new IllegalArgumentException("Content type may not be null");
- }
- final HeaderElement[] elements = BasicHeaderValueParser.parseElements(s, null);
- if (elements.length > 0) {
- return create(elements[0]);
- } else {
- throw new ParseException("Invalid content type: " + s);
- }
- }
-
- /**
- * Extracts <code>Content-Type</code> value from {@link HttpEntity} exactly as
- * specified by the <code>Content-Type</code> header of the entity. Returns <code>null</code>
- * if not specified.
- *
- * @param entity HTTP entity
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * <code>Content-Type</code> value.
- */
- public static ContentType get(
- final HttpEntity entity) throws ParseException, UnsupportedCharsetException {
- if (entity == null) {
- return null;
- }
- final Header header = entity.getContentType();
- if (header != null) {
- final HeaderElement[] elements = header.getElements();
- if (elements.length > 0) {
- return create(elements[0]);
- }
- }
- return null;
- }
-
- /**
- * Extracts <code>Content-Type</code> value from {@link HttpEntity} or returns default value
- * if not explicitly specified.
- *
- * @param entity HTTP entity
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * <code>Content-Type</code> value.
- */
- public static ContentType getOrDefault(final HttpEntity entity) throws ParseException {
- final ContentType contentType = get(entity);
- return contentType != null ? contentType : DEFAULT_TEXT;
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.httpclient;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-
-import android.net.http.AndroidHttpClient;
-
-public class CustomHTTPClient {
- private final AndroidHttpClient httpClient;
-
- public CustomHTTPClient(final AndroidHttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
- public String retrieveDataAsString(final URL url)
- throws URISyntaxException, ClientProtocolException, IOException {
-
- final ResponseHandler<String> handler = new ResponseHandler<String>() {
- @Override
- public String handleResponse(
- final HttpResponse response)
- throws UnsupportedEncodingException, IOException {
-
- if (response != null) {
- final HttpEntity entity = response.getEntity();
- if (entity != null) {
- try {
- final ContentType contentType = ContentType.getOrDefault(entity);
- final ByteArrayOutputStream buffer = CustomHTTPClient.this
- .sortResponse(response);
- return new String(buffer.toByteArray(), contentType.getCharset());
- } finally {
- entity.consumeContent();
- }
- }
-
- throw new IOException("There is no entity");
- }
-
- throw new IOException("There is no response");
- }
- };
-
- final HttpGet httpGet = new HttpGet();
- httpGet.setURI(url.toURI());
-
- return this.httpClient.execute(httpGet, handler);
- }
-
- public ByteArrayOutputStream retrieveRawData(final URL url)
- throws URISyntaxException, ClientProtocolException, IOException {
- final ResponseHandler<ByteArrayOutputStream> handler = new ResponseHandler<ByteArrayOutputStream>() {
-
- @Override
- public ByteArrayOutputStream handleResponse(
- final HttpResponse response)
- throws UnsupportedEncodingException, IOException {
-
- if (response != null) {
- final HttpEntity entity = response.getEntity();
- if (entity != null) {
- try {
- return CustomHTTPClient.this.sortResponse(response);
- } finally {
- entity.consumeContent();
- }
- }
-
- throw new IOException("There is no entity");
- }
-
- throw new IOException("There is no response");
- }
- };
-
- final HttpGet httpGet = new HttpGet();
- httpGet.setURI(url.toURI());
-
- return this.httpClient.execute(httpGet, handler);
- }
-
- public void close() {
- this.httpClient.close();
- }
-
- private ByteArrayOutputStream sortResponse(final HttpResponse httpResponse) throws IOException {
-
- if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- throw new IOException("Unexpected response code: "
- + httpResponse.getStatusLine().getStatusCode());
- }
-
- final HttpEntity entity = httpResponse.getEntity();
- final InputStream inputStream = entity.getContent();
- try {
- return this.readInputStream(inputStream);
- } finally {
- inputStream.close();
- }
-
- }
-
- private ByteArrayOutputStream readInputStream (final InputStream inputStream) throws IOException {
- final ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
- final int bufferSize = 1024;
- final byte[] buffer = new byte[bufferSize];
-
- int len = 0;
- while ((len = inputStream.read(buffer)) != -1) {
- byteBuffer.write(buffer, 0, len);
- }
-
- return byteBuffer;
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model;
-
-import android.content.Context;
-
-public class DatabaseQueries {
- private final Context localContext;
-
- public DatabaseQueries(final Context context) {
- this.localContext = context;
- }
-
- public WeatherLocation queryDataBase() {
-
- final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
- try {
- final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);
- return queryDb.queryDataBase();
- } finally {
- dbHelper.close();
- }
- }
-
- public long insertIntoDataBase(final WeatherLocation weatherLocation) {
-
- final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
- try {
- final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);
- return queryDb.insertIntoDataBase(weatherLocation);
- } finally {
- dbHelper.close();
- }
- }
-
- public void updateDataBase(final WeatherLocation weatherLocation) {
-
- final WeatherLocationDbHelper dbHelper = new WeatherLocationDbHelper(this.localContext);
- try {
- final WeatherLocationDbQueries queryDb = new WeatherLocationDbQueries(dbHelper);
- queryDb.updateDataBase(weatherLocation);
- } finally {
- dbHelper.close();
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model;
-
-import java.io.Serializable;
-import java.util.Date;
-
-
-public class WeatherLocation implements Serializable {
- private static final long serialVersionUID = -3781096380869053212L;
- private int id;
- private String city;
- private String country;
- private boolean isSelected;
- private double latitude;
- private double longitude;
- private Date lastCurrentUIUpdate;
- private Date lastForecastUIUpdate;
- private boolean isNew;
-
- public WeatherLocation setId(int id) {
- this.id = id;
- return this;
- }
-
- public WeatherLocation setCity(String city) {
- this.city = city;
- return this;
- }
-
- public WeatherLocation setCountry(String country) {
- this.country = country;
- return this;
- }
-
- public WeatherLocation setIsSelected(boolean isSelected) {
- this.isSelected = isSelected;
- return this;
- }
-
- public WeatherLocation setLatitude(double latitude) {
- this.latitude = latitude;
- return this;
- }
-
- public WeatherLocation setLongitude(double longitude) {
- this.longitude = longitude;
- return this;
- }
-
- public WeatherLocation setLastCurrentUIUpdate(Date lastCurrentUIUpdate) {
- this.lastCurrentUIUpdate = lastCurrentUIUpdate;
- return this;
- }
-
- public WeatherLocation setLastForecastUIUpdate(Date lastForecastUIUpdate) {
- this.lastForecastUIUpdate = lastForecastUIUpdate;
- return this;
- }
-
- public WeatherLocation setIsNew(final boolean isNew) {
- this.isNew = isNew;
- return this;
- }
-
- public int getId() {
- return this.id;
- }
-
- public String getCity() {
- return this.city;
- }
-
- public String getCountry() {
- return this.country;
- }
-
- public boolean getIsSelected() {
- return this.isSelected;
- }
-
- public double getLatitude() {
- return this.latitude;
- }
-
- public double getLongitude() {
- return this.longitude;
- }
-
- public Date getLastCurrentUIUpdate() {
- return this.lastCurrentUIUpdate;
- }
-
- public Date getLastForecastUIUpdate() {
- return this.lastForecastUIUpdate;
- }
-
- public boolean getIsNew() {
- return this.isNew;
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model;
-
-import android.provider.BaseColumns;
-
-public class WeatherLocationContract {
-
- // This class can't be instantiated
- private WeatherLocationContract() {}
-
- public static final class WeatherLocation implements BaseColumns {
-
- // This class can't be instantiated
- private WeatherLocation() {}
-
- public static final String TABLE_NAME = "locations";
-
- public static final String COLUMN_NAME_IS_SELECTED = "isSelected";
-
- public static final String COLUMN_NAME_LATITUDE = "latitude";
-
- public static final String COLUMN_NAME_LONGITUDE = "longitude";
-
- public static final String COLUMN_NAME_COUNTRY = "country";
-
- public static final String COLUMN_NAME_CITY = "city";
-
- public static final String COLUMN_NAME_LAST_FORECAST_UI_UPDATE = "lastForecastUpdate";
-
- public static final String COLUMN_NAME_LAST_CURRENT_UI_UPDATE = "lastCurrentUpdate";
-
- public static final String COLUMN_NAME_IS_NEW = "isNew";
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
-
-public class WeatherLocationDbHelper extends SQLiteOpenHelper {
- private static final String TAG = "LocationDbHelper";
- public static final int DATABASE_VERSION = 1;
- public static final String DATABASE_NAME = "Location.db";
-
- public WeatherLocationDbHelper(final Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(final SQLiteDatabase db) {
- db.execSQL("CREATE TABLE " + WeatherLocationContract.WeatherLocation.TABLE_NAME + " ("
- + WeatherLocationContract.WeatherLocation._ID + " INTEGER PRIMARY KEY, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_CITY + " TEXT" + " NOT NULL, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_COUNTRY + " TEXT" + " NOT NULL, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED + " INTEGER" + " NOT NULL, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE + " INTEGER, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE + " INTEGER, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_LATITUDE + " REAL" + " NOT NULL, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_LONGITUDE + " REAL" + " NOT NULL, "
- + WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_NEW + " INTEGER" + " NOT NULL "
- + ");");
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
- + newVersion + ", which will destroy all old data");
-
- // Kills the table and existing data
- db.execSQL("DROP TABLE IF EXISTS " + WeatherLocationContract.WeatherLocation.TABLE_NAME);
-
- // Recreates the database with a new version
- onCreate(db);
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model;
-
-import java.util.Date;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class WeatherLocationDbQueries {
- private final SQLiteOpenHelper mDbHelper;
-
- public interface DoQuery {
-
- public WeatherLocation doQuery(final Cursor cursor);
- }
-
- public WeatherLocationDbQueries(final SQLiteOpenHelper dbHelper) {
- this.mDbHelper = dbHelper;
- }
-
- public WeatherLocation queryDataBase() {
- final String selection = WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED + " = ?";
- final String[] selectionArgs = { "1" };
- final String[] projection = {
- WeatherLocationContract.WeatherLocation._ID,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_CITY,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_COUNTRY,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_LATITUDE,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_LONGITUDE,
- WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_NEW
- };
-
-
- final WeatherLocationDbQueries.DoQuery doQuery = new WeatherLocationDbQueries.DoQuery() {
-
- @Override
- public WeatherLocation doQuery(final Cursor cursor) {
- final int id = cursor.getInt(cursor.getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation._ID));
- final String city = cursor.getString(cursor.
- getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_CITY));
- final String country = cursor.getString(cursor.
- getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_COUNTRY));
- final boolean isSelected = (cursor.getInt(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED)) != 0);
- Date lastCurrentUIUpdate = null;
- if (!cursor.isNull(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE))) {
- final long javaTime = cursor.getLong(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE));
- lastCurrentUIUpdate = new Date(javaTime);
- }
- Date lasForecastUIUpdate = null;
- if (!cursor.isNull(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE))) {
- final long javaTime = cursor.getLong(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE));
- lasForecastUIUpdate = new Date(javaTime);
- }
- final double latitude = cursor.getDouble(cursor.
- getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LATITUDE));
- final double longitude = cursor.getDouble(cursor.
- getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LONGITUDE));
- final boolean isNew = (cursor.getInt(cursor
- .getColumnIndexOrThrow(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_NEW)) != 0);
-
-
- return new WeatherLocation()
- .setId(id)
- .setCity(city)
- .setCountry(country)
- .setIsSelected(isSelected)
- .setLastCurrentUIUpdate(lastCurrentUIUpdate)
- .setLastForecastUIUpdate(lasForecastUIUpdate)
- .setLatitude(latitude)
- .setLongitude(longitude)
- .setIsNew(isNew);
- }
- };
-
- return this.queryDataBase(
- WeatherLocationContract.WeatherLocation.TABLE_NAME, projection,
- selectionArgs, selection, doQuery);
- }
-
- public long insertIntoDataBase(final WeatherLocation weatherLocation) {
- // Create a new map of values, where column names are the keys
- final ContentValues values = new ContentValues();
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_CITY, weatherLocation.getCity());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_COUNTRY, weatherLocation.getCountry());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED, weatherLocation.getIsSelected());
- Date javaTime = weatherLocation.getLastCurrentUIUpdate();
- if (javaTime != null) {
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE, javaTime.getTime());
- }
- javaTime = weatherLocation.getLastForecastUIUpdate();
- if (javaTime != null) {
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE, javaTime.getTime());
- }
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LATITUDE, weatherLocation.getLatitude());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LONGITUDE, weatherLocation.getLongitude());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_NEW, weatherLocation.getIsNew());
-
- return this.insertIntoDataBase(WeatherLocationContract.WeatherLocation.TABLE_NAME, values);
- }
-
- public void updateDataBase(final WeatherLocation weatherLocation) {
- final String selection = WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED + " = ?";
- final String[] selectionArgs = { "1" };
- // Create a new map of values, where column names are the keys
- final ContentValues values = new ContentValues();
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_CITY, weatherLocation.getCity());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_COUNTRY, weatherLocation.getCountry());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_SELECTED, weatherLocation.getIsSelected());
- Date javaTime = weatherLocation.getLastCurrentUIUpdate();
- if (javaTime != null) {
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE, javaTime.getTime());
- } else {
- values.putNull(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_CURRENT_UI_UPDATE);
- }
- javaTime = weatherLocation.getLastForecastUIUpdate();
- if (javaTime != null) {
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE, javaTime.getTime());
- } else {
- values.putNull(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LAST_FORECAST_UI_UPDATE);
- }
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LATITUDE, weatherLocation.getLatitude());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_LONGITUDE, weatherLocation.getLongitude());
- values.put(WeatherLocationContract.WeatherLocation.COLUMN_NAME_IS_NEW, weatherLocation.getIsNew());
-
- this.updateDataBase(WeatherLocationContract.WeatherLocation.TABLE_NAME, selectionArgs, selection, values);
- }
-
- // TODO: May I perform another query after this method (after closing almost everything but mDbHelper)
- private WeatherLocation queryDataBase(final String table,
- final String[] projection, final String[] selectionArgs,
- final String selection, final DoQuery doQuery) {
- final SQLiteDatabase db = this.mDbHelper.getReadableDatabase();
- try {
- final Cursor cursor = db.query(table, projection, selection, selectionArgs, null, null, null);
- try {
- if (!cursor.moveToFirst()) {
- return null;
- }
- else {
- return doQuery.doQuery(cursor);
- }
- } finally {
- cursor.close();
- }
- } finally {
- db.close();
- }
- }
-
- // TODO: May I perform another query after this method (after closing almost everything but mDbHelper)
- private long insertIntoDataBase(final String table, final ContentValues values) {
- final SQLiteDatabase db = this.mDbHelper.getWritableDatabase();
- try {
- return db.insert(table, null, values);
- } finally {
- db.close();
- }
- }
-
- // TODO: May I perform another query after this method (after closing almost everything but mDbHelper)
- private long updateDataBase(final String table, final String[] selectionArgs,
- final String selection, final ContentValues values) {
- final SQLiteDatabase db = this.mDbHelper.getWritableDatabase();
- try {
- return db.update(table, values, selection, selectionArgs);
- } finally {
- db.close();
- }
- }
-
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Clouds implements Serializable {
- private static final long serialVersionUID = 8069387745331450810L;
- private Number all;
-
- public Number getAll(){
- return this.all;
- }
- public void setAll(final Number all){
- this.all = all;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Clouds [all=").append(this.all).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Coord implements Serializable {
- private static final long serialVersionUID = -2866026927720791310L;
- private Number lat;
- private Number lon;
-
- public Number getLat(){
- return this.lat;
- }
- public void setLat(final Number lat){
- this.lat = lat;
- }
- public Number getLon(){
- return this.lon;
- }
- public void setLon(final Number lon){
- this.lon = lon;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Coord [lat=").append(this.lat).append(", lon=").append(this.lon)
- .append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-public class Current implements Serializable {
- private static final long serialVersionUID = 7641628094751383380L;
- private String base;
- private Clouds clouds;
- private Number cod;
- private Coord coord;
- private Number dt;
- private Number id;
- private Main main;
- private String name;
- private Rain rain;
- private Snow snow;
- private Sys sys;
- private List<Weather> weather;
- private Wind wind;
- private byte[] iconData;
- private Date date;
-
- public String getBase(){
- return this.base;
- }
- public void setBase(final String base){
- this.base = base;
- }
- public Clouds getClouds(){
- return this.clouds;
- }
- public void setClouds(final Clouds clouds){
- this.clouds = clouds;
- }
-
- public Number getCod() {
- return this.cod;
- }
-
- public void setCod(final Number cod) {
- this.cod = cod;
- }
- public Coord getCoord(){
- return this.coord;
- }
- public void setCoord(final Coord coord){
- this.coord = coord;
- }
- public Number getDt(){
- return this.dt;
- }
- public void setDt(final Number dt){
- this.dt = dt;
- }
- public Number getId(){
- return this.id;
- }
- public void setId(final Number id){
- this.id = id;
- }
- public Main getMain(){
- return this.main;
- }
- public void setMain(final Main main){
- this.main = main;
- }
- public String getName(){
- return this.name;
- }
- public void setName(final String name){
- this.name = name;
- }
- public Rain getRain(){
- return this.rain;
- }
- public void setRain(final Rain rain){
- this.rain = rain;
- }
- public Snow getSnow() {
- return this.snow;
- }
- public void setSnow(final Snow snow) {
- this.snow = snow;
- }
- public Sys getSys(){
- return this.sys;
- }
- public void setSys(final Sys sys){
- this.sys = sys;
- }
- public List<Weather> getWeather(){
- return this.weather;
- }
- public void setWeather(final List<Weather> weather){
- this.weather = weather;
- }
- public Wind getWind(){
- return this.wind;
- }
- public void setWind(final Wind wind){
- this.wind = wind;
- }
-
- public byte[] getIconData() {
- return this.iconData;
- }
-
- public void setIconData(final byte[] iconData) {
- this.iconData = iconData;
- }
-
- public Date getDate() {
- return this.date;
- }
-
- public void setDate(final Date date) {
- this.date = date;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Current [base=").append(this.base).append(", clouds=")
- .append(this.clouds).append(", cod=").append(this.cod).append(", coord=")
- .append(this.coord).append(", dt=").append(this.dt).append(", id=").append(this.id)
- .append(", main=").append(this.main).append(", name=").append(this.name)
- .append(", rain=").append(this.rain).append(", snow=").append(this.snow)
- .append(", sys=").append(this.sys).append(", weather=").append(this.weather)
- .append(", wind=").append(this.wind).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Main implements Serializable {
- private static final long serialVersionUID = -7886213347552636533L;
- private Number grnd_level;
- private Number humidity;
- private Number pressure;
- private Number sea_level;
- private Number temp;
- private Number temp_max;
- private Number temp_min;
-
- public Number getGrnd_level() {
- return this.grnd_level;
- }
-
- public void setGrnd_level(final Number grnd_level) {
- this.grnd_level = grnd_level;
- }
-
- public Number getHumidity(){
- return this.humidity;
- }
- public void setHumidity(final Number humidity){
- this.humidity = humidity;
- }
- public Number getPressure(){
- return this.pressure;
- }
- public void setPressure(final Number pressure){
- this.pressure = pressure;
- }
-
- public Number getSea_level() {
- return this.sea_level;
- }
-
- public void setSea_level(final Number sea_level) {
- this.sea_level = sea_level;
- }
-
- public Number getTemp(){
- return this.temp;
- }
- public void setTemp(final Number temp){
- this.temp = temp;
- }
- public Number getTemp_max(){
- return this.temp_max;
- }
- public void setTemp_max(final Number temp_max){
- this.temp_max = temp_max;
- }
- public Number getTemp_min(){
- return this.temp_min;
- }
- public void setTemp_min(final Number temp_min){
- this.temp_min = temp_min;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Main [grnd_level=").append(this.grnd_level).append(", humidity=")
- .append(this.humidity).append(", pressure=").append(this.pressure)
- .append(", sea_level=").append(this.sea_level).append(", temp=").append(this.temp)
- .append(", temp_max=").append(this.temp_max).append(", temp_min=")
- .append(this.temp_min).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Rain implements Serializable {
- private static final long serialVersionUID = 8052419493935695322L;
- private Number three;
-
- public Number get3h(){
- return this.three;
- }
-
- public void set3h(final Number threeh) {
- this.three = threeh;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Rain [three=").append(this.three).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Snow implements Serializable {
- private static final long serialVersionUID = 1504151864003412278L;
- private Number three;
-
- public Number get3h() {
- return this.three;
- }
-
- public void set3h(final Number threeh) {
- this.three = threeh;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Snow [three=").append(this.three).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-
-public class Sys implements Serializable {
- private static final long serialVersionUID = 6081540634738547852L;
- private String country;
- private Number message;
- private Number sunrise;
- private Number sunset;
-
- public String getCountry(){
- return this.country;
- }
- public void setCountry(final String country){
- this.country = country;
- }
- public Number getMessage(){
- return this.message;
- }
- public void setMessage(final Number message){
- this.message = message;
- }
- public Number getSunrise(){
- return this.sunrise;
- }
- public void setSunrise(final Number sunrise){
- this.sunrise = sunrise;
- }
- public Number getSunset(){
- return this.sunset;
- }
- public void setSunset(final Number sunset){
- this.sunset = sunset;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Sys [country=").append(this.country).append(", message=")
- .append(this.message).append(", sunrise=").append(this.sunrise).append(", sunset=")
- .append(this.sunset).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Weather implements Serializable {
- private static final long serialVersionUID = 6682790432881461391L;
- private String description;
- private String icon;
- private Number id;
- private String main;
-
- public String getDescription(){
- return this.description;
- }
- public void setDescription(final String description){
- this.description = description;
- }
- public String getIcon(){
- return this.icon;
- }
- public void setIcon(final String icon){
- this.icon = icon;
- }
- public Number getId(){
- return this.id;
- }
- public void setId(final Number id){
- this.id = id;
- }
- public String getMain(){
- return this.main;
- }
- public void setMain(final String main){
- this.main = main;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Weather [description=").append(this.description).append(", icon=")
- .append(this.icon).append(", id=").append(this.id).append(", main=")
- .append(this.main).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.currentweather;
-
-import java.io.Serializable;
-
-public class Wind implements Serializable {
- private static final long serialVersionUID = -6895302757116888675L;
- private Number deg;
- private Number speed;
-
- public Number getDeg(){
- return this.deg;
- }
- public void setDeg(final Number deg){
- this.deg = deg;
- }
- public Number getSpeed(){
- return this.speed;
- }
- public void setSpeed(final Number speed){
- this.speed = speed;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Wind [deg=").append(this.deg).append(", speed=").append(this.speed)
- .append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-
-
-public class City implements Serializable {
- private static final long serialVersionUID = 3208415171959638923L;
- private Coord coord;
- private String country;
- private Number id;
- private String name;
- private Number population;
-
- public Coord getCoord(){
- return this.coord;
- }
- public void setCoord(final Coord coord){
- this.coord = coord;
- }
- public String getCountry(){
- return this.country;
- }
- public void setCountry(final String country){
- this.country = country;
- }
- public Number getId(){
- return this.id;
- }
- public void setId(final Number id){
- this.id = id;
- }
- public String getName(){
- return this.name;
- }
- public void setName(final String name){
- this.name = name;
- }
- public Number getPopulation(){
- return this.population;
- }
- public void setPopulation(final Number population){
- this.population = population;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("City [coord=").append(this.coord).append(", country=").append(this.country)
- .append(", id=").append(this.id).append(", name=").append(this.name)
- .append(", population=").append(this.population).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-
-public class Coord implements Serializable {
- private static final long serialVersionUID = -3182026816076893381L;
- private Number lat;
- private Number lon;
-
- public Number getLat(){
- return this.lat;
- }
- public void setLat(final Number lat){
- this.lat = lat;
- }
- public Number getLon(){
- return this.lon;
- }
- public void setLon(final Number lon){
- this.lon = lon;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Coord [lat=").append(this.lat).append(", lon=").append(this.lon)
- .append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class Forecast implements Serializable {
- private static final long serialVersionUID = -3401781053518082046L;
- private City city;
- private Number cnt;
- private Number cod;
- private List<name.gumartinm.weather.information.model.forecastweather.List> list;
- private Number message;
-
- public City getCity(){
- return this.city;
- }
- public void setCity(final City city){
- this.city = city;
- }
- public Number getCnt(){
- return this.cnt;
- }
- public void setCnt(final Number cnt){
- this.cnt = cnt;
- }
-
- public Number getCod() {
- return this.cod;
- }
-
- public void setCod(final Number cod) {
- this.cod = cod;
- }
-
- public List<name.gumartinm.weather.information.model.forecastweather.List> getList() {
- return this.list;
- }
-
- public void setList(final List<name.gumartinm.weather.information.model.forecastweather.List> list) {
- this.list = list;
- }
- public Number getMessage(){
- return this.message;
- }
- public void setMessage(final Number message){
- this.message = message;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Forecast [city=").append(this.city).append(", cnt=")
- .append(this.cnt).append(", cod=").append(this.cod).append(", list=")
- .append(this.list).append(", message=").append(this.message).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-
-
-public class List implements Serializable {
- private static final long serialVersionUID = -1322511710940950980L;
- private Number clouds;
- private Number deg;
- private Number dt;
- private Number humidity;
- private Number pressure;
- private Number rain;
- private Number snow;
- private Number speed;
- private Temp temp;
- private java.util.List<Weather> weather;
-
- public Number getClouds(){
- return this.clouds;
- }
- public void setClouds(final Number clouds){
- this.clouds = clouds;
- }
- public Number getDeg(){
- return this.deg;
- }
- public void setDeg(final Number deg){
- this.deg = deg;
- }
- public Number getDt(){
- return this.dt;
- }
- public void setDt(final Number dt){
- this.dt = dt;
- }
- public Number getHumidity(){
- return this.humidity;
- }
- public void setHumidity(final Number humidity){
- this.humidity = humidity;
- }
- public Number getPressure(){
- return this.pressure;
- }
- public void setPressure(final Number pressure){
- this.pressure = pressure;
- }
- public Number getRain(){
- return this.rain;
- }
- public void setRain(final Number rain){
- this.rain = rain;
- }
- public Number getSnow() {
- return this.snow;
- }
- public void setSnow(final Number snow) {
- this.snow = snow;
- }
- public Number getSpeed(){
- return this.speed;
- }
- public void setSpeed(final Number speed){
- this.speed = speed;
- }
- public Temp getTemp(){
- return this.temp;
- }
- public void setTemp(final Temp temp){
- this.temp = temp;
- }
-
- public java.util.List<Weather> getWeather() {
- return this.weather;
- }
-
- public void setWeather(final java.util.List<Weather> weather) {
- this.weather = weather;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("List [clouds=").append(this.clouds).append(", deg=").append(this.deg)
- .append(", dt=").append(this.dt).append(", humidity=").append(this.humidity)
- .append(", pressure=").append(this.pressure).append(", rain=").append(this.rain)
- .append(", snow=").append(this.snow).append(", speed=").append(this.speed)
- .append(", temp=").append(this.temp).append(", weather=").append(this.weather)
- .append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-
-public class Temp implements Serializable {
- private static final long serialVersionUID = -2240491260916844781L;
- private Number day;
- private Number eve;
- private Number max;
- private Number min;
- private Number morn;
- private Number night;
-
- public Number getDay(){
- return this.day;
- }
- public void setDay(final Number day){
- this.day = day;
- }
- public Number getEve(){
- return this.eve;
- }
- public void setEve(final Number eve){
- this.eve = eve;
- }
- public Number getMax(){
- return this.max;
- }
- public void setMax(final Number max){
- this.max = max;
- }
- public Number getMin(){
- return this.min;
- }
- public void setMin(final Number min){
- this.min = min;
- }
- public Number getMorn(){
- return this.morn;
- }
- public void setMorn(final Number morn){
- this.morn = morn;
- }
- public Number getNight(){
- return this.night;
- }
- public void setNight(final Number night){
- this.night = night;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Temp [day=").append(this.day).append(", eve=").append(this.eve)
- .append(", max=").append(this.max).append(", min=").append(this.min)
- .append(", morn=").append(this.morn).append(", night=").append(this.night)
- .append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.model.forecastweather;
-
-import java.io.Serializable;
-
-public class Weather implements Serializable {
- private static final long serialVersionUID = 4555025203754545425L;
- private String description;
- private String icon;
- private Number id;
- private String main;
-
- public String getDescription(){
- return this.description;
- }
- public void setDescription(final String description){
- this.description = description;
- }
- public String getIcon(){
- return this.icon;
- }
- public void setIcon(final String icon){
- this.icon = icon;
- }
- public Number getId(){
- return this.id;
- }
- public void setId(final Number id){
- this.id = id;
- }
- public String getMain(){
- return this.main;
- }
- public void setMain(final String main){
- this.main = main;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("Weather [description=").append(this.description).append(", icon=")
- .append(this.icon).append(", id=").append(this.id).append(", main=")
- .append(this.main).append("]");
- return builder.toString();
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.notification;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-import org.apache.http.client.ClientProtocolException;
-
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.http.AndroidHttpClient;
-import android.preference.PreferenceManager;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.NotificationManagerCompat;
-import android.support.v4.app.TaskStackBuilder;
-import android.util.Log;
-import android.widget.RemoteViews;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.activity.MainTabsActivity;
-import name.gumartinm.weather.information.httpclient.CustomHTTPClient;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.parser.JPOSCurrentParser;
-import name.gumartinm.weather.information.service.IconsList;
-import name.gumartinm.weather.information.service.ServiceCurrentParser;
-
-
-public class NotificationIntentService extends IntentService {
- private static final String TAG = "NotificationIntentService";
-
-
- public NotificationIntentService() {
- super("NIS-Thread");
- }
-
- @Override
- protected void onHandleIntent(final Intent intent) {
- final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
-
- if (weatherLocation != null) {
- final ServiceCurrentParser weatherService = new ServiceCurrentParser(new JPOSCurrentParser());
- final CustomHTTPClient HTTPClient = new CustomHTTPClient(
- AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent)));
-
- Current current = null;
- try {
- current = this.doInBackgroundThrowable(weatherLocation, HTTPClient, weatherService);
-
- } catch (final JsonParseException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final ClientProtocolException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final MalformedURLException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final URISyntaxException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final IOException e) {
- // logger infrastructure swallows UnknownHostException :/
- Log.e(TAG, "doInBackground exception: " + e.getMessage(), e);
- } finally {
- HTTPClient.close();
- }
-
- if (current != null) {
- this.showNotification(current, weatherLocation);
- }
- }
- }
-
- private Current doInBackgroundThrowable(final WeatherLocation weatherLocation,
- final CustomHTTPClient HTTPClient, final ServiceCurrentParser weatherService)
- throws ClientProtocolException, MalformedURLException, URISyntaxException,
- JsonParseException, IOException {
-
- final String APIVersion = this.getResources().getString(R.string.api_version);
-
- final String urlAPI = this.getResources().getString(R.string.uri_api_weather_today);
- final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion,
- weatherLocation.getLatitude(), weatherLocation.getLongitude());
- final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis());
- final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache));
-
- return weatherService.retrieveCurrentFromJPOS(jsonData);
- }
-
- private interface UnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private void showNotification(final Current current, final WeatherLocation weatherLocation) {
- final SharedPreferences sharedPreferences = PreferenceManager
- .getDefaultSharedPreferences(this.getApplicationContext());
-
- // TODO: repeating the same code in Overview, Specific and Current!!!
- // 1. Update units of measurement.
- // 1.1 Temperature
- String tempSymbol;
- UnitsConversor tempUnitsConversor;
- final String keyPreference = this.getApplicationContext().getString(R.string.weather_preferences_notifications_temperature_key);
- final String[] values = this.getResources().getStringArray(R.array.weather_preferences_temperature);
- final String unitsPreferenceValue = sharedPreferences.getString(
- keyPreference, this.getString(R.string.weather_preferences_temperature_celsius));
- if (unitsPreferenceValue.equals(values[0])) {
- tempSymbol = values[0];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value - 273.15;
- }
-
- };
- } else if (unitsPreferenceValue.equals(values[1])) {
- tempSymbol = values[1];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return (value * 1.8) - 459.67;
- }
-
- };
- } else {
- tempSymbol = values[2];
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value;
- }
-
- };
- }
-
-
- // 2. Formatters
- final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
- tempFormatter.applyPattern("#####.#####");
-
-
- // 3. Prepare data for RemoteViews.
- String tempMax = "";
- if (current.getMain().getTemp_max() != null) {
- double conversion = (Double) current.getMain().getTemp_max();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMax = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempMin = "";
- if (current.getMain().getTemp_min() != null) {
- double conversion = (Double) current.getMain().getTemp_min();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMin = tempFormatter.format(conversion) + tempSymbol;
- }
- Bitmap picture;
- if ((current.getWeather().size() > 0)
- && (current.getWeather().get(0).getIcon() != null)
- && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) {
- final String icon = current.getWeather().get(0).getIcon();
- picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
- .getResourceDrawable());
- } else {
- picture = BitmapFactory.decodeResource(this.getResources(),
- R.drawable.weather_severe_alert);
- }
- final String city = weatherLocation.getCity();
- final String country = weatherLocation.getCountry();
-
- // 4. Insert data in RemoteViews.
- final RemoteViews remoteView = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.notification);
- remoteView.setImageViewBitmap(R.id.weather_notification_image, picture);
- remoteView.setTextViewText(R.id.weather_notification_temperature_max, tempMax);
- remoteView.setTextViewText(R.id.weather_notification_temperature_min, tempMin);
- remoteView.setTextViewText(R.id.weather_notification_city, city);
- remoteView.setTextViewText(R.id.weather_notification_country, country);
-
- // 5. Activity launcher.
- final Intent resultIntent = new Intent(this.getApplicationContext(), MainTabsActivity.class);
- // The PendingIntent to launch our activity if the user selects this notification
-// final PendingIntent contentIntent = PendingIntent.getActivity(
-// this.getApplicationContext(), 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- // The stack builder object will contain an artificial back stack for the started Activity.
- // This ensures that navigating backward from the Activity leads out of
- // your application to the Home screen.
- final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this.getApplicationContext());
- // Adds the back stack for the Intent (but not the Intent itself)
- stackBuilder.addParentStack(MainTabsActivity.class);
- // Adds the Intent that starts the Activity to the top of the stack
- stackBuilder.addNextIntent(resultIntent);
- final PendingIntent resultPendingIntent =
- stackBuilder.getPendingIntent(
- 0,
- PendingIntent.FLAG_UPDATE_CURRENT
- );
-
- final NotificationManagerCompat notificationManager =
- NotificationManagerCompat.from(this.getApplicationContext());
-
-
- // 6. Create notification.
- final NotificationCompat.Builder notificationBuilder =
- new NotificationCompat.Builder(this.getApplicationContext())
- .setContent(remoteView)
- .setSmallIcon(R.drawable.ic_launcher)
- .setAutoCancel(true)
- .setLocalOnly(true)
- .setWhen(System.currentTimeMillis())
- .setContentIntent(resultPendingIntent)
- .setPriority(NotificationCompat.PRIORITY_DEFAULT);
-
- final Notification notification = notificationBuilder.build();
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
-
- // Send the notification.
- // Sets an ID for the notification, so it can be updated (just in case)
- int notifyID = 1;
- notificationManager.notify(notifyID, notification);
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.parser;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import name.gumartinm.weather.information.model.currentweather.Clouds;
-import name.gumartinm.weather.information.model.currentweather.Coord;
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.model.currentweather.Main;
-import name.gumartinm.weather.information.model.currentweather.Rain;
-import name.gumartinm.weather.information.model.currentweather.Snow;
-import name.gumartinm.weather.information.model.currentweather.Sys;
-import name.gumartinm.weather.information.model.currentweather.Weather;
-import name.gumartinm.weather.information.model.currentweather.Wind;
-
-public class JPOSCurrentParser {
-
- public Current retrieveCurrenFromJPOS(final String jsonData)
- throws JsonParseException, IOException {
- final JsonFactory f = new JsonFactory();
-
- final Current currentWeatherData = new Current();
- currentWeatherData.setClouds(new Clouds());
- currentWeatherData.setCoord(new Coord());
- currentWeatherData.setMain(new Main());
- currentWeatherData.setRain(new Rain());
- currentWeatherData.setSys(new Sys());
- currentWeatherData.setSnow(new Snow());
- currentWeatherData
- .setWeather(new ArrayList<Weather>());
- currentWeatherData.setWind(new Wind());
- final JsonParser jParser = f.createParser(jsonData);
-
- this.getCurrentWeatherData(currentWeatherData, jParser);
-
- return currentWeatherData;
- }
-
- private void getCurrentWeatherData(final Current currentWeatherData,
- final JsonParser jParser) throws JsonParseException, IOException {
- if (jParser.nextToken() == JsonToken.START_OBJECT) {
-
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String fieldname = jParser.getCurrentName();
- final JsonToken nextToken = jParser.nextToken();
- if (nextToken == JsonToken.START_OBJECT) {
- this.getCurrentWeatherDataObjects(currentWeatherData, jParser, fieldname);
- }
- if (nextToken == JsonToken.START_ARRAY) {
- JsonToken tokenNext = jParser.nextToken();
- while (tokenNext != JsonToken.END_ARRAY) {
- if (tokenNext == JsonToken.START_OBJECT) {
- this.getCurrentWeatherDataObjects(currentWeatherData, jParser, fieldname);
- }
- tokenNext = jParser.nextToken();
- }
- }
- if ((nextToken == JsonToken.VALUE_NUMBER_INT)
- || (nextToken == JsonToken.VALUE_STRING)) {
- this.getCurrentWeatherDataObjects(currentWeatherData, jParser, fieldname);
- }
- }
- }
- }
-
- private void getCurrentWeatherDataObjects(final Current currentWeatherData,
- final JsonParser jParser, final String fieldname) throws JsonParseException,
- IOException {
- if ("coord".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("lon".equals(namefield)) {
- currentWeatherData.getCoord().setLon(jParser.getDoubleValue());
- }
- if ("lat".equals(namefield)) {
- currentWeatherData.getCoord().setLat(jParser.getDoubleValue());
- }
- }
- }
- if ("sys".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("message".equals(namefield)) {
- currentWeatherData.getSys().setMessage(jParser.getDoubleValue());
- }
- if ("country".equals(namefield)) {
- currentWeatherData.getSys().setCountry(jParser.getValueAsString());
- }
- if ("sunrise".equals(namefield)) {
- currentWeatherData.getSys().setSunrise(jParser.getValueAsLong());
- }
- if ("sunset".equals(namefield)) {
- currentWeatherData.getSys().setSunset(jParser.getValueAsLong());
- }
- }
- }
- if ("weather".equals(fieldname)) {
- final Weather weather = new Weather();
- currentWeatherData.getWeather().add(weather);
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("id".equals(namefield)) {
- weather.setId(jParser.getIntValue());
- }
- if ("main".equals(namefield)) {
- weather.setMain(jParser.getText());
- }
- if ("description".equals(namefield)) {
- weather.setDescription(jParser.getText());
- }
- if ("icon".equals(namefield)) {
- weather.setIcon(jParser.getText());
- }
-
- }
- }
- if ("base".equals(fieldname)) {
- currentWeatherData.setBase(jParser.getText());
- }
- if ("main".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("temp".equals(namefield)) {
- currentWeatherData.getMain().setTemp(jParser.getDoubleValue());
- }
- if ("temp_min".equals(namefield)) {
- currentWeatherData.getMain().setTemp_min(jParser.getDoubleValue());
- }
- if ("temp_max".equals(namefield)) {
- currentWeatherData.getMain().setTemp_max(jParser.getDoubleValue());
- }
- if ("pressure".equals(namefield)) {
- currentWeatherData.getMain().setPressure(jParser.getDoubleValue());
- }
- if ("sea_level".equals(namefield)) {
- currentWeatherData.getMain().setSea_level(jParser.getDoubleValue());
- }
- if ("grnd_level".equals(namefield)) {
- currentWeatherData.getMain().setGrnd_level(jParser.getDoubleValue());
- }
- if ("humidity".equals(namefield)) {
- currentWeatherData.getMain().setHumidity(jParser.getDoubleValue());
- }
- }
- }
- if ("wind".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("speed".equals(namefield)) {
- currentWeatherData.getWind().setSpeed(jParser.getDoubleValue());
- }
- if ("deg".equals(namefield)) {
- currentWeatherData.getWind().setDeg(jParser.getDoubleValue());
- }
- }
- }
- if ("clouds".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("all".equals(namefield)) {
- currentWeatherData.getClouds().setAll(jParser.getDoubleValue());
- }
- }
- }
- if ("dt".equals(fieldname)) {
- currentWeatherData.setDt(jParser.getLongValue());
- }
- if ("rain".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("3h".equals(namefield)) {
- currentWeatherData.getRain().set3h(jParser.getDoubleValue());
- }
- }
- }
- if ("snow".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("3h".equals(namefield)) {
- currentWeatherData.getSnow().set3h(jParser.getDoubleValue());
- }
- }
- }
- if ("id".equals(fieldname)) {
- currentWeatherData.setId(jParser.getLongValue());
- }
- if ("name".equals(fieldname)) {
- currentWeatherData.setName(jParser.getText());
- }
- if ("cod".equals(fieldname)) {
- currentWeatherData.setCod(jParser.getIntValue());
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.parser;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import name.gumartinm.weather.information.model.forecastweather.City;
-import name.gumartinm.weather.information.model.forecastweather.Coord;
-import name.gumartinm.weather.information.model.forecastweather.Forecast;
-import name.gumartinm.weather.information.model.forecastweather.List;
-import name.gumartinm.weather.information.model.forecastweather.Temp;
-import name.gumartinm.weather.information.model.forecastweather.Weather;
-
-public class JPOSForecastParser {
-
- public Forecast retrieveForecastFromJPOS(final String jsonData)
- throws JsonParseException, IOException {
- final JsonFactory f = new JsonFactory();
-
- final Forecast forecastWeatherData = new Forecast();
- forecastWeatherData
- .setList(new ArrayList<List>(15));
- final City city = new City();
- city.setCoord(new Coord());
- forecastWeatherData.setCity(city);
- final JsonParser jParser = f.createParser(jsonData);
-
- this.getForecastWeatherData(forecastWeatherData, jParser);
-
- return forecastWeatherData;
- }
-
- private void getForecastWeatherData(final Forecast forecastWeatherData,
- final JsonParser jParser) throws JsonParseException, IOException {
- if (jParser.nextToken() == JsonToken.START_OBJECT) {
-
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String fieldname = jParser.getCurrentName();
- final JsonToken nextToken = jParser.nextToken();
- if (nextToken == JsonToken.START_OBJECT) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser, fieldname);
- }
- if (nextToken == JsonToken.START_ARRAY) {
- JsonToken tokenNext = jParser.nextToken();
- while (tokenNext != JsonToken.END_ARRAY) {
- if (tokenNext == JsonToken.START_OBJECT) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser, fieldname);
- }
- tokenNext = jParser.nextToken();
- }
- }
- if ((nextToken == JsonToken.VALUE_NUMBER_INT)
- || (nextToken == JsonToken.VALUE_STRING)) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser, fieldname);
- }
- }
- }
- }
-
- private void getForecastWeatherDataObjects(final Forecast forecastWeatherData,
- final JsonParser jParser, final String fieldname) throws JsonParseException,
- IOException {
-
- if ("cod".equals(fieldname)) {
- final String stringCod = jParser.getText();
- forecastWeatherData.setCod(Long.valueOf(stringCod));
- }
- if ("message".equals(fieldname)) {
- forecastWeatherData.setMessage(jParser.getDoubleValue());
- }
- if ("city".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- final JsonToken nextToken = jParser.nextToken(); // move to
- // value
- if ("id".equals(namefield)) {
- forecastWeatherData.getCity().setId(jParser.getLongValue());
- }
- if ("name".equals(namefield)) {
- forecastWeatherData.getCity().setName(jParser.getText());
- }
- if ("coord".equals(namefield)) {
- if (nextToken == JsonToken.START_OBJECT) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser, namefield);
- }
- }
- if ("country".equals(namefield)) {
- forecastWeatherData.getCity().setCountry(jParser.getText());
- }
- if ("population".equals(namefield)) {
- forecastWeatherData.getCity().setPopulation(jParser.getLongValue());
- }
- }
- }
- if ("cnt".equals(fieldname)) {
- forecastWeatherData.setCnt(jParser.getIntValue());
- }
- if ("coord".equals(fieldname)) {
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("lon".equals(namefield)) {
- forecastWeatherData.getCity().getCoord().setLon(jParser.getDoubleValue());
- }
- if ("lat".equals(namefield)) {
- forecastWeatherData.getCity().getCoord().setLat(jParser.getDoubleValue());
- }
- }
- }
- if ("list".equals(fieldname)) {
- final name.gumartinm.weather.information.model.forecastweather.List list = new name.gumartinm.weather.information.model.forecastweather.List();
- list.setTemp(new Temp());
- list.setWeather(new ArrayList<Weather>());
- forecastWeatherData.getList().add(list);
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- final JsonToken nextToken = jParser.nextToken(); // move to
- // value
- if ("dt".equals(namefield)) {
- list.setDt(jParser.getLongValue());
- }
- if ("temp".equals(namefield)) {
- if (nextToken == JsonToken.START_OBJECT) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser, namefield);
- }
- }
- if ("pressure".equals(namefield)) {
- list.setPressure(jParser.getDoubleValue());
- }
- if ("humidity".equals(namefield)) {
- list.setHumidity(jParser.getDoubleValue());
- }
- if ("weather".equals(namefield)) {
- if (nextToken == JsonToken.START_ARRAY) {
- JsonToken tokenNext = jParser.nextToken();
- while (tokenNext != JsonToken.END_ARRAY) {
- if (tokenNext == JsonToken.START_OBJECT) {
- this.getForecastWeatherDataObjects(forecastWeatherData, jParser,
- namefield);
- }
- tokenNext = jParser.nextToken();
- }
- }
- }
- if ("speed".equals(namefield)) {
- list.setSpeed(jParser.getDoubleValue());
- }
- if ("deg".equals(namefield)) {
- list.setDeg(jParser.getDoubleValue());
- }
- if ("clouds".equals(namefield)) {
- list.setClouds(jParser.getDoubleValue());
- }
- if ("rain".equals(namefield)) {
- list.setRain(jParser.getDoubleValue());
- }
- }
- }
- if ("temp".equals(fieldname)) {
- final name.gumartinm.weather.information.model.forecastweather.List list =
- forecastWeatherData.getList().get((forecastWeatherData.getList().size() - 1));
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
- if ("day".equals(namefield)) {
- list.getTemp().setDay(jParser.getDoubleValue());
- }
- if ("min".equals(namefield)) {
- list.getTemp().setMin(jParser.getDoubleValue());
- }
- if ("max".equals(namefield)) {
- list.getTemp().setMax(jParser.getDoubleValue());
- }
- if ("night".equals(namefield)) {
- list.getTemp().setNight(jParser.getDoubleValue());
- }
- if ("eve".equals(namefield)) {
- list.getTemp().setEve(jParser.getDoubleValue());
- }
- if ("morn".equals(namefield)) {
- list.getTemp().setMorn(jParser.getDoubleValue());
- }
- }
- }
- if ("weather".equals(fieldname)) {
- final name.gumartinm.weather.information.model.forecastweather.List list =
- forecastWeatherData.getList().get((forecastWeatherData.getList().size() - 1));
- final Weather weather = new Weather();
- while (jParser.nextToken() != JsonToken.END_OBJECT) {
- final String namefield = jParser.getCurrentName();
- jParser.nextToken(); // move to value
-
- if ("id".equals(namefield)) {
- weather.setId(jParser.getIntValue());
- }
- if ("main".equals(namefield)) {
- weather.setMain(jParser.getText());
- }
- if ("description".equals(namefield)) {
- weather.setDescription(jParser.getText());
- }
- if ("icon".equals(namefield)) {
- weather.setIcon(jParser.getText());
- }
- }
- list.getWeather().add(weather);
- }
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.service;
-
-import name.gumartinm.weather.information.R;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public enum IconsList {
- ICON_01d("01d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_clear;
- }
- },
- // TODO: I am sometimes receiving this code, there is no documentation about it on the
- // openweathermap site.... But it exists!!! Some day, try to find out more information about it.
- // see: http://openweathermap.org/img/w/01dd.png
- ICON_01dd("01dd") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_clear;
- }
- },
- ICON_01n("01n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_clear_night;
- }
- },
- ICON_02d("02d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_few_clouds;
- }
- },
- ICON_02n("02n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_few_clouds_night;
- }
- },
- ICON_03d("03d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_few_clouds;
- }
- },
- ICON_03n("03n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_few_clouds;
- }
- },
- ICON_04d("04d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_overcast;
- }
- },
- ICON_04n("04n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_overcast;
- }
- },
- ICON_09d("09d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_showers;
- }
- },
- ICON_09n("09n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_showers;
- }
- },
- ICON_10d("10d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_showers_scattered;
- }
- },
- ICON_10n("10n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_showers_scattered;
- }
- },
- ICON_11d("11d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_storm;
- }
- },
- ICON_11n("11n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_storm;
- }
- },
- ICON_13d("13d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_snow;
- }
- },
- ICON_13n("13n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_snow;
- }
- },
- ICON_50d("50d") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_fog;
- }
- },
- ICON_50n("50n") {
- @Override
- public int getResourceDrawable() {
- return R.drawable.weather_fog;
- }
- };
-
- private final String icon;
- // Map with every enum constant. Class variable initializer. JLS§12.4.2
- // Executed in textual order.
- private static final Map<String, IconsList> codeMap = new HashMap<String, IconsList>();
-
- // Static initializer. JLS§12.4.2 Executed in textual order.
- static {
- for (final IconsList code : IconsList.values()) {
- codeMap.put(code.getIcon(), code);
- }
- }
-
- private IconsList(final String icon) {
- this.icon = icon;
- }
-
- public static final IconsList getIcon(final String icon) {
- return codeMap.get(icon);
- }
-
- private String getIcon() {
- return this.icon;
- }
-
- public abstract int getResourceDrawable();
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.service;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StreamCorruptedException;
-import java.text.MessageFormat;
-
-import android.content.Context;
-import android.util.Log;
-
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.model.forecastweather.Forecast;
-
-
-public class PermanentStorage {
- private static final String TAG = "PermanentStorage";
- private static final String CURRENT_DATA_FILE = "current.file";
- private static final String FORECAST_DATA_FILE = "forecast.file";
- private static final String WIDGET_CURRENT_DATA_FILE = "current.{0}.file";
- private final Context context;
-
- public PermanentStorage(final Context context) {
- this.context = context;
- }
-
- public void saveCurrent(final Current current) {
-
- try {
- this.saveObject(CURRENT_DATA_FILE, current);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "saveCurrent exception: ", e);
- } catch (IOException e) {
- Log.e(TAG, "saveCurrent exception: ", e);
- }
- }
-
- public Current getCurrent() {
-
- try {
- return (Current) this.getObject(CURRENT_DATA_FILE);
- } catch (final StreamCorruptedException e) {
- Log.e(TAG, "getCurrent exception: ", e);
- } catch (final FileNotFoundException e) {
- Log.e(TAG, "getCurrent exception: ", e);
- } catch (final IOException e) {
- Log.e(TAG, "getCurrent exception: ", e);
- } catch (final ClassNotFoundException e) {
- Log.e(TAG, "getCurrent exception: ", e);
- }
-
- return null;
- }
-
- public void saveWidgetCurrentData(final Current current, final int appWidgetId) {
-
- final String fileName = MessageFormat.format(WIDGET_CURRENT_DATA_FILE, appWidgetId);
- try {
- this.saveObject(fileName, current);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "saveWidgetCurrentData exception: ", e);
- } catch (IOException e) {
- Log.e(TAG, "saveWidgetCurrentData exception: ", e);
- }
- }
-
- public Current getWidgetCurrentData(final int appWidgetId) {
-
- final String fileName = MessageFormat.format(WIDGET_CURRENT_DATA_FILE, appWidgetId);
- try {
- return (Current) this.getObject(fileName);
- } catch (final StreamCorruptedException e) {
- Log.e(TAG, "getWidgetCurrentData exception: ", e);
- } catch (final FileNotFoundException e) {
- Log.e(TAG, "getWidgetCurrentData exception: ", e);
- } catch (final IOException e) {
- Log.e(TAG, "getWidgetCurrentData exception: ", e);
- } catch (final ClassNotFoundException e) {
- Log.e(TAG, "getWidgetCurrentData exception: ", e);
- }
-
- return null;
- }
-
- public void removeWidgetCurrentData(final int appWidgetId) {
-
- final String fileName = MessageFormat.format(WIDGET_CURRENT_DATA_FILE, appWidgetId);
-
- try {
- this.removeFile(fileName);
- } catch (final IOException e) {
- Log.e(TAG, "removeWidgetCurrentData exception: ", e);
- }
- }
-
- public void saveForecast(final Forecast forecast) {
-
- try {
- this.saveObject(FORECAST_DATA_FILE, forecast);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "saveForecast exception: ", e);
- } catch (IOException e) {
- Log.e(TAG, "saveForecast exception: ", e);
- }
- }
-
- public Forecast getForecast() {
-
- try {
- return (Forecast) this.getObject(FORECAST_DATA_FILE);
- } catch (final StreamCorruptedException e) {
- Log.e(TAG, "getForecast exception: ", e);
- } catch (final FileNotFoundException e) {
- Log.e(TAG, "getForecast exception: ", e);
- } catch (final IOException e) {
- Log.e(TAG, "getForecast exception: ", e);
- } catch (final ClassNotFoundException e) {
- Log.e(TAG, "getForecast exception: ", e);
- }
-
- return null;
- }
-
- private void saveObject(final String fileName, final Object objectToStore)
- throws FileNotFoundException, IOException {
- final String temporaryFileName = fileName.concat(".tmp");
-
- final FileOutputStream tmpPersistFile = this.context.openFileOutput(
- temporaryFileName, Context.MODE_PRIVATE);
- try {
- final ObjectOutputStream oos = new ObjectOutputStream(tmpPersistFile);
- try {
- oos.writeObject(objectToStore);
-
- // Don't fear the fsync!
- // http://thunk.org/tytso/blog/2009/03/15/dont-fear-the-fsync/
- tmpPersistFile.flush();
- tmpPersistFile.getFD().sync();
- } finally {
- oos.close();
- }
- } finally {
- tmpPersistFile.close();
- }
-
- this.renameFile(temporaryFileName, fileName);
- }
-
- private Object getObject(final String fileName) throws StreamCorruptedException, FileNotFoundException,
- IOException, ClassNotFoundException {
- final InputStream persistFile = this.context.openFileInput(fileName);
- try {
- final ObjectInputStream ois = new ObjectInputStream(persistFile);
- try {
- return ois.readObject();
- } finally {
- ois.close();
- }
- } finally {
- persistFile.close();
- }
- }
-
- private void renameFile(final String fromFileName, final String toFileName) throws IOException {
- final File filesDir = this.context.getFilesDir();
- final File fromFile = new File(filesDir, fromFileName);
- final File toFile = new File(filesDir, toFileName);
- if (!fromFile.renameTo(toFile)) {
- if (!fromFile.delete()) {
- throw new IOException("PermanentStorage, delete file error");
- }
- throw new IOException("PermanentStorage, rename file error");
- }
- }
-
- private void removeFile(final String fileName) throws IOException {
- final File filesDir = this.context.getFilesDir();
- final File file = new File(filesDir, fileName);
-
- if (!file.delete()) {
- throw new IOException("PermanentStorage, remove file error");
- }
- }
-}
-
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.service;
-
-import com.fasterxml.jackson.core.JsonParseException;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Locale;
-
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.parser.JPOSCurrentParser;
-
-public class ServiceCurrentParser {
- private final JPOSCurrentParser JPOSParser;
-
- public ServiceCurrentParser(final JPOSCurrentParser jposParser) {
- this.JPOSParser = jposParser;
- }
-
- public Current retrieveCurrentFromJPOS(final String jsonData)
- throws JsonParseException, IOException {
- return this.JPOSParser.retrieveCurrenFromJPOS(jsonData);
- }
-
- public String createURIAPICurrent(final String urlAPI, final String APIVersion,
- final double latitude, final double longitude) {
-
- final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
- final Object[] values = new Object[3];
- values[0] = APIVersion;
- values[1] = latitude;
- values[2] = longitude;
-
- return formatURIAPI.format(values);
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.service;
-
-import com.fasterxml.jackson.core.JsonParseException;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Locale;
-
-import name.gumartinm.weather.information.model.forecastweather.Forecast;
-import name.gumartinm.weather.information.parser.JPOSForecastParser;
-
-public class ServiceForecastParser {
- private final JPOSForecastParser JPOSParser;
-
- public ServiceForecastParser(final JPOSForecastParser jposParser) {
- this.JPOSParser = jposParser;
- }
-
- public Forecast retrieveForecastFromJPOS(final String jsonData)
- throws JsonParseException, IOException {
- return this.JPOSParser.retrieveForecastFromJPOS(jsonData);
- }
-
- public String createURIAPIForecast(final String urlAPI, final String APIVersion,
- final double latitude, final double longitude, final String resultsNumber) {
-
- final MessageFormat formatURIAPI = new MessageFormat(urlAPI, Locale.US);
- final Object[] values = new Object[4];
- values[0] = APIVersion;
- values[1] = latitude;
- values[2] = longitude;
- values[3] = resultsNumber;
-
- return formatURIAPI.format(values);
- }
-}
+++ /dev/null
-/**
- * Copyright 2014 Gustavo Martin Morcuende
- *
- * 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.
- */
-package name.gumartinm.weather.information.widget;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.appwidget.AppWidgetManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.CompoundButton;
-import android.widget.Spinner;
-import android.widget.Switch;
-
-import name.gumartinm.weather.information.R;
-
-public class WidgetConfigure extends Activity {
- private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
-
- @Override
- public void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Find the widget id from the intent.
- final Intent intent = getIntent();
- final Bundle extras = intent.getExtras();
- boolean isActionFromUser = false;
-
- if (extras != null) {
- mAppWidgetId = extras.getInt(
- AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
-
- isActionFromUser = extras.getBoolean("actionFromUser", false);
- }
-
- // If they gave us an intent without the widget id, just bail.
- if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
- this.finish();
- }
-
- if (!isActionFromUser) {
- // Set the result to CANCELED. This will cause the widget host to cancel
- // out of the widget placement if they press the back button.
- this.setResult(RESULT_CANCELED);
- }
-
- // Set the view layout resource to use.
- this.setContentView(R.layout.appwidget_configure);
-
- /******************* Show/hide country field *******************/
- String keyPreference = this.getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- String realKeyPreference = keyPreference + "_" + mAppWidgetId;
-
- // What was saved to permanent storage (or default values if it is the first time)
- final boolean isShowCountry = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
- .getBoolean(realKeyPreference, false);
-
- // What is shown on the screen
- final Switch countrySwitch = (Switch) this.findViewById(R.id.weather_appwidget_configure_country);
- countrySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
- @Override
- public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
- if (isChecked) {
- buttonView.setText(WidgetConfigure.this.getString(R.string.widget_preferences_country_switch_on_summary));
- } else {
- buttonView.setText(WidgetConfigure.this.getString(R.string.widget_preferences_country_switch_off_summary));
- }
- }
- });
- if (isShowCountry) {
- countrySwitch.setChecked(true);
- countrySwitch.setText(this.getString(R.string.widget_preferences_country_switch_on_summary));
- } else {
- countrySwitch.setChecked(false);
- countrySwitch.setText(this.getString(R.string.widget_preferences_country_switch_off_summary));
- }
-
- /********************* Temperature units **********************/
- keyPreference = this.getApplicationContext().getString(
- R.string.widget_preferences_temperature_units_key);
- realKeyPreference = keyPreference + "_" + mAppWidgetId;
-
- // What was saved to permanent storage (or default values if it is the first time)
- final int tempValue = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
-
- // What is shown on the screen
- final Spinner tempUnits = (Spinner) this.findViewById(R.id.weather_appwidget_configure_temperature_units);
- tempUnits.setSelection(tempValue);
-
- /**
- * android:saveEnabled
- * Controls whether the saving of this view's state is enabled (that is, whether its onSaveInstanceState() method will be called).
- *
- * After onStart the onSaveInstanceState method will be called for every widget, so
- * I do not need to do anything else to retrieve the UI's state after changing orientation.
- *
- * I do not know if this is a good pattern, it does not look like that. I guess, I should use
- * on Resume instead of onCreate/onStart and implement my own onSaveInstanceState method.
- * But I am tired...
- */
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final ActionBar actionBar = this.getActionBar();
- actionBar.setTitle(this.getString(R.string.widget_preferences_action_settings));
- }
-
-
- public void onClickRefresh(final View view) {
- // Push widget update to surface
- WidgetProvider.refreshAppWidget(this.getApplicationContext(), mAppWidgetId);
- }
-
- public void onClickOk(final View view) {
- // Save to permanent storage
- final SharedPreferences.Editor prefs = this.getSharedPreferences(
- "WIDGET_PREFERENCES",
- Context.MODE_PRIVATE).edit();
-
- /******************* Show/hide country field *******************/
- // What is shown on the screen
- final Switch countrySwitch = (Switch) this.findViewById(R.id.weather_appwidget_configure_country);
- String keyPreference = this.getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- String realKeyPreference = keyPreference + "_" + mAppWidgetId;
- prefs.putBoolean(realKeyPreference, countrySwitch.isChecked());
-
- /********************* Temperature units **********************/
- // What is shown on the screen
- final Spinner tempUnits = (Spinner) this.findViewById(R.id.weather_appwidget_configure_temperature_units);
- keyPreference = this.getApplicationContext().getString(
- R.string.widget_preferences_temperature_units_key);
- realKeyPreference = keyPreference + "_" + mAppWidgetId;
- prefs.putInt(realKeyPreference, tempUnits.getSelectedItemPosition());
-
- /****************** Saving to permanent storage ***************/
- prefs.commit();
-
- // Push widget update to surface with newly set prefix
- WidgetProvider.updateAppWidget(this.getApplicationContext(), mAppWidgetId);
-
- // Make sure we pass back the original appWidgetId
- final Intent resultValue = new Intent();
- resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
- this.setResult(RESULT_OK, resultValue);
- finish();
- }
-
- public static void deletePreference(final Context context, final int appWidgetId) {
- final SharedPreferences.Editor prefs = context.getApplicationContext()
- .getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).edit();
-
- /******************* Show/hide country field *******************/
- String keyPreference = context.getApplicationContext().getString(
- R.string.widget_preferences_country_switch_key);
- String realKeyPreference = keyPreference + "_" + appWidgetId;
- prefs.remove(realKeyPreference);
-
- /********************* Temperature units **********************/
- keyPreference = context.getApplicationContext().getString(
- R.string.widget_preferences_temperature_units_key);
- realKeyPreference = keyPreference + "_" + appWidgetId;
- prefs.remove(realKeyPreference);
-
- /****************** Updating permanent storage ***************/
- prefs.commit();
- }
-}
+++ /dev/null
-package name.gumartinm.weather.information.widget;
-
-import android.app.IntentService;
-import android.app.PendingIntent;
-import android.appwidget.AppWidgetManager;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.net.http.AndroidHttpClient;
-import android.support.v4.app.TaskStackBuilder;
-import android.util.Log;
-import android.view.View;
-import android.widget.RemoteViews;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import name.gumartinm.weather.information.R;
-import name.gumartinm.weather.information.httpclient.CustomHTTPClient;
-import name.gumartinm.weather.information.model.DatabaseQueries;
-import name.gumartinm.weather.information.model.WeatherLocation;
-import name.gumartinm.weather.information.model.currentweather.Current;
-import name.gumartinm.weather.information.parser.JPOSCurrentParser;
-import name.gumartinm.weather.information.service.IconsList;
-import name.gumartinm.weather.information.service.PermanentStorage;
-import name.gumartinm.weather.information.service.ServiceCurrentParser;
-
-import org.apache.http.client.ClientProtocolException;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.Date;
-import java.util.Locale;
-
-public class WidgetIntentService extends IntentService {
- private static final String TAG = "WidgetIntentService";
- private static final long UPDATE_TIME_RATE = 86400000L;
-
- public WidgetIntentService() {
- super("WIS-Thread");
- }
-
- @Override
- protected void onHandleIntent(final Intent intent) {
- Log.i(TAG, "onHandleIntent");
- final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
- final boolean isRefreshAppWidget = intent.getBooleanExtra("refreshAppWidget", false);
-
- if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
- // Nothing to do. Something went wrong. Show error.
- return;
- }
-
-
- final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext());
- final WeatherLocation weatherLocation = query.queryDataBase();
-
- if (weatherLocation == null) {
- // Nothing to do. Show error.
- final RemoteViews view = this.makeErrorView(appWidgetId);
- this.updateWidget(view, appWidgetId);
- return;
- }
-
- // TODO: improve this code. Too tired right now...
- if (!isRefreshAppWidget) {
- RemoteViews view;
-
- final PermanentStorage store = new PermanentStorage(this.getApplicationContext());
- final Current current = store.getWidgetCurrentData(appWidgetId);
- if (current != null) {
- // Update UI.
- view = this.makeView(current, weatherLocation, appWidgetId);
- } else {
- // Show error.
- view = this.makeErrorView(appWidgetId);
- }
- this.updateWidget(view, appWidgetId);
- } else {
- RemoteViews view;
-
- final Current current = this.getRemoteCurrent(weatherLocation);
- if (current != null) {
- // Update UI.
- view = this.makeView(current, weatherLocation, appWidgetId);
-
- final PermanentStorage store = new PermanentStorage(this.getApplicationContext());
- store.saveWidgetCurrentData(current, appWidgetId);
- } else {
- // Show error.
- view = this.makeErrorView(appWidgetId);
- }
- this.updateWidget(view, appWidgetId);
- }
- }
-
- public static void deleteWidgetCurrentData(final Context context, final int appWidgetId) {
- final PermanentStorage store = new PermanentStorage(context.getApplicationContext());
-
- store.removeWidgetCurrentData(appWidgetId);
- }
-
- private Current getRemoteCurrent(final WeatherLocation weatherLocation) {
-
- final ServiceCurrentParser weatherService = new ServiceCurrentParser(new JPOSCurrentParser());
- final CustomHTTPClient HTTPClient = new CustomHTTPClient(
- AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent)));
-
- try {
- return this.getRemoteCurrentThrowable(weatherLocation, HTTPClient, weatherService);
-
- } catch (final JsonParseException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final ClientProtocolException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final MalformedURLException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final URISyntaxException e) {
- Log.e(TAG, "doInBackground exception: ", e);
- } catch (final IOException e) {
- // logger infrastructure swallows UnknownHostException :/
- Log.e(TAG, "doInBackground exception: " + e.getMessage(), e);
- } finally {
- HTTPClient.close();
- }
-
- return null;
- }
-
- private Current getRemoteCurrentThrowable(final WeatherLocation weatherLocation,
- final CustomHTTPClient HTTPClient, final ServiceCurrentParser weatherService)
- throws ClientProtocolException, MalformedURLException, URISyntaxException,
- JsonParseException, IOException {
-
- final String APIVersion = this.getResources().getString(R.string.api_version);
-
- final String urlAPI = this.getResources().getString(R.string.uri_api_weather_today);
- final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion,
- weatherLocation.getLatitude(), weatherLocation.getLongitude());
- final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis());
- final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache));
-
- return weatherService.retrieveCurrentFromJPOS(jsonData);
- }
-
- private interface UnitsConversor {
-
- public double doConversion(final double value);
- }
-
- private RemoteViews makeView(final Current current, final WeatherLocation weatherLocation, final int appWidgetId) {
-
- // TODO: repeating the same code in Overview, Specific and Current!!!
- // 1. Update units of measurement.
-
- UnitsConversor tempUnitsConversor;
- String keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_temperature_units_key);
- String realKeyPreference = keyPreference + "_" + appWidgetId;
- // What was saved to permanent storage (or default values if it is the first time)
- final int tempValue = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE).getInt(realKeyPreference, 0);
- final String tempSymbol = this.getResources().getStringArray(R.array.weather_preferences_temperature)[tempValue];
- if (tempValue == 0) {
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value - 273.15;
- }
-
- };
- } else if (tempValue == 1) {
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return (value * 1.8) - 459.67;
- }
-
- };
- } else {
- tempUnitsConversor = new UnitsConversor(){
-
- @Override
- public double doConversion(final double value) {
- return value;
- }
-
- };
- }
-
-
- // 2. Update country.
- keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_country_switch_key);
- realKeyPreference = keyPreference + "_" + appWidgetId;
- // What was saved to permanent storage (or default values if it is the first time)
- final boolean isCountry = this.getSharedPreferences("WIDGET_PREFERENCES", Context.MODE_PRIVATE)
- .getBoolean(realKeyPreference, false);
-
-
- // 3. Formatters
- final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US);
- tempFormatter.applyPattern("#####.#####");
-
-
- // 4. Prepare data for RemoteViews.
- String tempMax = "";
- if (current.getMain().getTemp_max() != null) {
- double conversion = (Double) current.getMain().getTemp_max();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMax = tempFormatter.format(conversion) + tempSymbol;
- }
- String tempMin = "";
- if (current.getMain().getTemp_min() != null) {
- double conversion = (Double) current.getMain().getTemp_min();
- conversion = tempUnitsConversor.doConversion(conversion);
- tempMin = tempFormatter.format(conversion) + tempSymbol;
- }
- Bitmap picture;
- if ((current.getWeather().size() > 0)
- && (current.getWeather().get(0).getIcon() != null)
- && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) {
- final String icon = current.getWeather().get(0).getIcon();
- picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon)
- .getResourceDrawable());
- } else {
- picture = BitmapFactory.decodeResource(this.getResources(),
- R.drawable.weather_severe_alert);
- }
- final String city = weatherLocation.getCity();
- final String country = weatherLocation.getCountry();
-
- // 5. Insert data in RemoteViews.
- final RemoteViews remoteView = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.appwidget);
- remoteView.setImageViewBitmap(R.id.weather_appwidget_image, picture);
- remoteView.setTextViewText(R.id.weather_appwidget_temperature_max, tempMax);
- remoteView.setTextViewText(R.id.weather_appwidget_temperature_min, tempMin);
- remoteView.setTextViewText(R.id.weather_appwidget_city, city);
- if (!isCountry) {
- remoteView.setViewVisibility(R.id.weather_appwidget_country, View.GONE);
- } else {
- // TODO: It is as if Android had a view cache. If I did not set VISIBLE value,
- // the country field would be gone forever... :/
- remoteView.setViewVisibility(R.id.weather_appwidget_country, View.VISIBLE);
- remoteView.setTextViewText(R.id.weather_appwidget_country, country);
- }
-
-
- // 6. Activity launcher.
- final Intent resultIntent = new Intent(this.getApplicationContext(), WidgetConfigure.class);
- resultIntent.putExtra("actionFromUser", true);
- resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- // resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK );
- // From: http://stackoverflow.com/questions/4011178/multiple-instances-of-widget-only-updating-last-widget
- final Uri data = Uri.withAppendedPath(Uri.parse("PAIN" + "://widget/id/") ,String.valueOf(appWidgetId));
- resultIntent.setData(data);
-
- final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this.getApplicationContext());
- // Adds the back stack for the Intent (but not the Intent itself)
- stackBuilder.addParentStack(WidgetConfigure.class);
- // Adds the Intent that starts the Activity to the top of the stack
- stackBuilder.addNextIntent(resultIntent);
- final PendingIntent resultPendingIntent =
- stackBuilder.getPendingIntent(
- 0,
- PendingIntent.FLAG_UPDATE_CURRENT
- );
- remoteView.setOnClickPendingIntent(R.id.weather_appwidget, resultPendingIntent);
-// final PendingIntent resultPendingIntent = PendingIntent.getActivity(
-// this.getApplicationContext(),
-// 0,
-// resultIntent,
-// PendingIntent.FLAG_UPDATE_CURRENT);
-// remoteView.setOnClickPendingIntent(R.id.weather_appwidget, resultPendingIntent);
-
- return remoteView;
- }
-
- private RemoteViews makeErrorView(final int appWidgetId) {
- final RemoteViews remoteView = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.appwidget_error);
-
- // 6. Activity launcher.
- final Intent resultIntent = new Intent(this.getApplicationContext(), WidgetConfigure.class);
- resultIntent.putExtra("actionFromUser", true);
- resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
-// resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK );
- // From: http://stackoverflow.com/questions/4011178/multiple-instances-of-widget-only-updating-last-widget
- final Uri data = Uri.withAppendedPath(Uri.parse("PAIN" + "://widget/id/") ,String.valueOf(appWidgetId));
- resultIntent.setData(data);
-
- final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this.getApplicationContext());
- // Adds the back stack for the Intent (but not the Intent itself)
- stackBuilder.addParentStack(WidgetConfigure.class);
- // Adds the Intent that starts the Activity to the top of the stack
- stackBuilder.addNextIntent(resultIntent);
- final PendingIntent resultPendingIntent =
- stackBuilder.getPendingIntent(
- 0,
- PendingIntent.FLAG_UPDATE_CURRENT
- );
- remoteView.setOnClickPendingIntent(R.id.weather_appwidget_error, resultPendingIntent);
-// final PendingIntent resultPendingIntent = PendingIntent.getActivity(
-// this.getApplicationContext(),
-// 0,
-// resultIntent,
-// PendingIntent.FLAG_UPDATE_CURRENT);
-// remoteView.setOnClickPendingIntent(R.id.weather_appwidget_error, resultPendingIntent);
-
- return remoteView;
- }
-
- private void updateWidget(final RemoteViews remoteView, final int appWidgetId) {
-
- final AppWidgetManager manager = AppWidgetManager.getInstance(this.getApplicationContext());
- manager.updateAppWidget(appWidgetId, remoteView);
- }
-
-// private void updateWidgets(final RemoteViews remoteView) {
-//
-// final ComponentName widgets = new ComponentName(this.getApplicationContext(), WidgetProvider.class);
-// final AppWidgetManager manager = AppWidgetManager.getInstance(this.getApplicationContext());
-// manager.updateAppWidget(widgets, remoteView);
-// }
-}
+++ /dev/null
-package name.gumartinm.weather.information.widget;
-
-
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProvider;
-import android.appwidget.AppWidgetProviderInfo;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-
-public class WidgetProvider extends AppWidgetProvider {
-
- @Override
- public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
- // For each widget that needs an update, get the text that we should display:
- // - Create a RemoteViews object for it
- // - Set the text in the RemoteViews object
- // - Tell the AppWidgetManager to show that views object for the widget.
- final int N = appWidgetIds.length;
- for (int i=0; i<N; i++) {
- int appWidgetId = appWidgetIds[i];
- // To prevent any ANR timeouts, we perform the update in a service
- final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- intent.putExtra("refreshAppWidget", true);
- context.startService(intent);
- }
- }
-
- @Override
- public void onDeleted(final Context context, final int[] appWidgetIds) {
- // When the user deletes the widget, delete the preference associated with it.
- final int N = appWidgetIds.length;
- for (int i=0; i<N; i++) {
- WidgetConfigure.deletePreference(context, appWidgetIds[i]);
- WidgetIntentService.deleteWidgetCurrentData(context, appWidgetIds[i]);
- }
- }
-
- public static void updateAppWidget(final Context context, final int appWidgetId) {
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
-
- updateAppWidget(context, appWidgetManager, appWidgetId);
- }
-
- public static void refreshAppWidget(final Context context, final int appWidgetId) {
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
-
- refreshAppWidget(context.getApplicationContext(), appWidgetManager, appWidgetId);
- }
-
- public static void refreshAllAppWidgets(final Context context) {
- final ComponentName widgets = new ComponentName(context.getApplicationContext(), WidgetProvider.class);
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
-
- final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(widgets);
- for (final int appWidgetId : appWidgetIds) {
- refreshAppWidget(context.getApplicationContext(), appWidgetManager, appWidgetId);
- }
- }
-
- private static void refreshAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
-
- int widgetId;
- Bundle myOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
-
- // Get the value of OPTION_APPWIDGET_HOST_CATEGORY
- int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
-
- // If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget
- boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
-
- // Once you know the widget's category, you can optionally load a different base layout, set different
- // properties, and so on. For example:
- //int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout;
-
- // Construct the RemoteViews object. It takes the package name (in our case, it's our
- // package, but it needs this because on the other side it's the widget host inflating
- // the layout from our package).
- //final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
-
- final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- intent.putExtra("refreshAppWidget", true);
- context.startService(intent);
- }
-
- private static void updateAppWidget(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId) {
-
- int widgetId;
- Bundle myOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
-
- // Get the value of OPTION_APPWIDGET_HOST_CATEGORY
- int category = myOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1);
-
- // If the value is WIDGET_CATEGORY_KEYGUARD, it's a lockscreen widget
- boolean isKeyguard = category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
-
- // Once you know the widget's category, you can optionally load a different base layout, set different
- // properties, and so on. For example:
- //int baseLayout = isKeyguard ? R.layout.keyguard_widget_layout : R.layout.widget_layout;
-
- // Construct the RemoteViews object. It takes the package name (in our case, it's our
- // package, but it needs this because on the other side it's the widget host inflating
- // the layout from our package).
- //final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
-
- final Intent intent = new Intent(context.getApplicationContext(), WidgetIntentService.class);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- intent.putExtra("refreshAppWidget", false);
- context.startService(intent);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<set>
- <translate xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromYDelta="100%"
- android:toYDelta="0%"
- android:interpolator="@android:anim/decelerate_interpolator"
- android:duration="@android:integer/config_mediumAnimTime"/>
-</set>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<set>
- <translate xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromYDelta="0%"
- android:toYDelta="-100%"
- android:interpolator="@android:anim/accelerate_interpolator"
- android:duration="@android:integer/config_mediumAnimTime"/>
-</set>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/weather_specific_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="fill_vertical|center_horizontal"
- android:orientation="vertical" >
-
- <!-- TODO: http://developer.android.com/guide/topics/manifest/supports-screens-element.html -->
- <!-- TODO: supporting multiple layouts/languages http://developer.android.com/guide/practices/screens_support.html -->
- <!-- TODO: Should I use RelativeLayout for long texts (I18N) and RTL/LTR UI?
- With long texts, many times, text will not fit... The same for WP8 :/ -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:layout_gravity="top|center"
- android:padding="50dp"
- android:orientation="horizontal" >
-
- <ImageView
- android:id="@+id/weather_specific_picture"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:contentDescription="@string/icon_weather_description"
- android:scaleType="fitCenter"
- android:gravity="center"
- android:layout_gravity="center"
- android:src="@drawable/weather_showers" />
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_specific_temp_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="55ºC"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_specific_temp_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAlignment="textStart"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="25ºC"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="normal" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:padding="25dp"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <TextView
- android:id="@+id/weather_specific_description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Light rain"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
- <!-- Humidity -->
- <TextView
- android:id="@+id/weather_specific_humidity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:layout_margin="5dp"
- android:gravity="start"
- android:text="@string/text_field_humidity"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
-
- <!-- Humidity Value-->
- <TextView
- android:id="@+id/weather_specific_humidity_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="83"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Humidity Units-->
- <TextView
- android:id="@+id/weather_specific_humidity_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Rain -->
- <TextView
- android:id="@+id/weather_specific_rain"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_rain"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Rain Value-->
- <TextView
- android:id="@+id/weather_specific_rain_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1.24"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Rain Units -->
- <TextView
- android:id="@+id/weather_specific_rain_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" mm 3h"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
-
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
-
- <!-- Wind -->
- <TextView
- android:id="@+id/weather_specific_wind"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_wind"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Wind Value-->
- <TextView
- android:id="@+id/weather_specific_wind_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Wind Units -->
- <TextView
- android:id="@+id/weather_specific_wind_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" m/s"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Clouds -->
- <TextView
- android:id="@+id/weather_specific_clouds"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_clouds"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Clouds Value-->
- <TextView
- android:id="@+id/weather_specific_clouds_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="end"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Clouds Units -->
- <TextView
- android:id="@+id/weather_specific_clouds_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <!-- Pressure -->
- <TextView
- android:id="@+id/weather_specific_pressure"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_pressure"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Pressure Value-->
- <TextView
- android:id="@+id/weather_specific_pressure_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1036.05"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Pressure Units-->
- <TextView
- android:id="@+id/weather_specific_pressure_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" hpa"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:fadingEdge="none"
- android:padding="10dp"
- android:orientation="horizontal"
- android:scrollbarAlwaysDrawVerticalTrack="false"
- android:scrollbars="none" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_morn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="MORNING"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_morn_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_day"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="DAY"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_day_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingStart="30dp"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_eve"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="EVENING"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_eve_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_night"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="NIGHT"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_night_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
-</ScrollView>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="name.gumartinm.weather.information.activity.WeatherInformationActivity"
- tools:ignore="MergeRootFrame" >
-
- <fragment
- android:id="@+id/weather_overview_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- class="name.gumartinm.weather.information.fragment.overview.OverviewFragment" />
-
- <fragment
- android:id="@+id/weather_specific_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- class="name.gumartinm.weather.information.fragment.specific.SpecificFragment" />
-
-</FrameLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/weather_specific_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="fill_vertical|center_horizontal"
- android:orientation="vertical" >
-
- <!-- TODO: http://developer.android.com/guide/topics/manifest/supports-screens-element.html -->
- <!-- TODO: supporting multiple layouts/languages http://developer.android.com/guide/practices/screens_support.html -->
- <!-- TODO: Should I use RelativeLayout for long texts (I18N) and RTL/LTR UI?
- With long texts, many times, text will not fit... The same for WP8 :/ -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:layout_gravity="top|center"
- android:padding="50dp"
- android:orientation="horizontal" >
-
- <ImageView
- android:id="@+id/weather_specific_picture"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:contentDescription="@string/icon_weather_description"
- android:scaleType="fitCenter"
- android:gravity="center"
- android:layout_gravity="center"
- android:src="@drawable/weather_showers" />
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_specific_temp_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="55ºC"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_specific_temp_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAlignment="textStart"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="25ºC"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="normal" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:padding="25dp"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <TextView
- android:id="@+id/weather_specific_description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Light rain"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
- <!-- Humidity -->
- <TextView
- android:id="@+id/weather_specific_humidity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:layout_margin="5dp"
- android:gravity="start"
- android:text="@string/text_field_humidity"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
-
- <!-- Humidity Value-->
- <TextView
- android:id="@+id/weather_specific_humidity_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="83"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Humidity Units-->
- <TextView
- android:id="@+id/weather_specific_humidity_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Rain -->
- <TextView
- android:id="@+id/weather_specific_rain"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_rain"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Rain Value-->
- <TextView
- android:id="@+id/weather_specific_rain_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1.24"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Rain Units -->
- <TextView
- android:id="@+id/weather_specific_rain_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" mm 3h"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
-
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
-
- <!-- Wind -->
- <TextView
- android:id="@+id/weather_specific_wind"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_wind"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Wind Value-->
- <TextView
- android:id="@+id/weather_specific_wind_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Wind Units -->
- <TextView
- android:id="@+id/weather_specific_wind_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" m/s"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Clouds -->
- <TextView
- android:id="@+id/weather_specific_clouds"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_clouds"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Clouds Value-->
- <TextView
- android:id="@+id/weather_specific_clouds_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="end"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Clouds Units -->
- <TextView
- android:id="@+id/weather_specific_clouds_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <!-- Pressure -->
- <TextView
- android:id="@+id/weather_specific_pressure"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_pressure"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Pressure Value-->
- <TextView
- android:id="@+id/weather_specific_pressure_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1036.05"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Pressure Units-->
- <TextView
- android:id="@+id/weather_specific_pressure_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" hpa"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <HorizontalScrollView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|start"
- android:padding="10dp"
- android:fadingEdge="none"
- android:scrollbars="horizontal|none" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:fadingEdge="none"
- android:orientation="horizontal"
- android:scrollbarAlwaysDrawVerticalTrack="false"
- android:scrollbars="none" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_morn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="MORNING"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_morn_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_day"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="DAY"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_day_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingStart="30dp"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_eve"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="EVENING"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_eve_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="30dp"
- android:orientation="vertical" >
-
- <!-- Time of day -->
- <TextView
- android:id="@+id/weather_specific_night"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="NIGHT"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textAlignment="center"
- android:layout_gravity="top|center"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <!-- Temperature -->
- <TextView
- android:id="@+id/weather_specific_night_temperature"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="55ºC"
- android:textAlignment="center"
- android:layout_gravity="bottom|center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- </HorizontalScrollView>
- </LinearLayout>
-</ScrollView>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:padding="@dimen/widget_margin">
-
- <LinearLayout
- android:id="@+id/weather_appwidget"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="fill"
- android:orientation="horizontal"
- android:baselineAligned="false"
- android:background="@drawable/appwidget_dark_bg">
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:padding="4dp"
- android:orientation="vertical" >
-
- <ImageView
- android:id="@+id/weather_appwidget_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="vertical"
- android:src="@drawable/weather_showers" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:padding="4dp"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_appwidget_temperature_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="12ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_appwidget_temperature_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="5ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="normal" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:orientation="vertical"
- android:padding="4dp" >
-
- <TextView
- android:id="@+id/weather_appwidget_city"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="Morata de Tajuña"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_appwidget_country"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="Spain"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
- </LinearLayout>
-
-
-
-
-
- </LinearLayout>
-</FrameLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <LinearLayout android:id="@+id/weather_appwidget_configure_button_layout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:orientation="horizontal"
- android:gravity="center">
- <Button
- android:id="@+id/weather_appwidget_configure_save_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:textAlignment="center"
- android:onClick="onClickOk"
- android:text="@android:string/ok" />
- </LinearLayout>
-
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_above="@id/weather_appwidget_configure_button_layout">
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/widget_preferences_country"
- android:padding="5dp"
- android:layout_gravity="start" />
-
- <View style="@style/Divider"/>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:padding="30dp">
-
- <Switch android:id="@+id/weather_appwidget_configure_country"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:checked="false"
- android:text="@string/widget_preferences_country_switch_off_summary"
- android:textOff="@string/widget_preferences_country_switch_off"
- android:textOn="@string/widget_preferences_country_switch_on" />
- </LinearLayout>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/widget_preferences_temperature_units"
- android:padding="5dp"
- android:layout_gravity="start" />
-
- <View style="@style/Divider"/>
-
- <Spinner android:id="@+id/weather_appwidget_configure_temperature_units"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="20dp"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:entries="@array/weather_preferences_temperature_human_value"
- android:spinnerMode="dialog" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/widget_preferences_button_refresh"
- android:padding="5dp"
- android:layout_gravity="start" />
-
- <View style="@style/Divider"/>
-
- <GridLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- android:padding="30dp">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/widget_configure_button_refresh_summary"
- android:padding="5dp"
- android:layout_gravity="start" />
-
- <Button android:id="@+id/weather_appwidget_configure_refresh_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:textAlignment="center"
- android:onClick="onClickRefresh"
- android:text="@string/widget_preferences_button_refresh"/>
-
- </GridLayout>
-
- </LinearLayout>
- </ScrollView>
-
-
-
-</RelativeLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:padding="@dimen/widget_margin">
-
- <LinearLayout
- android:id="@+id/weather_appwidget_error"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="fill"
- android:orientation="horizontal"
- android:baselineAligned="false"
- android:background="@drawable/appwidget_dark_bg">
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:padding="4dp"
- android:orientation="vertical" >
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="vertical"
- android:src="@drawable/ic_launcher" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:orientation="vertical"
- android:padding="4dp" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/text_field_remote_error"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
- </LinearLayout>
-
-
-
-
-
- </LinearLayout>
-</FrameLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:padding="4dip"
- android:gravity="center_horizontal"
- android:layout_width="match_parent" android:layout_height="match_parent">
-
- <android.support.v4.view.ViewPager
- android:id="@+id/pager"
- android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1">
- </android.support.v4.view.ViewPager>
-
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="fill"
- android:baselineAligned="false"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:orientation="vertical" >
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="vertical"
- android:src="@drawable/ic_launcher" />
- </LinearLayout>
-
-
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="2"
- android:gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_notification_city"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="Morata de Tajuña"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_notification_country"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="Spain"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_notification_temperature_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="12ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_notification_temperature_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="5ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="normal" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:orientation="vertical" >
-
- <ImageView
- android:id="@+id/weather_notification_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="vertical"
- android:src="@drawable/ic_launcher" />
-
- </LinearLayout>
-
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="horizontal"
- android:src="@drawable/ic_launcher" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application"
- android:textColor="?android:attr/colorForeground"
- android:padding="5dp"
- android:layout_gravity="start" />
- <View style="@style/Divider"
- android:layout_height="2dp"/>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_version"
- android:padding="20dp"
- android:layout_gravity="start" />
- <View style="@style/Divider"/>
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_legal"
- android:padding="20dp"
- android:layout_gravity="start"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground"
- android:onClick="onClickLegalInformation"/>
- <View style="@style/Divider"/>
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_source_code"
- android:padding="20dp"
- android:layout_gravity="start"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground"
- android:onClick="onClickSourceCode"/>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_remote_data"
- android:textColor="?android:attr/colorForeground"
- android:padding="5dp"
- android:layout_gravity="start" />
- <View style="@style/Divider"
- android:layout_height="2dp"/>
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_remote_data_openweathermap"
- android:padding="20dp"
- android:layout_gravity="start"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground"
- android:onClick="onClickRemoteData"/>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_developer"
- android:textColor="?android:attr/colorForeground"
- android:padding="5dp"
- android:layout_gravity="start" />
- <View style="@style/Divider"
- android:layout_height="2dp"/>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_developer_name"
- android:padding="20dp"
- android:layout_gravity="start" />
- <View style="@style/Divider"/>
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/weather_about_application_developer_web"
- android:padding="20dp"
- android:layout_gravity="start"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground"
- android:onClick="onClickMyWeb"/>
- <View style="@style/Divider"/>
- </LinearLayout>
-</ScrollView>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:actionBarNavMode="tabs" >
-
- <ScrollView
- android:id="@+id/weather_current_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center">
-
- <LinearLayout android:id="@+id/weather_current_data_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="fill_vertical|center_horizontal"
- android:orientation="vertical" >
-
- <!-- TODO: http://developer.android.com/guide/topics/manifest/supports-screens-element.html -->
- <!-- TODO: supporting multiple layouts/languages http://developer.android.com/guide/practices/screens_support.html -->
- <!-- TODO: Should I use RelativeLayout for long texts (I18N) and RTL/LTR UI?
- With long texts, many times, text will not fit... The same for WP8 :/ -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="top|center"
- android:padding="50dp"
- android:orientation="horizontal" >
-
- <ImageView
- android:id="@+id/weather_current_picture"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:contentDescription="@string/icon_weather_description"
- android:scaleType="fitCenter"
- android:gravity="center"
- android:layout_gravity="center"
- android:src="@drawable/weather_showers" />
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_current_temp_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="55ºC"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_current_temp_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAlignment="textStart"
- android:paddingEnd="10dp"
- android:paddingStart="20dp"
- android:singleLine="true"
- android:text="25ºC"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="normal" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:padding="25dp"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <TextView
- android:id="@+id/weather_current_description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Light rain"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|fill_horizontal"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
- <!-- Feels like -->
- <TextView
- android:id="@+id/weather_current_feelslike"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:layout_margin="5dp"
- android:gravity="start"
- android:text="@string/text_field_feels_like"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
-
- <!-- Feels like Value-->
- <TextView
- android:id="@+id/weather_current_feelslike_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="83"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Feels like Units-->
- <TextView
- android:id="@+id/weather_current_feelslike_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="ºC"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Snow -->
- <TextView
- android:id="@+id/weather_current_snow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_snow"
- android:gravity="end"
- android:layout_gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Snow Value-->
- <TextView
- android:id="@+id/weather_current_snow_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1.22"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Snow Units -->
- <TextView
- android:id="@+id/weather_current_snow_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" mm 3h"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|fill_horizontal"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
- <!-- Humidity -->
- <TextView
- android:id="@+id/weather_current_humidity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:layout_margin="5dp"
- android:gravity="start"
- android:text="@string/text_field_humidity"
- android:textAlignment="textStart"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
-
- <!-- Humidity Value-->
- <TextView
- android:id="@+id/weather_current_humidity_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="83"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Humidity Units-->
- <TextView
- android:id="@+id/weather_current_humidity_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Rain -->
- <TextView
- android:id="@+id/weather_current_rain"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_rain"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Rain Value-->
- <TextView
- android:id="@+id/weather_current_rain_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1.24"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Rain Units -->
- <TextView
- android:id="@+id/weather_current_rain_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" mm 3h"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
-
- <LinearLayout
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top|fill_horizontal"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="horizontal" >
- <!-- Wind -->
- <TextView
- android:id="@+id/weather_current_wind"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_wind"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Wind Value-->
- <TextView
- android:id="@+id/weather_current_wind_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Wind Units -->
- <TextView
- android:id="@+id/weather_current_wind_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" m/s"
- android:layout_gravity="start"
- android:gravity="start"
- android:textAlignment="textStart"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="horizontal" >
- <!-- Clouds -->
- <TextView
- android:id="@+id/weather_current_clouds"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_clouds"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Clouds Value-->
- <TextView
- android:id="@+id/weather_current_clouds_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="6.36"
- android:layout_gravity="end"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Clouds Units -->
- <TextView
- android:id="@+id/weather_current_clouds_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="%"
- android:layout_gravity="end"
- android:gravity="end"
- android:textAlignment="textEnd"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <!-- Pressure -->
- <TextView
- android:id="@+id/weather_current_pressure"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_pressure"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Pressure Value-->
- <TextView
- android:id="@+id/weather_current_pressure_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1036.05"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- <!-- Pressure Units-->
- <TextView
- android:id="@+id/weather_current_pressure_units"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text=" hpa"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:layout_marginEnd="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <!-- Sun rise -->
- <TextView
- android:id="@+id/weather_current_sunrise"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_sun_rise"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Sun rise Value-->
- <TextView
- android:id="@+id/weather_current_sunrise_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="2014.04.20 10:29:33"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="top|center"
- android:orientation="horizontal" >
-
- <!-- Sun rise -->
- <TextView
- android:id="@+id/weather_current_sunset"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/text_field_sun_set"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:textColor="@color/weather_time_of_day_color_title"
- android:layout_margin="5dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textStyle="bold" />
-
- <!-- Sun rise Value-->
- <TextView
- android:id="@+id/weather_current_sunset_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="2014.04.20 10:29:33"
- android:layout_gravity="center"
- android:gravity="center"
- android:textAlignment="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="5dp"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
- </LinearLayout>
- </LinearLayout>
- </ScrollView>
-
- <ProgressBar
- android:id="@+id/weather_current_progressbar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:visibility="gone"
- style="?android:attr/progressBarStyleLarge" />
-
- <TextView
- android:id="@+id/weather_current_error_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="@string/text_field_remote_error"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:visibility="gone" />
-
-</FrameLayout>
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <WebView android:id="@+id/weather_licenses"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- </WebView>
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:baselineAligned="false"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center_horizontal"
- android:orientation="horizontal"
- android:padding="5dp" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="match_parent"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_main_entry_date_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="SUN"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_main_entry_date_number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="APR 23"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="normal" />
-
- </LinearLayout>
-
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="match_parent"
- android:gravity="center"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/weather_main_entry_temperature_max"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="12ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/weather_main_entry_temperature_min"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="5ºC"
- android:textAlignment="center"
- android:textAllCaps="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/weather_time_of_day_color_title"
- android:textStyle="normal" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical" >
-
- <ImageView
- android:id="@+id/weather_main_entry_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:contentDescription="@string/icon_weather_description"
- android:orientation="vertical"
- android:src="@drawable/ic_launcher" />
-
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/weather_map"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- tools:context="name.gumartinm.weather.information.activity.MapActivity" >
-
- <LinearLayout
- android:id="@+id/weather_map_citycountry_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentStart="true" >
- <LinearLayout
- android:id="@+id/weather_map_city_container"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_gravity="center"
- android:gravity="center"
- android:layout_height="wrap_content">
- <TextView
- android:id="@+id/weather_map_city"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="City"
- android:layout_gravity="center"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textIsSelectable="false"
- android:textStyle="bold|normal" />
- </LinearLayout>
-
- <ProgressBar
- android:id="@+id/weather_map_progress"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:indeterminateBehavior="repeat"
- android:indeterminateDuration="3500"
- android:indeterminateOnly="true"
- android:visibility="gone" />
-
- <LinearLayout
- android:id="@+id/weather_map_country_container"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_gravity="center"
- android:gravity="center"
- android:layout_height="wrap_content" >
- <TextView
- android:id="@+id/weather_map_country"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Country"
- android:layout_gravity="center"
- android:textAlignment="center"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textIsSelectable="false"
- android:textStyle="bold|normal" />
- </LinearLayout>
- </LinearLayout>
-
- <fragment
- android:id="@+id/weather_map_fragment_map"
- android:name="com.google.android.gms.maps.MapFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@+id/weather_map_citycountry_container"
- android:layout_above="@+id/weather_map_buttons_container" />
-
- <LinearLayout
- android:id="@+id/weather_map_buttons_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentStart="true"
- android:orientation="horizontal"
- android:baselineAligned="false" >
- </LinearLayout>
-
-</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- android:baselineAligned="false" >
-
- <LinearLayout
- android:id="@+id/weather_map_button_savelocation_container"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_gravity="center"
- android:gravity="center"
- android:layout_height="wrap_content">
- <Button
- android:id="@+id/weather_map_button_savelocation"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:onClick="onClickSaveLocation"
- android:textAlignment="center"
- android:text="@string/weather_map_button_savelocation" />
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/weather_map_button_getlocation_container"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_gravity="center"
- android:gravity="center"
- android:layout_height="wrap_content" >
- <Button
- android:id="@+id/weather_map_button_getlocation"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:onClick="onClickGetLocation"
- android:textAlignment="center"
- android:enabled="false"
- android:text="@string/weather_map_button_getlocation" />
- </LinearLayout>
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
-
- <ProgressBar
- android:id="@+id/weather_map_progressbar"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:indeterminateBehavior="repeat"
- android:indeterminateDuration="3500"
- android:indeterminateOnly="true"
- android:visibility="visible" />
-
-</LinearLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/weather_specific"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:orientation="vertical"
- tools:context="name.gumartinm.weather.information.activity.SpecificActivity"
- tools:ignore="MergeRootFrame" >
-
-
- <fragment
- android:id="@+id/specific_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:layout="@layout/weather_specific_fragment"
- class="name.gumartinm.weather.information.fragment.specific.SpecificFragment" />
-
-</LinearLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
-
- <item android:id="@+id/weather_menu_settings"
- android:menuCategory="system"
- android:title="@string/weather_preferences_action_settings"
- android:titleCondensed="@string/weather_preferences_action_settings"
- android:checked="false"
- android:visible="true"
- android:checkable="false"
- android:enabled="true"
- android:icon="@drawable/ic_action_settings"
- android:showAsAction="ifRoom">
- </item>
- <item android:id="@+id/weather_menu_map"
- android:icon="@drawable/ic_action_map"
- android:showAsAction="ifRoom"
- android:visible="true"
- android:checkable="false"
- android:enabled="true"
- android:checked="false"
- android:title="@string/weather_map_action_map"
- android:titleCondensed="@string/weather_map_action_map">
- </item>
- <item android:id="@+id/weather_menu_about"
- android:showAsAction="never"
- android:visible="true"
- android:checkable="false"
- android:enabled="true"
- android:checked="false"
- android:orderInCategory="100"
- android:title="@string/weather_about_action"
- android:titleCondensed="@string/weather_about_action">
- </item>
-
-</menu>
+++ /dev/null
-<html>
-<head><meta charset="UTF-8"></head>
-<body>
-<h2>Notices for files:</h2>
-
-<ul>
- <li><a href="http://wiki.fasterxml.com/JacksonHome">jackson-core-2.3.3.jar</a></li>
-</ul>
-<a href="http://wiki.fasterxml.com/JacksonHome">http://wiki.fasterxml.com/JacksonHome</a>
-<pre style="background-color: #eeeeee; white-space: pre-wrap;">
-This copy of Jackson JSON processor streaming parser/generator is licensed under the
-Apache (Software) License, version 2.0 ("the License").
-See the License for details about distribution rights, and the
-specific rights regarding derivate works.
-
-You may obtain a copy of the License at:
-
-http://www.apache.org/licenses/LICENSE-2.0
-</pre>
-
-<ul>
- <li>weather-clear-night-symbolic.svg</li>
- <li>weather-clear-symbolic.svg</li>
- <li>weather-few-clouds-night-symbolic.svg</li>
- <li>weather-few-clouds-symbolic.svg</li>
- <li>weather-fog-symbolic.svg</li>
- <li>weather-overcast-symbolic.svg</li>
- <li>weather-severe-alert-symbolic.svg</li>
- <li>weather-showers-symbolic.svg</li>
- <li>weather_showers_scattered-symbolic.svg</li>
- <li>weather-snow-symbolic.svg</li>
- <li>weather-storm-symbolic.svg</li>
-</ul>
-<a href="http://www.gnome.org">GNOME Project</a>
-<br>
-<a href="https://github.com/GNOME/gnome-icon-theme-symbolic">https://github.com/GNOME/gnome-icon-theme-symbolic</a>
-<pre style="background-color: #eeeeee; white-space: pre-wrap;">
-This work is licenced under the Creative Commons Attribution-Share Alike 3.0
-United States License. To view a copy of this licence, visit
-http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
-Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
-
-When attributing the artwork, using "GNOME Project" is enough.
-Please link to http://www.gnome.org where available.
-</pre>
-
-<ul>
- <li>Consts.java</li>
- <li>ContentType.java</li>
-</ul>
-<a href="http://hc.apache.org/httpclient-3.x/license.html">http://hc.apache.org/httpclient-3.x/license.html</a>
-<pre style="background-color: #eeeeee; white-space: pre-wrap;">
-Apache HttpComponents Client
-Copyright 1999-2014 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
- 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
-</pre>
-
-<ul>
- <li>appwidget_dark_bg.9.png</li>
-</ul>
-<a href="http://developer.android.com/shareables/app_widget_templates-v4.0.zip">http://developer.android.com/shareables/app_widget_templates-v4.0.zip</a>
-<pre style="background-color: #eeeeee; white-space: pre-wrap;">
- Copyright (c) 2005-2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- 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.
-
-
- 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
-</pre>
-
-<ul>
- <li>Google Play Services</li>
-</ul>
-<a href="https://developer.android.com/google/play-services/index.html">https://developer.android.com/google/play-services/index.html</a>
-<pre style="background-color: #eeeeee; white-space: pre-wrap;">
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!--
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
- <!-- API 11 theme customizations can go here. -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
- <style name="Divider">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">1dp</item>
- <item name="android:layout_marginStart">20dp</item>
- <item name="android:layout_marginEnd">20dp</item>
- <item name="android:background">?android:attr/listDivider</item>
- </style>
-
- <color name="weather_time_of_day_color_title">#48aed4</color>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
- <dimen name="widget_margin">0dp</dimen>
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!--
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
- <!-- API 14 theme customizations can go here. -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
- <style name="Divider">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">1dp</item>
- <item name="android:layout_marginStart">20dp</item>
- <item name="android:layout_marginEnd">20dp</item>
- <item name="android:background">?android:attr/listDivider</item>
- </style>
-
- <color name="weather_time_of_day_color_title">#48aed4</color>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!--
- Example customization of dimensions originally defined in res/values/dimens.xml
- (such as screen margins) for screens with more than 820dp of available width. This
- would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
- -->
- <dimen name="activity_horizontal_margin">64dp</dimen>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
- <string-array name="weather_preferences_day_forecast">
- <item>5</item>
- <item>10</item>
- <item>14</item>
- </string-array>
- <string-array name="weather_preferences_day_forecast_human_value">
- <item>5 day forecast</item>
- <item>10 day forecast</item>
- <item>14 day forecast</item>
- </string-array>
- <string-array name="weather_preferences_update_time_rate">
- <item>900</item>
- <item>1800</item>
- <item>3600</item>
- <item>43200</item>
- <item>86400</item>
- </string-array>
- <string-array name="weather_preferences_update_time_rate_human_value">
- <item>fifteen minutes</item>
- <item>half hour</item>
- <item>one hour</item>
- <item>half day</item>
- <item>one day</item>
- </string-array>
- <string-array name="weather_preferences_refresh_interval">
- <item>300000</item>
- <item>900000</item>
- <item>1800000</item>
- <item>3600000</item>
- <item>7200000</item>
- <item>43200000</item>
- <item>86400000</item>
- </string-array>
- <string-array name="weather_preferences_refresh_interval_human_value">
- <item>five minutes</item>
- <item>fifteen minutes</item>
- <item>half hour</item>
- <item>one hour</item>
- <item>two hours</item>
- <item>half day</item>
- <item>one day</item>
- </string-array>
- <string-array name="weather_preferences_temperature">
- <item>@string/weather_preferences_temperature_celsius</item>
- <item>@string/weather_preferences_temperature_fahrenheit</item>
- <item>@string/weather_preferences_temperature_kelvin</item>
- </string-array>
- <string-array name="weather_preferences_temperature_human_value">
- <item>@string/weather_preferences_temperature_celsius_human_value</item>
- <item>@string/weather_preferences_temperature_fahrenheit_human_value</item>
- <item>@string/weather_preferences_temperature_kelvin_human_value</item>
- </string-array>
- <string-array name="weather_preferences_wind">
- <item>@string/weather_preferences_wind_meters</item>
- <item>@string/weather_preferences_wind_miles</item>
- </string-array>
- <string-array name="weather_preferences_wind_human_value">
- <item>@string/weather_preferences_wind_human_value_meters</item>
- <item>@string/weather_preferences_wind_human_value_miles</item>
- </string-array>
- <string-array name="weather_preferences_pressure">
- <item>@string/weather_preferences_pressure_pascal</item>
- <item>@string/weather_preferences_pressure_standard_atm</item>
- </string-array>
- <string-array name="weather_preferences_pressure_human_value">
- <item>@string/weather_preferences_pressure_human_value_pascal</item>
- <item>@string/weather_preferences_pressure_human_value_standard_atm</item>
- </string-array>
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
- <dimen name="widget_margin">8dp</dimen>
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <string name="app_name">Weather Information</string>
- <string name="icon_weather_description">Icon weather</string>
-
- <!-- Activities Current, Overview and Specific< -->
- <string name="text_tab_five_days_forecast">5 DAY FORECAST</string>
- <string name="text_tab_ten_days_forecast">10 DAY FORECAST</string>
- <string name="text_tab_fourteen_days_forecast">14 DAY FORECAST</string>
- <string name="text_field_sun_rise">SUN RISE</string>
- <string name="text_field_sun_set">SUN SET</string>
- <string name="text_field_feels_like">FEELS LIKE</string>
- <string name="text_field_clouds">CLOUDS</string>
- <string name="text_field_rain">RAIN</string>
- <string name="text_field_wind">WIND</string>
- <string name="text_field_snow">SNOW</string>
- <string name="text_field_pressure">PRESSURE</string>
- <string name="text_field_humidity">HUMIDITY</string>
- <string name="text_units_mm3h">mm 3h</string>
- <string name="text_units_percent">%</string>
- <string name="text_field_remote_error">No data available</string>
- <string name="text_field_description_when_error">no description available</string>
- <string name="text_field_no_chosen_location">no chosen location</string>
-
- <!-- Preferences Acitivity -->
- <string name="weather_preferences_action_settings">Settings</string>
- <string name="weather_preferences_units">Units</string>
- <string name="weather_preferences_temperature_key">weather_preferences_temperature</string>
- <string name="weather_preferences_temperature">Temperature</string>
- <string name="weather_preferences_temperature_celsius">ºC</string>
- <string name="weather_preferences_temperature_fahrenheit">ºF</string>
- <string name="weather_preferences_temperature_kelvin">K</string>
- <string name="weather_preferences_temperature_celsius_human_value">celsius</string>
- <string name="weather_preferences_temperature_fahrenheit_human_value">fahrenheit</string>
- <string name="weather_preferences_temperature_kelvin_human_value">kelvin</string>
- <string name="weather_preferences_notifications">Notifications</string>
- <string name="weather_preferences_notifications_switch_off_summary">Disabled</string>
- <string name="weather_preferences_notifications_switch_on_summary">Enabled</string>
- <string name="weather_preferences_notifications_switch_off">OFF</string>
- <string name="weather_preferences_notifications_switch_on">ON</string>
- <string name="weather_preferences_notifications_switch_key">weather_preferences_notifications_switch</string>
- <string name="weather_preferences_update_time_rate_key">weather_preferences_update_time_rate</string>
- <string name="weather_preferences_update_time_rate">Update time rate</string>
- <string name="weather_preferences_notifications_temperature_key">weather_preferences_notifications_temperature</string>
- <string name="weather_preferences_notifications_temperature">Temperature</string>
- <string name="weather_preferences_day_forecast_key">weather_preferences_day_forecast</string>
- <string name="weather_preferences_day_forecast">Forecast days number</string>
- <string name="weather_preferences_refresh_interval_key">weather_preferences_refresh_interval</string>
- <string name="weather_preferences_refresh_interval">Refresh interval</string>
- <string name="weather_preferences_wind_key">weather_preferences_wind</string>
- <string name="weather_preferences_wind">Wind</string>
- <string name="weather_preferences_wind_meters">m/s</string>
- <string name="weather_preferences_wind_miles">mph</string>
- <string name="weather_preferences_wind_human_value_meters">meter per second</string>
- <string name="weather_preferences_wind_human_value_miles">miles per hour</string>
- <string name="weather_preferences_pressure_key">weather_preferences_pressure</string>
- <string name="weather_preferences_pressure">Pressure</string>
- <string name="weather_preferences_pressure_pascal">hpa</string>
- <string name="weather_preferences_pressure_standard_atm">atm</string>
- <string name="weather_preferences_pressure_human_value_pascal">pascal</string>
- <string name="weather_preferences_pressure_human_value_standard_atm">standard atmosphere</string>
-
- <!-- Widget Preferences Activity -->
- <string name="widget_preferences_action_settings">Settings</string>
- <string name="widget_preferences_button_refresh">Refresh</string>
- <string name="widget_configure_button_refresh_summary">Refresh values</string>
- <string name="widget_preferences_temperature_units">Temperature units</string>
- <string name="widget_preferences_temperature_units_key">widget_preferences_temperature</string>
- <string name="widget_preferences_country">Country</string>
- <string name="widget_preferences_country_switch_key">widget_preferences_country_switch</string>
- <string name="widget_preferences_country_switch_off_summary">Hide country</string>
- <string name="widget_preferences_country_switch_on_summary">Show country</string>
- <string name="widget_preferences_country_switch_off">OFF</string>
- <string name="widget_preferences_country_switch_on">ON</string>
-
- <!-- Map Activity -->
- <string name="weather_map_action_map">Select Location</string>
- <string name="city_not_found">city not found</string>
- <string name="country_not_found">country not found</string>
- <string name="progress_dialog_generic_message">Please wait…</string>
- <string name="weather_map_button_savelocation">Save Location</string>
- <string name="weather_map_button_getlocation">Get Location</string>
- <string name="weather_map_not_enabled_location">You do not have enabled location.</string>
- <string name="weather_map_no_geocoder_available">Cannot get address. No geocoder available.</string>
- <string name="weather_map_mark_location">Mark your location</string>
-
- <!-- About Activity -->
- <string name="title_activity_about">About</string>
- <string name="weather_about_action">About</string>
- <string name="weather_about_application">APPLICATION</string>
- <string name="weather_about_application_version">Version 1.0</string>
- <string name="weather_about_application_legal">Legal information</string>
- <string name="weather_about_application_source_code">Source code</string>
- <string name="weather_about_application_remote_data">WEATHER DATA</string>
- <string name="weather_about_application_remote_data_openweathermap">OpenWeatherMap</string>
- <string name="weather_about_application_developer">DEVELOPER</string>
- <string name="weather_about_application_developer_name">Gustavo Martin Morcuende</string>
- <string name="weather_about_application_developer_web">Web</string>
-
- <!-- Licenses Activity -->
- <string name="weather_licenses_title">Licenses</string>
-
- <!-- DO NOT TRANSLATE -->
- <string name="uri_api_weather_today">http://api.openweathermap.org/data/{0}/weather?lat={1}&lon={2}&cnt=1</string>
- <string name="uri_api_weather_forecast">http://api.openweathermap.org/data/{0}/forecast/daily?lat={1}&lon={2}&cnt={3}&mode=json</string>
- <string name="api_version">2.5</string>
- <string name="application_source_code_url">https://github.com/gumartinm/JavaForFun/tree/master/Android/WeatherInformation</string>
- <string name="my_url">http://gumartinm.name</string>
- <string name="openweathermap_url">http://openweathermap.org/</string>
- <string name="http_client_agent">Android WeatherInformation Agent</string>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
- <style name="Divider">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">1dp</item>
- <item name="android:layout_marginStart">20dp</item>
- <item name="android:layout_marginEnd">20dp</item>
- <item name="android:background">?android:attr/listDivider</item>
- </style>
-
- <color name="weather_time_of_day_color_title">#48aed4</color>
-
-</resources>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
- android:minWidth="180dp"
- android:minHeight="40dp"
- android:minResizeWidth="180dp"
- android:minResizeHeight="40dp"
- android:resizeMode="none"
- android:previewImage="@drawable/ic_launcher"
- android:initialLayout="@layout/appwidget_error"
- android:configure="name.gumartinm.weather.information.widget.WidgetConfigure"
- android:widgetCategory="home_screen|keyguard"
- android:updatePeriodMillis="3600000">
-</appwidget-provider>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2014 Gustavo Martin Morcuende
-
- 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.
--->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
- <ListPreference android:key="@string/weather_preferences_day_forecast_key"
- android:title="@string/weather_preferences_day_forecast"
- android:entries="@array/weather_preferences_day_forecast_human_value"
- android:entryValues="@array/weather_preferences_day_forecast"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="14"
- android:summary="14 day forecast" />
- <ListPreference android:key="@string/weather_preferences_refresh_interval_key"
- android:title="@string/weather_preferences_refresh_interval"
- android:entries="@array/weather_preferences_refresh_interval_human_value"
- android:entryValues="@array/weather_preferences_refresh_interval"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="300000"
- android:summary="five minutes" />
- <PreferenceCategory android:title="@string/weather_preferences_units">
- <ListPreference android:key="@string/weather_preferences_temperature_key"
- android:title="@string/weather_preferences_temperature"
- android:summary="@string/weather_preferences_temperature_celsius_human_value"
- android:entries="@array/weather_preferences_temperature_human_value"
- android:entryValues="@array/weather_preferences_temperature"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="@string/weather_preferences_temperature_celsius" />
- <ListPreference android:key="@string/weather_preferences_wind_key"
- android:entryValues="@array/weather_preferences_wind"
- android:entries="@array/weather_preferences_wind_human_value"
- android:summary="@string/weather_preferences_wind_human_value_meters"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="@string/weather_preferences_wind_meters"
- android:title="@string/weather_preferences_wind"/>
- <ListPreference android:key="@string/weather_preferences_pressure_key"
- android:entryValues="@array/weather_preferences_pressure"
- android:entries="@array/weather_preferences_pressure_human_value"
- android:summary="@string/weather_preferences_pressure_human_value_pascal"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="@string/weather_preferences_pressure_pascal"
- android:title="@string/weather_preferences_pressure"/>
- </PreferenceCategory>
- <PreferenceCategory android:title="@string/weather_preferences_notifications">
- <SwitchPreference android:key="@string/weather_preferences_notifications_switch_key"
- android:summaryOn="@string/weather_preferences_notifications_switch_on_summary"
- android:summaryOff="@string/weather_preferences_notifications_switch_off_summary"
- android:switchTextOff="@string/weather_preferences_notifications_switch_off"
- android:switchTextOn="@string/weather_preferences_notifications_switch_on"
- android:selectable="true"
- android:enabled="true"
- android:defaultValue="@string/weather_preferences_notifications_switch_off"
- android:disableDependentsState="false"
- android:persistent="true"/>
- <ListPreference android:key="@string/weather_preferences_update_time_rate_key"
- android:entries="@array/weather_preferences_update_time_rate_human_value"
- android:entryValues="@array/weather_preferences_update_time_rate"
- android:title="@string/weather_preferences_update_time_rate"
- android:defaultValue="900"
- android:persistent="true"
- android:selectable="true"
- android:summary="fifteen minutes"
- android:dependency="@string/weather_preferences_notifications_switch_key"/>
- <ListPreference android:key="@string/weather_preferences_notifications_temperature_key"
- android:title="@string/weather_preferences_notifications_temperature"
- android:summary="@string/weather_preferences_temperature_celsius_human_value"
- android:entries="@array/weather_preferences_temperature_human_value"
- android:entryValues="@array/weather_preferences_temperature"
- android:selectable="true"
- android:persistent="true"
- android:defaultValue="@string/weather_preferences_temperature_celsius"
- android:dependency="@string/weather_preferences_notifications_switch_key"/>
- </PreferenceCategory>
-</PreferenceScreen>
+++ /dev/null
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.12.2'
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- }
-}
+++ /dev/null
-#Wed Apr 10 15:27:10 PDT 2013
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
+++ /dev/null
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+++ /dev/null
-@if "%DEBUG%" == "" @echo off\r
-@rem ##########################################################################\r
-@rem\r
-@rem Gradle startup script for Windows\r
-@rem\r
-@rem ##########################################################################\r
-\r
-@rem Set local scope for the variables with windows NT shell\r
-if "%OS%"=="Windows_NT" setlocal\r
-\r
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r
-set DEFAULT_JVM_OPTS=\r
-\r
-set DIRNAME=%~dp0\r
-if "%DIRNAME%" == "" set DIRNAME=.\r
-set APP_BASE_NAME=%~n0\r
-set APP_HOME=%DIRNAME%\r
-\r
-@rem Find java.exe\r
-if defined JAVA_HOME goto findJavaFromJavaHome\r
-\r
-set JAVA_EXE=java.exe\r
-%JAVA_EXE% -version >NUL 2>&1\r
-if "%ERRORLEVEL%" == "0" goto init\r
-\r
-echo.\r
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r
-echo.\r
-echo Please set the JAVA_HOME variable in your environment to match the\r
-echo location of your Java installation.\r
-\r
-goto fail\r
-\r
-:findJavaFromJavaHome\r
-set JAVA_HOME=%JAVA_HOME:"=%\r
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe\r
-\r
-if exist "%JAVA_EXE%" goto init\r
-\r
-echo.\r
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r
-echo.\r
-echo Please set the JAVA_HOME variable in your environment to match the\r
-echo location of your Java installation.\r
-\r
-goto fail\r
-\r
-:init\r
-@rem Get command-line arguments, handling Windowz variants\r
-\r
-if not "%OS%" == "Windows_NT" goto win9xME_args\r
-if "%@eval[2+2]" == "4" goto 4NT_args\r
-\r
-:win9xME_args\r
-@rem Slurp the command line arguments.\r
-set CMD_LINE_ARGS=\r
-set _SKIP=2\r
-\r
-:win9xME_args_slurp\r
-if "x%~1" == "x" goto execute\r
-\r
-set CMD_LINE_ARGS=%*\r
-goto execute\r
-\r
-:4NT_args\r
-@rem Get arguments from the 4NT Shell from JP Software\r
-set CMD_LINE_ARGS=%$\r
-\r
-:execute\r
-@rem Setup the command line\r
-\r
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar\r
-\r
-@rem Execute Gradle\r
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r
-\r
-:end\r
-@rem End local scope for the variables with windows NT shell\r
-if "%ERRORLEVEL%"=="0" goto mainEnd\r
-\r
-:fail\r
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r
-rem the _cmd.exe /c_ return code!\r
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1\r
-exit /b 1\r
-\r
-:mainEnd\r
-if "%OS%"=="Windows_NT" endlocal\r
-\r
-:omega\r
+++ /dev/null
-ECLIPSE ANDROID PROJECT IMPORT SUMMARY
-======================================
-
-Manifest Merging:
------------------
-Your project uses libraries that provide manifests, and your Eclipse
-project did not explicitly turn on manifest merging. In Android Gradle
-projects, manifests are always merged (meaning that contents from your
-libraries' manifests will be merged into the app manifest. If you had
-manually copied contents from library manifests into your app manifest
-you may need to remove these for the app to build correctly.
-
-Ignored Files:
---------------
-The following files were *not* copied into the new Gradle project; you
-should evaluate whether these are still needed in your project and if
-so manually move them:
-
-* ic_launcher-web.png
-* proguard-project.txt
-* tests/
-* tests/gen/
-* tests/gen/de/
-* tests/gen/de/example/
-* tests/gen/de/example/exampletdd/
-* tests/gen/de/example/exampletdd/test/
-* tests/gen/de/example/exampletdd/test/BuildConfig.java
-* tests/gen/de/example/exampletdd/test/R.java
-* tests/proguard-project.txt
-* tests/project.properties
-
-Replaced Jars with Dependencies:
---------------------------------
-The importer recognized the following .jar files as third party
-libraries and replaced them with Gradle dependencies instead. This has
-the advantage that more explicit version information is known, and the
-libraries can be updated automatically. However, it is possible that
-the .jar file in your project was of an older version than the
-dependency we picked, which could render the project not compileable.
-You can disable the jar replacement in the import wizard and try again:
-
-android-support-v4.jar => com.android.support:support-v4:+
-
-Replaced Libraries with Dependencies:
--------------------------------------
-The importer recognized the following library projects as third party
-libraries and replaced them with Gradle dependencies instead. This has
-the advantage that more explicit version information is known, and the
-libraries can be updated automatically. However, it is possible that
-the source files in your project were of an older version than the
-dependency we picked, which could render the project not compileable.
-You can disable the library replacement in the import wizard and try
-again:
-
-google-play-services_lib => [com.google.android.gms:play-services:+]
-
-Moved Files:
-------------
-Android Gradle projects use a different directory structure than ADT
-Eclipse projects. Here's how the projects were restructured:
-
-* AndroidManifest.xml => app/src/main/AndroidManifest.xml
-* libs/jackson-core-2.3.3.jar => app/libs/jackson-core-2.3.3.jar
-* lint.xml => app/lint.xml
-* res/ => app/src/main/res/
-* src/ => app/src/main/java/
-* tests/res/ => app/src/androidTest/res/
-* tests/src/ => app/src/androidTest/java/
-
-Next Steps:
------------
-You can now build the project. The Gradle project needs network
-connectivity to download dependencies.
-
-Bugs:
------
-If for some reason your project does not build, and you determine that
-it is due to a bug or limitation of the Eclipse to Gradle importer,
-please file a bug at http://b.android.com with category
-Component-Tools.
-
-(This import summary is for your information only, and can be deleted
-after import once you are satisfied with the results.)
+++ /dev/null
-include ':app'