1 /* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.layout; 19 20 import android.util.Config; 21 import android.util.Log; 22 23 public class HVGALayoutParameters implements LayoutParameters { 24 private static final String TAG = "HVGALayoutParameters"; 25 private static final boolean DEBUG = false; 26 private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV; 27 28 private int mType = -1; 29 30 private static final int IMAGE_HEIGHT_LANDSCAPE = 240; 31 private static final int TEXT_HEIGHT_LANDSCAPE = 80; 32 private static final int IMAGE_HEIGHT_PORTRAIT = 320; 33 private static final int TEXT_HEIGHT_PORTRAIT = 160; 34 HVGALayoutParameters(int type)35 public HVGALayoutParameters(int type) { 36 if ((type != HVGA_LANDSCAPE) && (type != HVGA_PORTRAIT)) { 37 throw new IllegalArgumentException( 38 "Bad layout type detected: " + type); 39 } 40 41 if (LOCAL_LOGV) { 42 Log.v(TAG, "HVGALayoutParameters.<init>(" + type + ")."); 43 } 44 mType = type; 45 } 46 getWidth()47 public int getWidth() { 48 return mType == HVGA_LANDSCAPE ? HVGA_LANDSCAPE_WIDTH 49 : HVGA_PORTRAIT_WIDTH; 50 } 51 getHeight()52 public int getHeight() { 53 return mType == HVGA_LANDSCAPE ? HVGA_LANDSCAPE_HEIGHT 54 : HVGA_PORTRAIT_HEIGHT; 55 } 56 getImageHeight()57 public int getImageHeight() { 58 return mType == HVGA_LANDSCAPE ? IMAGE_HEIGHT_LANDSCAPE 59 : IMAGE_HEIGHT_PORTRAIT; 60 } 61 getTextHeight()62 public int getTextHeight() { 63 return mType == HVGA_LANDSCAPE ? TEXT_HEIGHT_LANDSCAPE 64 : TEXT_HEIGHT_PORTRAIT; 65 } 66 getType()67 public int getType() { 68 return mType; 69 } 70 getTypeDescription()71 public String getTypeDescription() { 72 return mType == HVGA_LANDSCAPE ? "HVGA-L" : "HVGA-P"; 73 } 74 } 75