Files
packages_apps_Settings/src/com/android/settings/display/TwilightLocationDialog.java
Marcelo Arteiro 157030dcef Pending Location information added to Dark Theme
Resolved an issue in Settings where sunset/sunrise dark mode failed silently when a location was unavailable. Now, an error dialog is shown, even if location services are enabled, but a specific location is missing.

A footer stating the same issue is now present while the location is pending.

Existing banner that appears when Location is disabled is now being removed once Location is turned on. Previously the UI would refresh only after exiting and returning to the preference view.

Bug: 324548844
Bug: 402025928
Test: atest UiModeManagerServiceTest
Flag: EXEMPT bugfix
Change-Id: I914937185f11a686b453f929728b6329ebd05389
2025-03-20 03:21:45 -07:00

66 lines
2.4 KiB
Java

/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.display;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.android.settings.R;
import com.android.settings.Settings;
/**
* This class launches a dialog when users try to use twilight scheduling without
* turning on location services
*/
public class TwilightLocationDialog {
public static String TAG = "TwilightLocationDialog";
/**
* This method launches a dialog when users try to use twilight scheduling without
* turning on location services.
* @param context The context of the calling activity.
*/
public static void showLocationOff(Context context) {
final AlertDialog dialog = new AlertDialog.Builder(context)
.setPositiveButton(R.string.twilight_mode_launch_location, ((dialog1, which) -> {
Log.d(TAG, "clicked forget");
final Intent intent = new Intent();
intent.setClass(context, Settings.LocationSettingsActivity.class);
context.startActivity(intent);
}))
.setNegativeButton(R.string.cancel, null /* listener */)
.setMessage(R.string.twilight_mode_location_off_dialog_message)
.create();
dialog.show();
}
/**
* This method launches a dialog when users try to use twilight scheduling but the location
* could not be determined.
* @param context The context of the calling activity.
*/
public static void showLocationPending(Context context) {
final AlertDialog dialog = new AlertDialog.Builder(context)
.setPositiveButton(R.string.dlg_ok, null /* listener */)
.setMessage(R.string.twilight_mode_pending_location)
.create();
dialog.show();
}
}