1 /* 2 * Copyright (C) 2022 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 package com.android.quicksearchbox 17 18 import android.app.Activity 19 import android.os.Bundle 20 import android.view.View 21 import android.view.Window 22 import android.widget.FrameLayout 23 import android.widget.TextView 24 25 /** Activity that looks like a dialog window. */ 26 abstract class DialogActivity : Activity() { 27 @JvmField protected var mTitleView: TextView? = null 28 29 @JvmField protected var mContentFrame: FrameLayout? = null 30 31 @Override onCreatenull32 protected override fun onCreate(savedInstanceState: Bundle?) { 33 super.onCreate(savedInstanceState) 34 getWindow().requestFeature(Window.FEATURE_NO_TITLE) 35 setContentView(R.layout.dialog_activity) 36 mTitleView = findViewById(R.id.alertTitle) as TextView? 37 mContentFrame = findViewById(R.id.content) as FrameLayout? 38 } 39 setHeadingnull40 fun setHeading(titleRes: Int) { 41 mTitleView?.setText(titleRes) 42 } 43 setHeadingnull44 fun setHeading(title: CharSequence?) { 45 mTitleView?.setText(title) 46 } 47 setDialogContentnull48 fun setDialogContent(layoutRes: Int) { 49 mContentFrame?.removeAllViews() 50 getLayoutInflater().inflate(layoutRes, mContentFrame) 51 } 52 setDialogContentnull53 fun setDialogContent(content: View?) { 54 mContentFrame?.removeAllViews() 55 mContentFrame?.addView(content) 56 } 57 } 58