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