Home | History | Annotate | Download | only in am
      1 /*
      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 
     17 package com.android.server.am;
     18 
     19 import com.android.internal.R;
     20 
     21 import android.app.Dialog;
     22 import android.content.Context;
     23 import android.util.TypedValue;
     24 import android.view.Window;
     25 import android.view.WindowManager;
     26 import android.widget.ImageView;
     27 import android.widget.TextView;
     28 
     29 public final 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));
     40 
     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 
     45         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 }
     57