Owen Lin | 7a5e1e7 | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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.gallery3d.common; |
| 18 | |
Owen Lin | 30aa920 | 2012-06-27 19:01:21 +0800 | [diff] [blame] | 19 | import android.os.Build; |
Owen Lin | b47927b | 2012-06-22 12:31:33 +0800 | [diff] [blame] | 20 | import android.provider.MediaStore.MediaColumns; |
Owen Lin | 7a5e1e7 | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 21 | import android.view.View; |
| 22 | |
| 23 | public class ApiHelper { |
Owen Lin | 3a45725 | 2012-06-28 11:10:02 +0800 | [diff] [blame^] | 24 | public static interface VERSION_CODES { |
| 25 | // These value are copied from Build.VERSION_CODES |
| 26 | public static final int GINGERBREAD_MR1 = 10; |
| 27 | public static final int HONEYCOMB = 11; |
| 28 | public static final int HONEYCOMB_MR1 = 12; |
| 29 | public static final int HONEYCOMB_MR2 = 13; |
| 30 | public static final int ICE_CREAM_SANDWICH = 14; |
| 31 | public static final int ICE_CREAM_SANDWICH_MR1 = 15; |
| 32 | public static final int JELLY_BEAN = 16; |
| 33 | } |
Owen Lin | 7a5e1e7 | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 34 | |
| 35 | public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE = |
| 36 | hasField(View.class, "SYSTEM_UI_FLAG_LAYOUT_STABLE"); |
| 37 | |
| 38 | public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION = |
| 39 | hasField(View.class, "SYSTEM_UI_FLAG_HIDE_NAVIGATION"); |
| 40 | |
Owen Lin | b47927b | 2012-06-22 12:31:33 +0800 | [diff] [blame] | 41 | public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = |
| 42 | hasField(MediaColumns.class, "WIDTH"); |
| 43 | |
Owen Lin | 30aa920 | 2012-06-27 19:01:21 +0800 | [diff] [blame] | 44 | public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER = |
Owen Lin | 3a45725 | 2012-06-28 11:10:02 +0800 | [diff] [blame^] | 45 | Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; |
Owen Lin | 30aa920 | 2012-06-27 19:01:21 +0800 | [diff] [blame] | 46 | |
Owen Lin | 7a5e1e7 | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 47 | private static boolean hasField(Class<?> klass, String fieldName) { |
| 48 | try { |
| 49 | klass.getDeclaredField(fieldName); |
| 50 | return true; |
| 51 | } catch (NoSuchFieldException e) { |
| 52 | return false; |
| 53 | } |
| 54 | } |
| 55 | } |