diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallPresenter.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallPresenter.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 1299dd32d..bd81f1036 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -27,6 +27,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneCapabilities; import android.telecom.Phone; import android.telecom.PhoneAccountHandle; +import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.text.TextUtils; import android.view.Surface; @@ -34,6 +35,8 @@ import android.view.View; import com.google.common.base.Preconditions; +import com.android.contacts.common.util.MaterialColorMapUtils; +import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.incalluibind.ObjectFactory; import java.util.Collections; @@ -143,6 +146,11 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { private Phone mPhone; + /** Display colors for the UI. Consists of a primary color and secondary (darker) color */ + private MaterialPalette mThemeColors; + + private TelecomManager mTelecomManager; + public static synchronized InCallPresenter getInstance() { if (sInCallPresenter == null) { sInCallPresenter = new InCallPresenter(); @@ -1101,6 +1109,53 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { } /** + * Extract background color from call object. The theme colors will include a primary color + * and a secondary color. + */ + public void setThemeColors() { + if (mInCallActivity == null) { + return; + } + + Call call = CallList.getInstance().getFirstCall(); + TelecomManager tm = getTelecomManager(); + + int color = PhoneAccount.NO_COLOR; + + if (call != null && tm != null && tm.hasMultipleCallCapableAccounts()) { + PhoneAccount account = tm.getPhoneAccount(call.getAccountHandle()); + if (account != null) { + color = account.getColor(); + } + } + + // This method will set the background to default if the color is PhoneAccount.NO_COLOR. + mThemeColors = new InCallUIMaterialColorMapUtils(mContext.getResources()). + calculatePrimaryAndSecondaryColor(color); + + mInCallActivity.getWindow().setStatusBarColor(mThemeColors.mSecondaryColor); + } + + /** + * @return A palette for colors to display in the UI. + */ + public MaterialPalette getThemeColors() { + return mThemeColors; + } + + /** + * @return An instance of TelecomManager. + */ + private TelecomManager getTelecomManager() { + if (mTelecomManager == null) { + mTelecomManager = (TelecomManager) + mInCallActivity.getSystemService(Context.TELECOM_SERVICE); + } + return mTelecomManager; + } + + + /** * Private constructor. Must use getInstance() to get this singleton. */ private InCallPresenter() { |