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 androidx.annotation.Nullable; 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 @Nullable 44 private IconView mIconView; 45 SplitPlaceholderView(Context context, AttributeSet attrs)46 public SplitPlaceholderView(Context context, AttributeSet attrs) { 47 super(context, attrs); 48 } 49 50 @Nullable getIconView()51 public IconView getIconView() { 52 return mIconView; 53 } 54 setIconView(IconView iconView, int iconSize)55 public void setIconView(IconView iconView, int iconSize) { 56 if (mIconView == null) { 57 mIconView = new IconView(getContext()); 58 addView(mIconView); 59 } 60 mIconView.setDrawable(iconView.getDrawable()); 61 mIconView.setDrawableSize(iconSize, iconSize); 62 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(iconView.getLayoutParams()); 63 params.gravity = Gravity.CENTER; 64 mIconView.setLayoutParams(params); 65 } 66 } 67