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
18package com.android.mms.layout;
19
20import android.util.Log;
21
22public class HVGALayoutParameters implements LayoutParameters {
23    private static final String TAG = "HVGALayoutParameters";
24    private static final boolean DEBUG = false;
25    private static final boolean LOCAL_LOGV = false;
26
27    private int mType = -1;
28
29    private static final int IMAGE_HEIGHT_LANDSCAPE = 240;
30    private static final int TEXT_HEIGHT_LANDSCAPE  = 80;
31    private static final int IMAGE_HEIGHT_PORTRAIT  = 320;
32    private static final int TEXT_HEIGHT_PORTRAIT   = 160;
33
34    public HVGALayoutParameters(int type) {
35        if ((type != HVGA_LANDSCAPE) && (type != HVGA_PORTRAIT)) {
36            throw new IllegalArgumentException(
37                    "Bad layout type detected: " + type);
38        }
39
40        if (LOCAL_LOGV) {
41            Log.v(TAG, "HVGALayoutParameters.<init>(" + type + ").");
42        }
43        mType = type;
44    }
45
46    public int getWidth() {
47        return mType == HVGA_LANDSCAPE ? HVGA_LANDSCAPE_WIDTH
48                                       : HVGA_PORTRAIT_WIDTH;
49    }
50
51    public int getHeight() {
52        return mType == HVGA_LANDSCAPE ? HVGA_LANDSCAPE_HEIGHT
53                                       : HVGA_PORTRAIT_HEIGHT;
54    }
55
56    public int getImageHeight() {
57        return mType == HVGA_LANDSCAPE ? IMAGE_HEIGHT_LANDSCAPE
58                                       : IMAGE_HEIGHT_PORTRAIT;
59    }
60
61    public int getTextHeight() {
62        return mType == HVGA_LANDSCAPE ? TEXT_HEIGHT_LANDSCAPE
63                                       : TEXT_HEIGHT_PORTRAIT;
64    }
65
66    public int getType() {
67        return mType;
68    }
69
70    public String getTypeDescription() {
71        return mType == HVGA_LANDSCAPE ? "HVGA-L" : "HVGA-P";
72    }
73}
74