Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b95bd67 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Apply banner message for night light page"

parents 4a921534 f7e5b68b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -20,11 +20,9 @@
    android:title="@string/dark_ui_mode"
    settings:keywords="@string/keywords_dark_ui_mode">

    <com.android.settingslib.widget.LayoutPreference
    <com.android.settingslib.widget.BannerMessagePreference
        android:key="dark_ui_location_off"
        android:selectable="false"
        android:layout="@layout/twilight_mode_location_off"
        settings:allowDividerBelow="true"
        android:title="@string/twilight_mode_location_off_dialog_message"
        settings:controller="com.android.settings.display.TwilightLocationPreferenceController"/>

    <com.android.settingslib.widget.TopIntroPreference
+3 −5
Original line number Diff line number Diff line
@@ -20,12 +20,10 @@
    android:title="@string/night_display_title"
    settings:keywords="@string/keywords_display_night_display">

    <com.android.settingslib.widget.LayoutPreference
    <com.android.settingslib.widget.BannerMessagePreference
        android:key="dark_ui_location_off"
        android:selectable="false"
        android:layout="@layout/twilight_mode_location_off"
        settings:controller="com.android.settings.display.TwilightLocationPreferenceController"
        settings:allowDividerBelow="true"/>
        android:title="@string/twilight_mode_location_off_dialog_message"
        settings:controller="com.android.settings.display.TwilightLocationPreferenceController"/>

    <com.android.settingslib.widget.TopIntroPreference
        android:key="night_display_top_intro"
+15 −10
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.settings.display;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.view.View;

import androidx.preference.PreferenceScreen;

@@ -28,7 +27,7 @@ import com.android.settings.Settings;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.LayoutPreference;
import com.android.settingslib.widget.BannerMessagePreference;

/**
 * Controller to take the user to location settings page
@@ -46,13 +45,13 @@ public class TwilightLocationPreferenceController extends BasePreferenceControll
    @Override
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);
        final LayoutPreference preference = screen.findPreference(getPreferenceKey());
        final View button = preference.findViewById(R.id.go_to_location_setting);
        button.setOnClickListener(v -> {
        final BannerMessagePreference preference =
                (BannerMessagePreference) screen.findPreference(getPreferenceKey());
        preference
                .setPositiveButtonText(R.string.twilight_mode_launch_location)
                .setPositiveButtonOnClickListener(v -> {
                    mMetricsFeatureProvider.logClickedPreference(preference, getMetricsCategory());
            final Intent intent = new Intent();
            intent.setClass(mContext, Settings.LocationSettingsActivity.class);
            mContext.startActivity(intent);
                    launchLocationSettings();
                });
    }

@@ -61,4 +60,10 @@ public class TwilightLocationPreferenceController extends BasePreferenceControll
        return mLocationManager.isLocationEnabled() ? CONDITIONALLY_UNAVAILABLE
                : AVAILABLE_UNSEARCHABLE;
    }

    private void launchLocationSettings() {
        final Intent intent = new Intent();
        intent.setClass(mContext, Settings.LocationSettingsActivity.class);
        mContext.startActivity(intent);
    }
}