66d413544fcdbbbf606c67ab31ac5c18e8ea5f3a
[zxing.git] / rim / src / com / google / zxing / client / rim / AboutScreen.java
1 /*\r
2  * Copyright 2008 ZXing authors\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package com.google.zxing.client.rim;\r
18 \r
19 import net.rim.device.api.ui.Field;\r
20 import net.rim.device.api.ui.FieldChangeListener;\r
21 import net.rim.device.api.ui.Manager;\r
22 import net.rim.device.api.ui.Screen;\r
23 import net.rim.device.api.ui.Ui;\r
24 import net.rim.device.api.ui.UiEngine;\r
25 import net.rim.device.api.ui.DrawStyle;\r
26 import net.rim.device.api.ui.component.ButtonField;\r
27 import net.rim.device.api.ui.component.LabelField;\r
28 import net.rim.device.api.ui.container.MainScreen;\r
29 import net.rim.device.api.ui.container.VerticalFieldManager;\r
30 \r
31 /**\r
32  * The screen used to display the application 'about' information.\r
33  *\r
34  * This code was contributed by LifeMarks.\r
35  *\r
36  * @author Matt York (matt@lifemarks.mobi)\r
37  */\r
38 final class AboutScreen extends MainScreen {\r
39 \r
40   AboutScreen() {\r
41     setTitle(new LabelField("ZXing - About", DrawStyle.ELLIPSIS | USE_ALL_WIDTH));\r
42     Manager vfm = new VerticalFieldManager(FIELD_HCENTER);\r
43     Field title = new LabelField("ZXing - BlackBerry Client", FIELD_HCENTER);\r
44     Field uri = new LabelField("http://code.google.com/p/zxing/", FIELD_HCENTER);\r
45     vfm.add(title);\r
46     vfm.add(uri);\r
47     Field okButton = new ButtonField("OK", FIELD_HCENTER | ButtonField.CONSUME_CLICK);\r
48     okButton.setChangeListener(new ButtonListener(this));\r
49     vfm.add(okButton);\r
50     add(vfm);\r
51   }\r
52 \r
53   /**\r
54    * Used to close the screen when the ok button is pressed.\r
55    */\r
56   private static class ButtonListener implements FieldChangeListener {\r
57     private final Screen screen;\r
58     private ButtonListener(Screen screen) {\r
59       this.screen = screen;\r
60     }\r
61     public void fieldChanged(Field field, int context) {\r
62       UiEngine ui = Ui.getUiEngine();\r
63       ui.popScreen(screen);\r
64     }\r
65   }\r
66 \r
67 }\r