Issue 548, delete() before close() on FileConnection
[zxing.git] / rim / src / com / google / zxing / client / rim / HelpScreen.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.DrawStyle;\r
20 import net.rim.device.api.ui.Field;\r
21 import net.rim.device.api.ui.FieldChangeListener;\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.Manager;\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 help 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 HelpScreen extends MainScreen {\r
39 \r
40   HelpScreen() {\r
41     setTitle(new LabelField("ZXing - Help", DrawStyle.ELLIPSIS | USE_ALL_WIDTH));\r
42     Manager vfm = new VerticalFieldManager(FIELD_HCENTER);\r
43     Field aboutText = new LabelField("help info...", FIELD_HCENTER);\r
44     vfm.add(aboutText);\r
45     Field okButton = new ButtonField("OK", FIELD_HCENTER | ButtonField.CONSUME_CLICK);\r
46     okButton.setChangeListener(new ButtonListener(this));\r
47     vfm.add(okButton);\r
48     add(vfm);\r
49   }\r
50 \r
51   /**\r
52    * Closes the screen when the OK button is pressed.\r
53    */\r
54   private static class ButtonListener implements FieldChangeListener {\r
55     private final Screen screen;\r
56     private ButtonListener(Screen screen) {\r
57       this.screen = screen;\r
58     }\r
59     public void fieldChanged(Field field, int context) {\r
60       UiEngine ui = Ui.getUiEngine();\r
61       ui.popScreen(screen);\r
62     }\r
63   }\r
64 \r
65 }\r