Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4478438f authored by Michael W's avatar Michael W
Browse files

Dialer: Redesign InCallUI

* Light one keeps the gradient background,
  dark moves to a unicolor solid background
* Buttons get non phone dependent icon color
* Call end button also varies (icon) color
  on light/dark theme

Change-Id: I378718ff6ee9af63ba8b4ec9b3532f7f30b5e44a
parent be3c2d7e
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -446,11 +446,6 @@ public class CallButtonPresenter
      return;
    }

    if (call != null) {
      inCallButtonUi.updateInCallButtonUiColors(
          InCallPresenter.getInstance().getThemeColorManager().getSecondaryColor());
    }

    final boolean isEnabled =
        state.isConnectingOrConnected() && !state.isIncoming() && call != null;
    inCallButtonUi.setEnabled(isEnabled);
+0 −1
Original line number Diff line number Diff line
@@ -870,7 +870,6 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud
        "InCallPresenter.setBoundAndWaitingForOutgoingCall",
        "setBoundAndWaitingForOutgoingCall: " + isBound);
    boundAndWaitingForOutgoingCall = isBound;
    themeColorManager.setPendingPhoneAccountHandle(handle);
    if (isBound && inCallState == InCallState.NO_CALLS) {
      inCallState = InCallState.PENDING_OUTGOING;
    }
+2 −12
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.telecom.PhoneAccount;
import com.android.contacts.common.util.MaterialColorMapUtils;
import com.android.dialer.R;
import com.android.dialer.theme.base.ThemeComponent;

public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils {
@@ -55,17 +56,6 @@ public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils {
   */
  @Override
  public MaterialPalette calculatePrimaryAndSecondaryColor(int color) {
    if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
    return getDefaultPrimaryAndSecondaryColors(context);
  }

    for (int i = 0; i < primaryColors.length(); i++) {
      if (primaryColors.getColor(i, 0) == color) {
        return new MaterialPalette(primaryColors.getColor(i, 0), secondaryColors.getColor(i, 0));
      }
    }

    // The color isn't in the list, so use the superclass to find an approximate color.
    return super.calculatePrimaryAndSecondaryColor(color);
  }
}
+6 −33
Original line number Diff line number Diff line
@@ -17,11 +17,6 @@
package com.android.incallui;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.graphics.ColorUtils;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;

import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
@@ -31,6 +26,8 @@ import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.dialer.R;
import com.android.incallui.call.DialerCall;

import static android.telecom.PhoneAccount.NO_HIGHLIGHT_COLOR;

/**
 * Calculates the background color for the in call window. The background color is based on the SIM
 * and spam status.
@@ -44,32 +41,19 @@ public class ThemeColorManager {
  @ColorInt private int backgroundColorBottom;
  @ColorInt private int backgroundColorSolid;

  /**
   * If there is no actual call currently in the call list, this will be used as a fallback to
   * determine the theme color for InCallUI.
   */
  @Nullable private PhoneAccountHandle pendingPhoneAccountHandle;

  public ThemeColorManager(MaterialColorMapUtils colorMap) {
    this.colorMap = colorMap;
  }

  public void setPendingPhoneAccountHandle(@Nullable PhoneAccountHandle pendingPhoneAccountHandle) {
    this.pendingPhoneAccountHandle = pendingPhoneAccountHandle;
  }

  public void onForegroundCallChanged(Context context, @Nullable DialerCall newForegroundCall) {
    if (newForegroundCall == null) {
      updateThemeColors(context, getHighlightColor(context, pendingPhoneAccountHandle), false);
      updateThemeColors(context, false);
    } else {
      updateThemeColors(
          context,
          getHighlightColor(context, newForegroundCall.getAccountHandle()),
          newForegroundCall.isSpam());
      updateThemeColors(context, newForegroundCall.isSpam());
    }
  }

  private void updateThemeColors(Context context, @ColorInt int highlightColor, boolean isSpam) {
  private void updateThemeColors(Context context, boolean isSpam) {
    MaterialPalette palette;
    if (isSpam) {
      palette =
@@ -79,7 +63,7 @@ public class ThemeColorManager {
      backgroundColorBottom = context.getColor(R.color.incall_background_gradient_spam_bottom);
      backgroundColorSolid = context.getColor(R.color.incall_background_multiwindow_spam);
    } else {
      palette = colorMap.calculatePrimaryAndSecondaryColor(highlightColor);
      palette = colorMap.calculatePrimaryAndSecondaryColor(NO_HIGHLIGHT_COLOR);
      backgroundColorTop = context.getColor(R.color.incall_background_gradient_top);
      backgroundColorMiddle = context.getColor(R.color.incall_background_gradient_middle);
      backgroundColorBottom = context.getColor(R.color.incall_background_gradient_bottom);
@@ -90,17 +74,6 @@ public class ThemeColorManager {
    secondaryColor = palette.mSecondaryColor;
  }

  @ColorInt
  private int getHighlightColor(Context context, @Nullable PhoneAccountHandle handle) {
    if (handle != null) {
      PhoneAccount account = context.getSystemService(TelecomManager.class).getPhoneAccount(handle);
      if (account != null) {
        return account.getHighlightColor();
      }
    }
    return PhoneAccount.NO_HIGHLIGHT_COLOR;
  }

  @ColorInt
  public int getPrimaryColor() {
    return primaryColor;
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:color="@android:color/white" android:state_enabled="true"/>
  <item android:color="@color/incall_button_background_color" android:state_enabled="true"/>
  <item android:color="#99ffffff" android:state_enabled="false"/>
</selector>
Loading