1 /* 2 * Copyright (C) 2017 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.launcher3.anim; 18 19 import android.graphics.Rect; 20 21 import com.android.launcher3.util.PillRevealOutlineProvider; 22 23 /** 24 * Extension of {@link PillRevealOutlineProvider} which only changes the height of the pill. 25 * For now, we assume the height is added/removed from the bottom. 26 */ 27 public class PillHeightRevealOutlineProvider extends PillRevealOutlineProvider { 28 29 private final int mNewHeight; 30 PillHeightRevealOutlineProvider(Rect pillRect, float radius, int newHeight)31 public PillHeightRevealOutlineProvider(Rect pillRect, float radius, int newHeight) { 32 super(0, 0, pillRect, radius); 33 mOutline.set(pillRect); 34 mNewHeight = newHeight; 35 } 36 37 @Override setProgress(float progress)38 public void setProgress(float progress) { 39 mOutline.top = 0; 40 int heightDifference = mPillRect.height() - mNewHeight; 41 mOutline.bottom = (int) (mPillRect.bottom - heightDifference * (1 - progress)); 42 } 43 } 44