blob: 85b09257692004ddec84321a72c6cc66e5f3b7fb [file] [log] [blame]
Owen Lin9199c4d2012-06-20 16:54:24 +08001/*
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
17package com.android.gallery3d.common;
18
Owen Lin76bfd872012-06-27 19:01:21 +080019import android.os.Build;
Owen Lin0c4c03a2012-06-22 12:31:33 +080020import android.provider.MediaStore.MediaColumns;
Owen Lin9199c4d2012-06-20 16:54:24 +080021import android.view.View;
22
23public class ApiHelper {
Owen Lin987f5332012-06-28 11:10:02 +080024 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 Lin9199c4d2012-06-20 16:54:24 +080034
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 Lin0c4c03a2012-06-22 12:31:33 +080041 public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT =
42 hasField(MediaColumns.class, "WIDTH");
43
Owen Lin76bfd872012-06-27 19:01:21 +080044 public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER =
Owen Lin987f5332012-06-28 11:10:02 +080045 Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
Owen Lin76bfd872012-06-27 19:01:21 +080046
Owen Lin9199c4d2012-06-20 16:54:24 +080047 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}