blob: 8860a771fd5aba65afbf18f8fa24486bf5798c48 [file] [log] [blame]
Andrii Kulian962e4342018-01-23 20:17:31 -08001/**
2 * Copyright (c) 2018 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.google.android.test.activityview;
18
19import android.app.Activity;
20import android.app.ActivityView;
21import android.content.Intent;
22import android.os.Bundle;
23import android.widget.Button;
24import android.widget.LinearLayout;
25import android.widget.SeekBar;
26
27public class ActivityViewResizeActivity extends Activity {
28 private static final int SMALL_SIZE = 600;
29 private static final int LARGE_SIZE = 1200;
30
31 private ActivityView mActivityView;
32
33 private boolean mFlipSize;
34
35 @Override
36 protected void onCreate(Bundle savedInstanceState) {
37 super.onCreate(savedInstanceState);
38 setContentView(R.layout.activity_view_resize_activity);
39
40 mActivityView = findViewById(R.id.activity_view);
41
42 final Button launchButton = findViewById(R.id.activity_launch_button);
43 launchButton.setOnClickListener(v -> {
44 final Intent intent = new Intent(this, ActivityViewTestActivity.class);
45 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
46 mActivityView.startActivity(intent);
47 });
48 final Button resizeButton = findViewById(R.id.activity_resize_button);
49 if (resizeButton != null) {
50 resizeButton.setOnClickListener(v -> {
51 LinearLayout.LayoutParams params =
52 (LinearLayout.LayoutParams) mActivityView.getLayoutParams();
53 params.height = mFlipSize ? SMALL_SIZE : LARGE_SIZE;
54 mFlipSize = !mFlipSize;
55 mActivityView.setLayoutParams(params);
56 });
57 }
58 final SeekBar seekBar = findViewById(R.id.activity_view_seek_bar);
59 if (seekBar != null) {
60 seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
61 @Override
62 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
63 final LinearLayout.LayoutParams params =
64 (LinearLayout.LayoutParams) mActivityView.getLayoutParams();
65 params.height = SMALL_SIZE + progress * 10;
66 mActivityView.setLayoutParams(params);
67 }
68
69 @Override
70 public void onStartTrackingTouch(SeekBar seekBar) {
71 }
72
73 @Override
74 public void onStopTrackingTouch(SeekBar seekBar) {
75 }
76 });
77 }
78 }
79}