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

Commit a946d9a9 authored by Daniel Hillenbrand's avatar Daniel Hillenbrand Committed by Gerrit Code Review
Browse files

Merge "Battery Light: Add ability to configure (Part 2 of 2)" into ics

parents cc52f047 2aac983b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1412,6 +1412,8 @@

        <activity android:name=".notificationlight.NotificationLightSettings" />

        <activity android:name=".notificationlight.BatteryLightSettings" />

        <activity android:name="Settings$AnonymousStatsActivity"
                android:label="@string/anonymous_statistics_title"
                android:configChanges="orientation|keyboardHidden|screenSize"
+8 −2
Original line number Diff line number Diff line
@@ -738,8 +738,14 @@
    <string name="summary_font_size" translatable="false">%1$s</string>
    <!-- [CHAR LIMIT=40] Sound & display settings screen, title of dialog for picking font size -->
    <string name="dialog_title_font_size">Font size</string>
    <!-- Display settings screen, battery light repeat pulsing title -->
    <string name="battery_pulse_title">Pulse low battery light</string>

    <!-- Battery light settings #CM -->
    <string name="battery_light_title">Battery light</string>
    <string name="battery_low_pulse_title">Pulse if battery low</string>
    <string name="battery_light_list_title">Colors</string>
    <string name="battery_light_low_color_title">Battery low</string>
    <string name="battery_light_medium_color_title">Charging</string>
    <string name="battery_light_full_color_title">Fully charged</string>

    <!-- Backlight #CM -->
    <string name="backlight_title">Automatic backlight</string>
+57 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The CyanogenMod 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.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">

    <PreferenceCategory
        android:key="general_section"
        android:title="@string/notification_light_general_title">

        <CheckBoxPreference
            android:key="battery_light"
            android:title="@string/battery_light_title"
            android:persistent="false" />

        <CheckBoxPreference
            android:key="battery_low_pulse"
            android:title="@string/battery_low_pulse_title"
            android:persistent="false" />

        </PreferenceCategory>

    <PreferenceCategory
        android:key="colors_list"
        android:title="@string/battery_light_list_title" >

        <com.android.settings.notificationlight.ApplicationLightPreference
            android:key="low_color"
            android:title="@string/battery_light_low_color_title"
            android:persistent="false" />

        <com.android.settings.notificationlight.ApplicationLightPreference
            android:key="medium_color"
            android:title="@string/battery_light_medium_color_title"
            android:persistent="false" />

        <com.android.settings.notificationlight.ApplicationLightPreference
            android:key="full_color"
            android:title="@string/battery_light_full_color_title"
            android:persistent="false" />

    </PreferenceCategory>

</PreferenceScreen>
+4 −4
Original line number Diff line number Diff line
@@ -47,10 +47,10 @@
            android:title="@string/notification_pulse_title"
            android:fragment="com.android.settings.notificationlight.NotificationLightSettings" />

        <CheckBoxPreference
            android:key="battery_pulse"
            android:title="@string/battery_pulse_title"
            android:persistent="false" />
        <PreferenceScreen
            android:key="battery_light"
            android:title="@string/battery_light_title"
            android:fragment="com.android.settings.notificationlight.BatteryLightSettings" />

        <PreferenceCategory
            android:key="category_animation_options"
+15 −11
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
    private static final String KEY_AUTOMATIC_BACKLIGHT = "backlight_widget";
    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
    private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
    private static final String KEY_BATTERY_PULSE = "battery_pulse";
    private static final String KEY_BATTERY_LIGHT = "battery_light";
    private static final String KEY_DISPLAY_ROTATION = "display_rotation";
    private static final String KEY_ELECTRON_BEAM_ANIMATION_ON = "electron_beam_animation_on";
    private static final String KEY_ELECTRON_BEAM_ANIMATION_OFF = "electron_beam_animation_off";
@@ -62,10 +62,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
    private static final String ROTATION_ANGLE_DELIM_FINAL = " & ";

    private CheckBoxPreference mVolumeWake;
    private CheckBoxPreference mBatteryPulse;
    private CheckBoxPreference mElectronBeamAnimationOn;
    private CheckBoxPreference mElectronBeamAnimationOff;
    private PreferenceScreen mNotificationPulse;
    private PreferenceScreen mBatteryPulse;

    private final Configuration mCurConfig = new Configuration();

@@ -113,15 +113,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
            }
        }

        mBatteryPulse = (CheckBoxPreference) findPreference(KEY_BATTERY_PULSE);
        mBatteryPulse = (PreferenceScreen) findPreference(KEY_BATTERY_LIGHT);
        if (mBatteryPulse != null) {
            if (getResources().getBoolean(
                    com.android.internal.R.bool.config_intrusiveBatteryLed) == false) {
                getPreferenceScreen().removePreference(mBatteryPulse);
            } else {
                mBatteryPulse.setChecked(Settings.System.getInt(resolver,
                        Settings.System.BATTERY_LIGHT_PULSE, 1) == 1);
                mBatteryPulse.setOnPreferenceChangeListener(this);
                updateBatteryPulseDescription();
            }
        }

@@ -266,11 +264,21 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
        }
    }

    private void updateBatteryPulseDescription() {
        if (Settings.System.getInt(getActivity().getContentResolver(),
                Settings.System.BATTERY_LIGHT_ENABLED, 0) == 1) {
            mBatteryPulse.setSummary(getString(R.string.notification_light_enabled));
        } else {
            mBatteryPulse.setSummary(getString(R.string.notification_light_disabled));
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        updateDisplayRotationPreferenceDescription();
        updateLightPulseDescription();
        updateBatteryPulseDescription();

        getContentResolver().registerContentObserver(
                Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true,
@@ -286,11 +294,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mBatteryPulse) {
            boolean value = mBatteryPulse.isChecked();
            Settings.System.putInt(getContentResolver(), Settings.System.BATTERY_LIGHT_PULSE,
                    value ? 1 : 0);
        } else if (preference == mElectronBeamAnimationOn) {
        if (preference == mElectronBeamAnimationOn) {
            Settings.System.putInt(getContentResolver(), Settings.System.ELECTRON_BEAM_ANIMATION_ON,
                    mElectronBeamAnimationOn.isChecked() ? 1 : 0);
            return true;
Loading