1 /* 2 * Copyright (C) 2011 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.inputmethod.tools.edittextvariations; 18 19 import android.os.Build; 20 21 import com.android.inputmethod.tools.edittextvariations.R; 22 23 import java.util.ArrayList; 24 import java.util.Collections; 25 import java.util.List; 26 27 public final class ThemeItem { 28 public final int id; 29 public final String name; 30 ThemeItem(final String name, final int resId)31 private ThemeItem(final String name, final int resId) { 32 this.id = resId; 33 this.name = name; 34 } 35 36 private static final String THEME_DEFAULT = "Default"; 37 private static final String THEME_HOLO = "Theme_Holo"; 38 private static final String THEME_HOLO_LIGHT = "Theme_Holo_Light"; 39 private static final String THEME_DEVICE_DEFAULT = "Theme_DeviceDefault"; 40 private static final String THEME_DEVICE_DEFAULT_LIGHT = "Theme_DeviceDefault_Light"; 41 private static final String THEME_MATERIAL = "Theme_Material"; 42 private static final String THEME_MATERIAL_LIGHT = "Theme_Material_Light"; 43 getDefaultThemeName()44 public static String getDefaultThemeName() { 45 return THEME_DEFAULT; 46 } 47 48 public static final List<ThemeItem> THEME_LIST = createThemeList( 49 THEME_HOLO, THEME_HOLO_LIGHT, THEME_DEVICE_DEFAULT, THEME_DEVICE_DEFAULT_LIGHT, 50 THEME_MATERIAL, THEME_MATERIAL_LIGHT); 51 createThemeList(final String... candidateList)52 private static List<ThemeItem> createThemeList(final String... candidateList) { 53 final ArrayList<ThemeItem> list = new ArrayList<>(); 54 55 // Default theme is always available as it's defined in our resource. 56 list.add(new ThemeItem(THEME_DEFAULT, R.style.defaultActivityTheme)); 57 58 for (final String name : candidateList) { 59 final FinalClassField<Integer> constant = 60 FinalClassField.newInstance(android.R.style.class, name, 0); 61 if (constant.defined) { 62 list.add(new ThemeItem(name, constant.value)); 63 } 64 } 65 66 return Collections.unmodifiableList(list); 67 } 68 } 69