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

Commit dfda68c1 authored by Bryce Lee's avatar Bryce Lee
Browse files

Move HideComplicationTouchHandler out of DreamTouchModule.

HideComplicationTouchHandler provides visibility control over
complications on the dream overlay. As complications move out
of the overlay, the related dependences such as
HideComplicationTouchHandler must also relocate. This changelist
refactors the touch handler into a new package and related
component. Also, the handler is now provided at the top level
DreamOverlayModule rather than the DreamTouchModule.

Note that some naming is temporary, due to collisions as packages
are transferred out from under the dream package. For example,
the dreamcomplication package will eventually become the
complication package.

Test: atest HideComplicationTouchHandlerTest
Bug: 261781069
Change-Id: I9bee8b053b434fc5dc7586f1e6d3bdbf1cc2e34f
parent 2e4a1f62
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -25,13 +25,15 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.DreamOverlayNotificationCountProvider;
import com.android.systemui.dreams.complication.dagger.RegisteredComplicationsModule;
import com.android.systemui.dreams.dreamcomplication.dagger.ComplicationComponent;

import dagger.Module;
import dagger.Provides;

import java.util.Optional;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;

/**
 * Dagger Module providing Dream-related functionality.
@@ -41,6 +43,7 @@ import dagger.Provides;
            LowLightDreamModule.class,
        },
        subcomponents = {
            ComplicationComponent.class,
            DreamOverlayComponent.class,
        })
public interface DreamModule {
+18 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.DreamOverlayContainerView;
import com.android.systemui.dreams.DreamOverlayStatusBarView;
import com.android.systemui.dreams.complication.Complication;
import com.android.systemui.dreams.dreamcomplication.HideComplicationTouchHandler;
import com.android.systemui.dreams.dreamcomplication.dagger.ComplicationComponent;
import com.android.systemui.dreams.touch.DreamTouchHandler;
import com.android.systemui.touch.TouchInsetManager;

@@ -37,6 +40,7 @@ import dagger.Lazy;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ElementsIntoSet;
import dagger.multibindings.IntoSet;

import java.util.HashSet;
import java.util.Set;
@@ -274,4 +278,18 @@ public abstract class DreamOverlayModule {
            @Named(DREAM_TOUCH_HANDLERS) @Nullable Set<DreamTouchHandler> touchHandlers) {
        return touchHandlers != null ? touchHandlers : new HashSet<>();
    }

    /**
     * Provides {@link HideComplicationTouchHandler} for inclusion in touch handling over the dream.
     */
    @Provides
    @IntoSet
    public static DreamTouchHandler providesHideComplicationTouchHandler(
            ComplicationComponent.Factory componentFactory,
            Complication.VisibilityController visibilityController,
            TouchInsetManager touchInsetManager) {
        ComplicationComponent component =
                componentFactory.create(visibilityController, touchInsetManager);
        return component.getHideComplicationTouchHandler();
    }
}
+5 −3
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 */

package com.android.systemui.dreams.touch;
package com.android.systemui.dreams.dreamcomplication;

import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewModule.COMPLICATIONS_FADE_OUT_DELAY;
import static com.android.systemui.dreams.complication.dagger.ComplicationHostViewModule.COMPLICATIONS_RESTORE_TIMEOUT;
import static com.android.systemui.dreams.dreamcomplication.dagger.ComplicationModule.COMPLICATIONS_FADE_OUT_DELAY;
import static com.android.systemui.dreams.dreamcomplication.dagger.ComplicationModule.COMPLICATIONS_RESTORE_TIMEOUT;

import android.util.Log;
import android.view.MotionEvent;
@@ -28,6 +28,8 @@ import androidx.annotation.Nullable;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dreams.complication.Complication;
import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor;
import com.android.systemui.dreams.touch.DreamTouchHandler;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.touch.TouchInsetManager;
import com.android.systemui.util.concurrency.DelayableExecutor;
+21 −0
Original line number Diff line number Diff line
package com.android.systemui.dreams.dreamcomplication.dagger

import com.android.systemui.dreams.complication.Complication
import com.android.systemui.dreams.dreamcomplication.HideComplicationTouchHandler
import com.android.systemui.touch.TouchInsetManager
import dagger.BindsInstance
import dagger.Subcomponent

@Subcomponent(modules = [ComplicationModule::class])
interface ComplicationComponent {
    /** Factory for generating [ComplicationComponent]. */
    @Subcomponent.Factory
    interface Factory {
        fun create(
            @BindsInstance visibilityController: Complication.VisibilityController,
            @BindsInstance touchInsetManager: TouchInsetManager
        ): ComplicationComponent
    }

    fun getHideComplicationTouchHandler(): HideComplicationTouchHandler
}
+28 −0
Original line number Diff line number Diff line
package com.android.systemui.dreams.dreamcomplication.dagger

import android.content.res.Resources
import com.android.systemui.R
import com.android.systemui.dagger.qualifiers.Main
import dagger.Module
import dagger.Provides
import javax.inject.Named

@Module
object ComplicationModule {
    const val COMPLICATIONS_RESTORE_TIMEOUT = "complication_restore_timeout"
    const val COMPLICATIONS_FADE_OUT_DELAY = "complication_fade_out_delay"

    /** Provides the delay to wait for before fading out complications. */
    @Provides
    @Named(COMPLICATIONS_FADE_OUT_DELAY)
    fun providesComplicationsFadeOutDelay(@Main resources: Resources): Int {
        return resources.getInteger(R.integer.complicationFadeOutDelayMs)
    }

    /** Provides the timeout for restoring complication visibility. */
    @Provides
    @Named(COMPLICATIONS_RESTORE_TIMEOUT)
    fun providesComplicationsRestoreTimeout(@Main resources: Resources): Int {
        return resources.getInteger(R.integer.complicationRestoreMs)
    }
}
Loading