From d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 15 Mar 2017 14:41:07 -0700 Subject: Update Dialer source from latest green build. * Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942 --- .../dialer/shortcuts/AutoValue_DialerShortcut.java | 161 --------------------- .../dialer/shortcuts/CallContactActivity.java | 16 +- .../android/dialer/shortcuts/DialerShortcut.java | 6 +- .../dialer/shortcuts/res/values/strings.xml | 6 +- .../android/dialer/shortcuts/res/xml/shortcuts.xml | 4 +- 5 files changed, 20 insertions(+), 173 deletions(-) delete mode 100644 java/com/android/dialer/shortcuts/AutoValue_DialerShortcut.java (limited to 'java/com/android/dialer/shortcuts') diff --git a/java/com/android/dialer/shortcuts/AutoValue_DialerShortcut.java b/java/com/android/dialer/shortcuts/AutoValue_DialerShortcut.java deleted file mode 100644 index ef995c816..000000000 --- a/java/com/android/dialer/shortcuts/AutoValue_DialerShortcut.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer.shortcuts; - -import android.support.annotation.NonNull; -import javax.annotation.Generated; - -@Generated("com.google.auto.value.processor.AutoValueProcessor") - final class AutoValue_DialerShortcut extends DialerShortcut { - - private final long contactId; - private final String lookupKey; - private final String displayName; - private final int rank; - - private AutoValue_DialerShortcut( - long contactId, - String lookupKey, - String displayName, - int rank) { - this.contactId = contactId; - this.lookupKey = lookupKey; - this.displayName = displayName; - this.rank = rank; - } - - @Override - long getContactId() { - return contactId; - } - - @NonNull - @Override - String getLookupKey() { - return lookupKey; - } - - @NonNull - @Override - String getDisplayName() { - return displayName; - } - - @Override - int getRank() { - return rank; - } - - @Override - public String toString() { - return "DialerShortcut{" - + "contactId=" + contactId + ", " - + "lookupKey=" + lookupKey + ", " - + "displayName=" + displayName + ", " - + "rank=" + rank - + "}"; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DialerShortcut) { - DialerShortcut that = (DialerShortcut) o; - return (this.contactId == that.getContactId()) - && (this.lookupKey.equals(that.getLookupKey())) - && (this.displayName.equals(that.getDisplayName())) - && (this.rank == that.getRank()); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.contactId >>> 32) ^ this.contactId; - h *= 1000003; - h ^= this.lookupKey.hashCode(); - h *= 1000003; - h ^= this.displayName.hashCode(); - h *= 1000003; - h ^= this.rank; - return h; - } - - static final class Builder extends DialerShortcut.Builder { - private Long contactId; - private String lookupKey; - private String displayName; - private Integer rank; - Builder() { - } - private Builder(DialerShortcut source) { - this.contactId = source.getContactId(); - this.lookupKey = source.getLookupKey(); - this.displayName = source.getDisplayName(); - this.rank = source.getRank(); - } - @Override - DialerShortcut.Builder setContactId(long contactId) { - this.contactId = contactId; - return this; - } - @Override - DialerShortcut.Builder setLookupKey(String lookupKey) { - this.lookupKey = lookupKey; - return this; - } - @Override - DialerShortcut.Builder setDisplayName(String displayName) { - this.displayName = displayName; - return this; - } - @Override - DialerShortcut.Builder setRank(int rank) { - this.rank = rank; - return this; - } - @Override - DialerShortcut build() { - String missing = ""; - if (this.contactId == null) { - missing += " contactId"; - } - if (this.lookupKey == null) { - missing += " lookupKey"; - } - if (this.displayName == null) { - missing += " displayName"; - } - if (this.rank == null) { - missing += " rank"; - } - if (!missing.isEmpty()) { - throw new IllegalStateException("Missing required properties:" + missing); - } - return new AutoValue_DialerShortcut( - this.contactId, - this.lookupKey, - this.displayName, - this.rank); - } - } - -} \ No newline at end of file diff --git a/java/com/android/dialer/shortcuts/CallContactActivity.java b/java/com/android/dialer/shortcuts/CallContactActivity.java index 1e9a01b39..40bf97b87 100644 --- a/java/com/android/dialer/shortcuts/CallContactActivity.java +++ b/java/com/android/dialer/shortcuts/CallContactActivity.java @@ -56,11 +56,20 @@ public class CallContactActivity extends TransactionSafeActivity } } + /** + * Attempt to make a call, finishing the activity if the required permissions are already granted. + * If the required permissions are not already granted, the activity is not finished so that the + * user can choose to grant or deny them. + */ private void makeCall() { CallSpecificAppData callSpecificAppData = new CallSpecificAppData(); callSpecificAppData.callInitiationType = CallInitiationType.Type.LAUNCHER_SHORTCUT; - PhoneNumberInteraction.startInteractionForPhoneCall( - this, contactUri, false /* isVideoCall */, callSpecificAppData); + boolean interactionStarted = + PhoneNumberInteraction.startInteractionForPhoneCall( + this, contactUri, false /* isVideoCall */, callSpecificAppData); + if (interactionStarted) { + finish(); + } } @Override @@ -115,6 +124,7 @@ public class CallContactActivity extends TransactionSafeActivity int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case PhoneNumberInteraction.REQUEST_READ_CONTACTS: + case PhoneNumberInteraction.REQUEST_CALL_PHONE: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { @@ -122,8 +132,8 @@ public class CallContactActivity extends TransactionSafeActivity } else { Toast.makeText(this, R.string.dialer_shortcut_no_permissions, Toast.LENGTH_SHORT) .show(); + finish(); } - finish(); break; } default: diff --git a/java/com/android/dialer/shortcuts/DialerShortcut.java b/java/com/android/dialer/shortcuts/DialerShortcut.java index f2fb3301a..a8d4204fe 100644 --- a/java/com/android/dialer/shortcuts/DialerShortcut.java +++ b/java/com/android/dialer/shortcuts/DialerShortcut.java @@ -22,7 +22,7 @@ import android.net.Uri; import android.os.Build.VERSION_CODES; import android.provider.ContactsContract.Contacts; import android.support.annotation.NonNull; - +import com.google.auto.value.AutoValue; /** * Convenience data structure. @@ -31,7 +31,7 @@ import android.support.annotation.NonNull; * convenience methods for doing things like constructing labels. */ @TargetApi(VERSION_CODES.N_MR1) // Shortcuts introduced in N MR1 - +@AutoValue abstract class DialerShortcut { /** Marker value indicates that shortcut has no setRank. Used by pinned shortcuts. */ @@ -160,7 +160,7 @@ abstract class DialerShortcut { return new AutoValue_DialerShortcut.Builder().setRank(NO_RANK); } - + @AutoValue.Builder abstract static class Builder { /** diff --git a/java/com/android/dialer/shortcuts/res/values/strings.xml b/java/com/android/dialer/shortcuts/res/values/strings.xml index 1e2c87f12..5f14a8100 100644 --- a/java/com/android/dialer/shortcuts/res/values/strings.xml +++ b/java/com/android/dialer/shortcuts/res/values/strings.xml @@ -30,8 +30,8 @@ be found or doesn't have any phone numbers. [CHAR LIMIT=70] --> Contact no longer available. - - Cannot call without contact permissions. + + Cannot call without permissions. diff --git a/java/com/android/dialer/shortcuts/res/xml/shortcuts.xml b/java/com/android/dialer/shortcuts/res/xml/shortcuts.xml index 5e8f58d1f..49149e3e1 100644 --- a/java/com/android/dialer/shortcuts/res/xml/shortcuts.xml +++ b/java/com/android/dialer/shortcuts/res/xml/shortcuts.xml @@ -24,8 +24,6 @@ + android:data="content://com.android.contacts/contacts"/> -- cgit v1.2.3