Wenyi Wang | aac0e66 | 2015-12-18 17:17:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.contacts.compat; |
| 18 | |
| 19 | import android.content.ContentResolver; |
| 20 | import android.provider.ContactsContract; |
| 21 | import android.provider.ContactsContract.PinnedPositions; |
| 22 | |
Wenyi Wang | aac0e66 | 2015-12-18 17:17:33 -0800 | [diff] [blame] | 23 | /** |
| 24 | * Compatibility class for {@link android.provider.ContactsContract.PinnedPositions} |
| 25 | */ |
| 26 | public class PinnedPositionsCompat { |
| 27 | /** |
| 28 | * Not instantiable. |
| 29 | */ |
| 30 | private PinnedPositionsCompat() { |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * copied from android.provider.ContactsContract.PinnedPositions#UNDEMOTE_METHOD |
| 35 | */ |
| 36 | private static final String UNDEMOTE_METHOD = "undemote"; |
| 37 | |
| 38 | /** |
| 39 | * Compatibility method for {@link android.provider.ContactsContract.PinnedPositions#undemote} |
| 40 | */ |
| 41 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 42 | if (contentResolver == null) { |
| 43 | return; |
| 44 | } |
| 45 | if (CompatUtils.isLollipopCompatible()) { |
| 46 | PinnedPositions.undemote(contentResolver, contactId); |
| 47 | } else { |
| 48 | // copied from android.provider.ContactsContract.PinnedPositions.undemote() |
| 49 | contentResolver.call(ContactsContract.AUTHORITY_URI, UNDEMOTE_METHOD, |
| 50 | String.valueOf(contactId), null); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | } |