Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java +4 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,12 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da private int mColor; private final MobileIconsViewModel mMobileIconsViewModel; private final StatusBarLocation mLocation; public DemoStatusIcons( LinearLayout statusIcons, MobileIconsViewModel mobileIconsViewModel, StatusBarLocation location, int iconSize ) { super(statusIcons.getContext()); Loading @@ -71,6 +73,7 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da mIconSize = iconSize; mColor = DarkIconDispatcher.DEFAULT_ICON_TINT; mMobileIconsViewModel = mobileIconsViewModel; mLocation = location; if (statusIcons instanceof StatusIconContainer) { setShouldRestrictIcons(((StatusIconContainer) statusIcons).isRestrictingIcons()); Loading Loading @@ -287,7 +290,7 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da ModernStatusBarMobileView view = ModernStatusBarMobileView.constructAndBind( mobileContext, "mobile", mMobileIconsViewModel.viewModelForSub(subId) mMobileIconsViewModel.viewModelForSub(subId, mLocation) ); // mobile always goes at the end Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java +10 −3 Original line number Diff line number Diff line Loading @@ -359,6 +359,7 @@ public interface StatusBarIconController { // Whether or not these icons show up in dumpsys protected boolean mShouldLog = false; private StatusBarIconController mController; private final StatusBarLocation mLocation; // Enables SystemUI demo mode to take effect in this group protected boolean mDemoable = true; Loading @@ -381,6 +382,7 @@ public interface StatusBarIconController { mContext = group.getContext(); mIconSize = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.status_bar_icon_size); mLocation = location; if (statusBarPipelineFlags.runNewMobileIconsBackend()) { // This starts the flow for the new pipeline, and will notify us of changes if Loading @@ -394,7 +396,7 @@ public interface StatusBarIconController { if (statusBarPipelineFlags.runNewWifiIconBackend()) { // This starts the flow for the new pipeline, and will notify us of changes if // {@link StatusBarPipelineFlags#useNewWifiIcon} is also true. mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, location); mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, mLocation); } else { mWifiViewModel = null; } Loading Loading @@ -569,7 +571,7 @@ public interface StatusBarIconController { .constructAndBind( mobileContext, slot, mMobileIconsViewModel.viewModelForSub(subId) mMobileIconsViewModel.viewModelForSub(subId, mLocation) ); } Loading Loading @@ -705,7 +707,12 @@ public interface StatusBarIconController { } protected DemoStatusIcons createDemoStatusIcons() { return new DemoStatusIcons((LinearLayout) mGroup, mMobileIconsViewModel, mIconSize); return new DemoStatusIcons( (LinearLayout) mGroup, mMobileIconsViewModel, mLocation, mIconSize ); } } } packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R import com.android.systemui.common.ui.binder.IconViewBinder import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconViewModel import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.LocationBasedMobileViewModel import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch Loading @@ -39,7 +39,7 @@ object MobileIconBinder { @JvmStatic fun bind( view: ViewGroup, viewModel: MobileIconViewModel, viewModel: LocationBasedMobileViewModel, ) { val activityContainer = view.requireViewById<View>(R.id.inout_container) val activityIn = view.requireViewById<ImageView>(R.id.mobile_in) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/view/ModernStatusBarMobileView.kt +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.systemui.R import com.android.systemui.statusbar.BaseStatusBarFrameLayout import com.android.systemui.statusbar.StatusBarIconView.STATE_ICON import com.android.systemui.statusbar.pipeline.mobile.ui.binder.MobileIconBinder import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconViewModel import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.LocationBasedMobileViewModel import java.util.ArrayList class ModernStatusBarMobileView( Loading Loading @@ -71,7 +71,7 @@ class ModernStatusBarMobileView( fun constructAndBind( context: Context, slot: String, viewModel: MobileIconViewModel, viewModel: LocationBasedMobileViewModel, ): ModernStatusBarMobileView { return (LayoutInflater.from(context) .inflate(R.layout.status_bar_mobile_signal_group_new, null) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/LocationBasedMobileViewModel.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * 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.mobile.ui.viewmodel import android.graphics.Color import com.android.systemui.statusbar.phone.StatusBarLocation import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf /** * A view model for an individual mobile icon that embeds the notion of a [StatusBarLocation]. This * allows the mobile icon to change some view parameters at different locations * * @param commonImpl for convenience, this class wraps a base interface that can provides all of the * common implementations between locations. See [MobileIconViewModel] */ abstract class LocationBasedMobileViewModel( val commonImpl: MobileIconViewModelCommon, ) : MobileIconViewModelCommon by commonImpl { abstract val tint: Flow<Int> companion object { fun viewModelForLocation( commonImpl: MobileIconViewModelCommon, loc: StatusBarLocation, ): LocationBasedMobileViewModel = when (loc) { StatusBarLocation.HOME -> HomeMobileIconViewModel(commonImpl) StatusBarLocation.KEYGUARD -> KeyguardMobileIconViewModel(commonImpl) StatusBarLocation.QS -> QsMobileIconViewModel(commonImpl) } } } class HomeMobileIconViewModel( commonImpl: MobileIconViewModelCommon, ) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.CYAN) } class QsMobileIconViewModel(commonImpl: MobileIconViewModelCommon) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.GREEN) } class KeyguardMobileIconViewModel(commonImpl: MobileIconViewModelCommon) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.MAGENTA) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java +4 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,12 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da private int mColor; private final MobileIconsViewModel mMobileIconsViewModel; private final StatusBarLocation mLocation; public DemoStatusIcons( LinearLayout statusIcons, MobileIconsViewModel mobileIconsViewModel, StatusBarLocation location, int iconSize ) { super(statusIcons.getContext()); Loading @@ -71,6 +73,7 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da mIconSize = iconSize; mColor = DarkIconDispatcher.DEFAULT_ICON_TINT; mMobileIconsViewModel = mobileIconsViewModel; mLocation = location; if (statusIcons instanceof StatusIconContainer) { setShouldRestrictIcons(((StatusIconContainer) statusIcons).isRestrictingIcons()); Loading Loading @@ -287,7 +290,7 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da ModernStatusBarMobileView view = ModernStatusBarMobileView.constructAndBind( mobileContext, "mobile", mMobileIconsViewModel.viewModelForSub(subId) mMobileIconsViewModel.viewModelForSub(subId, mLocation) ); // mobile always goes at the end Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java +10 −3 Original line number Diff line number Diff line Loading @@ -359,6 +359,7 @@ public interface StatusBarIconController { // Whether or not these icons show up in dumpsys protected boolean mShouldLog = false; private StatusBarIconController mController; private final StatusBarLocation mLocation; // Enables SystemUI demo mode to take effect in this group protected boolean mDemoable = true; Loading @@ -381,6 +382,7 @@ public interface StatusBarIconController { mContext = group.getContext(); mIconSize = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.status_bar_icon_size); mLocation = location; if (statusBarPipelineFlags.runNewMobileIconsBackend()) { // This starts the flow for the new pipeline, and will notify us of changes if Loading @@ -394,7 +396,7 @@ public interface StatusBarIconController { if (statusBarPipelineFlags.runNewWifiIconBackend()) { // This starts the flow for the new pipeline, and will notify us of changes if // {@link StatusBarPipelineFlags#useNewWifiIcon} is also true. mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, location); mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, mLocation); } else { mWifiViewModel = null; } Loading Loading @@ -569,7 +571,7 @@ public interface StatusBarIconController { .constructAndBind( mobileContext, slot, mMobileIconsViewModel.viewModelForSub(subId) mMobileIconsViewModel.viewModelForSub(subId, mLocation) ); } Loading Loading @@ -705,7 +707,12 @@ public interface StatusBarIconController { } protected DemoStatusIcons createDemoStatusIcons() { return new DemoStatusIcons((LinearLayout) mGroup, mMobileIconsViewModel, mIconSize); return new DemoStatusIcons( (LinearLayout) mGroup, mMobileIconsViewModel, mLocation, mIconSize ); } } }
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import com.android.settingslib.graph.SignalDrawable import com.android.systemui.R import com.android.systemui.common.ui.binder.IconViewBinder import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconViewModel import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.LocationBasedMobileViewModel import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch Loading @@ -39,7 +39,7 @@ object MobileIconBinder { @JvmStatic fun bind( view: ViewGroup, viewModel: MobileIconViewModel, viewModel: LocationBasedMobileViewModel, ) { val activityContainer = view.requireViewById<View>(R.id.inout_container) val activityIn = view.requireViewById<ImageView>(R.id.mobile_in) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/view/ModernStatusBarMobileView.kt +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.systemui.R import com.android.systemui.statusbar.BaseStatusBarFrameLayout import com.android.systemui.statusbar.StatusBarIconView.STATE_ICON import com.android.systemui.statusbar.pipeline.mobile.ui.binder.MobileIconBinder import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconViewModel import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.LocationBasedMobileViewModel import java.util.ArrayList class ModernStatusBarMobileView( Loading Loading @@ -71,7 +71,7 @@ class ModernStatusBarMobileView( fun constructAndBind( context: Context, slot: String, viewModel: MobileIconViewModel, viewModel: LocationBasedMobileViewModel, ): ModernStatusBarMobileView { return (LayoutInflater.from(context) .inflate(R.layout.status_bar_mobile_signal_group_new, null) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/LocationBasedMobileViewModel.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * 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.mobile.ui.viewmodel import android.graphics.Color import com.android.systemui.statusbar.phone.StatusBarLocation import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf /** * A view model for an individual mobile icon that embeds the notion of a [StatusBarLocation]. This * allows the mobile icon to change some view parameters at different locations * * @param commonImpl for convenience, this class wraps a base interface that can provides all of the * common implementations between locations. See [MobileIconViewModel] */ abstract class LocationBasedMobileViewModel( val commonImpl: MobileIconViewModelCommon, ) : MobileIconViewModelCommon by commonImpl { abstract val tint: Flow<Int> companion object { fun viewModelForLocation( commonImpl: MobileIconViewModelCommon, loc: StatusBarLocation, ): LocationBasedMobileViewModel = when (loc) { StatusBarLocation.HOME -> HomeMobileIconViewModel(commonImpl) StatusBarLocation.KEYGUARD -> KeyguardMobileIconViewModel(commonImpl) StatusBarLocation.QS -> QsMobileIconViewModel(commonImpl) } } } class HomeMobileIconViewModel( commonImpl: MobileIconViewModelCommon, ) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.CYAN) } class QsMobileIconViewModel(commonImpl: MobileIconViewModelCommon) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.GREEN) } class KeyguardMobileIconViewModel(commonImpl: MobileIconViewModelCommon) : MobileIconViewModelCommon, LocationBasedMobileViewModel(commonImpl) { override val tint: Flow<Int> = flowOf(Color.MAGENTA) }