[ContactsExchanger]update ContactsExchanger(tizen_2.1)
authorji.ji <ji.ji@samsung.com>
Thu, 23 May 2013 06:54:48 +0000 (15:54 +0900)
committerji.ji <ji.ji@samsung.com>
Thu, 23 May 2013 06:54:48 +0000 (15:54 +0900)
Change-Id: I6a99abe04e460f02c83b5b6d4c25bf7049af4b53

config.xml
icon.png
index.html
js/app.js
js/app.nfc.js
js/app.ui.js

index ad4e570..bb0ceb9 100644 (file)
@@ -43,6 +43,6 @@
        <tizen:privilege name="http://tizen.org/privilege/nfc.p2p" />
        <tizen:privilege name="http://tizen.org/privilege/nfc.tag" />
        <tizen:setting screen-orientation="portrait"
-               context-menu="disable" background-support="disable" encryption="disable"
+               context-menu="disable" background-support="enable" encryption="disable"
                install-location="auto" />
 </widget>
index 33fbb63..9765b1b 100644 (file)
Binary files a/icon.png and b/icon.png differ
index 9997941..cf1e8e4 100644 (file)
@@ -10,7 +10,7 @@
 
        <script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.min.js"></script>
        <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
-       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.min.js" data-framework-theme="tizen-white" data-framework-viewport-scale="false"></script>
+       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.min.js" data-framework-theme="tizen-white"></script>
 
        <script type="text/javascript" src="./js/app.js"></script>
        <script type="text/javascript" src="./js/app.config.js"></script>
 </head>
 
 <body>
-       <div id="start" data-role="page" data-add-back-btn="header" data-footer-exist="true">
+       <div id="start" data-role="page" data-add-back-btn="header">
                <div data-role="header" id="header-start" data-position="fixed">
                        <h1>CONTACTS EXCHANGER</h1>
                </div>
 
-               <div data-role="content" id="content-start" data-scroll="none"></div>
+               <div data-role="content" id="content-start"></div>
        </div>
 
        <div id="choose" data-role="page" data-add-back-btn="footer" data-footer-exist="true">
@@ -47,7 +47,7 @@
                        <h1></h1>
                </div>
 
-               <div data-role="content" id="content-transfer" data-scroll="none"></div>
+               <div data-role="content" id="content-transfer"></div>
        </div>
 
        <div id="contact" data-role="page" data-add-back-btn="footer" data-footer-exist="true">
index 49821ed..4e07527 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -54,11 +54,11 @@ var app = null;
                saveDefaultCard: function saveDefaultCard() {
                        var elementSelected = $('#list-choose li.selected');
                        localStorage.started = true;
-                       localStorage.id = elementSelected.attr('id');
-                       localStorage.firstName = elementSelected.attr('firstName');
-                       localStorage.lastName = elementSelected.attr('lastName');
-                       localStorage.phoneNumber = elementSelected.attr('phoneNumber');
-                       localStorage.vCard = elementSelected.attr('vCard');
+                       localStorage.id = elementSelected.data('id');
+                       localStorage.firstName = elementSelected.data('firstName');
+                       localStorage.lastName = elementSelected.data('lastName');
+                       localStorage.phoneNumber = elementSelected.data('phoneNumber');
+                       localStorage.vCard = elementSelected.data('vCard');
                        $.mobile.changePage('#start');
                },
 
@@ -78,7 +78,7 @@ var app = null;
                 * @param {Error} e
                 */
                getAddressBooksError: function getAddressBooksError(e) {
-                       console.log('getAddressBooks() error: ' + e.message);
+                       console.error('getAddressBooks() error: ' + e.message);
                },
 
                initAddressBook: function initAddressBook() {
@@ -95,10 +95,14 @@ var app = null;
                countDown: function countDown(time, obj) {
                        obj.text(time);
                        if (time > 0) {
-                               time -= 1;
-                               this.timeOutHandler = setTimeout(function () {
-                                       this.countDown(time, obj);
-                               }.bind(this), 1000);
+                               if (this.nfc.isPowered()) {
+                                       time -= 1;
+                                       this.timeOutHandler = setTimeout(function () {
+                                               this.countDown(time, obj);
+                                       }.bind(this), 1000);
+                               } else {
+                                       this.nfc.timeExpired();
+                               }
                        } else {
                                this.nfc.timeExpired();
                        }
index 9f3fe2a..30aa4e0 100644 (file)
                        tizen.application.getCurrentApplication().exit();
                },
 
+               isPowered: function nfc_isPowered() {
+                       return this.nfcAdapter.powered;
+               },
+
                startNFC: function nfc_startNFC() {
 
                        try {
index 06bfd30..1e016da 100644 (file)
@@ -201,17 +201,17 @@ App.Ui = null;
                 */
                readFromCard: function ui_readFromCard(event) {
                        event.preventDefault();
-                               if (tizen.nfc.getDefaultAdapter().powered) {
-                                       try {
-                                               $('#transfer').data('option', 'read');
-                                               $.mobile.changePage('#transfer');
-                                       } catch (e) {
-                                               console.error(e.message);
-                                       }
-                               } else {
-                                       $.mobile.changePage('#start');
-                                       alert('Please turn on NFC adapter');
+                       if (tizen.nfc.getDefaultAdapter().powered) {
+                               try {
+                                       $('#transfer').data('option', 'read');
+                                       $.mobile.changePage('#transfer');
+                               } catch (e) {
+                                       console.error(e.message);
                                }
+                       } else {
+                               $.mobile.changePage('#start');
+                               alert('Please turn on NFC adapter');
+                       }
                },
 
                /**
@@ -258,8 +258,16 @@ App.Ui = null;
                 */
                communicateWithOtherDevice: function ui_communicateWithOtherDevice(event) {
                        event.preventDefault();
-                       $('#transfer').data('option', 'communicate');
-                       $.mobile.changePage('#transfer');
+                       if (tizen.nfc.getDefaultAdapter().powered) {
+                               try {
+                                       $('#transfer').data('option', 'communicate');
+                                       $.mobile.changePage('#transfer');
+                               } catch (e) {
+                                       console.error(e.message);
+                               }
+                       } else {
+                               alert('Please turn on NFC adapter');
+                       }
                },
 
                /**
@@ -342,11 +350,7 @@ App.Ui = null;
                 */
                getContactsListElement: function ui_getContactsListElement(contact) {
                        var html =
-                                       '<li class="ui-li-multiline" firstName="' + contact.firstName
-                                       + '" lastName="' + contact.lastName +
-                                       '" phoneNumber="' + contact.phoneNumber +
-                                       '" id="' + contact.id +
-                                       '" vCard="' + contact.vCard + '">'
+                                       '<li class="ui-li-multiline">'
                                        + '<a href="#">' + contact.caller
                                        + '<span class="ui-li-text-sub">' +
                                        contact.phoneNumber
@@ -405,7 +409,8 @@ App.Ui = null;
                                len,
                                listElement,
                                listElementTap,
-                               self = this;
+                               self = this,
+                               contact;
 
                        listElementTap = function (event) {
                                event.preventDefault();
@@ -414,8 +419,14 @@ App.Ui = null;
                        };
 
                        for (i = 0, len = sortedContactList.length; i < len; i += 1) {
-                               listElement = $(this.getContactsListElement(sortedContactList[i]));
-                               if (localStorage.id === listElement.attr('id')) {
+                               listElement = $(this.getContactsListElement(contact = sortedContactList[i]));
+                               listElement
+                                       .data('firstName', contact.firstName)
+                                       .data('lastName', contact.lastName)
+                                       .data('phoneNumber', contact.phoneNumber)
+                                       .data('id', contact.id)
+                                       .data('vCard', contact.vCard);
+                               if (localStorage.id === listElement.data('id')) {
                                        listElement.addClass('selected');
                                }
                                ul.append(listElement);
@@ -468,6 +479,10 @@ App.Ui = null;
                                self.app.nfc.stopNFC();
                        });
 
+                       $('#header-start').on('click', '.ui-btn-back.ui-focus', function () {
+                               return false;
+                       });
+
                        $('#footer-contact').on('tap', '.ui-btn-back', function (event) {
                                event.preventDefault();
                                $.mobile.changePage('#start');