Home | History | Annotate | Download | only in app
      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 
     17 package com.android.gallery3d.app;
     18 
     19 import android.content.Context;
     20 import android.content.res.Resources;
     21 
     22 import com.android.gallery3d.R;
     23 import com.android.gallery3d.ui.AlbumSetSlotRenderer;
     24 import com.android.gallery3d.ui.SlotView;
     25 
     26 final class Config {
     27     public static class AlbumSetPage {
     28         private static AlbumSetPage sInstance;
     29 
     30         public SlotView.Spec slotViewSpec;
     31         public AlbumSetSlotRenderer.LabelSpec labelSpec;
     32         public int paddingTop;
     33         public int paddingBottom;
     34         public int placeholderColor;
     35 
     36         public static synchronized AlbumSetPage get(Context context) {
     37             if (sInstance == null) {
     38                 sInstance = new AlbumSetPage(context);
     39             }
     40             return sInstance;
     41         }
     42 
     43         private AlbumSetPage(Context context) {
     44             Resources r = context.getResources();
     45 
     46             placeholderColor = r.getColor(R.color.albumset_placeholder);
     47 
     48             slotViewSpec = new SlotView.Spec();
     49             slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land);
     50             slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port);
     51             slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.albumset_slot_gap);
     52             slotViewSpec.slotHeightAdditional = 0;
     53 
     54             paddingTop = r.getDimensionPixelSize(R.dimen.albumset_padding_top);
     55             paddingBottom = r.getDimensionPixelSize(R.dimen.albumset_padding_bottom);
     56 
     57             labelSpec = new AlbumSetSlotRenderer.LabelSpec();
     58             labelSpec.labelBackgroundHeight = r.getDimensionPixelSize(
     59                     R.dimen.albumset_label_background_height);
     60             labelSpec.titleOffset = r.getDimensionPixelSize(
     61                     R.dimen.albumset_title_offset);
     62             labelSpec.countOffset = r.getDimensionPixelSize(
     63                     R.dimen.albumset_count_offset);
     64             labelSpec.titleFontSize = r.getDimensionPixelSize(
     65                     R.dimen.albumset_title_font_size);
     66             labelSpec.countFontSize = r.getDimensionPixelSize(
     67                     R.dimen.albumset_count_font_size);
     68             labelSpec.leftMargin = r.getDimensionPixelSize(
     69                     R.dimen.albumset_left_margin);
     70             labelSpec.titleRightMargin = r.getDimensionPixelSize(
     71                     R.dimen.albumset_title_right_margin);
     72             labelSpec.iconSize = r.getDimensionPixelSize(
     73                     R.dimen.albumset_icon_size);
     74             labelSpec.backgroundColor = r.getColor(
     75                     R.color.albumset_label_background);
     76             labelSpec.titleColor = r.getColor(R.color.albumset_label_title);
     77             labelSpec.countColor = r.getColor(R.color.albumset_label_count);
     78         }
     79     }
     80 
     81     public static class AlbumPage {
     82         private static AlbumPage sInstance;
     83 
     84         public SlotView.Spec slotViewSpec;
     85         public int placeholderColor;
     86 
     87         public static synchronized AlbumPage get(Context context) {
     88             if (sInstance == null) {
     89                 sInstance = new AlbumPage(context);
     90             }
     91             return sInstance;
     92         }
     93 
     94         private AlbumPage(Context context) {
     95             Resources r = context.getResources();
     96 
     97             placeholderColor = r.getColor(R.color.album_placeholder);
     98 
     99             slotViewSpec = new SlotView.Spec();
    100             slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land);
    101             slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port);
    102             slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.album_slot_gap);
    103         }
    104     }
    105 
    106     public static class ManageCachePage extends AlbumSetPage {
    107         private static ManageCachePage sInstance;
    108 
    109         public final int cachePinSize;
    110         public final int cachePinMargin;
    111 
    112         public static synchronized ManageCachePage get(Context context) {
    113             if (sInstance == null) {
    114                 sInstance = new ManageCachePage(context);
    115             }
    116             return sInstance;
    117         }
    118 
    119         public ManageCachePage(Context context) {
    120             super(context);
    121             Resources r = context.getResources();
    122             cachePinSize = r.getDimensionPixelSize(R.dimen.cache_pin_size);
    123             cachePinMargin = r.getDimensionPixelSize(R.dimen.cache_pin_margin);
    124         }
    125     }
    126 }
    127 
    128