← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ahayzen/ubuntu-weather-app/reboot-fix-ap-location-detect into lp:ubuntu-weather-app/reboot

 

Andrew Hayzen has proposed merging lp:~ahayzen/ubuntu-weather-app/reboot-fix-ap-location-detect into lp:ubuntu-weather-app/reboot.

Commit message:
* Add auto detect location option in the settings
* Set auto detect location to false when running autopilot

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)

For more details, see:
https://code.launchpad.net/~ahayzen/ubuntu-weather-app/reboot-fix-ap-location-detect/+merge/265908

* Add auto detect location option in the settings
* Set auto detect location to false when running autopilot
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~ahayzen/ubuntu-weather-app/reboot-fix-ap-location-detect into lp:ubuntu-weather-app/reboot.
=== modified file 'app/components/CurrentLocation.qml'
--- app/components/CurrentLocation.qml	2015-06-18 01:42:03 +0000
+++ app/components/CurrentLocation.qml	2015-07-26 15:05:37 +0000
@@ -41,7 +41,7 @@
     }
 
     function searchResponseHandler(msgObject) {
-        if (!msgObject.error) {
+        if (!msgObject.error && settings.autoDetectLocation) {
             console.log("Loc to add:", JSON.stringify(msgObject.result.locations[0]))
             storage.updateCurrentLocation(msgObject.result.locations[0])
         }
@@ -51,7 +51,7 @@
     PositionSource {
         id: currentPosition
         updateInterval: 1000
-        active: true
+        active: settings.autoDetectLocation
 
         onPositionChanged: {
             var coord = currentPosition.position.coordinate

=== modified file 'app/ubuntu-weather-app.qml'
--- app/ubuntu-weather-app.qml	2015-07-25 22:06:50 +0000
+++ app/ubuntu-weather-app.qml	2015-07-26 15:05:37 +0000
@@ -91,6 +91,11 @@
     /* Fill the location pages with their data. */
     function fillPages(locations) {
         locationsList = []
+
+        if (settings.addedCurrentLocation && !settings.autoDetectLocation) {
+            locations.splice(0, 1);
+        }
+
         locationsList = locations;
     }
 
@@ -132,6 +137,7 @@
         */
         property int current: 0
 
+        property bool autoDetectLocation: true
         property int refreshInterval: 1800
         property string precipUnits
         property string service

=== modified file 'app/ui/LocationsPage.qml'
--- app/ui/LocationsPage.qml	2015-06-28 19:04:43 +0000
+++ app/ui/LocationsPage.qml	2015-07-26 15:05:37 +0000
@@ -72,7 +72,7 @@
                 left: parent.left
                 right: parent.right
             }
-            height: settings.addedCurrentLocation ? units.gu(8) : units.gu(0)
+            height: settings.addedCurrentLocation && settings.autoDetectLocation ? units.gu(8) : units.gu(0)
             interactive: false
             model: currentLocationModel
             delegate: WeatherListItem {
@@ -262,7 +262,7 @@
                 "icon": iconMap[data.data[0].current.icon]
             }
 
-            if (!settings.addedCurrentLocation || i > 0) {
+            if (!settings.addedCurrentLocation || i > 0 || !settings.autoDetectLocation) {
                 locationsModel.append(loc)
             } else {
                 currentLocationModel.append(loc)

=== modified file 'app/ui/SettingsPage.qml'
--- app/ui/SettingsPage.qml	2015-06-28 22:54:14 +0000
+++ app/ui/SettingsPage.qml	2015-07-26 15:05:37 +0000
@@ -42,5 +42,10 @@
             title: i18n.tr("Refresh Interval")
             onClicked: mainPageStack.push(Qt.resolvedUrl("settings/RefreshIntervalPage.qml"))
         }
+
+        StandardListItem {
+            title: i18n.tr("Privacy")
+            onClicked: mainPageStack.push(Qt.resolvedUrl("settings/PrivacyPage.qml"))
+        }
     }
 }

=== added file 'app/ui/settings/PrivacyPage.qml'
--- app/ui/settings/PrivacyPage.qml	1970-01-01 00:00:00 +0000
+++ app/ui/settings/PrivacyPage.qml	2015-07-26 15:05:37 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Weather App
+ *
+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Weather App is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import Ubuntu.Components 1.2
+import Ubuntu.Components.ListItems 1.0 as ListItem
+
+Page {
+    title: i18n.tr("Privacy")
+
+    ListItem.Standard {
+        control: CheckBox {
+            checked: settings.autoDetectLocation
+
+            onClicked: {
+                settings.autoDetectLocation = checked;
+                refreshData(false, true);
+            }
+        }
+        text: i18n.tr("Auto detect location")
+    }
+}

=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot	2015-07-18 19:08:21 +0000
+++ po/com.ubuntu.weather.pot	2015-07-26 15:05:37 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: ubuntu-weather-app\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-07-18 18:04+0100\n"
+"POT-Creation-Date: 2015-07-26 16:04+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -18,31 +18,31 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
-#: ../app/components/DayDelegate.qml:193
+#: ../app/components/DayDelegate.qml:199
 msgid "Chance of rain"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:202
+#: ../app/components/DayDelegate.qml:205
 msgid "Winds"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:209
+#: ../app/components/DayDelegate.qml:212
 msgid "UV Index"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:214
+#: ../app/components/DayDelegate.qml:217
 msgid "Pollen"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:220
+#: ../app/components/DayDelegate.qml:223
 msgid "Humidity"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:226
+#: ../app/components/DayDelegate.qml:229
 msgid "Sunrise"
 msgstr ""
 
-#: ../app/components/DayDelegate.qml:232
+#: ../app/components/DayDelegate.qml:235
 msgid "Sunset"
 msgstr ""
 
@@ -66,11 +66,11 @@
 msgid "Cancel selection"
 msgstr ""
 
-#: ../app/ubuntu-weather-app.qml:168
+#: ../app/ubuntu-weather-app.qml:178
 msgid "Searching for current location..."
 msgstr ""
 
-#: ../app/ubuntu-weather-app.qml:177
+#: ../app/ubuntu-weather-app.qml:187
 msgid "Add a manual location"
 msgstr ""
 
@@ -122,7 +122,7 @@
 msgid "Units"
 msgstr ""
 
-#: ../app/ui/SettingsPage.qml:37 ../app/ui/settings/DataProviderPage.qml:24
+#: ../app/ui/SettingsPage.qml:37 ../app/ui/settings/DataProviderPage.qml:25
 msgid "Data Provider"
 msgstr ""
 
@@ -130,10 +130,18 @@
 msgid "Refresh Interval"
 msgstr ""
 
+#: ../app/ui/SettingsPage.qml:47 ../app/ui/settings/PrivacyPage.qml:24
+msgid "Privacy"
+msgstr ""
+
 #: ../app/ui/settings/DataProviderPage.qml:37
 msgid "Provider"
 msgstr ""
 
+#: ../app/ui/settings/PrivacyPage.qml:35
+msgid "Auto detect location"
+msgstr ""
+
 #: ../app/ui/settings/RefreshIntervalPage.qml:30
 #: ../app/ui/settings/RefreshIntervalPage.qml:31
 #: ../app/ui/settings/RefreshIntervalPage.qml:32

=== modified file 'tests/autopilot/ubuntu_weather_app/databases/CMakeLists.txt'
--- tests/autopilot/ubuntu_weather_app/databases/CMakeLists.txt	2015-07-25 13:52:18 +0000
+++ tests/autopilot/ubuntu_weather_app/databases/CMakeLists.txt	2015-07-26 15:05:37 +0000
@@ -1,6 +1,6 @@
 # make the database files visible on qtcreator
 file(GLOB PYTHON_TEST_DATABASE_FILES
      RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
-     *.ini)
+     *.ini *.conf)
 
 add_custom_target(ubuntu-weather-app_PYTHONTestDatabaseFiles ALL SOURCES ${PYTHON_TEST_DATABASE_FILES})

=== added file 'tests/autopilot/ubuntu_weather_app/databases/location_added.conf'
--- tests/autopilot/ubuntu_weather_app/databases/location_added.conf	1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_weather_app/databases/location_added.conf	2015-07-26 15:05:37 +0000
@@ -0,0 +1,3 @@
+[weatherSettings]
+autoDetectLocation=false
+migrated=true

=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
--- tests/autopilot/ubuntu_weather_app/tests/__init__.py	2015-07-23 00:50:12 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py	2015-07-26 15:05:37 +0000
@@ -223,7 +223,7 @@
 
         return result
 
-    def load_vars(self):
+    def load_database_vars(self):
         self.app_dir = os.path.join(
             os.environ.get('HOME'),
             ".local/share/com.ubuntu.weather")
@@ -235,30 +235,67 @@
             os.path.join(os.path.dirname(__file__), '..', 'files'))
 
 
-class UbuntuWeatherAppTestCase(BaseTestCaseWithPatchedHome, DatabaseMixin):
+class SettingsMixin(object):
+
+    """
+    Helper functions for dealing with the settings file
+    """
+
+    def create_settings_with_location_added(self):
+        logger.debug("Creating settings with location added")
+
+        if not os.path.exists(self.settings_dir):
+            os.makedirs(self.settings_dir)
+
+        shutil.copyfile(self.settings_location_added, self.settings_filepath)
+
+        self.assertThat(
+            lambda: os.path.exists(self.settings_filepath),
+            Eventually(Equals(True)))
+
+    def load_settings_vars(self):
+        self.db_dir = os.path.abspath(
+            os.path.join(os.path.dirname(__file__), '..', 'databases'))
+        self.settings_dir = os.path.join(
+            os.environ.get('HOME'),
+            ".config/com.ubuntu.weather")
+        self.settings_filepath = os.path.join(self.settings_dir,
+            'com.ubuntu.weather.conf')
+        self.settings_location_added = os.path.join(self.db_dir,
+            "location_added.conf")
+
+class UbuntuWeatherAppTestCase(BaseTestCaseWithPatchedHome, DatabaseMixin,
+                               SettingsMixin):
 
     """Base test case that launches the ubuntu-weather-app."""
 
     def setUp(self):
         super(UbuntuWeatherAppTestCase, self).setUp()
 
-        self.load_vars()
+        self.load_database_vars()
         self.create_blank_db()
 
+        self.load_settings_vars()
+        self.create_settings_with_location_added()
+
         self.app = UbuntuWeatherApp(self.launcher())
 
 
 class UbuntuWeatherAppTestCaseWithData(BaseTestCaseWithPatchedHome,
-                                       DatabaseMixin):
+                                       DatabaseMixin,
+                                       SettingsMixin):
 
     """Base test case that launches the ubuntu-weather-app with data."""
 
     def setUp(self):
         super(UbuntuWeatherAppTestCaseWithData, self).setUp()
 
-        self.load_vars()
+        self.load_database_vars()
         self.create_blank_db()
 
+        self.load_settings_vars()
+        self.create_settings_with_location_added()
+
         logger.debug("Adding fake data to new database")
         self.add_locations_to_database()
 


Follow ups