Dejan Noveski avatar Dejan Noveski committed 34e4236

Code comments, LICENSE, README, cleaned up android permissions

Comments (0)

Files changed (5)

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="me.oglasuva.mobile"
-    android:versionCode="2"
-    android:versionName="0.3.1" >
+    android:versionCode="3"
+    android:versionName="0.3.3" >
 	
     <supports-screens
 	android:largeScreens="true"
 	android:resizeable="true"
 	android:anyDensity="true"
 	/>
-	<!-- uses-permission android:name="android.permission.CAMERA" /-->
-	<!-- uses-permission android:name="android.permission.VIBRATE" /-->
-	<!-- uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /-->
-	<!-- uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /-->
-	<!-- uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /-->
 	<uses-permission android:name="android.permission.READ_PHONE_STATE" />
 	<uses-permission android:name="android.permission.INTERNET" />
-	<!-- uses-permission android:name="android.permission.RECEIVE_SMS" /-->
-	<!-- uses-permission android:name="android.permission.RECORD_AUDIO" /-->
-	<!-- uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /-->
-	<!-- uses-permission android:name="android.permission.READ_CONTACTS" /-->
-	<!-- uses-permission android:name="android.permission.WRITE_CONTACTS" /-->
 	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-	<!-- uses-permission android:name="android.permission.GET_ACCOUNTS" /-->
-	<!-- uses-permission android:name="android.permission.BROADCAST_STICKY" /-->
     <uses-sdk android:minSdkVersion="10" />
 
     <application
+Copyright (c) 2012, Atomidata <info@atomidata.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, 
+this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation 
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+==============================================================
+This product also include the following software:
+==============================================================
+
+--------------------------------------------------------------
+JQuery from http://jquery.com
+
+MIT-style license
+
+license available from: https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
+
+--------------------------------------------------------------
+JQueryMobile from http://jquerymobile.com
+
+MIT-style license
+
+license available from: https://github.com/jquery/jquery-mobile/blob/master/MIT-LICENSE.txt
+
+--------------------------------------------------------------
+Phonegap/Cordova from: http://phonegap.com
+
+Apache license
+
+license available from: http://phonegap.com/about/license
+
+--------------------------------------------------------------
+Android from: http://android.com
+
+Apache license
+
+license available from: http://source.android.com/source/licenses.html
+Oglasuvame.mobile е мобилна апликација за работа со порталот за огласи - http://oglasuva.me
+ROADMAP:
+########
+
+version 0.5:
+	Контакт преку e-mail
+
+version 0.6:
+	Слики - модификации на рест сервисот и апликацијата.
+
+version 1.0:
+	Поставување огласи, промена на JQM 1.0.1 во JQM 1.1 - оптимизација и bugfixing.

assets/www/main.js

+/*
+Copyright (c) 2012, Atomidata <info@atomidata.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, 
+this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation 
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+==============================================================
+This product also include the following software:
+==============================================================
+
+--------------------------------------------------------------
+JQuery from http://jquery.com
+
+MIT-style license
+
+license available from: https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
+
+--------------------------------------------------------------
+JQueryMobile from http://jquerymobile.com
+
+MIT-style license
+
+license available from: https://github.com/jquery/jquery-mobile/blob/master/MIT-LICENSE.txt
+
+--------------------------------------------------------------
+Phonegap/Cordova from: http://phonegap.com
+
+Apache license
+
+license available from: http://phonegap.com/about/license
+
+--------------------------------------------------------------
+Android from: http://android.com
+
+Apache license
+
+license available from: http://source.android.com/source/licenses.html
+
+*/
+
+
+// Define global object that holds search/filter state
 var OglSettings = {
 	chosen_region: "",
 	chosen_category: "",
 	purpose: ""
 }
 
-
+// API URL
 var API_URL = "http://oglasuva.me/api/";
 
 document.addEventListener("deviceready", onDeviceReady, false);
 
 function onDeviceReady(){
 
+	// Allow x-domain ajax calls
     $.mobile.allowCrossDomainPages = true;
     $.support.cors = true;
+    
+    // Don't animate page transitions - helps with speed
     $.mobile.defaultPageTransition = 'none';    
+    
+    // Check for internet connection
 	checkConnection();
 	
+	// Global AJAX settings - not async, timeout and disable caching.
 	$.ajaxSetup({
 		timeout: 10000,
 		async: false,
 }
 
 function checkConnection() {
+	// Using phonegap lib to check for network connection
     var networkState = navigator.network.connection.type;
 
     var states = {};
     states[Connection.CELL_4G]  = 'Cell 4G connection';
     states[Connection.NONE]     = 'No network connection';
 
+    // The app doesn't work w/o an internet connection. Exit if none.
     if(networkState == Connection.NONE){
     	navigator.notification.confirm(
     	        'Апликацијата работи само со активна интернет конекција',  // message
 }
 
 function loadRegions(){
+	// Load the regions from the REST endpoint into the spinner.
 	if($("#region-select option").length<=1){
 		$.get(API_URL + "regions.json", function(data){
 			$.each(data, function(idx, em){
 }
 
 function loadCategories(){
+	// Load the categories from the REST endpoint into the spinner.
 	if($("#category-select option").length<=1){
 		
 		$.get(API_URL + "categories.json", function(data){
 			$.each(data, function(idx, em){
+				// The categories are tiered. Top tier are option goups.
 				var optgroup = $('<optgroup label="'+em.name+'"></optgroup>');
 				$(optgroup).appendTo("#category-select");
 				$.each(em.child_categories, function(ix, el){
 }
 
 function loadClassifieds(callback){	
+	// Load the classifieds, using the global filter state.
 	$.ajax({
 		async: false,
 		timeout: 5000,
 				
 			if($(data).length>0){
 				if(OglSettings.current_page==0)
-					$("#classifieds-listview").html("");
+					$("#classifieds-listview").html(""); // Filter is new, reset state of the listview.
 				$.each(data, function(idx, em){
+					// Load the classifieds
 					var li = $('<li data-theme="a">\
 							<a href="#" data-icon="plus"><h3>'+em.title.toLowerCase()+'</h3>\
 							<p>'+formatElementContent(em)+'</p></a></li>');
-
+					
+					// Show the "load more" button at the end of the list
 					if($("#more-btn").length>0){
 						$(li).insertAfter("#classifieds-listview li:not(.more-btn):last");
 					}
 						$(li).appendTo("#classifieds-listview");
 					}
 					
+					// Tie the tap event - when a list item is tapped, load classifieds details.
 					$(li).tap(function(){fetchDetails(em.id);});
 				});
+				
 				if($(data).length>=15 && $("#more-btn").length==0){
 					var li = $('<li data-theme="b" class="more-btn"><a id="more-btn" href="#details">Следни Огласи</a></li>');
 					$(li).appendTo("#classifieds-listview");
 				}
-				$("#classifieds-listview").listview('refresh');				
+				// Refresh the listview. Essential to do enhancement again.
+				$("#classifieds-listview").listview('refresh');
 				OglSettings.current_page += 1;				
 			}
 			else{
 			}
 		    
 			if(callback){
+				// If we supply a callback, we call it.
 				callback();
 			}
 		}, 
 }
 
 function formatElementContent(em){
+	// Returns the listview item format
 	var content = "";
 	content += "<b>"+ em.category.name +"</b> | ";
 	content += "<b>"+em.purpose.name+" во "+ em.region.name+"</b>";
 }
 
 function fetchDetails(id){
+	// Fetch the details of the classified ad and prep the classified details page.
 	$.ajax({
 			url: API_URL + "details/"+id+".json",
 			cache: false,
 					$('#details .details-contact-mobile-phone').html("");
 				
 				if(data.location_lon){
+					// Google map
 					$("#details-map").css("width","100%");
 					$("#details-map").css("height","10em");
 					var latitude = data.location_lat;
 					$("#details-map").css("width","100%");
 					$("#details-map").css("height","0em");
 					$("#details-map").html("");
-				}				
+				}
+				// Make the phone number links - buttons.
 				$("#details .details-contact-mobile-phone a,#details .details-contact-home-phone a").button();
+				// Refresh the page - update the layout and the enhancements.
 				$("#details").page();
+				// Move to details page.
 				$.mobile.changePage('#details', {transition: 'none'});
 				
 			}, 
 }
 
 $("#classifieds").live('pageinit', function(e){
-	
 	loadClassifieds();
 	
+	// Filter button updates search/filter state and loads classifieds
 	$("#filter-button").tap(function(e){
 		e.preventDefault();
 		OglSettings.search_query = $("#q").val();
 		loadClassifieds(function(){$.mobile.changePage("#classifieds");});
 	});
 	
+	// Reset the filters
 	$("#filter-all-button").tap(function(e){
 		e.preventDefault();
 		OglSettings.search_query = "";
 		loadClassifieds(function(){$.mobile.changePage("#classifieds");});
 	});
 	
+	// Load next page and scroll to the next page
 	$("#more-btn").live("tap", function(e){
 		e.preventDefault();
 		var t = $(this).offset().top;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.