diff options
author | calderwoodra <calderwoodra@google.com> | 2017-12-19 15:58:58 -0800 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-12-22 08:50:09 -0800 |
commit | c35c7580d48516eb8fedaad1142a40428c780946 (patch) | |
tree | eba88ee0b18884e3fd2660e89a9a42df1efb3b9a /java/com/android/dialer/databasepopulator/ContactsPopulator.java | |
parent | e2da6ef8a56bd9f7eedfa1c6d89e968590e0c09b (diff) |
Implemented SpeedDialEntry Room Database.
This CL includes everything needed to interface with the SpeedDialEntry
database. As an excersice to demonstrate it's functionlity, it also updates
favorites to read from SpeedDialEntry database and the add favorites screen to
insert into it.
Bug: 36841782
Test: existing
PiperOrigin-RevId: 179615699
Change-Id: I8938ef87244dffbd240506c112b445d147a88193
Diffstat (limited to 'java/com/android/dialer/databasepopulator/ContactsPopulator.java')
-rw-r--r-- | java/com/android/dialer/databasepopulator/ContactsPopulator.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/java/com/android/dialer/databasepopulator/ContactsPopulator.java b/java/com/android/dialer/databasepopulator/ContactsPopulator.java index f22552db7..484851826 100644 --- a/java/com/android/dialer/databasepopulator/ContactsPopulator.java +++ b/java/com/android/dialer/databasepopulator/ContactsPopulator.java @@ -32,6 +32,8 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.text.TextUtils; import com.android.dialer.common.Assert; +import com.android.dialer.speeddial.room.SpeedDialDatabaseComponent; +import com.android.dialer.speeddial.room.SpeedDialEntry; import com.google.auto.value.AutoValue; import java.io.ByteArrayOutputStream; import java.util.ArrayList; @@ -49,6 +51,7 @@ public final class ContactsPopulator { .addEmail(new Email("m@example.com")) .setIsStarred(true) .setPinned(1) + .setContactId(1L) .setOrangePhoto() .build(), // US, contact with a non-e164 number. @@ -58,6 +61,7 @@ public final class ContactsPopulator { .addEmail(new Email("l@example.com")) .setIsStarred(true) .setPinned(2) + .setContactId(2L) .setBluePhoto() .build(), // UK, number where the (0) should be dropped. @@ -67,6 +71,7 @@ public final class ContactsPopulator { .addEmail(new Email("r@example.com")) .setIsStarred(true) .setPinned(3) + .setContactId(3L) .setRedPhoto() .build(), // US and Australia, contact with a long name and multiple phone numbers. @@ -77,6 +82,7 @@ public final class ContactsPopulator { .addPhoneNumber(new PhoneNumber("+61 2 9374 4001", Phone.TYPE_FAX_HOME)) .setIsStarred(true) .setPinned(4) + .setContactId(4L) .setPurplePhoto() .build(), // US, phone number shared with another contact and 2nd phone number with wait and pause. @@ -155,6 +161,14 @@ public final class ContactsPopulator { addContact(SIMPLE_CONTACTS[5], operations); try { context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); + SpeedDialDatabaseComponent.get(context.getApplicationContext()) + .speedDialDatabase() + .getSpeedDialEntryDao() + .insert( + new SpeedDialEntry( + SIMPLE_CONTACTS[0].getPhoneNumbers().get(0).value, + SIMPLE_CONTACTS[0].getContactId(), + SpeedDialEntry.VOICE)); } catch (RemoteException | OperationApplicationException e) { Assert.fail("error adding contacts: " + e); } @@ -192,6 +206,7 @@ public final class ContactsPopulator { .withValue( ContactsContract.RawContacts.PINNED, contact.getIsStarred() ? contact.getPinned() : 0) + .withValue(ContactsContract.RawContacts.CONTACT_ID, contact.getContactId()) .withYieldAllowed(true) .build()); @@ -262,6 +277,9 @@ public final class ContactsPopulator { abstract int getPinned(); + @NonNull + abstract long getContactId(); + @Nullable abstract ByteArrayOutputStream getPhotoStream(); @@ -277,6 +295,7 @@ public final class ContactsPopulator { .setAccountName("foo@example") .setPinned(0) .setIsStarred(false) + .setContactId(0) .setPhoneNumbers(new ArrayList<>()) .setEmails(new ArrayList<>()); } @@ -296,6 +315,8 @@ public final class ContactsPopulator { abstract Builder setPinned(int position); + abstract Builder setContactId(long contactId); + abstract Builder setPhotoStream(ByteArrayOutputStream photoStream); abstract Builder setPhoneNumbers(@NonNull List<PhoneNumber> phoneNumbers); |