Merge "Add shadow to dream overlay home controls button." into udc-dev am: 3502d6baf5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23146423 Change-Id: Ia39a32e2a90648bad1525917f16948553168898e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,9 +18,7 @@
|
|||||||
-->
|
-->
|
||||||
<shape
|
<shape
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<solid android:color="?androidprv:attr/colorSurface"/>
|
|
||||||
<size
|
<size
|
||||||
android:width="@dimen/dream_overlay_bottom_affordance_height"
|
android:width="@dimen/dream_overlay_bottom_affordance_height"
|
||||||
android:height="@dimen/dream_overlay_bottom_affordance_width"/>
|
android:height="@dimen/dream_overlay_bottom_affordance_width"/>
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
android:layout_width="@dimen/dream_overlay_bottom_affordance_width"
|
android:layout_width="@dimen/dream_overlay_bottom_affordance_width"
|
||||||
android:layout_gravity="bottom|start"
|
android:layout_gravity="bottom|start"
|
||||||
android:padding="@dimen/dream_overlay_bottom_affordance_padding"
|
android:padding="@dimen/dream_overlay_bottom_affordance_padding"
|
||||||
android:background="@drawable/dream_overlay_bottom_affordance_bg"
|
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:tint="?android:attr/textColorPrimary"
|
android:tint="?android:attr/textColorPrimary"
|
||||||
android:src="@drawable/controls_icon"
|
|
||||||
android:contentDescription="@string/quick_controls_title" />
|
android:contentDescription="@string/quick_controls_title" />
|
||||||
|
|||||||
@@ -1643,6 +1643,19 @@
|
|||||||
<dimen name="dream_overlay_bottom_affordance_height">64dp</dimen>
|
<dimen name="dream_overlay_bottom_affordance_height">64dp</dimen>
|
||||||
<dimen name="dream_overlay_bottom_affordance_width">64dp</dimen>
|
<dimen name="dream_overlay_bottom_affordance_width">64dp</dimen>
|
||||||
<dimen name="dream_overlay_bottom_affordance_radius">32dp</dimen>
|
<dimen name="dream_overlay_bottom_affordance_radius">32dp</dimen>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_key_text_shadow_dx">0.5dp</dimen>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_key_text_shadow_dy">0.5dp</dimen>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_key_text_shadow_radius">1dp</dimen>
|
||||||
|
<item name="dream_overlay_bottom_affordance_key_shadow_alpha" format="float" type="dimen">
|
||||||
|
0.35
|
||||||
|
</item>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_ambient_text_shadow_dx">0.5dp</dimen>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_ambient_text_shadow_dy">0.5dp</dimen>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_ambient_text_shadow_radius">2dp</dimen>
|
||||||
|
<item name="dream_overlay_bottom_affordance_ambient_shadow_alpha" format="float" type="dimen">
|
||||||
|
0.4
|
||||||
|
</item>
|
||||||
|
<dimen name="dream_overlay_bottom_affordance_inset">1dp</dimen>
|
||||||
<dimen name="dream_overlay_bottom_affordance_padding">14dp</dimen>
|
<dimen name="dream_overlay_bottom_affordance_padding">14dp</dimen>
|
||||||
<dimen name="dream_overlay_complication_clock_time_text_size">86dp</dimen>
|
<dimen name="dream_overlay_complication_clock_time_text_size">86dp</dimen>
|
||||||
<dimen name="dream_overlay_complication_clock_subtitle_text_size">24sp</dimen>
|
<dimen name="dream_overlay_complication_clock_subtitle_text_size">24sp</dimen>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.systemui.shared.shadow
|
package com.android.systemui.shared.shadow
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.BlendMode
|
import android.graphics.BlendMode
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@@ -106,6 +107,14 @@ class DoubleShadowIconDrawable(
|
|||||||
mIconDrawable.draw(canvas)
|
mIconDrawable.draw(canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getIntrinsicHeight(): Int {
|
||||||
|
return mCanvasSize
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getIntrinsicWidth(): Int {
|
||||||
|
return mCanvasSize
|
||||||
|
}
|
||||||
|
|
||||||
override fun getOpacity(): Int {
|
override fun getOpacity(): Int {
|
||||||
return PixelFormat.TRANSPARENT
|
return PixelFormat.TRANSPARENT
|
||||||
}
|
}
|
||||||
@@ -121,4 +130,8 @@ class DoubleShadowIconDrawable(
|
|||||||
override fun setTint(color: Int) {
|
override fun setTint(color: Int) {
|
||||||
mIconDrawable.setTint(color)
|
mIconDrawable.setTint(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setTintList(tint: ColorStateList?) {
|
||||||
|
mIconDrawable.setTintList(tint)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static com.android.systemui.controls.dagger.ControlsComponent.Visibility.
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -39,6 +40,7 @@ import com.android.systemui.controls.dagger.ControlsComponent;
|
|||||||
import com.android.systemui.controls.management.ControlsListingController;
|
import com.android.systemui.controls.management.ControlsListingController;
|
||||||
import com.android.systemui.controls.ui.ControlsActivity;
|
import com.android.systemui.controls.ui.ControlsActivity;
|
||||||
import com.android.systemui.controls.ui.ControlsUiController;
|
import com.android.systemui.controls.ui.ControlsUiController;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dagger.qualifiers.SystemUser;
|
import com.android.systemui.dagger.qualifiers.SystemUser;
|
||||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
@@ -56,17 +58,20 @@ import javax.inject.Named;
|
|||||||
* devices at home like lights and thermostats).
|
* devices at home like lights and thermostats).
|
||||||
*/
|
*/
|
||||||
public class DreamHomeControlsComplication implements Complication {
|
public class DreamHomeControlsComplication implements Complication {
|
||||||
|
private final Resources mResources;
|
||||||
private final DreamHomeControlsComplicationComponent.Factory mComponentFactory;
|
private final DreamHomeControlsComplicationComponent.Factory mComponentFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DreamHomeControlsComplication(
|
public DreamHomeControlsComplication(
|
||||||
|
@Main Resources resources,
|
||||||
DreamHomeControlsComplicationComponent.Factory componentFactory) {
|
DreamHomeControlsComplicationComponent.Factory componentFactory) {
|
||||||
|
mResources = resources;
|
||||||
mComponentFactory = componentFactory;
|
mComponentFactory = componentFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder createView(ComplicationViewModel model) {
|
public ViewHolder createView(ComplicationViewModel model) {
|
||||||
return mComponentFactory.create().getViewHolder();
|
return mComponentFactory.create(mResources).getViewHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,12 +18,19 @@ package com.android.systemui.complication.dagger;
|
|||||||
|
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.android.settingslib.Utils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.complication.DreamHomeControlsComplication;
|
import com.android.systemui.complication.DreamHomeControlsComplication;
|
||||||
|
import com.android.systemui.shared.shadow.DoubleShadowIconDrawable;
|
||||||
|
import com.android.systemui.shared.shadow.DoubleShadowTextHelper;
|
||||||
|
|
||||||
|
import dagger.BindsInstance;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import dagger.Subcomponent;
|
import dagger.Subcomponent;
|
||||||
@@ -59,7 +66,7 @@ public interface DreamHomeControlsComplicationComponent {
|
|||||||
*/
|
*/
|
||||||
@Subcomponent.Factory
|
@Subcomponent.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
DreamHomeControlsComplicationComponent create();
|
DreamHomeControlsComplicationComponent create(@BindsInstance Resources resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +75,7 @@ public interface DreamHomeControlsComplicationComponent {
|
|||||||
@Module
|
@Module
|
||||||
interface DreamHomeControlsModule {
|
interface DreamHomeControlsModule {
|
||||||
String DREAM_HOME_CONTROLS_CHIP_VIEW = "dream_home_controls_chip_view";
|
String DREAM_HOME_CONTROLS_CHIP_VIEW = "dream_home_controls_chip_view";
|
||||||
|
String DREAM_HOME_CONTROLS_BACKGROUND_DRAWABLE = "dream_home_controls_background_drawable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the dream home controls chip view.
|
* Provides the dream home controls chip view.
|
||||||
@@ -75,9 +83,56 @@ public interface DreamHomeControlsComplicationComponent {
|
|||||||
@Provides
|
@Provides
|
||||||
@DreamHomeControlsComplicationScope
|
@DreamHomeControlsComplicationScope
|
||||||
@Named(DREAM_HOME_CONTROLS_CHIP_VIEW)
|
@Named(DREAM_HOME_CONTROLS_CHIP_VIEW)
|
||||||
static ImageView provideHomeControlsChipView(LayoutInflater layoutInflater) {
|
static ImageView provideHomeControlsChipView(
|
||||||
return (ImageView) layoutInflater.inflate(R.layout.dream_overlay_home_controls_chip,
|
LayoutInflater layoutInflater,
|
||||||
null, false);
|
@Named(DREAM_HOME_CONTROLS_BACKGROUND_DRAWABLE) Drawable backgroundDrawable) {
|
||||||
|
final ImageView chip =
|
||||||
|
(ImageView) layoutInflater.inflate(R.layout.dream_overlay_home_controls_chip,
|
||||||
|
null, false);
|
||||||
|
chip.setBackground(backgroundDrawable);
|
||||||
|
|
||||||
|
return chip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@DreamHomeControlsComplicationScope
|
||||||
|
@Named(DREAM_HOME_CONTROLS_BACKGROUND_DRAWABLE)
|
||||||
|
static Drawable providesHomeControlsBackground(Context context, Resources resources) {
|
||||||
|
final Drawable background = new DoubleShadowIconDrawable(createShadowInfo(
|
||||||
|
resources,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_key_text_shadow_radius,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_key_text_shadow_dx,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_key_text_shadow_dy,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_key_shadow_alpha
|
||||||
|
),
|
||||||
|
createShadowInfo(
|
||||||
|
resources,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_ambient_text_shadow_radius,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_ambient_text_shadow_dx,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_ambient_text_shadow_dy,
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_ambient_shadow_alpha
|
||||||
|
),
|
||||||
|
resources.getDrawable(R.drawable.dream_overlay_bottom_affordance_bg),
|
||||||
|
resources.getDimensionPixelOffset(
|
||||||
|
R.dimen.dream_overlay_bottom_affordance_width),
|
||||||
|
resources.getDimensionPixelSize(R.dimen.dream_overlay_bottom_affordance_inset)
|
||||||
|
);
|
||||||
|
|
||||||
|
background.setTintList(
|
||||||
|
Utils.getColorAttr(context, com.android.internal.R.attr.colorSurface));
|
||||||
|
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DoubleShadowTextHelper.ShadowInfo createShadowInfo(Resources resources,
|
||||||
|
int blurId, int offsetXId, int offsetYId, int alphaId) {
|
||||||
|
|
||||||
|
return new DoubleShadowTextHelper.ShadowInfo(
|
||||||
|
resources.getDimension(blurId),
|
||||||
|
resources.getDimension(offsetXId),
|
||||||
|
resources.getDimension(offsetYId),
|
||||||
|
resources.getFloat(alphaId)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -72,6 +73,9 @@ public class DreamHomeControlsComplicationTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private Resources mResources;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ControlsComponent mControlsComponent;
|
private ControlsComponent mControlsComponent;
|
||||||
|
|
||||||
@@ -118,7 +122,7 @@ public class DreamHomeControlsComplicationTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void complicationType() {
|
public void complicationType() {
|
||||||
final DreamHomeControlsComplication complication =
|
final DreamHomeControlsComplication complication =
|
||||||
new DreamHomeControlsComplication(mComponentFactory);
|
new DreamHomeControlsComplication(mResources, mComponentFactory);
|
||||||
assertThat(complication.getRequiredTypeAvailability()).isEqualTo(
|
assertThat(complication.getRequiredTypeAvailability()).isEqualTo(
|
||||||
COMPLICATION_TYPE_HOME_CONTROLS);
|
COMPLICATION_TYPE_HOME_CONTROLS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user