diff options
| author | 2022-02-04 13:48:53 -0800 | |
|---|---|---|
| committer | 2022-02-25 09:55:54 -0800 | |
| commit | a970d6fe2bd1cf42bd0c72e53af37f63235a7feb (patch) | |
| tree | ae4d4d4a603f3e668a48f125718d605cfccc8c37 | |
| parent | 927480798a2534e747a622572580e98d86d41153 (diff) | |
Remove ComplicationHostViewComponent.
This changelist removes ComplicationHostViewComponent. No additional bound instances were introduced by this ComplicationHostViewComponent, leading to unnecessary scoping.
Bug: 214292772
Test: atest DreamOverlayContainerViewControllerTest
Change-Id: I802cd9308733ed8e0b84737a62bd65638df53ec6
7 files changed, 72 insertions, 118 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index 3d3e4a492871..69f15e692065 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -27,7 +27,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.ComplicationHostViewController; -import com.android.systemui.dreams.complication.dagger.ComplicationHostViewComponent; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.dagger.DreamOverlayModule; import com.android.systemui.util.ViewController; @@ -69,7 +68,7 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve @Inject public DreamOverlayContainerViewController( DreamOverlayContainerView containerView, - ComplicationHostViewComponent.Factory complicationHostViewFactory, + ComplicationHostViewController complicationHostViewController, @Named(DreamOverlayModule.DREAM_OVERLAY_CONTENT_VIEW) ViewGroup contentView, DreamOverlayStatusBarViewController statusBarViewController, @Main Handler handler, @@ -84,7 +83,7 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve mView.getResources().getDimensionPixelSize( R.dimen.dream_overlay_notifications_drag_area_height); - mComplicationHostViewController = complicationHostViewFactory.create().getController(); + mComplicationHostViewController = complicationHostViewController; final View view = mComplicationHostViewController.getView(); mDreamOverlayContentView.addView(view, diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java index f627f150384b..62b319bd9e97 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationHostViewController.java @@ -16,7 +16,7 @@ package com.android.systemui.dreams.complication; -import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewComponent.SCOPED_COMPLICATIONS_LAYOUT; +import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewModule.SCOPED_COMPLICATIONS_LAYOUT; import static com.android.systemui.dreams.complication.dagger.ComplicationModule.SCOPED_COMPLICATIONS_MODEL; import android.graphics.Rect; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java index 437e799106c5..2999c723f634 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java @@ -16,8 +16,8 @@ package com.android.systemui.dreams.complication; -import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewComponent.COMPLICATION_MARGIN; -import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewComponent.SCOPED_COMPLICATIONS_LAYOUT; +import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewModule.COMPLICATION_MARGIN; +import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewModule.SCOPED_COMPLICATIONS_LAYOUT; import android.util.Log; import android.view.View; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewComponent.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewComponent.java deleted file mode 100644 index 20b0e50db984..000000000000 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewComponent.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2022 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.systemui.dreams.complication.dagger; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import android.content.res.Resources; -import android.view.LayoutInflater; - -import androidx.constraintlayout.widget.ConstraintLayout; - -import com.android.internal.util.Preconditions; -import com.android.systemui.R; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dreams.complication.ComplicationHostViewController; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Named; -import javax.inject.Scope; - -import dagger.Module; -import dagger.Provides; -import dagger.Subcomponent; - -/** - * {@link ComplicationHostViewComponent} encapsulates the shared logic around the host view layer - * for complications. Anything that references the layout should be provided through this component - * and its child module. The factory should be used in order to best tie the lifetime of the view - * to components. - */ -@Subcomponent(modules = { - ComplicationHostViewComponent.ComplicationHostViewModule.class, -}) -@ComplicationHostViewComponent.ComplicationHostViewScope -public interface ComplicationHostViewComponent { - String SCOPED_COMPLICATIONS_LAYOUT = "scoped_complications_layout"; - String COMPLICATION_MARGIN = "complication_margin"; - /** Scope annotation for singleton items within {@link ComplicationHostViewComponent}. */ - @Documented - @Retention(RUNTIME) - @Scope - @interface ComplicationHostViewScope {} - - /** - * Factory for generating a new scoped component. - */ - @Subcomponent.Factory - interface Factory { - ComplicationHostViewComponent create(); - } - - /** */ - ComplicationHostViewController getController(); - - /** - * Module for providing a scoped host view. - */ - @Module - abstract class ComplicationHostViewModule { - /** - * Generates a {@link ConstraintLayout}, which can host - * {@link com.android.systemui.dreams.complication.Complication} instances. - */ - @Provides - @Named(SCOPED_COMPLICATIONS_LAYOUT) - @ComplicationHostViewScope - static ConstraintLayout providesComplicationHostView( - LayoutInflater layoutInflater) { - return Preconditions.checkNotNull((ConstraintLayout) - layoutInflater.inflate(R.layout.dream_overlay_complications_layer, - null), - "R.layout.dream_overlay_complications_layer did not properly inflated"); - } - - @Provides - @Named(COMPLICATION_MARGIN) - @ComplicationHostViewScope - static int providesComplicationPadding(@Main Resources resources) { - return resources.getDimensionPixelSize(R.dimen.dream_overlay_complication_margin); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewModule.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewModule.java new file mode 100644 index 000000000000..f701173c26f6 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationHostViewModule.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2022 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.systemui.dreams.complication.dagger; + +import android.content.res.Resources; +import android.view.LayoutInflater; + +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.android.internal.util.Preconditions; +import com.android.systemui.R; +import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.dreams.dagger.DreamOverlayComponent; + +import javax.inject.Named; + +import dagger.Module; +import dagger.Provides; + +/** + * Module for providing a scoped host view. + */ +@Module +public abstract class ComplicationHostViewModule { + public static final String SCOPED_COMPLICATIONS_LAYOUT = "scoped_complications_layout"; + public static final String COMPLICATION_MARGIN = "complication_margin"; + + /** + * Generates a {@link ConstraintLayout}, which can host + * {@link com.android.systemui.dreams.complication.Complication} instances. + */ + @Provides + @Named(SCOPED_COMPLICATIONS_LAYOUT) + @DreamOverlayComponent.DreamOverlayScope + static ConstraintLayout providesComplicationHostView( + LayoutInflater layoutInflater) { + return Preconditions.checkNotNull((ConstraintLayout) + layoutInflater.inflate(R.layout.dream_overlay_complications_layer, + null), + "R.layout.dream_overlay_complications_layer did not properly inflated"); + } + + @Provides + @Named(COMPLICATION_MARGIN) + @DreamOverlayComponent.DreamOverlayScope + static int providesComplicationPadding(@Main Resources resources) { + return resources.getDimensionPixelSize(R.dimen.dream_overlay_complication_margin); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationModule.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationModule.java index b29e8c9ec5a7..785a95df930d 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationModule.java @@ -35,9 +35,10 @@ import dagger.Provides; /** * Module for housing components related to rendering complications. */ -@Module(subcomponents = { +@Module(includes = { + ComplicationHostViewModule.class, + }, subcomponents = { ComplicationViewModelComponent.class, - ComplicationHostViewComponent.class, }) public interface ComplicationModule { String SCOPED_COMPLICATIONS_MODEL = "scoped_complications_model"; diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java index d0e10fba11c5..ff9e13a48bec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java @@ -33,7 +33,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.dreams.complication.ComplicationHostViewController; -import com.android.systemui.dreams.complication.dagger.ComplicationHostViewComponent; import org.junit.Before; import org.junit.Test; @@ -66,12 +65,6 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { ComplicationHostViewController mComplicationHostViewController; @Mock - ComplicationHostViewComponent.Factory mComplicationHostViewComponentFactory; - - @Mock - ComplicationHostViewComponent mComplicationHostViewComponent; - - @Mock ViewGroup mDreamOverlayContentView; @Mock @@ -88,14 +81,10 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase { DREAM_OVERLAY_NOTIFICATIONS_DRAG_AREA_HEIGHT); when(mDreamOverlayContainerView.getResources()).thenReturn(mResources); when(mDreamOverlayContainerView.getViewTreeObserver()).thenReturn(mViewTreeObserver); - when(mComplicationHostViewComponentFactory.create()) - .thenReturn(mComplicationHostViewComponent); - when(mComplicationHostViewComponent.getController()) - .thenReturn(mComplicationHostViewController); mController = new DreamOverlayContainerViewController( mDreamOverlayContainerView, - mComplicationHostViewComponentFactory, + mComplicationHostViewController, mDreamOverlayContentView, mDreamOverlayStatusBarViewController, mHandler, |