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

Commit f7bed1a1 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [3716234, 3716235, 3715523] into pi-release

Change-Id: I59580df3f5fe4caaa1f30a861e6461e1ab55104a
parents 88b1165d 05de08eb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -57,15 +57,15 @@

    <!-- When the lock screen is showing and the phone plugged in, and the battery
         is not fully charged, say that it's charging.  -->
    <string name="keyguard_plugged_in">Charging</string>
    <string name="keyguard_plugged_in"><xliff:g id="percentage">%s</xliff:g>Charging</string>

    <!-- When the lock screen is showing and the phone plugged in, and the battery
         is not fully charged, and it's plugged into a fast charger, say that it's charging fast.  -->
    <string name="keyguard_plugged_in_charging_fast">Charging rapidly</string>
    <string name="keyguard_plugged_in_charging_fast"><xliff:g id="percentage">%s</xliff:g>Charging rapidly</string>

    <!-- When the lock screen is showing and the phone plugged in, and the battery
         is not fully charged, and it's plugged into a slow charger, say that it's charging slowly.  -->
    <string name="keyguard_plugged_in_charging_slowly">Charging slowly</string>
    <string name="keyguard_plugged_in_charging_slowly"><xliff:g id="percentage">%s</xliff:g>Charging slowly</string>

    <!-- When the lock screen is showing and the battery is low, warn user to plug
         in the phone soon. -->
+6 −6
Original line number Diff line number Diff line
@@ -946,14 +946,14 @@
    <!-- Interruption level: Alarms only.  Optimized for narrow two-line display. [CHAR LIMIT=40] -->
    <string name="interruption_level_alarms_twoline">Alarms\nonly</string>

    <!-- Indication on the keyguard that is shown when the device is charging. [CHAR LIMIT=40]-->
    <string name="keyguard_indication_charging_time">Charging (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
    <!-- Indication on the keyguard that is shown when the device is charging. [CHAR LIMIT=50]-->
    <string name="keyguard_indication_charging_time"><xliff:g id="percentage">%2$s</xliff:g>Charging (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>

    <!-- Indication on the keyguard that is shown when the device is charging rapidly. Should match keyguard_plugged_in_charging_fast [CHAR LIMIT=40]-->
    <string name="keyguard_indication_charging_time_fast">Charging rapidly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
    <!-- Indication on the keyguard that is shown when the device is charging rapidly. Should match keyguard_plugged_in_charging_fast [CHAR LIMIT=50]-->
    <string name="keyguard_indication_charging_time_fast"><xliff:g id="percentage">%2$s</xliff:g>Charging rapidly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>

    <!-- Indication on the keyguard that is shown when the device is charging slowly. Should match keyguard_plugged_in_charging_slowly [CHAR LIMIT=40]-->
    <string name="keyguard_indication_charging_time_slowly">Charging slowly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
    <!-- Indication on the keyguard that is shown when the device is charging slowly. Should match keyguard_plugged_in_charging_slowly [CHAR LIMIT=50]-->
    <string name="keyguard_indication_charging_time_slowly"><xliff:g id="percentage">%2$s</xliff:g>Charging slowly (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>

    <!-- Related to user switcher --><skip/>

+18 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.systemui.util.wakelock.WakeLock;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.text.NumberFormat;
import java.util.IllegalFormatConversionException;

/**
 * Controls the indications and error messages shown on the Keyguard
@@ -411,14 +412,29 @@ public class KeyguardIndicationController {
                break;
        }

        String percentage = NumberFormat.getPercentInstance()
                .format(mBatteryLevel / 100f);
        if (hasChargingTime) {
            // We now have battery percentage in these strings and it's expected that all
            // locales will also have it in the future. For now, we still have to support the old
            // format until all languages get the new translations.
            String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
                    mContext, chargingTimeRemaining);
            try {
                return mContext.getResources().getString(chargingId, chargingTimeFormatted,
                        percentage);
            } catch (IllegalFormatConversionException e) {
                return mContext.getResources().getString(chargingId, chargingTimeFormatted);
            }
        } else {
            // Same as above
            try {
                return mContext.getResources().getString(chargingId, percentage);
            } catch (IllegalFormatConversionException e) {
                return mContext.getResources().getString(chargingId);
            }
        }
    }

    public void setStatusBarKeyguardViewManager(
            StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.systemui.statusbar;

import android.content.Context;
import android.database.ContentObserver;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;

public class VibratorHelper {

    private final Vibrator mVibrator;
    private final Context mContext;
    private boolean mHapticFeedbackEnabled;

    final private ContentObserver mVibrationObserver = new ContentObserver(Handler.getMain()) {
        @Override
        public void onChange(boolean selfChange) {
            updateHapticFeedBackEnabled();
        }
    };

    public VibratorHelper(Context context) {
        mContext = context;
        mVibrator = context.getSystemService(Vibrator.class);

        mContext.getContentResolver().registerContentObserver(
                Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED), true,
                mVibrationObserver);
        mVibrationObserver.onChange(false /* selfChange */);
    }

    public void vibrate(final int effectId) {
        if (mHapticFeedbackEnabled) {
            AsyncTask.execute(() ->
                    mVibrator.vibrate(VibrationEffect.get(effectId, false /* fallback */)));
        }
    }

    private void updateHapticFeedBackEnabled() {
        mHapticFeedbackEnabled = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) != 0;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.os.SystemProperties;
import android.os.VibrationEffect;
import android.support.annotation.ColorInt;
import android.util.AttributeSet;
import android.util.Log;
@@ -67,6 +68,7 @@ import com.android.systemui.recents.RecentsOnboarding;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.NavigationBarCompat;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.policy.DeadZone;
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
import com.android.systemui.statusbar.policy.TintedKeyButtonDrawable;
@@ -148,6 +150,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
    private Divider mDivider;
    private RecentsOnboarding mRecentsOnboarding;
    private NotificationPanelView mPanelView;
    private final VibratorHelper mVibratorHelper;

    private int mRotateBtnStyle = R.style.RotateButtonCCWStart90;

@@ -243,6 +246,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

        mOverviewProxyService = Dependency.get(OverviewProxyService.class);
        mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
        mVibratorHelper = new VibratorHelper(context);

        mConfiguration = new Configuration();
        mConfiguration.updateFrom(context.getResources().getConfiguration());
@@ -311,6 +315,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                } else if (mRecentsButtonBounds.contains(x, y)) {
                    mDownHitTarget = HIT_TARGET_OVERVIEW;
                }

                // Vibrate tick whenever down occurs on navigation bar
                mVibratorHelper.vibrate(VibrationEffect.EFFECT_TICK);
                break;
        }
        return mGestureHelper.onInterceptTouchEvent(event);
Loading