~josharenson/unity8/fix-greeter-password-focus

« back to all changes in this revision

Viewing changes to qml/Wizard/Pages/here-terms.qml

  • Committer: Josh Arenson
  • Date: 2016-03-25 19:53:42 UTC
  • mfrom: (1978.1.6 sessions-model)
  • mto: This revision was merged to the branch mainline in revision 1986.
  • Revision ID: joshua.arenson@canonical.com-20160325195342-ibax564aavo3lk2i
merge prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2014,2015 Canonical, Ltd.
 
2
 * Copyright (C) 2014-2016 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
15
15
 */
16
16
 
17
17
import QtQuick 2.4
18
 
import AccountsService 0.1
19
 
import Qt.labs.folderlistmodel 2.1
20
18
import Ubuntu.Components 1.3
21
19
import Ubuntu.Web 0.2
22
20
import ".." as LocalComponents
26
24
 
27
25
    title: i18n.tr("Terms & Conditions")
28
26
    customBack: true
29
 
 
30
 
    FolderListModel {
31
 
        id: termsModel
32
 
        folder: AccountsService.hereLicensePath
33
 
        nameFilters: ["*.html"]
34
 
        showDirs: false
35
 
        showOnlyReadable: true
36
 
        onCountChanged: loadFileContent()
37
 
    }
38
 
 
39
 
    function makeFileName(lang, country) {
40
 
        return lang + "_" + country + ".html"
41
 
    }
42
 
 
43
 
    function defaultCountryForLanguage(lang) {
44
 
        if (lang === "da") return "DK"
45
 
        if (lang === "en") return "US"
46
 
        if (lang === "ko") return "KR"
47
 
        if (lang === "zh") return "CN"
48
 
        return lang.toUpperCase()
49
 
    }
50
 
 
51
 
    function determineFileName() {
52
 
        var codes = i18n.language.split(".")[0].split("_")
53
 
        var defaultCountry = defaultCountryForLanguage(codes[0])
54
 
        if (codes.count === 1)
55
 
            codes = [codes[0], defaultCountry]
56
 
        var perfectMatch = makeFileName(codes[0], codes[1])
57
 
        var nearMatch = makeFileName(codes[0], defaultCountry)
58
 
        var nearMatchExists = false
59
 
 
60
 
        for (var i = 0; i < termsModel.count; i++) {
61
 
            var fileName = termsModel.get(i, "fileName")
62
 
            if (fileName == perfectMatch) {
63
 
                return perfectMatch
64
 
            } else if (fileName == nearMatch) {
65
 
                nearMatchExists = true
66
 
            }
67
 
        }
68
 
 
69
 
        if (nearMatchExists) {
70
 
            return nearMatch
71
 
        } else {
72
 
            return makeFileName("en", "US")
73
 
        }
74
 
    }
75
 
 
76
 
    function loadFileContent() {
77
 
        var xhr = new XMLHttpRequest
78
 
        xhr.open("GET", AccountsService.hereLicensePath + "/" + determineFileName())
79
 
        xhr.onreadystatechange = function() {
80
 
            if (xhr.readyState == XMLHttpRequest.DONE) {
81
 
                termsLabel.text = xhr.responseText
82
 
            }
83
 
        }
84
 
        xhr.send()
85
 
    }
 
27
    customTitle: true
86
28
 
87
29
    onBackClicked: {
88
30
        if (webview.visible) {
89
 
            termsLabel.visible = true
90
 
        } else {
91
 
            pageStack.prev()
 
31
            showBrowser(false);
 
32
        } else {
 
33
            pageStack.prev();
 
34
        }
 
35
    }
 
36
 
 
37
    function showBrowser(show) {
 
38
        if (show) {
 
39
            label1.visible = false;
 
40
            label2.visible = false;
 
41
            label3.visible = false;
 
42
            label4.visible = false;
 
43
            webview.visible = true;
 
44
        } else {
 
45
            webview.visible = false;
 
46
            label1.visible = true;
 
47
            label2.visible = true;
 
48
            label3.visible = true;
 
49
            label4.visible = true;
92
50
        }
93
51
    }
94
52
 
95
53
    Column {
96
54
        id: column
97
55
        anchors.fill: content
98
 
 
99
 
        Label {
100
 
            id: termsLabel
101
 
            objectName: "termsLabel"
102
 
            anchors.left: parent.left
103
 
            anchors.right: parent.right
104
 
            wrapMode: Text.Wrap
105
 
            linkColor: theme.palette.normal.foregroundText
 
56
        anchors.leftMargin: staticMargin
 
57
        anchors.rightMargin: wideMode ? parent.rightMargin : staticMargin
 
58
        spacing: units.gu(3)
 
59
 
 
60
        Label {
 
61
            id: label1
 
62
            anchors.left: parent.left
 
63
            anchors.right: parent.right
 
64
            wrapMode: Text.Wrap
 
65
            color: textColor
 
66
            fontSize: "small"
 
67
            font.weight: Font.Light
 
68
            lineHeight: 1.2
 
69
            text: i18n.tr("Your device uses positioning technologies provided by HERE.")
 
70
        }
 
71
 
 
72
        Label {
 
73
            id: label2
 
74
            anchors.left: parent.left
 
75
            anchors.right: parent.right
 
76
            wrapMode: Text.Wrap
 
77
            color: textColor
 
78
            fontSize: "small"
 
79
            font.weight: Font.Light
 
80
            lineHeight: 1.2
 
81
            text: i18n.tr("To provide you with positioning services and to improve their quality, HERE collects information about nearby cell towers and Wi-Fi hotspots around your current location whenever your position is being found.")
 
82
        }
 
83
 
 
84
        Label {
 
85
            id: label3
 
86
            anchors.left: parent.left
 
87
            anchors.right: parent.right
 
88
            wrapMode: Text.Wrap
 
89
            color: textColor
 
90
            fontSize: "small"
 
91
            font.weight: Font.Light
 
92
            lineHeight: 1.2
 
93
            text: i18n.tr("The information collected is used to analyze the service and to improve the use of service, but not to identify you personally.")
 
94
        }
 
95
 
 
96
        Label {
 
97
            id: label4
 
98
            anchors.left: parent.left
 
99
            anchors.right: parent.right
 
100
            wrapMode: Text.Wrap
 
101
            color: textColor
 
102
            fontSize: "small"
 
103
            font.weight: Font.Light
 
104
            lineHeight: 1.2
 
105
            linkColor: UbuntuColors.orange
 
106
            text: i18n.tr("By continuing, you agree to the HERE platform %1 and %2.")
 
107
                         .arg("<a href=\"http://here.com/terms/service-terms\">" + i18n.tr("Service Terms") + "</a>")
 
108
                         .arg("<a href=\"http://here.com/privacy/privacy-policy\">" + i18n.tr("Privacy Policy") + "</a>");
106
109
            onLinkActivated: {
107
 
                webview.url = link
108
 
                termsLabel.visible = false
 
110
                showBrowser(true);
 
111
                webview.url = link;
109
112
            }
110
113
        }
111
114
 
114
117
            objectName: "webview"
115
118
            anchors.left: parent.left
116
119
            anchors.right: parent.right
 
120
            anchors.leftMargin: -leftMargin
 
121
            anchors.rightMargin: -rightMargin
117
122
            height: parent.height
118
 
            visible: !termsLabel.visible
 
123
            visible: false
119
124
        }
120
125
    }
121
126
}