From 291a2abd11f839fb9604306275950d6d6d483b32 Mon Sep 17 00:00:00 2001 From: Vera Izrailit Date: Mon, 13 Jun 2016 14:36:50 +0300 Subject: [PATCH] Changed the logic of showing reservation titles: now showing the organizer email address if the name is not available. --- README.md | 1 + app/build.gradle | 4 +-- .../PlatformCalendarDataProxy.java | 27 ++++++++++++++----- .../main/res/layout/room_traffic_lights.xml | 2 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9b500383..a56eba53 100644 --- a/README.md +++ b/README.md @@ -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 ------- diff --git a/app/build.gradle b/app/build.gradle index 1d546e01..b0a972fb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/com/futurice/android/reservator/model/platformcalendar/PlatformCalendarDataProxy.java b/app/src/main/java/com/futurice/android/reservator/model/platformcalendar/PlatformCalendarDataProxy.java index 94301721..a7aef446 100644 --- a/app/src/main/java/com/futurice/android/reservator/model/platformcalendar/PlatformCalendarDataProxy.java +++ b/app/src/main/java/com/futurice/android/reservator/model/platformcalendar/PlatformCalendarDataProxy.java @@ -300,7 +300,6 @@ public Vector getRooms() throws ReservatorException { if (location == null || location.isEmpty()) { location = name; } - rooms.add(new PlatformCalendarRoom( name, result.getString(1), @@ -427,10 +426,11 @@ private HashSet 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); @@ -449,21 +449,29 @@ private HashSet 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 *

- * 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_" *

* 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; } @@ -472,6 +480,7 @@ private Vector 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; @@ -488,8 +497,14 @@ private Vector 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(); diff --git a/app/src/main/res/layout/room_traffic_lights.xml b/app/src/main/res/layout/room_traffic_lights.xml index d753ef67..342a1c4b 100644 --- a/app/src/main/res/layout/room_traffic_lights.xml +++ b/app/src/main/res/layout/room_traffic_lights.xml @@ -1,6 +1,6 @@ diff --git a/build.gradle b/build.gradle index b565356a..512379b2 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c71e760..87ad4b30 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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