1 /* 2 * Copyright 2021 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.quickstep.views; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.util.FloatProperty; 22 import android.view.Gravity; 23 import android.widget.FrameLayout; 24 25 import com.android.quickstep.util.SplitSelectStateController; 26 27 public class SplitPlaceholderView extends FrameLayout { 28 29 public static final FloatProperty<SplitPlaceholderView> ALPHA_FLOAT = 30 new FloatProperty<SplitPlaceholderView>("SplitViewAlpha") { 31 @Override 32 public void setValue(SplitPlaceholderView splitPlaceholderView, float v) { 33 splitPlaceholderView.setVisibility(v != 0 ? VISIBLE : GONE); 34 splitPlaceholderView.setAlpha(v); 35 } 36 37 @Override 38 public Float get(SplitPlaceholderView splitPlaceholderView) { 39 return splitPlaceholderView.getAlpha(); 40 } 41 }; 42 43 private SplitSelectStateController mSplitController; 44 private IconView mIcon; 45 SplitPlaceholderView(Context context, AttributeSet attrs)46 public SplitPlaceholderView(Context context, AttributeSet attrs) { 47 super(context, attrs); 48 } 49 init(SplitSelectStateController controller)50 public void init(SplitSelectStateController controller) { 51 this.mSplitController = controller; 52 } 53 getSplitController()54 public SplitSelectStateController getSplitController() { 55 return mSplitController; 56 } 57 setIcon(IconView icon)58 public void setIcon(IconView icon) { 59 if (mIcon == null) { 60 mIcon = new IconView(getContext()); 61 addView(mIcon); 62 } 63 mIcon.setDrawable(icon.getDrawable()); 64 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(icon.getLayoutParams()); 65 params.gravity = Gravity.CENTER; 66 mIcon.setLayoutParams(params); 67 } 68 } 69