Merge "Import translations. DO NOT MERGE" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1990ce0..f4ff282 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3241,6 +3241,17 @@
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings" />
</activity>
+
+ <activity android:name="Settings$GlobalActionsPanelSettingsActivity"
+ android:label="@string/global_actions_panel_title">
+ <intent-filter>
+ <action android:name="com.android.settings.GLOBAL_ACTIONS_PANEL_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
+ </activity>
+
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index f6fe0c2..b4ebc57 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -165,6 +165,7 @@
public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
+ public static class GlobalActionsPanelSettingsActivity extends SettingsActivity {}
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1dbae00..cb98892 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -36,6 +36,7 @@
import android.os.Handler;
import android.os.UserHandle;
import android.os.Vibrator;
+import android.provider.DeviceConfig;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.text.TextUtils;
@@ -168,6 +169,8 @@
private static final String ANIMATION_ON_VALUE = "1";
private static final String ANIMATION_OFF_VALUE = "0";
+ static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+
private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
private final Handler mHandler = new Handler();
@@ -389,6 +392,15 @@
: stateSummaryCombo;
}
+ @VisibleForTesting
+ static boolean isRampingRingerEnabled(final Context context) {
+ return (Settings.Global.getInt(
+ context.getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, 0) == 1)
+ && DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
+ }
+
private void handleToggleTextContrastPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
@@ -866,7 +878,7 @@
Settings.System.RING_VIBRATION_INTENSITY,
vibrator.getDefaultRingVibrationIntensity());
if (Settings.System.getInt(context.getContentResolver(),
- Settings.System.VIBRATE_WHEN_RINGING, 0) == 0) {
+ Settings.System.VIBRATE_WHEN_RINGING, 0) == 0 && !isRampingRingerEnabled(context)) {
ringIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
}
CharSequence ringIntensityString =
diff --git a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
index 818c414..4dee348 100644
--- a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
@@ -29,7 +29,7 @@
public RingVibrationIntensityPreferenceController(Context context) {
super(context, PREF_KEY, Settings.System.RING_VIBRATION_INTENSITY,
- Settings.System.VIBRATE_WHEN_RINGING);
+ Settings.System.VIBRATE_WHEN_RINGING, /* supportRampingRinger= */ true);
}
@Override
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
index 3e12011..babfb9a 100644
--- a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
@@ -46,7 +46,11 @@
@Override
protected String getVibrationEnabledSetting() {
- return Settings.System.VIBRATE_WHEN_RINGING;
+ if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
+ return Settings.Global.APPLY_RAMPING_RINGER;
+ } else {
+ return Settings.System.VIBRATE_WHEN_RINGING;
+ }
}
@Override
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index e52f92d..9d71176 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -40,15 +40,17 @@
private final SettingObserver mSettingsContentObserver;
private final String mSettingKey;
private final String mEnabledKey;
+ private final boolean mSupportRampingRinger;
private Preference mPreference;
public VibrationIntensityPreferenceController(Context context, String prefkey,
- String settingKey, String enabledKey) {
+ String settingKey, String enabledKey, boolean supportRampingRinger) {
super(context, prefkey);
mVibrator = mContext.getSystemService(Vibrator.class);
mSettingKey = settingKey;
mEnabledKey = enabledKey;
+ mSupportRampingRinger= supportRampingRinger;
mSettingsContentObserver = new SettingObserver(settingKey) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -57,6 +59,11 @@
};
}
+ public VibrationIntensityPreferenceController(Context context, String prefkey,
+ String settingKey, String enabledKey) {
+ this(context, prefkey, settingKey, enabledKey, /* supportRampingRinger= */ false);
+ }
+
@Override
public void onStart() {
mContext.getContentResolver().registerContentObserver(
@@ -80,10 +87,11 @@
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
- final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
- mEnabledKey, 1) == 1;
+ final boolean enabled = (Settings.System.getInt(mContext.getContentResolver(),
+ mEnabledKey, 1) == 1) ||
+ (mSupportRampingRinger && AccessibilitySettings.isRampingRingerEnabled(mContext));
return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
- }
+ }
public static CharSequence getIntensityString(Context context, int intensity) {
final boolean supportsMultipleIntensities = context.getResources().getBoolean(
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
index deaef46..480041a 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
@@ -114,11 +114,20 @@
boolean vibrationEnabled = candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF;
if (hasVibrationEnabledSetting()) {
// Update vibration enabled setting
- boolean wasEnabled = Settings.System.getInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), 1) == 1;
+ final String vibrationEnabledSetting = getVibrationEnabledSetting();
+ final boolean wasEnabled = TextUtils.equals(
+ vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
+ ? true
+ : (Settings.System.getInt(
+ getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
if (vibrationEnabled != wasEnabled) {
- Settings.System.putInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), vibrationEnabled ? 1 : 0);
+ if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) {
+ Settings.Global.putInt(getContext().getContentResolver(),
+ vibrationEnabledSetting, 0);
+ } else {
+ Settings.System.putInt(getContext().getContentResolver(),
+ vibrationEnabledSetting, vibrationEnabled ? 1 : 0);
+ }
}
}
// There are two conditions that need to change the intensity.
@@ -196,8 +205,12 @@
protected String getDefaultKey() {
int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
- final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
- getVibrationEnabledSetting(), 1) == 1;
+ final String vibrationEnabledSetting = getVibrationEnabledSetting();
+ final boolean vibrationEnabled = TextUtils.equals(
+ vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
+ ? true
+ : (Settings.System.getInt(
+ getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
if (!vibrationEnabled) {
vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 9b12309..e92c967 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -138,7 +138,9 @@
mProgressBar = (ProgressBar) findViewById(R.id.fingerprint_progress_bar);
mVibrator = getSystemService(Vibrator.class);
- DescriptionStyler.applyPartnerCustomizationStyle(mRepeatMessage);
+ if (getLayout().shouldApplyPartnerHeavyThemeResource()) {
+ DescriptionStyler.applyPartnerCustomizationStyle(mRepeatMessage);
+ }
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index d073dbc..b35a974 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -83,6 +83,7 @@
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.GlobalActionsPanelSettings;
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.gestures.SystemNavigationGestureSettings;
@@ -279,7 +280,8 @@
ToggleBackupSettingFragment.class.getName(),
PreviouslyConnectedDeviceDashboardFragment.class.getName(),
BatterySaverScheduleSettings.class.getName(),
- MobileNetworkListFragment.class.getName()
+ MobileNetworkListFragment.class.getName(),
+ GlobalActionsPanelSettings.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index ca3e5cc..1af9065 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -24,10 +24,12 @@
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -51,11 +53,12 @@
@VisibleForTesting
boolean mVideoReady;
private boolean mVideoPaused;
- private float mAspectRadio = 1.0f;
+ private float mAspectRatio = 1.0f;
private int mPreviewResource;
private boolean mViewVisible;
private Surface mSurface;
private int mAnimationId;
+ private int mHeight = LinearLayout.LayoutParams.MATCH_PARENT - 1; // video height in pixels
public VideoPreference(Context context) {
super(context);
@@ -121,7 +124,11 @@
R.id.video_container);
imageView.setImageResource(mPreviewResource);
- layout.setAspectRatio(mAspectRadio);
+ layout.setAspectRatio(mAspectRatio);
+ if (mHeight >= LinearLayout.LayoutParams.MATCH_PARENT) {
+ layout.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT, mHeight));
+ }
updateViewStates(imageView, playButton);
video.setOnClickListener(v -> updateViewStates(imageView, playButton));
@@ -247,8 +254,17 @@
return mVideoPaused;
}
+ /**
+ * sets the height of the video preference
+ * @param height in dp
+ */
+ public void setHeight(float height) {
+ mHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height,
+ mContext.getResources().getDisplayMetrics());
+ }
+
@VisibleForTesting
void updateAspectRatio() {
- mAspectRadio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
+ mAspectRatio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
}
}
diff --git a/src/com/android/settings/wifi/qrcode/QrCodeGenerator.java b/src/com/android/settings/wifi/qrcode/QrCodeGenerator.java
index 08fcb10..d9682d2 100644
--- a/src/com/android/settings/wifi/qrcode/QrCodeGenerator.java
+++ b/src/com/android/settings/wifi/qrcode/QrCodeGenerator.java
@@ -20,10 +20,16 @@
import android.graphics.Color;
import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
public final class QrCodeGenerator {
/**
* Generates a barcode image with {@code contents}.
@@ -34,8 +40,13 @@
*/
public static Bitmap encodeQrCode(String contents, int size)
throws WriterException, IllegalArgumentException {
+ final Map<EncodeHintType, Object> hints = new HashMap<>();
+ if (!isIso88591(contents)) {
+ hints.put(EncodeHintType.CHARACTER_SET, StandardCharsets.UTF_8.name());
+ }
+
final BitMatrix qrBits = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE,
- size, size);
+ size, size, hints);
final Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
@@ -44,4 +55,9 @@
}
return bitmap;
}
+
+ private static boolean isIso88591(String contents) {
+ CharsetEncoder encoder = StandardCharsets.ISO_8859_1.newEncoder();
+ return encoder.canEncode(contents);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 43bdc30..5813bd8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -25,12 +25,14 @@
import android.content.ContentResolver;
import android.content.Context;
import android.os.Vibrator;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.testutils.XmlTestUtils;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +40,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import java.util.List;
@@ -135,6 +138,32 @@
}
}
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_bothFlagsOn_Enabled() {
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_settingsFlagOff_Disabled() {
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void testIsRampingRingerEnabled_deviceConfigFlagOff_Disabled() {
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "false", false /* makeDefault*/);
+ assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
+ }
+
private void verifyAccessibilityTimeoutSummary(String preferenceKey, int resId) {
final Preference preference = new Preference(mContext);
doReturn(preference).when(mSettings).findPreference(preferenceKey);
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
new file mode 100644
index 0000000..d23d2f0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+public class RingVibrationPreferenceFragmentTest {
+
+ private Context mContext;
+ private RingVibrationPreferenceFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mFragment = spy(new RingVibrationPreferenceFragment());
+ doReturn(mContext).when(mFragment).getContext();
+ }
+
+ @Test
+ @Config(shadows = {ShadowDeviceConfig.class})
+ public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() {
+ // Turn on both flags to enable ramping ringer.
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
+ assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
+ Settings.Global.APPLY_RAMPING_RINGER);
+ }
+
+ @Test
+ public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() {
+ // Turn off Settings.Global.APPLY_RAMPING_RINGER to disable ramping ringer.
+ Settings.Global.putInt(
+ mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
+ assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
+ Settings.System.VIBRATE_WHEN_RINGING);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
index bd2ce1e..3f67137 100644
--- a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
@@ -128,4 +128,23 @@
assertThat(mQrCode).isEqualTo(googleUrl);
}
+
+ @Test
+ public void testDecode_unicodePictureCaptured_QrCodeCorrectValue() {
+ final String unicodeTest = "中文測試";
+
+ try {
+ final Bitmap bmp = QrCodeGenerator.encodeQrCode(unicodeTest, 320);
+ final int[] intArray = new int[bmp.getWidth() * bmp.getHeight()];
+ bmp.getPixels(intArray, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
+ LuminanceSource source = new RGBLuminanceSource(bmp.getWidth(), bmp.getHeight(),
+ intArray);
+ final BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
+ mCamera.decodeImage(bitmap);
+ bmp.recycle();
+ } catch (WriterException e) {
+ }
+
+ assertThat(mQrCode).isEqualTo(unicodeTest);
+ }
}