Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bug fixes for Android, refresh, and disabling avatar change for now

  • Loading branch information...
commit beb470890c32da8b706d4d9bff8ab293cf301e3f 1 parent 1a58d05
@kwhinnery kwhinnery authored
View
BIN  app/assets/android/img/general/refresh.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/iphone/img/general/refresh.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/iphone/img/general/refresh@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
10 app/controllers/agenda.js
@@ -11,9 +11,11 @@ var sunday = [],
$.loading = Alloy.createController('loading');
$.index.add($.loading.getView());
+$.loading.start();
//Load agenda data
Session.getAll(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
var sessions = e.sessions;
@@ -67,6 +69,14 @@ if (!Alloy.isTablet) {
$.agendaTable.setData(tuesday);
}
});
+
+ //reset to day one if need be, since Android will not retain animation positions when a view has been unloaded from the hierarchy
+ $.on('focus', function() {
+ if ($.agendaTable && sunday.length > 0) {
+ $.agendaTable && ($.agendaTable.setData(sunday));
+ $.headerView.goTo(0);
+ }
+ });
}
//show session detail drawer
View
97 app/controllers/home.js
@@ -9,67 +9,74 @@ $.index.add($.loading.getView());
function loadContent() {
//Grab current agenda item
Session.getNext(function(e) {
- var session = e.next;
- $.title.text = session.name;
- $.presenter.text = session.custom_fields.presenter;
- $.location.text = session.custom_fields.location;
-
- if ($.dailySchedule) {
- var now = moment(),
- monDate = moment('Oct 22, 2012'),
- tueDate = moment('Oct 23, 2012');
- day = 'tuesday';
- if (now.diff(monDate) < 0) {
- day = 'sunday'
- }
- else if (now.diff(tueDate) < 0) {
- day = 'monday';
+ if (e.success) {
+ var session = e.next;
+ $.title.text = session.name;
+ $.presenter.text = session.custom_fields.presenter;
+ $.location.text = session.custom_fields.location;
+
+ if ($.dailySchedule) {
+ var now = moment(),
+ monDate = moment('Oct 22, 2012'),
+ tueDate = moment('Oct 23, 2012');
+ day = 'tuesday';
+ if (now.diff(monDate) < 0) {
+ day = 'sunday'
+ }
+ else if (now.diff(tueDate) < 0) {
+ day = 'monday';
+ }
+
+ Session.getForDay(day, function(ev) {
+ if (e.success) {
+ var data = [];
+ for (var i = 0, l = ev.sessions.length; i<l; i++) {
+ data.push(new ui.AgendaRow(ev.sessions[i]));
+ }
+ $.dailySchedule.setData(data);
+ }
+ else {
+ ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
+ }
+ });
}
- Session.getForDay(day, function(ev) {
+ //Grab latest status updates
+ Status.query(function(e) {
+ $.loading.stop();
+ $.index.remove($.loading.getView());
if (e.success) {
var data = [];
- for (var i = 0, l = ev.sessions.length; i<l; i++) {
- data.push(new ui.AgendaRow(ev.sessions[i]));
+ for (var i = 0, l = e.statuses.length; i<l; i++) {
+ var status = e.statuses[i];
+ if (status.photo && !status.photo.processed) continue;
+ data.push(new ui.StatusRow(status));
}
- $.dailySchedule.setData(data);
+ $.streamTable.setData(data);
}
else {
- ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
+ ui.alert('networkGenericErrorTitle', 'activityStreamError');
}
- });
+ },10);
+ }
+ else {
+ Ti.API.error('error fetching initial content: '+e);
+ ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
}
-
- //Grab latest status updates
- Status.query(function(e) {
- $.index.remove($.loading.getView());
- if (e.success) {
- var data = [];
- for (var i = 0, l = e.statuses.length; i<l; i++) {
- data.push(new ui.StatusRow(e.statuses[i]));
- }
- $.streamTable.setData(data);
- }
- else {
- ui.alert('networkGenericErrorTitle', 'activityStreamError');
- }
- },10);
});
}
//Listen for status update, and refresh.
-Ti.App.addEventListener('app:status.update', function(e) {
- if (e.withPhoto && Ti.Platform.osname === 'android') {
- //swallow this for now - if we try to assign a URL to an image view we crash, so avoid doing it for now
- }
- else {
- loadContent();
- }
-});
+function startRefresh() {
+ $.index.add($.loading.getView());
+ $.loading.start();
+ loadContent();
+}
+Ti.App.addEventListener('app:status.update', startRefresh);
//Fire manually when this view receives "focus"
-$.on('focus', loadContent);
+$.on('focus', startRefresh);
//Go to activity stream
$.streamTable.on('click', function() {
View
4 app/controllers/index.js
@@ -11,13 +11,12 @@ if (!Ti.Network.online) {
ui.alert('networkErrTitle', 'networkErrMsg');
}
-
//create view hierarchy components
$.login = Alloy.createController('login');
-$.main = Alloy.createController('main');
//Check Login Status
if (User.confirmLogin()) {
+ $.main = Alloy.createController('main');
$.clouds && ($.index.remove($.clouds));
$.index.backgroundImage = '/img/general/bg-interior.png';
$.index.add($.main.getView());
@@ -31,6 +30,7 @@ else {
//Monitor Login Status
$.login.on('loginSuccess', function(e) {
+ $.main = Alloy.createController('main');
$.clouds && ($.index.remove($.clouds));
$.index.backgroundImage = '/img/general/bg-interior.png';
$.index.add($.main.getView());
View
2  app/controllers/loading.js
@@ -10,8 +10,6 @@ $.loader.images = [
'/img/loading/load-cloud9.png'
];
-$.loader.start();
-
$.start = function() {
$.loader.start();
};
View
3  app/controllers/login.js
@@ -43,13 +43,16 @@ if (OS_IOS) {
//Login using network creds
$.login.on('click', function() {
$.index.parent.add($.loading.getView());
+ $.loading.start();
$.email.blur();
$.password.blur();
User.login($.email.value, $.password.value, function(e) {
$.trigger('loginSuccess', e);
$.password.value = '';
+ $.loading.stop();
$.index.parent.remove($.loading.getView());
}, function() {
+ $.loading.stop();
$.index.parent.remove($.loading.getView());
showError();
});
View
5 app/controllers/postFormView.js
@@ -173,6 +173,7 @@ $.submit.on('click', function() {
var currentPost = $.post.value;
$.postContainer.add($.loading.getView());
+ $.loading.start();
Status.create({
message:(currentPost === '') ? 'Just uploaded from @codestrong 2012!' : currentPost, //empty string - status update tangram requires a message
photo:currentBlob
@@ -182,6 +183,7 @@ $.submit.on('click', function() {
if (twitterOn || fbOn) {
var args = {
success: function(ev) {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
ui.alert('updateSuccessTitle', 'updateSuccessText');
$.trigger('success');
@@ -190,6 +192,7 @@ $.submit.on('click', function() {
});
},
error: function(ev) {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
Ti.API.error('Error on social post: '+ev);
ui.alert('updateErrorTitle', 'updateErrorText');
@@ -234,6 +237,7 @@ $.submit.on('click', function() {
}
}
else {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
ui.alert('updateSuccessTitle', 'updateSuccessText');
$.trigger('success');
@@ -243,6 +247,7 @@ $.submit.on('click', function() {
}
}
else {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
Ti.API.error('Error on ACS post: '+e);
ui.alert('updateErrorTitle', 'updateErrorText');
View
18 app/controllers/profile.js
@@ -19,8 +19,10 @@ if (userDetails.attributes.title) {
$.avatar.image = User.generateAvatarURL();
$.logout.on('click', function() {
+ $.loading.start();
$.index.add($.loading.getView());
User.logout(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
Ti.App.fireEvent('app:logout');
@@ -33,12 +35,21 @@ $.logout.on('click', function() {
//Handle image attachment
$.avatar.on('click', function() {
+ //TODO: Support image attachment - partially implemented, needs more testing for production.
+
var od = Ti.UI.createOptionDialog({
- options:[L('photoGallery'), L('camera'), L('cancel')],
- cancel:2,
- title:L('chooseAvatar')
+ options:['Go', L('cancel')],
+ cancel:1,
+ title:L('gravatar')
+ });
+ od.addEventListener('click', function(e) {
+ if (e.index === 0) {
+ Ti.Platform.openURL('http://gravatar.com');
+ }
});
+ od.show();
+ /*
od.addEventListener('click', function(e) {
var callbacks = {
success: function(e) {
@@ -71,6 +82,7 @@ $.avatar.on('click', function() {
else {
od.show();
}
+ */
});
View
40 app/controllers/stream.js
@@ -5,12 +5,19 @@ $.loading = Alloy.createController('loading');
$.index.add($.loading.getView());
function loadRows() {
+ if (OS_ANDROID) {
+ $.table.setData([
+ {title:L('loadingLatest'), color:'#000'}
+ ]);
+ }
Status.query(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
var td = [];
for (var i = 0, l = e.statuses.length; i<l; i++) {
var status = e.statuses[i];
+ if (status.photo && !status.photo.processed) continue;
td.push(new ui.StatusRow(status));
}
$.table.setData(td);
@@ -21,18 +28,20 @@ function loadRows() {
});
}
+function startRefresh() {
+ $.index.add($.loading.getView());
+ $.loading.start();
+ loadRows();
+}
+
//Listen for status update, and refresh.
-Ti.App.addEventListener('app:status.update', function(e) {
- if (e.withPhoto && Ti.Platform.osname === 'android') {
- //swallow this for now - if we try to assign a URL to an image view we crash, so avoid doing it for now
- }
- else {
- loadRows();
- }
-});
+Ti.App.addEventListener('app:status.update', startRefresh);
//Fire manually when this view receives "focus"
-$.on('focus', loadRows);
+$.on('focus', startRefresh);
+
+//Refresh when requested
+$.refresh.on('click', startRefresh);
//Show a detail view for rows with an image
$.table.on('click', function(e) {
@@ -46,13 +55,13 @@ $.table.on('click', function(e) {
if (e.source.statusObject) {
statusObject = e.source.statusObject;
}
- else if (e.source.parent.sessionObject) {
+ else if (e.source.parent.statusObject) {
statusObject = e.source.parent.statusObject;
}
- else if (e.source.parent.parent && e.source.parent.parent.sessionObject) {
+ else if (e.source.parent.parent && e.source.parent.parent.statusObject) {
statusObject = e.source.parent.parent.statusObject;
}
- else if (e.source.parent.parent.parent && e.source.parent.parent.parent.sessionObject) {
+ else if (e.source.parent.parent.parent && e.source.parent.parent.parent.statusObject) {
statusObject = e.source.parent.parent.parent.statusObject;
}
}
@@ -113,5 +122,12 @@ $.table.on('click', function(e) {
web = null;
close = null;
});
+
+ if (OS_ANDROID) {
+ Ti.UI.createNotification({
+ message:L('pinch'),
+ duration:Ti.UI.NOTIFICATION_DURATION_LONG
+ }).show();
+ }
}
});
View
7 app/controllers/venue.js
@@ -17,5 +17,10 @@ if (!Alloy.isTablet) {
$.venue.image = '/img/venue/venue-4th-floor.png';
}
});
+
+ //reset to day one if need be, since Android will not retain animation positions when a view has been unloaded from the hierarchy
+ $.on('focus', function() {
+ $.venue.image = '/img/venue/venue-3rd-floor.png';
+ $.headerView.goTo(0);
+ });
}
-
View
21 app/lib/Session.js
@@ -16,6 +16,13 @@ function Session() {}
//Get a complete session listing (this will never top 100)
Session.getAll = function(callback) {
+ if (!Ti.Network.online) {
+ callback({
+ success:false
+ });
+ return;
+ }
+
//hit cache first
if (sessions.length > 0) {
//return a simulated event immediately
@@ -42,6 +49,13 @@ Session.getAll = function(callback) {
//TODO: Figure out how to sort of date fields in ACS
Session.getNext = function(cb) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
Cloud.Events.query({
page:1,
per_page:100,
@@ -68,6 +82,13 @@ Session.getNext = function(cb) {
//Return all sessions for a given day - if before conference, show day 1, if after, show day 3
Session.getForDay = function(dateString, cb) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
if (days[dateString].length > 0) {
cb({
success:true,
View
14 app/lib/Status.js
@@ -15,6 +15,13 @@ function Status() {}
* }
*/
Status.create = function(args, cb) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
var avatar = User.generateAvatarURL(),
user = User.getUserDetails();
@@ -39,6 +46,13 @@ Status.create = function(args, cb) {
//Get status updates
Status.query = function(cb, limit) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
Cloud.Statuses.query({
limit:limit||50,
response_json_depth:8,
View
28 app/lib/User.js
@@ -87,6 +87,13 @@ User.tweet = function(args) {
* }
*/
User.facebookPost = function(args) {
+ if (!Ti.Network.online) {
+ args.error({
+ success:false
+ });
+ return;
+ }
+
if (args.image) {
Ti.Facebook.requestWithGraphPath('me/photos', {
message:args.message,
@@ -116,6 +123,13 @@ User.facebookPost = function(args) {
//Log in an Appcelerator network user
User.login = function(username, password, success, error) {
+ if (!Ti.Network.online) {
+ error({
+ success:false
+ });
+ return;
+ }
+
var xhr = Ti.Network.createHTTPClient();
//Parity issue: iOS fires onload for 4xx and 3xx status codes, so need to manually check onload
@@ -207,6 +221,13 @@ User.generateAvatarURL = function() {
//Log out the current user
User.logout = function(cb) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
Cloud.Users.logout(function(e) {
if (e.success) {
if (User.confirmLogin.toFacebook()) {
@@ -223,6 +244,13 @@ User.logout = function(cb) {
//Assign the given photo as the profile photo for the current user
User.assignProfilePhoto = function(blob, cb) {
+ if (!Ti.Network.online) {
+ cb({
+ success:false
+ });
+ return;
+ }
+
Cloud.Users.update({
photo:blob
}, function(e) {
View
8 app/lib/ui.js
@@ -16,7 +16,7 @@ exports.alert = function(titleid, textid) {
else {
Ti.UI.createNotification({
message:L(textid),
- duration:Ti.UI.NOTIFICATION_DURATION_SHORT
+ duration:Ti.UI.NOTIFICATION_DURATION_LONG
}).show();
}
};
@@ -158,6 +158,12 @@ exports.HeaderView = function(options) {
self.addEventListener(ev,cb);
};
+ //Shift indicator to desired index
+ self.goTo = function(idx) {
+ var rightOffset = (options.optionWidth*(Math.abs(idx-(options.options.length-1))))+'dp';
+ indicator.right = rightOffset;
+ };
+
return self;
};
View
12 app/styles/stream.tss
@@ -16,6 +16,18 @@
}
},
+'#refresh': {
+ width:'50dp',
+ right:0
+},
+
+'#refreshIcon': {
+ right:'10dp',
+ image:'/img/general/refresh.png',
+ height:'20dp',
+ width:'20dp'
+},
+
'#table': {
top:'50dp',
left:'10dp',
View
3  app/views/stream.xml
@@ -2,6 +2,9 @@
<View id="index">
<View id="header" class="appContent">
<Label id="headerLabel" textid="activityStream"/>
+ <View id="refresh">
+ <ImageView id="refreshIcon"/>
+ </View>
<View class="fauxShadow"/>
</View>
<TableView id="table"/>
View
5 i18n/en/strings.xml
@@ -65,6 +65,7 @@
<string name="disconnectFacebook">Disconnect from Facebook</string>
<string name="working">COLLECTING DATA IN DIGITAL RAIN BARRELS...</string>
+ <string name="loadingLatest">LOADING LATEST UPDATES....</string>
<string name="aboutOneOne">This application was built with Appcelerator, the number one platform for cloud service-enabled mobile applications.</string>
<string name="aboutOneTwo">The natve mobile app was built on Titanium, the open source SDK for creating pure native applications in JavaScript.</string>
@@ -74,5 +75,9 @@
<string name="aboutTwo">This application is open source under the Apache 2.0 License, and is available for download at http://bit.ly/codestrong_src</string>
<string name="specialThanks">SPECIAL THANKS</string>
<string name="aboutThree">We'd like to also give special thanks to Maria Iu, Greg DiPaolo, Monica Malone, Lisa Kohn, Tony Lukasavage, Fred Spencer, Kevin Whinnery, and the rest of the Appcelerator team that helped make this application possible. Code Strong!</string>
+
+ <string name="pinch">Pinch to zoom on this photo</string>
+ <string name="gravatar">Your Appcelerator account uses Gravatar - change this photo at gravatar.com</string>
+
</resources>
View
2  manifest
@@ -2,7 +2,7 @@
#publisher:kwhinnery
#url:http://www.codestrong.com
#image:appicon.png
-#appid:com.appcelerator.codestrongmobile
+#appid:com.appcelerator.codestrong2012
#desc:not specified
#type:ipad
#guid:663bee76-3574-46ac-9f21-a6c53075771d
Please sign in to comment.
Something went wrong with that request. Please try again.