Skip to content

Commit

Permalink
layout fix to support tablet and update improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopagliarulo committed Nov 9, 2014
1 parent 23b8616 commit ba4aa12
Show file tree
Hide file tree
Showing 33 changed files with 185 additions and 55 deletions.
37 changes: 34 additions & 3 deletions app/alloy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ Alloy.Globals.Map = require('ti.map');
Alloy.Globals.osName = Ti.Platform.osname;
Alloy.Globals.filesDownload = {};
Alloy.Globals.updateCount = 0;
Alloy.Globals.isAndroidTablet = false;
switch(Alloy.Globals.osName){
case 'android':
Alloy.Globals.isAndroidTablet = (Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_LARGE || Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_XLARGE);
Alloy.Globals.museo_slab_500 = 'museo_slab_500';
Alloy.Globals.museo_slab_700 = 'museo_slab_700';
Alloy.Globals.museosans_300 = 'museosans_300';
Expand Down Expand Up @@ -97,6 +99,15 @@ updateData = function(type){
if(typeof mapping != 'undefined'){
for(var key in node){
if(typeof mapping[key] != 'undefined'){
if(node[key] != ""){
if(typeof mapping[key]['type'] != 'undefined' && mapping[key]['type'] == 'file' && typeof mapping[key]['callback'] != 'undefined' ){
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key], type) : node[key];
}
else{
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key]) : node[key];
}
}
/*
if(typeof mapping[key]['type'] != 'undefined' && mapping[key]['type'] == 'file' && typeof mapping[key]['callback'] != 'undefined' && node[key] != ""){
file = true;
files[files.length] = {
Expand All @@ -109,6 +120,7 @@ updateData = function(type){
else if(node[key] != ""){
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key]) : node[key];
}
*/
}
}
}
Expand All @@ -120,6 +132,10 @@ updateData = function(type){
var currentCollection = collection.get(object[id]);
if(typeof object['changed'] == 'undefined' || (typeof currentCollection != 'undefined' && object['changed'] > currentCollection.get('changed')) || typeof currentCollection == 'undefined'){
ids[ids.length] = object[id];
Ti.API.info(JSON.stringify(object));
var row = Alloy.createModel(type,object);
row.save();
/*
if(file){
if(typeof Alloy.Globals.filesDownload[type] == 'undefined'){
Alloy.Globals.filesDownload[type] = new Array();
Expand All @@ -130,6 +146,7 @@ updateData = function(type){
var row = Alloy.createModel(type,object);
row.save();
}
*/
}
}
}
Expand Down Expand Up @@ -163,11 +180,17 @@ updateData = function(type){
client.open("GET", url);
client.send();
};
function getImageBlob(url, data, field, type, files){
function getImageBlob(url, type){
Alloy.Globals.updateCount++;
var filename = url.substring(url.lastIndexOf('/')+1);
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,filename);
var xhr = Titanium.Network.createHTTPClient({
onload : function(e){
if (xhr.status == 200 ) {
f.write(this.responseData); // write to the file
var type = this._properties['type'];
// this.responseData
/*
var data = this._properties['data'];
var field = this._properties['field'];
var files = this._properties['files'];
Expand All @@ -181,12 +204,15 @@ function getImageBlob(url, data, field, type, files){
var currentFile = files.shift();
currentFile.callback(currentFile.value, data, currentFile.field, type, files);
}
*/
}
event = {};
event.type = type;
Ti.App.fireEvent('updateDataEnd',event);
},
onerror : function(e) {
var type = this._properties['type'];
/*
var data = this._properties['data'];
var field = this._properties['field'];
var files = this._properties['files'];
Expand All @@ -200,20 +226,26 @@ function getImageBlob(url, data, field, type, files){
var currentFile = files.shift();
currentFile.callback(currentFile.value, data, currentFile.field, type, files);
}
*/
event = {};
event.type = type;
Ti.App.fireEvent('updateDataEnd',event);
},
});

xhr.applyProperties({
'type' : type,
});
/*
xhr.applyProperties({
'data' : data,
'field' : field,
'type' : type,
'files' : files
});
*/
xhr.open('GET',url);
xhr.send();
return f.nativePath;
}
function getSponsorType(sponsorType){
var sponsorTypes = {
Expand Down Expand Up @@ -530,4 +562,3 @@ function twitterShare(data){
});

}
Alloy.Globals.isAndroidTablet = (Ti.Platform.osname == "android" && (Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_LARGE || Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_XLARGE));
Binary file modified app/assets/android/images/res-port-hdpi/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-hdpi/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-ldpi/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-ldpi/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-mdpi/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-mdpi/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-xhdpi/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-xhdpi/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-xxhdpi/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/android/images/res-port-xxhdpi/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/favOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/favOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion app/controllers/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ for(var i = 0; i < blogPost.length; i++){
var image = Ti.UI.createImageView({touchEnabled: false, bubbeParent: true, image : blogPostImage, width : "100%"});
var label = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : blogPost[i].title});
$.addClass(label,"listTitle");
if(Alloy.Globals.isAndroidTablet){
$.addClass(label,"listTitleTablet");
}
var rowSeparator = Ti.UI.createView();
$.addClass(rowSeparator,"rowSeparator");
$.addClass(rowSeparator,"rowSeparatorBlog");
view.add(label);
view.add(image);
view.add(rowSeparator);
Expand Down
18 changes: 14 additions & 4 deletions app/controllers/blogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ var viewLabel = Ti.UI.createView({
$.addClass(viewLabel,"viewLabel");

var labelTitle = Ti.UI.createLabel({
text : blogPost.title
text : blogPost.title,
width: "80%"
});
$.addClass(labelTitle,"listTitle");
if(Alloy.Globals.isAndroidTablet){
$.addClass(labelTitle,"listTitleTablet");
}
var labelDate = Ti.UI.createLabel({
text : blogPost.date
});
$.addClass(labelDate,"listDate");
if(Alloy.Globals.isAndroidTablet){
$.addClass(labelDate,"listDateTablet");
}
$.headerBlog.add(image);
$.headerBlog.add(labelDate);
viewLabel.add(labelTitle);
Expand All @@ -58,13 +65,15 @@ webView.addEventListener('load', function(e) {
});
var social = Ti.UI.createView({
height : Ti.UI.SIZE,
layout : 'vertical'
layout : 'vertical',
width: "20%"
});
$.addClass(social,"social");
var fb = Ti.UI.createImageView({
image : '/images/facebook.png',
top : "5dp",
bubbleParent : false
bubbleParent : false,
width:"50%"
});
fb.addEventListener("click",function(e){
var data = {
Expand All @@ -77,7 +86,8 @@ social.add(fb);
var twitter = Ti.UI.createImageView({
image : '/images/twitter.png',
top : "5dp",
bubbleParent : false
bubbleParent : false,
width:"50%"
});
twitter.addEventListener("click",function(e){
var data = blogPost.url + Alloy.CFG.hastag;
Expand Down
18 changes: 15 additions & 3 deletions app/controllers/favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function createRow(talkData){
$.addClass(headerSeparatorBottom,"headerSeparatorBottom");
var time = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.time});
$.addClass(time,"scheduleDate");
if(Alloy.Globals.isAndroidTablet){
$.addClass(time,"scheduleDateTablet");
}
headerViewElement.add(headerSeparatorTop);
headerViewElement.add(time);
headerViewElement.add(headerSeparatorBottom);
Expand All @@ -50,17 +53,26 @@ function createRow(talkData){
var rowView = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "horizontal", width: Ti.UI.FILL, height: Ti.UI.SIZE});
$.addClass(rowView,"rowView");
var title = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.title});
$.addClass(title,"listTitle");
$.addClass(title,"listTitleSession");
$.addClass(title,"listTitle listTitleSession");
if(Alloy.Globals.isAndroidTablet){
$.addClass(title,"
listTitleTablet listTitleSessionTablet");
}
var speaker = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.name + " " + talk.surname});
$.addClass(speaker,"listSpeaker");
if(Alloy.Globals.isAndroidTablet){
$.addClass(speaker,"listSpeakerTablet");
}

var track = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.track});
$.addClass(track,"listTrack");
if(Alloy.Globals.isAndroidTablet){
$.addClass(track,"listTrackTablet");
}
var rowViewLeft = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "80%", height: Ti.UI.SIZE});
var rowViewRight = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "20%", height: Ti.UI.SIZE});

var favorite = Ti.UI.createImageView({image : '/images/favOn.png', nid : talk.nid, bubbleParent : false});
var favorite = Ti.UI.createImageView({image : '/images/favOn.png', nid : talk.nid, bubbleParent : false, width:"50%"});
$.addClass(favorite,"favorite");
favorite.addEventListener('click',function(e){
var favorites = Alloy.Collections.instance('favorites');
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/infoDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ else{
text : infoPost.title
});
$.addClass(labelTitle,"listTitle");
if(Alloy.Globals.isAndroidTablet){
$.addClass(labelTitle,"listTitleTablet");
}
$.infoPost.add(labelTitle);
}

Expand Down
21 changes: 18 additions & 3 deletions app/controllers/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function createRow(talkHoursList){
var timeContainer = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout: "absolute",height: Ti.UI.SIZE, width: Ti.UI.FILL});
var time = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talkHoursList[i] .time});
$.addClass(time,"scheduleDate");
if(Alloy.Globals.isAndroidTablet){
$.addClass(time,"scheduleDateTablet");
}
var headerSeparatorTop = Ti.UI.createView();
$.addClass(headerSeparatorTop,"headerSeparatorTop");
var headerSeparatorBottom = Ti.UI.createView();
Expand Down Expand Up @@ -68,13 +71,21 @@ function createRow(talkHoursList){
var rowView = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "horizontal", width: Ti.UI.FILL, height: Ti.UI.SIZE});
$.addClass(rowView,"rowView");
var title = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.title});
$.addClass(title,"listTitle");
$.addClass(title,"listTitleSession");
$.addClass(title,"listTitle listTitleSession");
if(Alloy.Globals.isAndroidTablet){
$.addClass(title,"listTitleTablet listTitleSessionTablet");
}
var speaker = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.name + " " + talk.surname});
$.addClass(speaker,"listSpeaker");
if(Alloy.Globals.isAndroidTablet){
$.addClass(speaker,"listSpeakerTablet");
}

var track = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.track});
$.addClass(track,"listTrack");
if(Alloy.Globals.isAndroidTablet){
$.addClass(track,"listTrackTablet");
}
var rowViewLeft = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "80%", height: Ti.UI.SIZE});
var rowViewRight = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "20%", height: Ti.UI.SIZE});

Expand All @@ -86,13 +97,17 @@ function createRow(talkHoursList){
speakerTwitter = "@" + talk.speaker[k].twitter + " ";
}
$.addClass(speaker,"listSpeaker");
if(Alloy.Globals.isAndroidTablet){
$.addClass(speaker,"listSpeakerTablet");
}
rowViewLeft.add(speaker);
}
var twitter = Ti.UI.createImageView({
image : '/images/twitter.png',
top : "5dp",
bubbleParent : false,
speaker : speakerTwitter
speaker : speakerTwitter,
width:"50%"
});
twitter.addEventListener("click",function(e){
var data = e.source.speaker + Alloy.CFG.hastag;
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ if(GPSerror === false){
else{
var error = Ti.UI.createLabel({text : GPSerror});
$.addClass(error,"error");
if(Alloy.Globals.isAndroidTablet){
$.addClass(error,"errorTablet");
}
$.mapContainer.add(error);
}
18 changes: 15 additions & 3 deletions app/controllers/schedule_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function createRow(talkData){
$.addClass(headerViewElement,"headerSession");
var time = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.time});
$.addClass(time,"scheduleDate");
if(Alloy.Globals.isAndroidTablet){
$.addClass(time,"scheduleDateTablet");
}
var headerSeparatorTop = Ti.UI.createView();
$.addClass(headerSeparatorTop,"headerSeparatorTop");
var headerSeparatorBottom = Ti.UI.createView();
Expand All @@ -68,16 +71,22 @@ function createRow(talkData){
var rowView = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "horizontal", width: Ti.UI.FILL, height: Ti.UI.SIZE});
$.addClass(rowView,"rowView");
var title = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.title});
$.addClass(title,"listTitle");
$.addClass(title,"listTitleSession");
$.addClass(title,"listTitle listTitleSession");
if(Alloy.Globals.isAndroidTablet){
$.addClass(title,"listTitleTablet listTitleSessionTablet");
}

// var track = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.track});
// $.addClass(track,"listTrack");
// if(Alloy.Globals.isAndroidTablet){
// $.addClass(track,"listTrackTablet");
// }

var rowViewLeft = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "80%", height: Ti.UI.SIZE});
var rowViewRight = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "20%", height: Ti.UI.SIZE});

var imagePath = (inFavorite) ? '/images/favOn.png' : '/images/favOff.png';
var favorite = Ti.UI.createImageView({image : imagePath, nid : talk.nid, bubbleParent : false});
var favorite = Ti.UI.createImageView({image : imagePath, nid : talk.nid, bubbleParent : false, width:"50%"});
$.addClass(favorite,"favorite");
favorite.addEventListener('click',function(e){
var favorites = Alloy.Collections.instance('favorites');
Expand All @@ -102,6 +111,9 @@ function createRow(talkData){
for(var k = 0; k < talk.speaker.length; k++){
var speaker = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.speaker[k].name + " " + talk.speaker[k].surname});
$.addClass(speaker,"listSpeaker");
if(Alloy.Globals.isAndroidTablet){
$.addClass(speaker,"listSpeakerTablet");
}
rowViewLeft.add(speaker);
}
rowViewRight.add(favorite);
Expand Down
17 changes: 14 additions & 3 deletions app/controllers/schedule_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function createRow(talkHoursList){
$.addClass(headerViewElement,"headerSession");
var time = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talkHoursList[i] .time});
$.addClass(time,"scheduleDate");
if(Alloy.Globals.isAndroidTablet){
$.addClass(time,"scheduleDateTablet");
}
var headerSeparatorTop = Ti.UI.createView();
$.addClass(headerSeparatorTop,"headerSeparatorTop");
var headerSeparatorBottom = Ti.UI.createView();
Expand All @@ -59,16 +62,21 @@ function createRow(talkHoursList){
var rowView = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "horizontal", width: Ti.UI.FILL, height: Ti.UI.SIZE});
$.addClass(rowView,"rowView");
var title = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.title});
$.addClass(title,"listTitle");
$.addClass(title,"listTitleSession");
$.addClass(title,"listTitle listTitleSession");
if(Alloy.Globals.isAndroidTablet){
$.addClass(title,"listTitleTablet listTitleSessionTablet");
}

var track = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.track});
$.addClass(track,"listTrack");
if(Alloy.Globals.isAndroidTablet){
$.addClass(track,"listTrackTablet");
}
var rowViewLeft = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "80%", height: Ti.UI.SIZE});
var rowViewRight = Ti.UI.createView({touchEnabled: false, bubbeParent: true, layout : "vertical", width: "20%", height: Ti.UI.SIZE});

var imagePath = (inFavorite) ? '/images/favOn.png' : '/images/favOff.png';
var favorite = Ti.UI.createImageView({image : imagePath, nid : talk.nid, bubbleParent : false});
var favorite = Ti.UI.createImageView({image : imagePath, nid : talk.nid, bubbleParent : false, width:"50%"});
$.addClass(favorite,"favorite");
favorite.addEventListener('click',function(e){
var favorites = Alloy.Collections.instance('favorites');
Expand All @@ -92,6 +100,9 @@ function createRow(talkHoursList){
for(var k = 0; k < talk.speaker.length; k++){
var speaker = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : talk.speaker[k].name + " " + talk.speaker[k].surname});
$.addClass(speaker,"listSpeaker");
if(Alloy.Globals.isAndroidTablet){
$.addClass(speaker,"listSpeakerTablet");
}
rowViewLeft.add(speaker);
}
rowViewRight.add(favorite);
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/speaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ for(var i = 0; i < speakerData.length; i++){
$.addClass(image,"listImage");
var title = Ti.UI.createLabel({touchEnabled: false, bubbeParent: true, text : speaker.name + "\n" + speaker.surname});
$.addClass(title,"listTitle");
if(Alloy.Globals.isAndroidTablet){
$.addClass(title,"listTitleTablet");
}

var tableViewSection = Ti.UI.createView({height : Ti.UI.SIZE, layout: "vertical"});
rowView.add(image);
Expand Down
Loading

0 comments on commit ba4aa12

Please sign in to comment.