1/* 2 * Copyright (C) 2016 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 17package com.android.systemui.stackdivider; 18 19import android.annotation.Nullable; 20import android.app.Activity; 21import android.app.ActivityManager; 22import android.os.Bundle; 23import android.view.KeyEvent; 24import android.view.MotionEvent; 25import android.view.View; 26import android.view.View.OnTouchListener; 27import android.widget.TextView; 28 29import com.android.systemui.R; 30 31/** 32 * Translucent activity that gets started on top of a task in multi-window to inform the user that 33 * we forced the activity below to be resizable. 34 */ 35public class ForcedResizableInfoActivity extends Activity implements OnTouchListener { 36 37 private static final long DISMISS_DELAY = 2500; 38 39 private final Runnable mFinishRunnable = new Runnable() { 40 @Override 41 public void run() { 42 finish(); 43 } 44 }; 45 46 @Override 47 protected void onCreate(@Nullable Bundle savedInstanceState) { 48 super.onCreate(savedInstanceState); 49 setContentView(R.layout.forced_resizable_activity); 50 TextView tv = (TextView) findViewById(com.android.internal.R.id.message); 51 tv.setText(R.string.dock_forced_resizable); 52 getWindow().setTitle(getString(R.string.dock_forced_resizable)); 53 getWindow().getDecorView().setOnTouchListener(this); 54 } 55 56 @Override 57 protected void onStart() { 58 super.onStart(); 59 getWindow().getDecorView().postDelayed(mFinishRunnable, DISMISS_DELAY); 60 } 61 62 @Override 63 protected void onStop() { 64 super.onStop(); 65 finish(); 66 } 67 68 @Override 69 public boolean onTouch(View v, MotionEvent event) { 70 finish(); 71 return true; 72 } 73 74 @Override 75 public boolean onKeyDown(int keyCode, KeyEvent event) { 76 finish(); 77 return true; 78 } 79 80 @Override 81 public void finish() { 82 super.finish(); 83 overridePendingTransition(0, R.anim.forced_resizable_exit); 84 } 85 86 @Override 87 public void setTaskDescription(ActivityManager.TaskDescription taskDescription) { 88 // Do nothing 89 } 90} 91