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