1 /* 2 * Copyright (C) 2019 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.settings.notification; 17 18 import android.app.Dialog; 19 import android.app.settings.SettingsEnums; 20 import android.os.Bundle; 21 22 import androidx.appcompat.app.AlertDialog; 23 24 import com.android.settings.R; 25 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 26 27 public class BubbleWarningDialogFragment extends InstrumentedDialogFragment { 28 static final String KEY_PKG = "p"; 29 static final String KEY_UID = "u"; 30 31 32 @Override getMetricsCategory()33 public int getMetricsCategory() { 34 return SettingsEnums.DIALOG_APP_BUBBLE_SETTINGS; 35 } 36 setPkgInfo(String pkg, int uid)37 public BubbleWarningDialogFragment setPkgInfo(String pkg, int uid) { 38 Bundle args = new Bundle(); 39 args.putString(KEY_PKG, pkg); 40 args.putInt(KEY_UID, uid); 41 setArguments(args); 42 return this; 43 } 44 45 @Override onCreateDialog(Bundle savedInstanceState)46 public Dialog onCreateDialog(Bundle savedInstanceState) { 47 super.onCreate(savedInstanceState); 48 final Bundle args = getArguments(); 49 final String pkg = args.getString(KEY_PKG); 50 final int uid = args.getInt(KEY_UID); 51 52 final String title = 53 getResources().getString(R.string.bubbles_feature_disabled_dialog_title); 54 final String summary = getResources() 55 .getString(R.string.bubbles_feature_disabled_dialog_text); 56 return new AlertDialog.Builder(getContext()) 57 .setMessage(summary) 58 .setTitle(title) 59 .setCancelable(true) 60 .setPositiveButton(R.string.bubbles_feature_disabled_button_approve, 61 (dialog, id) -> 62 BubblePreferenceController.applyBubblesApproval( 63 getContext(), pkg, uid)) 64 .setNegativeButton(R.string.bubbles_feature_disabled_button_cancel, 65 (dialog, id) -> 66 BubblePreferenceController.revertBubblesApproval( 67 getContext(), pkg, uid)) 68 .create(); 69 } 70 } 71