1 /*
2  * Copyright (C) 2021 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.datetime;
18 
19 import android.app.AlertDialog;
20 import android.app.Dialog;
21 import android.app.settings.SettingsEnums;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.provider.Settings;
25 
26 import com.android.settings.R;
27 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
28 
29 /**
30  * Dialog shown when user tries to enable GeoTZ with Location toggle disabled.
31  */
32 public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFragment {
33 
LocationToggleDisabledDialogFragment()34     public LocationToggleDisabledDialogFragment() {}
35 
36     @Override
onCreateDialog(Bundle savedInstanceState)37     public Dialog onCreateDialog(Bundle savedInstanceState) {
38         return new AlertDialog.Builder(getActivity())
39                 .setTitle(R.string.location_time_zone_detection_location_is_off_dialog_title)
40                 .setIcon(R.drawable.ic_warning_24dp)
41                 .setMessage(R.string.location_time_zone_detection_location_is_off_dialog_message)
42                 .setPositiveButton(
43                         R.string.location_time_zone_detection_location_is_off_dialog_ok_button,
44                         (dialog, which) -> {
45                             Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
46                                     .setPackage(getContext().getPackageName());
47                             getContext().startActivity(intent);
48                         })
49                 .setNegativeButton(
50                         R.string.location_time_zone_detection_location_is_off_dialog_cancel_button,
51                         (dialog, which) -> {})
52                 .create();
53     }
54 
55     @Override
getMetricsCategory()56     public int getMetricsCategory() {
57         return SettingsEnums.DIALOG_DATE_TIME_ENABLE_GEOTZ_WITH_DISABLED_LOCATION;
58     }
59 }
60