1bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov/* 2bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * Copyright (C) 2016 The Android Open Source Project 3bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * 4bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * Licensed under the Apache License, Version 2.0 (the "License"); 5bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * you may not use this file except in compliance with the License. 6bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * You may obtain a copy of the License at 7bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * 8bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * http://www.apache.org/licenses/LICENSE-2.0 9bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * 10bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * Unless required by applicable law or agreed to in writing, software 11bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * distributed under the License is distributed on an "AS IS" BASIS, 12bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * See the License for the specific language governing permissions and 14bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov * limitations under the License. 15bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov */ 16bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov 17bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikovpackage android.support.percent; 18bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov 19bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikovimport android.app.Activity; 20bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikovimport android.os.Bundle; 21bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikovimport android.view.WindowManager; 22bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov 23bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikovabstract class BaseTestActivity extends Activity { 24bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov @Override 25bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov protected void onCreate(Bundle savedInstanceState) { 26bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov super.onCreate(savedInstanceState); 27320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas overridePendingTransition(0, 0); 28bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 29bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov final int contentView = getContentViewLayoutResId(); 30bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov if (contentView > 0) { 31bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov setContentView(contentView); 32bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov } 33bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov onContentViewSet(); 34bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 35bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov } 36bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov 37320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas @Override 38320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas public void finish() { 39320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas super.finish(); 40320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas overridePendingTransition(0, 0); 41320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas } 42320463c1cf5f8e50cce340df195b60835fe23002Aurimas Liutikas 43bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov protected abstract int getContentViewLayoutResId(); 44bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov 45bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov protected void onContentViewSet() {} 46bcbbc065a6ff7a0cd2ebb0b29cc9298a6fce77e5Kirill Grouchnikov} 47