• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.messaging.datamodel;
17 
18 import android.net.Uri;
19 import android.text.TextUtils;
20 
21 import com.android.ex.chips.RecipientEntry;
22 
23 /**
24  * An extension of RecipientEntry for Bugle's use since Bugle uses phone numbers to identify
25  * participants / recipients instead of contact ids. This allows the user to send to multiple
26  * phone numbers of the same contact.
27  */
28 public class BugleRecipientEntry extends RecipientEntry {
29 
BugleRecipientEntry(final int entryType, final String displayName, final String destination, final int destinationType, final String destinationLabel, final long contactId, final Long directoryId, final long dataId, final Uri photoThumbnailUri, final boolean isFirstLevel, final boolean isValid, final String lookupKey)30     protected BugleRecipientEntry(final int entryType, final String displayName,
31             final String destination, final int destinationType, final String destinationLabel,
32             final long contactId, final Long directoryId, final long dataId,
33             final Uri photoThumbnailUri, final boolean isFirstLevel, final boolean isValid,
34             final String lookupKey) {
35         super(entryType, displayName, destination, destinationType, destinationLabel, contactId,
36                 directoryId, dataId, photoThumbnailUri, isFirstLevel, isValid, lookupKey);
37     }
38 
constructTopLevelEntry(final String displayName, final int displayNameSource, final String destination, final int destinationType, final String destinationLabel, final long contactId, final Long directoryId, final long dataId, final String thumbnailUriAsString, final boolean isValid, final String lookupKey)39     public static BugleRecipientEntry constructTopLevelEntry(final String displayName,
40             final int displayNameSource, final String destination, final int destinationType,
41             final String destinationLabel, final long contactId, final Long directoryId,
42             final long dataId, final String thumbnailUriAsString, final boolean isValid,
43             final String lookupKey) {
44         return new BugleRecipientEntry(ENTRY_TYPE_PERSON, displayName, destination, destinationType,
45                 destinationLabel, contactId, directoryId, dataId, (thumbnailUriAsString != null
46                 ? Uri.parse(thumbnailUriAsString) : null), true, isValid, lookupKey);
47     }
48 
constructSecondLevelEntry(final String displayName, final int displayNameSource, final String destination, final int destinationType, final String destinationLabel, final long contactId, final Long directoryId, final long dataId, final String thumbnailUriAsString, final boolean isValid, final String lookupKey)49     public static BugleRecipientEntry constructSecondLevelEntry(final String displayName,
50             final int displayNameSource, final String destination, final int destinationType,
51             final String destinationLabel, final long contactId, final Long directoryId,
52             final long dataId, final String thumbnailUriAsString, final boolean isValid,
53             final String lookupKey) {
54         return new BugleRecipientEntry(ENTRY_TYPE_PERSON, displayName, destination, destinationType,
55                 destinationLabel, contactId, directoryId, dataId, (thumbnailUriAsString != null
56                 ? Uri.parse(thumbnailUriAsString) : null), false, isValid, lookupKey);
57     }
58 
59     @Override
isSamePerson(final RecipientEntry entry)60     public boolean isSamePerson(final RecipientEntry entry) {
61         return getDestination() != null && entry.getDestination() != null &&
62                 TextUtils.equals(getDestination(), entry.getDestination());
63     }
64 }
65