Loading src/com/android/contacts/common/compat/CompatUtils.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.contacts.common.compat; import android.content.Context; import android.os.Build; public class CompatUtils { // private constructor to prevent this class from being initialized from outside uses private CompatUtils() {} public static int getColorCompat(Context context, int resId) { if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.LOLLIPOP) >= Build.VERSION_CODES.M) { return context.getColor(resId); } else { return context.getResources().getColor(resId); } } } src/com/android/contacts/common/list/ContactListItemView.java +4 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.android.contacts.common.compat.CompatUtils; /** * A custom view for an item in the contact list. * The view contains the contact's photo, a set of text views (for name, status, etc...) and Loading Loading @@ -1517,8 +1519,8 @@ public class ContactListItemView extends ViewGroup ImageView photo = getPhotoView(); photo.setScaleType(ImageView.ScaleType.CENTER); photo.setImageDrawable(getContext().getDrawable(drawableId)); photo.setImageTintList(ColorStateList.valueOf( getContext().getColor(R.color.search_shortcut_icon_color))); photo.setImageTintList(ColorStateList.valueOf(CompatUtils.getColorCompat( getContext(), R.color.search_shortcut_icon_color))); } @Override Loading Loading
src/com/android/contacts/common/compat/CompatUtils.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.contacts.common.compat; import android.content.Context; import android.os.Build; public class CompatUtils { // private constructor to prevent this class from being initialized from outside uses private CompatUtils() {} public static int getColorCompat(Context context, int resId) { if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.LOLLIPOP) >= Build.VERSION_CODES.M) { return context.getColor(resId); } else { return context.getResources().getColor(resId); } } }
src/com/android/contacts/common/list/ContactListItemView.java +4 −2 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.android.contacts.common.compat.CompatUtils; /** * A custom view for an item in the contact list. * The view contains the contact's photo, a set of text views (for name, status, etc...) and Loading Loading @@ -1517,8 +1519,8 @@ public class ContactListItemView extends ViewGroup ImageView photo = getPhotoView(); photo.setScaleType(ImageView.ScaleType.CENTER); photo.setImageDrawable(getContext().getDrawable(drawableId)); photo.setImageTintList(ColorStateList.valueOf( getContext().getColor(R.color.search_shortcut_icon_color))); photo.setImageTintList(ColorStateList.valueOf(CompatUtils.getColorCompat( getContext(), R.color.search_shortcut_icon_color))); } @Override Loading