blob: cb2b7bbeaff2a47c8af5b2b45215209276c06139 [file] [log] [blame]
James Dong199d1c12011-03-17 11:48:13 -07001/*
2 * Copyright (C) 2011 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
Dianne Hackborn0dad3642010-09-09 21:25:35 -070017package com.android.server.am;
18
19import com.android.internal.R;
20
21import android.app.Dialog;
22import android.content.Context;
Adam Powell947f7822011-01-07 22:30:48 -080023import android.util.TypedValue;
Dianne Hackborn0dad3642010-09-09 21:25:35 -070024import android.view.Window;
25import android.view.WindowManager;
26import android.widget.ImageView;
27import android.widget.TextView;
28
29public class LaunchWarningWindow extends Dialog {
30 public LaunchWarningWindow(Context context, ActivityRecord cur, ActivityRecord next) {
31 super(context, R.style.Theme_Toast);
32
33 requestWindowFeature(Window.FEATURE_LEFT_ICON);
34 getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
35 getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
36 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
37
38 setContentView(R.layout.launch_warning);
39 setTitle(context.getText(R.string.launch_warning_title));
Adam Powell947f7822011-01-07 22:30:48 -080040
41 TypedValue out = new TypedValue();
42 getContext().getTheme().resolveAttribute(android.R.attr.alertDialogIcon, out, true);
43 getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, out.resourceId);
44
Dianne Hackborn0dad3642010-09-09 21:25:35 -070045 ImageView icon = (ImageView)findViewById(R.id.replace_app_icon);
46 icon.setImageDrawable(next.info.applicationInfo.loadIcon(context.getPackageManager()));
47 TextView text = (TextView)findViewById(R.id.replace_message);
48 text.setText(context.getResources().getString(R.string.launch_warning_replace,
49 next.info.applicationInfo.loadLabel(context.getPackageManager()).toString()));
50 icon = (ImageView)findViewById(R.id.original_app_icon);
51 icon.setImageDrawable(cur.info.applicationInfo.loadIcon(context.getPackageManager()));
52 text = (TextView)findViewById(R.id.original_message);
53 text.setText(context.getResources().getString(R.string.launch_warning_original,
54 cur.info.applicationInfo.loadLabel(context.getPackageManager()).toString()));
55 }
56}