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
17package com.android.packageinstaller.permission.ui;
18
19import android.app.Activity;
20import android.app.AlertDialog;
21import android.content.ActivityNotFoundException;
22import android.content.DialogInterface;
23import android.content.DialogInterface.OnClickListener;
24import android.content.DialogInterface.OnDismissListener;
25import android.content.Intent;
26import android.os.Bundle;
27import android.provider.Settings;
28import android.util.Log;
29
30import com.android.packageinstaller.R;
31
32public class OverlayWarningDialog extends Activity implements OnClickListener, OnDismissListener {
33
34    private static final String TAG = "OverlayWarningDialog";
35
36    @Override
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
49    public void onDismiss(DialogInterface dialog) {
50        finish();
51    }
52
53    @Override
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