Skip to content

Commit

Permalink
Merge pull request #36 from futurice/reservation-title
Browse files Browse the repository at this point in the history
Changed the logic of showing reservation titles: now showing the orga…
  • Loading branch information
vtainio authored Aug 6, 2016
2 parents 77e2e9c + 291a2ab commit 0dd3c1f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ People who have contributed to Reservator:
* [Olli Jarva](https://github.com/ojarva)
* [Pekka Pulli](https://github.com/pekkapulli)
* [Ville Tainio](https://github.com/Wisheri)
* [Vera Izrailit](https://github.com/izrailit)

Support
-------
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 17
compileSdkVersion 22
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.futurice.android.reservator"
minSdkVersion 14
targetSdkVersion 18
targetSdkVersion 22

testApplicationId "com.futurice.android.reservator.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public Vector<Room> getRooms() throws ReservatorException {
if (location == null || location.isEmpty()) {
location = name;
}

rooms.add(new PlatformCalendarRoom(
name,
result.getString(1),
Expand Down Expand Up @@ -427,10 +426,11 @@ private HashSet<Reservation> getInstancesTableReservations(
long start = result.getLong(2);
long end = Math.max(start, result.getLong(3));
String eventOrganizerAccount = result.getString(4);
// Log.d("ReservationDetails", "id=" + eventId + ", title=" + title + ", organizer=" + eventOrganizerAccount);

Reservation res = new Reservation(
Long.toString(eventId) + "-" + Long.toString(start),
makeEventTitle(room.getName(), eventId, title, DEFAULT_MEETING_NAME),
makeEventTitle(room.getName(), eventId, title, eventOrganizerAccount, DEFAULT_MEETING_NAME),
new TimeSpan(new DateTime(start), new DateTime(end)));
if (eventOrganizerAccount != null && calendarAccount.equals(eventOrganizerAccount.toLowerCase())) {
res.setIsCancellable(true);
Expand All @@ -449,21 +449,29 @@ private HashSet<Reservation> getInstancesTableReservations(
* Make a title. We first try to get some sort of an organizer, speaker or attendee name,
* ignoring empty names and the name of this room and preferring those who have accepted the
* invitation to those who are unknown/tentative, and those to those who have not declined.
* If the name is empty but the email address is not we use the email address
* <p/>
* If that fails to yield a name we use the stored meeting title.
* If that fails to yield a name we use the event owner, unless it starts with "futurice.com_"
* <p/>
* As a last resort, a "default name" is returned.
*
* @author vsin
*/
private String makeEventTitle(final String roomName, final long eventId, final String storedTitle, final String defaultTitle) {
private String makeEventTitle(final String roomName, final long eventId, final String storedTitle, final String organizer,
final String defaultTitle) {
for (String attendee : getAuthoritySortedAttendees(eventId)) {
// Log.d("Attendee", attendee + ", room name = " + roomName + ", organizer = " + organizer);
if (attendee != null && !attendee.isEmpty() && !attendee.equals(roomName)) {
return attendee;
}
}

if (storedTitle != null && !storedTitle.isEmpty()) return storedTitle;
if (organizer != null && !organizer.isEmpty() && !organizer.startsWith("futurice.com_")) {
// Log.d("Organizer", organizer);
return organizer;
}

/// if (storedTitle != null && !storedTitle.isEmpty()) return storedTitle;
return defaultTitle;
}

Expand All @@ -472,6 +480,7 @@ private Vector<String> getAuthoritySortedAttendees(final long eventId) {

String[] mProjection = {
CalendarContract.Attendees.ATTENDEE_NAME,
CalendarContract.Attendees.ATTENDEE_EMAIL,
CalendarContract.Attendees.ATTENDEE_RELATIONSHIP,
CalendarContract.Attendees.ATTENDEE_STATUS};
String mSelectionClause = CalendarContract.Attendees.EVENT_ID + " = " + eventId;
Expand All @@ -488,8 +497,14 @@ private Vector<String> getAuthoritySortedAttendees(final long eventId) {
if (result != null) {
if (result.getCount() > 0) {
result.moveToFirst();
// Log.d("SortedAttendees", "eventId=" + eventId + ", attendeeName=" + result.getString(0) + ", attendeeEmail=" +
// result.getString(1)+ ", " + result.getCount());
do {
attendees.add(result.getString(0));
if (result.getString(0) != null && !result.getString(0).isEmpty()) {
attendees.add(result.getString(0));
} else {
attendees.add(result.getString(1));
}
} while (result.moveToNext());
}
result.close();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/room_traffic_lights.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="20dp">

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed Jun 08 13:39:15 EEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

0 comments on commit 0dd3c1f

Please sign in to comment.