1 /* 2 * Copyright (C) 2020 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.display; 18 19 import android.app.AlertDialog; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.util.Log; 23 24 import com.android.settings.R; 25 import com.android.settings.Settings; 26 27 /** 28 * This class launches a dialog when users try to use twilight scheduling without 29 * turning on location services 30 */ 31 public class TwilightLocationDialog { 32 public static String TAG = "TwilightLocationDialog"; 33 34 /** 35 * This method launches a dialog when users try to use twilight scheduling without 36 * turning on location services. 37 * @param context The context of the calling activity. 38 */ showLocationOff(Context context)39 public static void showLocationOff(Context context) { 40 final AlertDialog dialog = new AlertDialog.Builder(context) 41 .setPositiveButton(R.string.twilight_mode_launch_location, ((dialog1, which) -> { 42 Log.d(TAG, "clicked forget"); 43 final Intent intent = new Intent(); 44 intent.setClass(context, Settings.LocationSettingsActivity.class); 45 context.startActivity(intent); 46 })) 47 .setNegativeButton(R.string.cancel, null /* listener */) 48 .setMessage(R.string.twilight_mode_location_off_dialog_message) 49 .create(); 50 dialog.show(); 51 } 52 53 /** 54 * This method launches a dialog when users try to use twilight scheduling but the location 55 * could not be determined. 56 * @param context The context of the calling activity. 57 */ showLocationPending(Context context)58 public static void showLocationPending(Context context) { 59 final AlertDialog dialog = new AlertDialog.Builder(context) 60 .setPositiveButton(R.string.dlg_ok, null /* listener */) 61 .setMessage(R.string.twilight_mode_pending_location) 62 .create(); 63 dialog.show(); 64 } 65 } 66