Snap for 5321987 from e67344a5c5 to qt-release
Change-Id: Ie4e7018825fafdba0c39ab02a6b82643d9979752
This commit is contained in:
@@ -736,7 +736,7 @@
|
||||
<activity
|
||||
android:name=".notification.ZenSuggestionActivity"
|
||||
android:label="@string/zen_mode_settings_title"
|
||||
android:icon="@drawable/ic_do_not_disturb_on_24dp"
|
||||
android:icon="@drawable/ic_suggestion_dnd"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -796,7 +796,7 @@
|
||||
|
||||
<activity android:name=".wallpaper.WallpaperSuggestionActivity"
|
||||
android:label="@string/wallpaper_settings_title"
|
||||
android:icon="@drawable/ic_wallpaper"
|
||||
android:icon="@drawable/ic_suggestion_wallpaper"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -889,7 +889,7 @@
|
||||
<activity
|
||||
android:name="Settings$NightDisplaySuggestionActivity"
|
||||
android:enabled="@*android:bool/config_nightDisplayAvailable"
|
||||
android:icon="@drawable/ic_settings_night_display">
|
||||
android:icon="@drawable/ic_suggestion_night_display">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
|
||||
@@ -1628,7 +1628,7 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name=".password.ScreenLockSuggestionActivity"
|
||||
android:icon="@drawable/ic_settings_security">
|
||||
android:icon="@drawable/ic_suggestion_security">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.suggested.category.DEFAULT" />
|
||||
@@ -2635,7 +2635,7 @@
|
||||
|
||||
<activity android:name=".wifi.calling.WifiCallingSuggestionActivity"
|
||||
android:label="@string/wifi_calling_settings_title"
|
||||
android:icon="@drawable/ic_settings_wireless">
|
||||
android:icon="@drawable/ic_suggestion_wireless">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
|
||||
|
||||
28
res/drawable/ic_suggestion_dnd.xml
Normal file
28
res/drawable/ic_suggestion_dnd.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8c0,-4.41 3.59,-8 8,-8c4.41,0 8,3.59 8,8C20,16.41 16.41,20 12,20z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M7,11h10v2h-10z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_suggestion_night_display.xml
Normal file
25
res/drawable/ic_suggestion_night_display.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M6.28,4.81c0,0.16 0.01,0.32 0.02,0.48c0.38,6.58 5.83,12.03 12.41,12.41c0.16,0.01 0.32,0.02 0.47,0.02c-1.58,1.2 -3.53,1.88 -5.56,1.88c-0.46,0 -0.93,-0.03 -1.4,-0.1c-3.96,-0.58 -7.13,-3.75 -7.71,-7.71C4.13,9.24 4.8,6.75 6.28,4.81M8.27,0.6c-0.08,0 -0.17,0.02 -0.25,0.07c-3.8,2.2 -6.2,6.56 -5.49,11.4c0.7,4.82 4.59,8.7 9.4,9.4c0.57,0.08 1.13,0.12 1.69,0.12c4.15,0 7.78,-2.26 9.72,-5.62c0.2,-0.35 -0.07,-0.76 -0.44,-0.76c-0.05,0 -0.1,0.01 -0.15,0.02c-1.03,0.31 -2.12,0.48 -3.25,0.48c-0.22,0 -0.44,-0.01 -0.67,-0.02C13.23,15.38 8.62,10.77 8.29,5.17C8.21,3.81 8.38,2.49 8.75,1.26C8.86,0.91 8.59,0.6 8.27,0.6L8.27,0.6z"/>
|
||||
</vector>
|
||||
28
res/drawable/ic_suggestion_security.xml
Normal file
28
res/drawable/ic_suggestion_security.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,15m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M18.5,1C16.01,1 14,3.01 14,5.5V8H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10c0,-1.1 -0.9,-2 -2,-2h-2V5.5C16,4.12 17.12,3 18.5,3C19.88,3 21,4.12 21,5.5V6h2V5.5C23,3.01 20.99,1 18.5,1zM18,10v10H6V10H18z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_suggestion_wallpaper.xml
Normal file
25
res/drawable/ic_suggestion_wallpaper.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M9,12.71l2.14,2.58l3,-3.87L18,16.57H6L9,12.71zM5,5h6V3H5C3.9,3 3,3.9 3,5v6h2V5zM19,19h-6v2h6c1.1,0 2,-0.9 2,-2v-6h-2V19zM5,19v-6H3v6c0,1.1 0.9,2 2,2h6v-2H5zM19,5v6h2V5c0,-1.1 -0.9,-2 -2,-2h-6v2H19zM16,9c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1c-0.55,0 -1,0.45 -1,1S15.45,9 16,9z"/>
|
||||
</vector>
|
||||
25
res/drawable/ic_suggestion_wireless.xml
Normal file
25
res/drawable/ic_suggestion_wireless.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24.0dp"
|
||||
android:height="24.0dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3l3,-3C13.35,15.34 10.66,15.34 9,17zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z"/>
|
||||
</vector>
|
||||
@@ -18,7 +18,8 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<com.android.settingslib.widget.settingsspinner.SettingsSpinner
|
||||
android:id="@+id/filter_spinner"
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="@dimen/homepage_card_icon_size"
|
||||
android:layout_height="@dimen/homepage_card_icon_size"
|
||||
android:tint="?android:attr/colorAccent"/>
|
||||
android:layout_height="@dimen/homepage_card_icon_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
|
||||
@@ -21,57 +21,50 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_container"
|
||||
<LinearLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_container"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/apps_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
settings:fastScrollEnabled="true"
|
||||
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
||||
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
||||
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/apps_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
settings:fastScrollEnabled="true"
|
||||
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
||||
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||
settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
||||
settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/no_applications"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/no_applications"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:visibility="invisible"/>
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/loading_container"/>
|
||||
|
||||
<include layout="@layout/loading_container"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -89,6 +89,7 @@ import android.widget.ListView;
|
||||
import android.widget.TabWidget;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
@@ -950,24 +951,30 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) original).getBitmap(), width,
|
||||
height, false);
|
||||
} else {
|
||||
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(bitmap);
|
||||
original.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
original.draw(canvas);
|
||||
bitmap = createBitmap(original, width, height);
|
||||
}
|
||||
return new BitmapDrawable(null, bitmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the {@link Drawable} to a {@link Bitmap}.
|
||||
* Create an Icon pointing to a drawable.
|
||||
*/
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
public static IconCompat createIconWithDrawable(Drawable drawable) {
|
||||
Bitmap bitmap;
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable)drawable).getBitmap();
|
||||
bitmap = ((BitmapDrawable)drawable).getBitmap();
|
||||
} else {
|
||||
final int width = drawable.getIntrinsicWidth();
|
||||
final int height = drawable.getIntrinsicHeight();
|
||||
bitmap = createBitmap(drawable,
|
||||
width > 0 ? width : 1,
|
||||
height > 0 ? height : 1);
|
||||
}
|
||||
return IconCompat.createWithBitmap(bitmap);
|
||||
}
|
||||
|
||||
final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
private static Bitmap createBitmap(Drawable drawable, int width, int height) {
|
||||
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
|
||||
@@ -186,7 +186,6 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
private View mLoadingContainer;
|
||||
private View mListContainer;
|
||||
private RecyclerView mRecyclerView;
|
||||
private SearchView mSearchView;
|
||||
|
||||
// Size resource used for packages whose size computation failed for some reason
|
||||
@@ -220,7 +219,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
@VisibleForTesting
|
||||
FilterSpinnerAdapter mFilterAdapter;
|
||||
@VisibleForTesting
|
||||
View mContentContainer;
|
||||
RecyclerView mRecyclerView;
|
||||
|
||||
private View mRootView;
|
||||
private Spinner mFilterSpinner;
|
||||
@@ -330,7 +329,6 @@ public class ManageApplications extends InstrumentedFragment
|
||||
Bundle savedInstanceState) {
|
||||
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
||||
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||
mContentContainer = mRootView.findViewById(R.id.content_container);
|
||||
mListContainer = mRootView.findViewById(R.id.list_container);
|
||||
if (mListContainer != null) {
|
||||
// Create adapter and list view here
|
||||
@@ -861,14 +859,14 @@ public class ManageApplications extends InstrumentedFragment
|
||||
// overlapped by floating filter.
|
||||
if (hasFilter) {
|
||||
mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
|
||||
mManageApplications.mContentContainer.setPadding(0 /* left */,
|
||||
mManageApplications.mRecyclerView.setPadding(0 /* left */,
|
||||
mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.app_bar_height) /* top */,
|
||||
0 /* right */,
|
||||
0 /* bottom */);
|
||||
} else {
|
||||
mManageApplications.mSpinnerHeader.setVisibility(View.GONE);
|
||||
mManageApplications.mContentContainer.setPadding(0 /* left */, 0 /* top */,
|
||||
mManageApplications.mRecyclerView.setPadding(0 /* left */, 0 /* top */,
|
||||
0 /* right */,
|
||||
0 /* bottom */);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class BluetoothDevicesSlice implements CustomSliceable {
|
||||
.getBtClassDrawableWithDescription(mContext, device);
|
||||
|
||||
if (pair.first != null) {
|
||||
return IconCompat.createWithBitmap(Utils.drawableToBitmap(pair.first));
|
||||
return Utils.createIconWithDrawable(pair.first);
|
||||
} else {
|
||||
return IconCompat.createWithResource(mContext,
|
||||
com.android.internal.R.drawable.ic_settings_bluetooth);
|
||||
|
||||
@@ -30,9 +30,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -243,7 +240,7 @@ public class NotificationChannelSlice implements CustomSliceable {
|
||||
return null;
|
||||
}
|
||||
|
||||
return IconCompat.createWithBitmap(Utils.drawableToBitmap(drawable));
|
||||
return Utils.createIconWithDrawable(drawable);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -23,8 +23,6 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.UserHandle;
|
||||
@@ -87,7 +85,7 @@ public class MediaOutputSlice implements CustomSliceable {
|
||||
|
||||
final Drawable drawable =
|
||||
Utils.getBadgedIcon(mIconDrawableFactory, pm, mPackageName, UserHandle.myUserId());
|
||||
final IconCompat icon = IconCompat.createWithBitmap(getBitmapFromDrawable(drawable));
|
||||
final IconCompat icon = Utils.createIconWithDrawable(drawable);
|
||||
|
||||
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
|
||||
final SliceAction primarySliceAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
|
||||
@@ -134,17 +132,6 @@ public class MediaOutputSlice implements CustomSliceable {
|
||||
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
|
||||
}
|
||||
|
||||
private Bitmap getBitmapFromDrawable(Drawable drawable) {
|
||||
final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
final Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private ListBuilder.RowBuilder getMediaDeviceRow(MediaDevice device) {
|
||||
final String title = device.getName();
|
||||
final PendingIntent broadcastAction =
|
||||
|
||||
@@ -22,21 +22,21 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
/**
|
||||
* Preference controller for "Mobile data"
|
||||
*/
|
||||
@@ -115,8 +115,18 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mTelephonyManager.isDataEnabled()
|
||||
&& mSubId == SubscriptionManager.getDefaultDataSubscriptionId();
|
||||
return mTelephonyManager.isDataEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(!isOpportunistic());
|
||||
}
|
||||
|
||||
private boolean isOpportunistic() {
|
||||
SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
|
||||
return info != null && info.isOpportunistic();
|
||||
}
|
||||
|
||||
public static Uri getObservableUri(int subId) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ContextualWifiSlice extends WifiSlice {
|
||||
}
|
||||
|
||||
d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||
return IconCompat.createWithBitmap(Utils.drawableToBitmap(d));
|
||||
return Utils.createIconWithDrawable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,11 @@ import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
@@ -48,6 +53,8 @@ import android.util.IconDrawableFactory;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -96,7 +103,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWifiIpAddresses_succeeds() throws Exception {
|
||||
public void getWifiIpAddresses_succeeds() throws Exception {
|
||||
when(wifiManager.getCurrentNetwork()).thenReturn(network);
|
||||
LinkAddress address = new LinkAddress(InetAddress.getByName("127.0.0.1"), 0);
|
||||
LinkProperties lp = new LinkProperties();
|
||||
@@ -107,7 +114,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWifiIpAddresses_nullLinkProperties() {
|
||||
public void getWifiIpAddresses_nullLinkProperties() {
|
||||
when(wifiManager.getCurrentNetwork()).thenReturn(network);
|
||||
// Explicitly set the return value to null for readability sake.
|
||||
when(connectivityManager.getLinkProperties(network)).thenReturn(null);
|
||||
@@ -116,7 +123,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWifiIpAddresses_nullNetwork() {
|
||||
public void getWifiIpAddresses_nullNetwork() {
|
||||
// Explicitly set the return value to null for readability sake.
|
||||
when(wifiManager.getCurrentNetwork()).thenReturn(null);
|
||||
|
||||
@@ -124,7 +131,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitializeVolumeDoesntBreakOnNullVolume() {
|
||||
public void initializeVolumeDoesntBreakOnNullVolume() {
|
||||
VolumeInfo info = new VolumeInfo("id", 0, new DiskInfo("id", 0), "");
|
||||
StorageManager storageManager = mock(StorageManager.class, RETURNS_DEEP_STUBS);
|
||||
when(storageManager.findVolumeById(anyString())).thenReturn(info);
|
||||
@@ -133,13 +140,13 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstallationStatus_notInstalled_shouldReturnUninstalled() {
|
||||
public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
|
||||
assertThat(Utils.getInstallationStatus(new ApplicationInfo()))
|
||||
.isEqualTo(R.string.not_installed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstallationStatus_enabled_shouldReturnInstalled() {
|
||||
public void getInstallationStatus_enabled_shouldReturnInstalled() {
|
||||
final ApplicationInfo info = new ApplicationInfo();
|
||||
info.flags = ApplicationInfo.FLAG_INSTALLED;
|
||||
info.enabled = true;
|
||||
@@ -148,7 +155,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstallationStatus_disabled_shouldReturnDisabled() {
|
||||
public void getInstallationStatus_disabled_shouldReturnDisabled() {
|
||||
final ApplicationInfo info = new ApplicationInfo();
|
||||
info.flags = ApplicationInfo.FLAG_INSTALLED;
|
||||
info.enabled = false;
|
||||
@@ -157,7 +164,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
|
||||
public void isProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
|
||||
when(mDevicePolicyManager.isDeviceOwnerAppOnAnyUser(PACKAGE_NAME)).thenReturn(true);
|
||||
|
||||
assertThat(Utils.isProfileOrDeviceOwner(mUserManager, mDevicePolicyManager, PACKAGE_NAME))
|
||||
@@ -165,7 +172,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsProfileOrDeviceOwner_profileOwnerApp_returnTrue() {
|
||||
public void isProfileOrDeviceOwner_profileOwnerApp_returnTrue() {
|
||||
final List<UserInfo> userInfos = new ArrayList<>();
|
||||
userInfos.add(new UserInfo());
|
||||
|
||||
@@ -178,7 +185,7 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEditTextCursorPosition_shouldGetExpectedEditTextLenght() {
|
||||
public void setEditTextCursorPosition_shouldGetExpectedEditTextLenght() {
|
||||
final EditText editText = new EditText(mContext);
|
||||
final CharSequence text = "test";
|
||||
editText.setText(text, TextView.BufferType.EDITABLE);
|
||||
@@ -189,7 +196,36 @@ public class UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBadgedIcon_usePackageNameAndUserId()
|
||||
public void createIconWithDrawable_BitmapDrawable() {
|
||||
final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
|
||||
final BitmapDrawable drawable = new BitmapDrawable(mContext.getResources(), bitmap);
|
||||
|
||||
final IconCompat icon = Utils.createIconWithDrawable(drawable);
|
||||
|
||||
assertThat(icon.getBitmap()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createIconWithDrawable_ColorDrawable() {
|
||||
final ColorDrawable drawable = new ColorDrawable(Color.BLACK);
|
||||
|
||||
final IconCompat icon = Utils.createIconWithDrawable(drawable);
|
||||
|
||||
assertThat(icon.getBitmap()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createIconWithDrawable_VectorDrawable() {
|
||||
final VectorDrawable drawable = VectorDrawable.create(mContext.getResources(),
|
||||
R.drawable.ic_settings_accent);
|
||||
|
||||
final IconCompat icon = Utils.createIconWithDrawable(drawable);
|
||||
|
||||
assertThat(icon.getBitmap()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBadgedIcon_usePackageNameAndUserId()
|
||||
throws PackageManager.NameNotFoundException {
|
||||
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
|
||||
PACKAGE_NAME, PackageManager.GET_META_DATA, USER_ID);
|
||||
|
||||
@@ -466,27 +466,27 @@ public class ManageApplicationsTest {
|
||||
|
||||
@Test
|
||||
public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
|
||||
mFragment.mContentContainer = new View(mContext);
|
||||
mFragment.mRecyclerView = new RecyclerView(mContext);
|
||||
mFragment.mSpinnerHeader = new View(mContext);
|
||||
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
|
||||
|
||||
mFragment.mFilterAdapter.updateFilterView(true);
|
||||
|
||||
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(
|
||||
assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(
|
||||
mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
|
||||
mFragment.mContentContainer = new View(mContext);
|
||||
mFragment.mRecyclerView = new RecyclerView(mContext);
|
||||
mFragment.mSpinnerHeader = new View(mContext);
|
||||
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
|
||||
|
||||
mFragment.mFilterAdapter.updateFilterView(false);
|
||||
|
||||
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
|
||||
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0);
|
||||
assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private void setUpOptionMenus() {
|
||||
|
||||
@@ -149,4 +149,23 @@ public class MobileDataPreferenceControllerTest {
|
||||
|
||||
verify(mTelephonyManager).setDataEnabled(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_returnUserDataEnabled() {
|
||||
mController.init(mFragmentManager, SUB_ID);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
|
||||
doReturn(true).when(mTelephonyManager).isDataEnabled();
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_opportunistic_disabled() {
|
||||
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
|
||||
mController.init(mFragmentManager, SUB_ID);
|
||||
doReturn(true).when(mSubscriptionInfo).isOpportunistic();
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,11 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.util.Size;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.LuminanceSource;
|
||||
import com.google.zxing.RGBLuminanceSource;
|
||||
|
||||
Reference in New Issue
Block a user