Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef5c656e authored by Sara Ting's avatar Sara Ting Committed by Android (Google) Code Review
Browse files

Merge "Add calendar owner to event info if more than 1 calendar." into ics-ub-calendar-mr1

parents efec631b 6aad0ffc
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -149,12 +149,43 @@
                android:layout_height="wrap_content"
                android:paddingLeft="16dip"
                android:paddingRight="16dip"
                android:layout_marginTop="8dip"
                android:orientation="vertical">
                <!-- Calendar Owner -->
                <LinearLayout
                    android:id="@+id/calendar_container"
                    android:visibility="gone"
                    android:paddingRight="16dip"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <TextView
                        android:id="@+id/calendar_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:singleLine="true"
                        android:text="@string/view_event_calendar_label"
                        android:textColor="@color/event_info_organizer_color"
                        style="?android:attr/textAppearanceSmall"
                        android:textSize="14sp"/>
                    <TextView
                        android:id="@+id/calendar_name"
                        android:layout_width="0px"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:layout_weight="1"
                        android:singleLine="true"
                        android:layout_marginLeft="2dip"
                        android:textIsSelectable="true"
                        android:textColor="@color/event_info_organizer_color"
                        style="?android:attr/textAppearanceSmall"
                        android:textSize="14sp"/>
                </LinearLayout>

                <!-- Organizer -->
                <LinearLayout
                    android:id="@+id/organizer_container"
                    android:visibility="gone"
                    android:layout_marginTop="8dip"
                    android:paddingRight="16dip"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
+66 −28
Original line number Diff line number Diff line
@@ -160,11 +160,48 @@
                    style="?android:attr/textAppearanceLarge" />
            </LinearLayout>

            <LinearLayout
                android:layout_marginTop="10dip"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <!-- Calendar Owner -->
                <LinearLayout
                    android:id="@+id/calendar_container"
                    android:visibility="gone"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <TextView
                        android:id="@+id/calendar_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingLeft="16dip"
                        android:singleLine="true"
                        android:text="@string/view_event_calendar_label"
                        android:textColor="@color/event_info_organizer_color"
                        style="?android:attr/textAppearanceSmall"
                        android:textSize="18sp"/>
                    <TextView
                        android:id="@+id/calendar_name"
                        android:layout_width="0px"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:layout_weight="1"
                        android:singleLine="true"
                        android:layout_marginLeft="4dip"
                        android:layout_marginRight="8dip"
                        android:textIsSelectable="true"
                        android:textColor="@color/event_info_organizer_color"
                        style="?android:attr/textAppearanceSmall"
                        android:textSize="18sp"/>
                </LinearLayout>

                <!-- Organizer -->
                <LinearLayout
                    android:id="@+id/organizer_container"
                    android:visibility="gone"
                android:layout_marginTop="10dip"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
@@ -192,6 +229,7 @@
                        style="?android:attr/textAppearanceSmall"
                        android:textSize="18sp"/>
                </LinearLayout>
            </LinearLayout>

            <!-- DESCRIPTION -->
            <include
+28 −14
Original line number Diff line number Diff line
@@ -148,9 +148,11 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
    private static final int TOKEN_QUERY_ATTENDEES = 1 << 2;
    private static final int TOKEN_QUERY_DUPLICATE_CALENDARS = 1 << 3;
    private static final int TOKEN_QUERY_REMINDERS = 1 << 4;
    private static final int TOKEN_QUERY_VISIBLE_CALENDARS = 1 << 5;
    private static final int TOKEN_QUERY_ALL = TOKEN_QUERY_DUPLICATE_CALENDARS
            | TOKEN_QUERY_ATTENDEES | TOKEN_QUERY_CALENDARS | TOKEN_QUERY_EVENT
            | TOKEN_QUERY_REMINDERS;
            | TOKEN_QUERY_REMINDERS | TOKEN_QUERY_VISIBLE_CALENDARS;

    private int mCurrentQuery = 0;

    private static final String[] EVENT_PROJECTION = new String[] {
@@ -252,6 +254,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange

    static final String CALENDARS_WHERE = Calendars._ID + "=?";
    static final String CALENDARS_DUPLICATE_NAME_WHERE = Calendars.CALENDAR_DISPLAY_NAME + "=?";
    static final String CALENDARS_VISIBLE_WHERE = Calendars.VISIBLE + "=?";

    private static final String NANP_ALLOWED_SYMBOLS = "()+-*#.";
    private static final int NANP_MIN_DIGITS = 7;
@@ -287,7 +290,6 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
    private boolean mCanModifyEvent;
    private boolean mIsBusyFreeCalendar;
    private int mNumOfAttendees;

    private EditResponseHelper mEditResponseHelper;
    private boolean mDeleteDialogVisible = false;
    private DeleteEventHelper mDeleteHelper;
@@ -460,16 +462,25 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
                mRemindersCursor = Utils.matrixCursorFromCursor(cursor);
                initReminders(mView, mRemindersCursor);
                break;
            case TOKEN_QUERY_VISIBLE_CALENDARS:
                if (cursor.getCount() > 1) {
                    // Start duplicate calendars query to detect whether to add the calendar
                    // email to the calendar owner display.
                    String displayName = mCalendarsCursor.getString(CALENDARS_INDEX_DISPLAY_NAME);
                    mHandler.startQuery(TOKEN_QUERY_DUPLICATE_CALENDARS, null,
                            Calendars.CONTENT_URI, CALENDARS_PROJECTION,
                            CALENDARS_DUPLICATE_NAME_WHERE, new String[] {displayName}, null);
                } else {
                    // Don't need to display the calendar owner when there is only a single
                    // calendar.  Skip the duplicate calendars query.
                    setVisibilityCommon(mView, R.id.calendar_container, View.GONE);
                    mCurrentQuery |= TOKEN_QUERY_DUPLICATE_CALENDARS;
                }
                break;
            case TOKEN_QUERY_DUPLICATE_CALENDARS:
                Resources res = activity.getResources();
                SpannableStringBuilder sb = new SpannableStringBuilder();

                // Label
                String label = res.getString(R.string.view_event_calendar_label);
                sb.append(label).append(" ");
                sb.setSpan(new StyleSpan(Typeface.BOLD), 0, label.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                // Calendar display name
                String calendarName = mCalendarsCursor.getString(CALENDARS_INDEX_DISPLAY_NAME);
                sb.append(calendarName);
@@ -477,15 +488,19 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
                // Show email account if display name is not unique and
                // display name != email
                String email = mCalendarsCursor.getString(CALENDARS_INDEX_OWNER_ACCOUNT);
                if (cursor.getCount() > 1 && !calendarName.equalsIgnoreCase(email)) {
                if (cursor.getCount() > 1 && !calendarName.equalsIgnoreCase(email) &&
                        Utils.isValidEmail(email)) {
                    sb.append(" (").append(email).append(")");
                }

                setVisibilityCommon(mView, R.id.calendar_container, View.VISIBLE);
                setTextCommon(mView, R.id.calendar_name, sb);
                break;
            }
            cursor.close();
            sendAccessibilityEventIfQueryDone(token);
            // All queries are done, show the view

            // All queries are done, show the view.
            if (mCurrentQuery == TOKEN_QUERY_ALL) {
                if (mLoadingMsgView.getAlpha() == 1) {
                    // Loading message is showing, let it stay a bit more (to prevent
@@ -1695,10 +1710,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange

            String displayName = mCalendarsCursor.getString(CALENDARS_INDEX_DISPLAY_NAME);

            // start duplicate calendars query
            mHandler.startQuery(TOKEN_QUERY_DUPLICATE_CALENDARS, null, Calendars.CONTENT_URI,
                    CALENDARS_PROJECTION, CALENDARS_DUPLICATE_NAME_WHERE,
                    new String[] {displayName}, null);
            // start visible calendars query
            mHandler.startQuery(TOKEN_QUERY_VISIBLE_CALENDARS, null, Calendars.CONTENT_URI,
                    CALENDARS_PROJECTION, CALENDARS_VISIBLE_WHERE, new String[] {"1"}, null);

            mEventOrganizerEmail = mEventCursor.getString(EVENT_INDEX_ORGANIZER);
            mIsOrganizer = mCalendarOwnerAccount.equalsIgnoreCase(mEventOrganizerEmail);