blob: c42c5fed63f95c4ca5e8a06f62b0da9727cce1e6 [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.annotation.TargetApi;
20import android.os.Build;
Owen Lin0c4c03a2012-06-22 12:31:33 +080021import android.provider.MediaStore.MediaColumns;
Owen Lin9199c4d2012-06-20 16:54:24 +080022import android.view.View;
23
Owen Lin76bfd872012-06-27 19:01:21 +080024@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Owen Lin9199c4d2012-06-20 16:54:24 +080025public class ApiHelper {
26
27 public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_LAYOUT_STABLE =
28 hasField(View.class, "SYSTEM_UI_FLAG_LAYOUT_STABLE");
29
30 public static final boolean HAS_VIEW_SYSTEM_UI_FLAG_HIDE_NAVIGATION =
31 hasField(View.class, "SYSTEM_UI_FLAG_HIDE_NAVIGATION");
32
Owen Lin0c4c03a2012-06-22 12:31:33 +080033 public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT =
34 hasField(MediaColumns.class, "WIDTH");
35
Owen Lin76bfd872012-06-27 19:01:21 +080036 public static final boolean HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER =
37 Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
38
Owen Lin9199c4d2012-06-20 16:54:24 +080039 private static boolean hasField(Class<?> klass, String fieldName) {
40 try {
41 klass.getDeclaredField(fieldName);
42 return true;
43 } catch (NoSuchFieldException e) {
44 return false;
45 }
46 }
47}