1 /*
2  * Copyright (C) 2015 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.packageinstaller.permission.ui;
18 
19 import android.app.Activity;
20 import android.app.AlertDialog;
21 import android.content.ActivityNotFoundException;
22 import android.content.DialogInterface;
23 import android.content.DialogInterface.OnClickListener;
24 import android.content.DialogInterface.OnDismissListener;
25 import android.content.Intent;
26 import android.os.Bundle;
27 import android.provider.Settings;
28 import android.util.Log;
29 
30 import com.android.permissioncontroller.R;
31 
32 public class OverlayWarningDialog extends Activity implements OnClickListener, OnDismissListener {
33 
34     private static final String TAG = "OverlayWarningDialog";
35 
36     @Override
onCreate(Bundle savedInstanceState)37     protected void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39 
40         new AlertDialog.Builder(this)
41                 .setTitle(R.string.screen_overlay_title)
42                 .setMessage(R.string.screen_overlay_message)
43                 .setPositiveButton(R.string.screen_overlay_button, this)
44                 .setOnDismissListener(this)
45                 .show();
46     }
47 
48     @Override
onDismiss(DialogInterface dialog)49     public void onDismiss(DialogInterface dialog) {
50         finish();
51     }
52 
53     @Override
onClick(DialogInterface dialog, int which)54     public void onClick(DialogInterface dialog, int which) {
55         finish();
56         try {
57             startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION));
58         } catch (ActivityNotFoundException e) {
59             Log.w(TAG, "No manage overlay settings", e);
60         }
61     }
62 
63 }
64