diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-02 02:27:47 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-02 02:27:47 +0000 |
commit | 43e844eaa4224050bbbac335bdf049eb4cf074f7 (patch) | |
tree | cc4ad23b0b7fbebdf37e96113e4f5ff6530e8fce | |
parent | c82ffa7cf29df64f5309f06199e7757ec0b2b9b4 (diff) | |
parent | d78f93b4439f05ba2251b21c9d84b671884df98d (diff) |
Merge "Added public notification for calls" into nyc-dev
am: d78f93b443
* commit 'd78f93b4439f05ba2251b21c9d84b671884df98d':
Added public notification for calls
-rw-r--r-- | InCallUI/src/com/android/incallui/StatusBarNotifier.java | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 315c0d0ae..946e0ebd0 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -51,7 +51,6 @@ import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; -import com.android.incallui.Call.State; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallState; @@ -268,9 +267,23 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } /* - * Nothing more to check...build and send it. + * This builder is used for the notification shown when the device is locked and the user + * has set their notification settings to 'hide sensitive content' + * {@see Notification.Builder#setPublicVersion}. + */ + Notification.Builder publicBuilder = new Notification.Builder(mContext); + publicBuilder.setSmallIcon(iconResId) + .setColor(mContext.getResources().getColor(R.color.dialer_theme_color)) + // Hide work call state for the lock screen notification + .setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT)); + setNotificationWhen(call, callState, publicBuilder); + + /* + * Builder for the notification shown when the device is unlocked or the user has set their + * notification settings to 'show all notification content'. */ final Notification.Builder builder = getNotificationBuilder(); + builder.setPublicVersion(publicBuilder.build()); // Set up the main intent to send the user to the in-call screen final PendingIntent inCallPendingIntent = createLaunchPendingIntent(); @@ -335,12 +348,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, private void createIncomingCallNotification( Call call, int state, Notification.Builder builder) { - if (state == Call.State.ACTIVE) { - builder.setUsesChronometer(true); - builder.setWhen(call.getConnectTimeMillis()); - } else { - builder.setUsesChronometer(false); - } + setNotificationWhen(call, state, builder); // Add hang up option for any active calls (active | onhold), outgoing calls (dialing). if (state == Call.State.ACTIVE || @@ -358,6 +366,20 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } } + /* + * Sets the notification's when section as needed. For active calls, this is explicitly set as + * the duration of the call. For all other states, the notification will automatically show the + * time at which the notification was created. + */ + private void setNotificationWhen(Call call, int state, Notification.Builder builder) { + if (state == Call.State.ACTIVE) { + builder.setUsesChronometer(true); + builder.setWhen(call.getConnectTimeMillis()); + } else { + builder.setUsesChronometer(false); + } + } + /** * Checks the new notification data and compares it against any notification that we * are already displaying. If the data is exactly the same, we return false so that |