1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.setupcompat.logging 17 18 import android.view.View 19 20 /** 21 * An abstract class which can be attached to a Setupcompat layout and provides methods for logging 22 * impressions and interactions of its views and buttons. 23 */ 24 interface LoggingObserver { lognull25 fun log(event: SetupCompatUiEvent) 26 27 sealed class SetupCompatUiEvent { 28 data class LayoutInflatedEvent(val view: View) : SetupCompatUiEvent() 29 30 data class LayoutShownEvent(val view: View) : SetupCompatUiEvent() 31 32 data class ButtonInflatedEvent(val view: View, val buttonType: ButtonType) : 33 SetupCompatUiEvent() 34 35 data class ButtonShownEvent(val view: View, val buttonType: ButtonType) : SetupCompatUiEvent() 36 37 data class ButtonInteractionEvent(val view: View, val interactionType: InteractionType) : 38 SetupCompatUiEvent() 39 } 40 41 enum class ButtonType { 42 UNKNOWN, 43 PRIMARY, 44 SECONDARY 45 } 46 47 enum class InteractionType { 48 UNKNOWN, 49 TAP, 50 LONG_PRESS, 51 DOUBLE_TAP 52 } 53 } 54