Snap for 6626737 from b3a67455cd to mainline-release
Change-Id: If2b0266bd074a852bd88948e7cc725d36e379331
This commit is contained in:
@@ -423,8 +423,9 @@
|
||||
|
||||
<!-- Output switcher panel related dimensions -->
|
||||
<dimen name="output_switcher_slice_padding_top">11dp</dimen>
|
||||
<dimen name="output_switcher_slice_max_height">506dp</dimen>
|
||||
<dimen name="output_switcher_slice_max_height">458dp</dimen>
|
||||
<dimen name="output_switcher_panel_icon_size">52dp</dimen>
|
||||
<dimen name="output_switcher_panel_icon_corner_radius">16dp</dimen>
|
||||
|
||||
<!-- Text padding for EmptyTextSettings -->
|
||||
<dimen name="empty_text_padding">24dp</dimen>
|
||||
|
||||
@@ -11322,7 +11322,7 @@
|
||||
<string name="platform_compat_default_disabled_title">Default disabled changes</string>
|
||||
<!-- Title for target SDK gated app compat changes category (do not translate 'targetSdkVersion') [CHAR LIMIT=50] -->
|
||||
<string name="platform_compat_target_sdk_title">Enabled for targetSdkVersion > <xliff:g id="number" example="29">%d</xliff:g></string>
|
||||
<!-- Title for the dialog shown when no debuggable apps are available [CHAR LIMIT=20] -->
|
||||
<!-- Title for the dialog shown when no debuggable apps are available [CHAR LIMIT=30] -->
|
||||
<string name="platform_compat_dialog_title_no_apps">No apps available</string>
|
||||
<!-- Explanatory text shown when no debuggable apps are available [CHAR LIMIT=NONE] -->
|
||||
<string name="platform_compat_dialog_text_no_apps">App compatibility changes can only be modified for debuggable apps. Install a debuggable app and try again.</string>
|
||||
@@ -12135,7 +12135,7 @@
|
||||
|
||||
<!-- Title for media control settings [CHAR LIMIT=50]-->
|
||||
<string name="media_controls_title">Media</string>
|
||||
<!-- Summary for media control settings [CHAR LIMIT=50]-->
|
||||
<!-- Summary for media control settings [CHAR LIMIT=60]-->
|
||||
<string name="media_controls_summary">Hide player when the media session has ended</string>
|
||||
<!-- Description of toggle to enable or disable the media resumption feature in quick settings [CHAR LIMIT=NONE]-->
|
||||
<string name="media_controls_resume_description">The player allows you to resume a session from the expanded Quick Settings panel.</string>
|
||||
|
||||
@@ -92,8 +92,11 @@ import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TabWidget;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.Preference;
|
||||
@@ -1113,4 +1116,25 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bitmap with rounded corner.
|
||||
*
|
||||
* @param context application context.
|
||||
* @param source bitmap to apply round corner.
|
||||
* @param cornerRadius corner radius value.
|
||||
*/
|
||||
public static Bitmap convertCornerRadiusBitmap(@NonNull Context context,
|
||||
@NonNull Bitmap source, @NonNull float cornerRadius) {
|
||||
final Bitmap roundedBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
final RoundedBitmapDrawable drawable =
|
||||
RoundedBitmapDrawableFactory.create(context.getResources(), source);
|
||||
drawable.setAntiAlias(true);
|
||||
drawable.setCornerRadius(cornerRadius);
|
||||
final Canvas canvas = new Canvas(roundedBitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return roundedBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.content.Intent;
|
||||
import android.location.LocationManager;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -57,13 +56,9 @@ public class TwilightLocationPreferenceController extends BasePreferenceControll
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setVisible(!mLocationManager.isLocationEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
return mLocationManager.isLocationEnabled() ? CONDITIONALLY_UNAVAILABLE
|
||||
: AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,10 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
|
||||
@VisibleForTesting
|
||||
List<ContextualCard> filterEligibleCards(List<ContextualCard> candidates) {
|
||||
if (candidates.isEmpty()) {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
final ExecutorService executor = Executors.newFixedThreadPool(candidates.size());
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
List<Future<ContextualCard>> eligibleCards = new ArrayList<>();
|
||||
|
||||
@@ -116,7 +116,11 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
||||
if (metadata != null) {
|
||||
final Bitmap bitmap = metadata.getDescription().getIconBitmap();
|
||||
if (bitmap != null) {
|
||||
return IconCompat.createWithBitmap(bitmap);
|
||||
final Bitmap roundBitmap = Utils.convertCornerRadiusBitmap(mContext, bitmap,
|
||||
(float) mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.output_switcher_panel_icon_corner_radius));
|
||||
|
||||
return IconCompat.createWithBitmap(roundBitmap);
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Media meta data does not contain icon information");
|
||||
|
||||
@@ -127,10 +127,12 @@ public class SlicesDatabaseAccessor {
|
||||
int numResults = resultCursor.getCount();
|
||||
|
||||
if (numResults == 0) {
|
||||
resultCursor.close();
|
||||
throw new IllegalStateException("Invalid Slices key from path: " + path);
|
||||
}
|
||||
|
||||
if (numResults > 1) {
|
||||
resultCursor.close();
|
||||
throw new IllegalStateException(
|
||||
"Should not match more than 1 slice with path: " + path);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.LocationManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TwilightLocationPreferenceControllerTest {
|
||||
private static final String TEST_KEY = "test_key";
|
||||
|
||||
private Context mContext;
|
||||
private TwilightLocationPreferenceController mController;
|
||||
|
||||
@Mock
|
||||
private LocationManager mLocationManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(LocationManager.class)).thenReturn(mLocationManager);
|
||||
mController = new TwilightLocationPreferenceController(mContext, TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_locationEnabled_shouldBeCONDITIONALLY_UNAVAILABLE() {
|
||||
when(mLocationManager.isLocationEnabled()).thenReturn(true);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_locationDisabled_shouldBeAVAILABLE_UNSEARCHABLE() {
|
||||
when(mLocationManager.isLocationEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
}
|
||||
@@ -232,13 +232,20 @@ public class MediaDeviceUpdateWorkerTest {
|
||||
public void onSlicePinned_packageUpdated_checkPackageName() {
|
||||
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
|
||||
when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
|
||||
|
||||
mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, URI1);
|
||||
mMediaDeviceUpdateWorker.mLocalMediaManager = mock(LocalMediaManager.class);
|
||||
when(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName())
|
||||
.thenReturn(TEST_DEVICE_PACKAGE_NAME1);
|
||||
mMediaDeviceUpdateWorker.onSlicePinned();
|
||||
|
||||
assertThat(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName()).matches(
|
||||
TEST_DEVICE_PACKAGE_NAME1);
|
||||
|
||||
mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, URI2);
|
||||
mMediaDeviceUpdateWorker.mLocalMediaManager = mock(LocalMediaManager.class);
|
||||
when(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName())
|
||||
.thenReturn(TEST_DEVICE_PACKAGE_NAME2);
|
||||
mMediaDeviceUpdateWorker.onSlicePinned();
|
||||
|
||||
assertThat(mMediaDeviceUpdateWorker.mLocalMediaManager.getPackageName()).matches(
|
||||
|
||||
@@ -121,10 +121,12 @@ public class MediaOutputIndicatorWorkerTest {
|
||||
|
||||
@Test
|
||||
public void onSlicePinned_packageUpdated_checkPackageName() {
|
||||
mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager;
|
||||
initPlayback();
|
||||
when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo);
|
||||
when(mMediaController.getPlaybackState()).thenReturn(mPlaybackState);
|
||||
when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
|
||||
when(mLocalMediaManager.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
|
||||
|
||||
mMediaOutputIndicatorWorker.onSlicePinned();
|
||||
waitForLocalMediaManagerInit();
|
||||
@@ -132,7 +134,7 @@ public class MediaOutputIndicatorWorkerTest {
|
||||
TEST_PACKAGE_NAME);
|
||||
|
||||
when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME2);
|
||||
mMediaOutputIndicatorWorker.mLocalMediaManager = null;
|
||||
when(mLocalMediaManager.getPackageName()).thenReturn(TEST_PACKAGE_NAME2);
|
||||
mMediaOutputIndicatorWorker.onSlicePinned();
|
||||
waitForLocalMediaManagerInit();
|
||||
|
||||
|
||||
@@ -270,23 +270,27 @@ public class SettingsSliceProviderTest {
|
||||
|
||||
@Test
|
||||
public void onBindSlice_nightModeChanged_shouldReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
|
||||
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
final SliceData data = getDummyData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
assertThat(ShadowTheme.isThemeRebased()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindSlice_nightModeNotChanged_shouldNotReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
|
||||
SliceData data = getDummyData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
assertThat(ShadowTheme.isThemeRebased()).isFalse();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user