Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 android.assist.testapp; |
| 18 | |
Alice Lee | 0cad7a1 | 2015-08-19 14:54:54 -0700 | [diff] [blame] | 19 | import android.assist.common.Utils; |
| 20 | |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 21 | import android.app.Activity; |
Alice Lee | 0cad7a1 | 2015-08-19 14:54:54 -0700 | [diff] [blame] | 22 | import android.content.Intent; |
Alice Lee | eb39d69 | 2015-08-25 14:29:16 -0700 | [diff] [blame] | 23 | import android.graphics.Bitmap; |
| 24 | import android.os.Bundle; |
| 25 | import android.util.Log; |
| 26 | import android.view.View; |
| 27 | import android.view.View.MeasureSpec; |
| 28 | import android.view.ViewGroup; |
| 29 | import android.view.ViewTreeObserver; |
| 30 | import android.view.ViewTreeObserver.OnGlobalLayoutListener; |
| 31 | |
| 32 | import java.io.ByteArrayOutputStream; |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 33 | import android.os.Bundle; |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 34 | import android.util.Log; |
Alice Lee | 0cad7a1 | 2015-08-19 14:54:54 -0700 | [diff] [blame] | 35 | import android.view.View; |
| 36 | import android.view.ViewTreeObserver; |
| 37 | import android.view.ViewTreeObserver.OnGlobalLayoutListener; |
| 38 | |
| 39 | import java.lang.Override; |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 40 | |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 41 | public class TestApp extends Activity { |
Alice Lee | 69f4ec4 | 2015-08-05 14:17:57 -0700 | [diff] [blame] | 42 | static final String TAG = "TestApp"; |
Alice Lee | d71a07b | 2015-07-29 14:30:56 -0700 | [diff] [blame] | 43 | |
Alice Lee | e4839c3 | 2015-09-04 15:11:35 -0700 | [diff] [blame] | 44 | private String mTestCaseName; |
| 45 | |
Alice Lee | 69f4ec4 | 2015-08-05 14:17:57 -0700 | [diff] [blame] | 46 | @Override |
| 47 | public void onCreate(Bundle savedInstanceState) { |
| 48 | super.onCreate(savedInstanceState); |
| 49 | Log.i(TAG, "TestApp created"); |
Alice Lee | e4839c3 | 2015-09-04 15:11:35 -0700 | [diff] [blame] | 50 | mTestCaseName = getIntent().getStringExtra(Utils.TESTCASE_TYPE); |
| 51 | switch (mTestCaseName) { |
| 52 | case Utils.LARGE_VIEW_HIERARCHY: |
| 53 | setContentView(R.layout.multiple_text_views); |
| 54 | return; |
| 55 | default: |
| 56 | setContentView(R.layout.test_app); |
| 57 | } |
Alice Lee | 69f4ec4 | 2015-08-05 14:17:57 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public void onResume() { |
| 62 | super.onResume(); |
Alice Lee | 0cad7a1 | 2015-08-19 14:54:54 -0700 | [diff] [blame] | 63 | Log.i(TAG, "TestApp has resumed"); |
| 64 | final View layout = findViewById(android.R.id.content); |
| 65 | ViewTreeObserver vto = layout.getViewTreeObserver(); |
| 66 | vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { |
| 67 | @Override |
| 68 | public void onGlobalLayout() { |
| 69 | layout.getViewTreeObserver().removeOnGlobalLayoutListener(this); |
Alice Lee | e4839c3 | 2015-09-04 15:11:35 -0700 | [diff] [blame] | 70 | sendBroadcast(new Intent(Utils.APP_3P_HASRESUMED)); |
Alice Lee | 0cad7a1 | 2015-08-19 14:54:54 -0700 | [diff] [blame] | 71 | } |
| 72 | }); |
Alice Lee | 69f4ec4 | 2015-08-05 14:17:57 -0700 | [diff] [blame] | 73 | } |
| 74 | } |