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 17 package com.android.systemui.car.systembar; 18 19 import static com.android.systemui.car.displayarea.DisplayAreaComponent.COLLAPSE_APPLICATION_PANEL; 20 21 import android.content.Context; 22 import android.content.Intent; 23 24 import androidx.localbroadcastmanager.content.LocalBroadcastManager; 25 26 /** 27 * {@link RecentsButtonStateProvider} that relies on callers to manually change the Recents state. 28 */ 29 public class CarUiRecentsButtonStateProvider extends RecentsButtonStateProvider { 30 private final Context mContext; 31 CarUiRecentsButtonStateProvider(Context context, CarSystemBarButton carSystemBarButton)32 public CarUiRecentsButtonStateProvider(Context context, CarSystemBarButton carSystemBarButton) { 33 super(context, carSystemBarButton); 34 mContext = context; 35 } 36 37 @Override initialiseListener()38 protected void initialiseListener() { 39 // no-op: Launcher is responsible to inform SystemUI when Panel showing Recents is 40 // expanded/collapsed 41 } 42 43 @Override toggleRecents()44 protected boolean toggleRecents() { 45 if (getIsRecentsActive()) { 46 Intent intent = new Intent(COLLAPSE_APPLICATION_PANEL); 47 LocalBroadcastManager.getInstance(mContext.getApplicationContext()).sendBroadcast( 48 intent); 49 return true; 50 } 51 return super.toggleRecents(); 52 } 53 } 54