1 /* 2 * Copyright (C) 2022 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.settings.development; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.app.settings.SettingsEnums; 22 import android.content.DialogInterface; 23 import android.os.Bundle; 24 25 import androidx.annotation.NonNull; 26 import androidx.fragment.app.Fragment; 27 import androidx.fragment.app.FragmentActivity; 28 import androidx.fragment.app.FragmentManager; 29 30 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 31 32 /** 33 * Information dialog shown when enabling back animations 34 */ 35 public class BackAnimationPreferenceDialog extends InstrumentedDialogFragment 36 implements DialogInterface.OnClickListener { 37 38 public static final String TAG = "BackAnimationDlg"; 39 BackAnimationPreferenceDialog()40 private BackAnimationPreferenceDialog() { 41 } 42 43 /** 44 * Show this dialog. 45 */ show(@onNull Fragment host)46 public static void show(@NonNull Fragment host) { 47 FragmentActivity activity = host.getActivity(); 48 if (activity == null) { 49 return; 50 } 51 FragmentManager manager = activity.getSupportFragmentManager(); 52 if (manager.findFragmentByTag(TAG) == null) { 53 BackAnimationPreferenceDialog dialog = new BackAnimationPreferenceDialog(); 54 dialog.setTargetFragment(host, 0 /* requestCode */); 55 dialog.show(manager, TAG); 56 } 57 } 58 59 @Override getMetricsCategory()60 public int getMetricsCategory() { 61 return SettingsEnums.DIALOG_BACK_ANIMATIONS; 62 } 63 64 @Override 65 @NonNull onCreateDialog(Bundle savedInstanceState)66 public Dialog onCreateDialog(Bundle savedInstanceState) { 67 return new AlertDialog.Builder(getActivity()) 68 .setTitle(com.android.settingslib.R.string.back_navigation_animation) 69 .setMessage(com.android.settingslib.R.string.back_navigation_animation_dialog) 70 .setPositiveButton(android.R.string.ok, this /* onClickListener */) 71 .create(); 72 } 73 74 @Override onClick(DialogInterface dialog, int which)75 public void onClick(DialogInterface dialog, int which) { 76 // Do nothing 77 } 78 } 79