Config.java revision fafa06467fd79a1cf525b861ae0372db0b85bf09
1/* 2 * Copyright (C) 2010 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.app; 18 19import com.android.gallery3d.R; 20import com.android.gallery3d.ui.SlotView; 21import com.android.gallery3d.ui.AlbumSetView; 22 23import android.content.Context; 24import android.content.res.Resources; 25 26final class Config { 27 public static class AlbumSetPage { 28 private static AlbumSetPage sInstance; 29 30 public SlotView.Spec slotViewSpec; 31 public AlbumSetView.LabelSpec labelSpec; 32 33 public static synchronized AlbumSetPage get(Context context) { 34 if (sInstance == null) { 35 sInstance = new AlbumSetPage(context); 36 } 37 return sInstance; 38 } 39 40 private AlbumSetPage(Context context) { 41 Resources r = context.getResources(); 42 43 slotViewSpec = new SlotView.Spec(); 44 slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land); 45 slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port); 46 slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.albumset_slot_gap); 47 48 labelSpec = new AlbumSetView.LabelSpec(); 49 labelSpec.labelBackgroundHeight = r.getDimensionPixelSize( 50 R.dimen.albumset_label_background_height); 51 labelSpec.titleOffset = r.getDimensionPixelSize( 52 R.dimen.albumset_title_offset); 53 labelSpec.countOffset = r.getDimensionPixelSize( 54 R.dimen.albumset_count_offset); 55 labelSpec.titleFontSize = r.getDimensionPixelSize( 56 R.dimen.albumset_title_font_size); 57 labelSpec.countFontSize = r.getDimensionPixelSize( 58 R.dimen.albumset_count_font_size); 59 labelSpec.leftMargin = r.getDimensionPixelSize( 60 R.dimen.albumset_left_margin); 61 labelSpec.iconSize = r.getDimensionPixelSize( 62 R.dimen.albumset_icon_size); 63 } 64 } 65 66 public static class AlbumPage { 67 private static AlbumPage sInstance; 68 69 public SlotView.Spec slotViewSpec; 70 71 public static synchronized AlbumPage get(Context context) { 72 if (sInstance == null) { 73 sInstance = new AlbumPage(context); 74 } 75 return sInstance; 76 } 77 78 private AlbumPage(Context context) { 79 Resources r = context.getResources(); 80 81 slotViewSpec = new SlotView.Spec(); 82 slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land); 83 slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port); 84 slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.album_slot_gap); 85 } 86 } 87 88 public static class ManageCachePage extends AlbumSetPage { 89 private static ManageCachePage sInstance; 90 91 public final int cachePinSize; 92 public final int cachePinMargin; 93 94 public static synchronized ManageCachePage get(Context context) { 95 if (sInstance == null) { 96 sInstance = new ManageCachePage(context); 97 } 98 return sInstance; 99 } 100 101 public ManageCachePage(Context context) { 102 super(context); 103 Resources r = context.getResources(); 104 cachePinSize = r.getDimensionPixelSize(R.dimen.cache_pin_size); 105 cachePinMargin = r.getDimensionPixelSize(R.dimen.cache_pin_margin); 106 } 107 } 108 109 public static class PhotoPage { 110 private static PhotoPage sInstance; 111 112 // These are all height values. See the comment in FilmStripView for 113 // the meaning of these values. 114 public final int filmstripTopMargin; 115 public final int filmstripMidMargin; 116 public final int filmstripBottomMargin; 117 public final int filmstripThumbSize; 118 public final int filmstripContentSize; 119 public final int filmstripGripSize; 120 public final int filmstripBarSize; 121 122 // These are width values. 123 public final int filmstripGripWidth; 124 125 public static synchronized PhotoPage get(Context context) { 126 if (sInstance == null) { 127 sInstance = new PhotoPage(context); 128 } 129 return sInstance; 130 } 131 132 public PhotoPage(Context context) { 133 Resources r = context.getResources(); 134 filmstripTopMargin = r.getDimensionPixelSize(R.dimen.filmstrip_top_margin); 135 filmstripMidMargin = r.getDimensionPixelSize(R.dimen.filmstrip_mid_margin); 136 filmstripBottomMargin = r.getDimensionPixelSize(R.dimen.filmstrip_bottom_margin); 137 filmstripThumbSize = r.getDimensionPixelSize(R.dimen.filmstrip_thumb_size); 138 filmstripContentSize = r.getDimensionPixelSize(R.dimen.filmstrip_content_size); 139 filmstripGripSize = r.getDimensionPixelSize(R.dimen.filmstrip_grip_size); 140 filmstripBarSize = r.getDimensionPixelSize(R.dimen.filmstrip_bar_size); 141 filmstripGripWidth = r.getDimensionPixelSize(R.dimen.filmstrip_grip_width); 142 } 143 } 144} 145 146