1 /* 2 * Copyright (C) 2013 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package com.android.mail.ui.settings; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.app.DialogFragment; 22 import android.content.DialogInterface; 23 import android.content.DialogInterface.OnClickListener; 24 import android.os.Bundle; 25 import android.widget.Toast; 26 27 import com.android.mail.R; 28 import com.android.mail.preferences.MailPrefs; 29 30 public class ClearPictureApprovalsDialogFragment extends DialogFragment implements OnClickListener { 31 32 public static final String FRAGMENT_TAG = "ClearPictureApprovalsDialogFragment"; 33 34 // Public no-args constructor needed for fragment re-instantiation 35 public ClearPictureApprovalsDialogFragment() {} 36 37 /** 38 * Creates a new instance of {@link ClearPictureApprovalsDialogFragment}. 39 * @return The newly created {@link ClearPictureApprovalsDialogFragment}. 40 */ 41 public static ClearPictureApprovalsDialogFragment newInstance() { 42 final ClearPictureApprovalsDialogFragment fragment = 43 new ClearPictureApprovalsDialogFragment(); 44 return fragment; 45 } 46 47 @Override 48 public Dialog onCreateDialog(final Bundle savedInstanceState) { 49 return new AlertDialog.Builder(getActivity()) 50 .setTitle(R.string.clear_display_images_whitelist_dialog_title) 51 .setMessage(R.string.clear_display_images_whitelist_dialog_message) 52 .setIconAttribute(android.R.attr.alertDialogIcon) 53 .setPositiveButton(R.string.clear, this) 54 .setNegativeButton(R.string.cancel, this) 55 .create(); 56 } 57 58 @Override 59 public void onClick(DialogInterface dialog, int which) { 60 if (which == DialogInterface.BUTTON_POSITIVE) { 61 final MailPrefs mailPrefs = MailPrefs.get(getActivity()); 62 mailPrefs.clearSenderWhiteList(); 63 Toast.makeText(getActivity(), R.string.sender_whitelist_cleared, Toast.LENGTH_SHORT) 64 .show(); 65 } 66 } 67 } 68