[SB Refactor] Move the wifi view binding class to shared/.
The mobile view will need the exact same binding object, so move it to be shared between mobile and wifi. Bug: 238425913 Test: verify wifi icon still tints correctly Change-Id: I8ac2384a377b5fa61a429c3135f10a23c3544a40
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.statusbar.pipeline.shared.ui.binder
|
||||
|
||||
import com.android.systemui.statusbar.StatusBarIconView
|
||||
|
||||
/**
|
||||
* Defines interface for an object that acts as the binding between a modern status bar view and its
|
||||
* view-model.
|
||||
*
|
||||
* Users of the view binder classes in the modern status bar pipeline should use this to control the
|
||||
* binder after it is bound.
|
||||
*/
|
||||
interface ModernStatusBarViewBinding {
|
||||
/** Returns true if the icon should be visible and false otherwise. */
|
||||
fun getShouldIconBeVisible(): Boolean
|
||||
|
||||
/** Notifies that the visibility state has changed. */
|
||||
fun onVisibilityStateChanged(@StatusBarIconView.VisibleState state: Int)
|
||||
|
||||
/** Notifies that the icon tint has been updated. */
|
||||
fun onIconTintChanged(newTint: Int)
|
||||
|
||||
/** Notifies that the decor tint has been updated (used only for the dot). */
|
||||
fun onDecorTintChanged(newTint: Int)
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import com.android.systemui.statusbar.StatusBarIconView
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_DOT
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_ICON
|
||||
import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewBinding
|
||||
import com.android.systemui.statusbar.pipeline.wifi.ui.model.WifiIcon
|
||||
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWifiViewModel
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
@@ -49,31 +50,12 @@ import kotlinx.coroutines.launch
|
||||
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
||||
object WifiViewBinder {
|
||||
|
||||
/**
|
||||
* Defines interface for an object that acts as the binding between the view and its view-model.
|
||||
*
|
||||
* Users of the [WifiViewBinder] class should use this to control the binder after it is bound.
|
||||
*/
|
||||
interface Binding {
|
||||
/** Returns true if the wifi icon should be visible and false otherwise. */
|
||||
fun getShouldIconBeVisible(): Boolean
|
||||
|
||||
/** Notifies that the visibility state has changed. */
|
||||
fun onVisibilityStateChanged(@StatusBarIconView.VisibleState state: Int)
|
||||
|
||||
/** Notifies that the icon tint has been updated. */
|
||||
fun onIconTintChanged(newTint: Int)
|
||||
|
||||
/** Notifies that the decor tint has been updated (used only for the dot). */
|
||||
fun onDecorTintChanged(newTint: Int)
|
||||
}
|
||||
|
||||
/** Binds the view to the view-model, continuing to update the former based on the latter. */
|
||||
@JvmStatic
|
||||
fun bind(
|
||||
view: ViewGroup,
|
||||
viewModel: LocationBasedWifiViewModel,
|
||||
): Binding {
|
||||
): ModernStatusBarViewBinding {
|
||||
val groupView = view.requireViewById<ViewGroup>(R.id.wifi_group)
|
||||
val iconView = view.requireViewById<ImageView>(R.id.wifi_signal)
|
||||
val dotView = view.requireViewById<StatusBarIconView>(R.id.status_bar_dot)
|
||||
@@ -148,7 +130,7 @@ object WifiViewBinder {
|
||||
}
|
||||
}
|
||||
|
||||
return object : Binding {
|
||||
return object : ModernStatusBarViewBinding {
|
||||
override fun getShouldIconBeVisible(): Boolean {
|
||||
return viewModel.wifiIcon.value is WifiIcon.Visible
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.android.systemui.statusbar.BaseStatusBarFrameLayout
|
||||
import com.android.systemui.statusbar.StatusBarIconView
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_DOT
|
||||
import com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN
|
||||
import com.android.systemui.statusbar.pipeline.shared.ui.binder.ModernStatusBarViewBinding
|
||||
import com.android.systemui.statusbar.pipeline.wifi.ui.binder.WifiViewBinder
|
||||
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWifiViewModel
|
||||
|
||||
@@ -40,7 +41,7 @@ class ModernStatusBarWifiView(
|
||||
) : BaseStatusBarFrameLayout(context, attrs) {
|
||||
|
||||
private lateinit var slot: String
|
||||
private lateinit var binding: WifiViewBinder.Binding
|
||||
private lateinit var binding: ModernStatusBarViewBinding
|
||||
|
||||
@StatusBarIconView.VisibleState
|
||||
private var iconVisibleState: Int = STATE_HIDDEN
|
||||
|
||||
Reference in New Issue
Block a user