/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.test.ui.app;

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

/** Activity that updates a TextView when its screen orientation is changed. */
public class ScreenOrientationWithoutOnConfigurationChangedActivity extends Activity {
  private static final String TAG = "ScreenOrientationWithoutOnConfigurationChangedActivity";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.screen_orientation_without_onconfigurationchanged_activity);

    String orientation;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      orientation = "landscape";
    } else {
      orientation = "portrait";
    }

    TextView textView = (TextView) findViewById(R.id.screen_orientation);
    textView.setText(orientation);
    Log.d(TAG, "onCreate. Orientation set to " + orientation);
  }
}

@@ -999,18 +999,23 @@
 ng TAG =
+%0A     
  
-%22
 ScreenOr
@@ -1060,17 +1060,38 @@
 Activity
-%22
+.class.getSimpleName()
 ;%0A%0A  @Ov
@@ -1305,52 +1305,466 @@
 tion
-;%0A    if (getResources().getConfiguration().
+ = setOrientationString(getResources().getConfiguration().orientation);%0A    Log.d(TAG, %22onCreate. Orientation set to %22 + orientation);%0A  %7D%0A%0A  @Override%0A  public void onResume() %7B%0A    super.onResume();%0A    String orientation = setOrientationString(getResources().getConfiguration().orientation);%0A    Log.d(TAG, %22onResume. Orientation set to %22 + orientation);%0A  %7D%0A%0A  private String setOrientationString(int orientation) %7B%0A    String orientationString;%0A    if (
 orie
@@ -1826,24 +1826,30 @@
  orientation
+String
  = %22landscap
@@ -1882,16 +1882,22 @@
 entation
+String
  = %22port
@@ -2020,72 +2020,45 @@
 tion
+String
 );%0A    
-Log.d(TAG, %22onCreate. Orientation set to %22 + orientation)
+return orientationString
 ;%0A  

Update orientation TextView when ScreenOrientationWithoutOnConfigurationChangedActivity is resumed