/[aagtl_public1]/src/com/zoffcc/applications/aagtl/TextEntryActivity.java
aagtl

Contents of /src/com/zoffcc/applications/aagtl/TextEntryActivity.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sun Aug 5 14:00:28 2012 UTC (11 years, 7 months ago) by zoffadmin
File size: 6561 byte(s)
license text correction
1 /**
2 * aagtl Advanced Geocaching Tool for Android
3 * loosely based on agtl by Daniel Fett <fett@danielfett.de>
4 * Copyright (C) 2010 - 2012 Zoff <aagtl@work.zoff.cc>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 package com.zoffcc.applications.aagtl;
22
23 import android.app.Activity;
24 import android.content.Intent;
25 import android.os.Bundle;
26 import android.text.method.PasswordTransformationMethod;
27 import android.util.TypedValue;
28 import android.view.Gravity;
29 import android.view.View;
30 import android.view.WindowManager;
31 import android.view.View.OnClickListener;
32 import android.widget.Button;
33 import android.widget.EditText;
34 import android.widget.LinearLayout;
35 import android.widget.RelativeLayout;
36 import android.widget.TextView;
37 import android.widget.RelativeLayout.LayoutParams;
38
39 public class TextEntryActivity extends Activity
40 {
41 private EditText u;
42 private EditText p;
43
44 public RelativeLayout mainscreen_map_view;
45
46 @Override
47 protected void onCreate(Bundle savedInstanceState)
48 {
49 super.onCreate(savedInstanceState);
50
51 getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
52 WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
53 LinearLayout panel = new LinearLayout(this);
54 panel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
55 panel.setOrientation(LinearLayout.VERTICAL);
56
57 // Userid : label and text field
58 TextView lblUserid = new TextView(this);
59 lblUserid.setText("Userid");
60 lblUserid.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f);
61 lblUserid.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
62 LayoutParams.WRAP_CONTENT));
63
64 u = new EditText(this);
65 u.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
66 // ttfUserid.setText("a");
67
68 // Password : label and text field
69 TextView lblPassword = new TextView(this);
70 lblPassword.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f);
71 lblPassword.setText("Password");
72 lblPassword.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
73 LayoutParams.WRAP_CONTENT));
74
75 p = new EditText(this);
76 p.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
77 p.setTransformationMethod(new PasswordTransformationMethod());
78 // ttfPassword.setText("a");
79
80 // login button
81 final Button btnLogin = new Button(this);
82 btnLogin.setText("Save");
83 btnLogin
84 .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
85 btnLogin.setGravity(Gravity.CENTER);
86 btnLogin.setOnClickListener(new OnClickListener()
87 {
88 public void onClick(View v)
89 {
90 executeDone();
91 }
92 });
93
94
95 // title
96 try
97 {
98 String s = getIntent().getExtras().getString("title");
99 if (s.length() > 0)
100 {
101 this.setTitle(s);
102 }
103 }
104 catch (Exception e)
105 {
106 }
107
108 // username
109 try
110 {
111 u = new EditText(this);
112 u.setSingleLine();
113 u.setText(getIntent().getExtras().getString("username"));
114 }
115 catch (Exception e)
116 {
117 }
118
119 // password
120 try
121 {
122 p = new EditText(this);
123 p.setSingleLine();
124 p.setText(getIntent().getExtras().getString("password"));
125 p.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance());
126 }
127 catch (Exception e)
128 {
129 }
130
131
132 // actually adding the views (that have layout set on them) to the panel
133 // userid
134 panel.addView(lblUserid);
135 panel.addView(u);
136 // password
137 panel.addView(lblPassword);
138 panel.addView(p);
139 // loginbutton
140 panel.addView(btnLogin);
141
142 setContentView(panel);
143
144
145 //
146 //
147 //
148 //
149 //
150 //
151 // getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
152 // WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
153 //
154 // requestWindowFeature(0);
155 // LayoutParams layoutParams_mainscreen_map_view = new RelativeLayout.LayoutParams(200, 300);
156 // mainscreen_map_view = new RelativeLayout(this);
157 // mainscreen_map_view.setLayoutParams(layoutParams_mainscreen_map_view);
158 // setContentView(mainscreen_map_view);
159 //
160 // // title
161 // try
162 // {
163 // String s = getIntent().getExtras().getString("title");
164 // if (s.length() > 0)
165 // {
166 // this.setTitle(s);
167 // }
168 // }
169 // catch (Exception e)
170 // {
171 // }
172 //
173 // // username
174 // try
175 // {
176 // u = new EditText(this);
177 // u.setText(getIntent().getExtras().getString("username"));
178 // }
179 // catch (Exception e)
180 // {
181 // }
182 //
183 // // password
184 // try
185 // {
186 // p = new EditText(this);
187 // p.setText(getIntent().getExtras().getString("password"));
188 // }
189 // catch (Exception e)
190 // {
191 // }
192 //
193 //
194 // // button
195 // Button button = new Button(this);
196 // button.setOnClickListener(new OnClickListener()
197 // {
198 // public void onClick(View v)
199 // {
200 // executeDone();
201 // }
202 // });
203 //
204 // RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(200, 55);
205 // lp1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
206 // mainscreen_map_view.addView(u, lp1);
207 //
208 // RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(200, 55);
209 // lp2.addRule(RelativeLayout.CENTER_VERTICAL);
210 // mainscreen_map_view.addView(p, lp2);
211 //
212 // RelativeLayout.LayoutParams lp3 = new RelativeLayout.LayoutParams(200, 55);
213 // lp3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
214 // mainscreen_map_view.addView(button, lp3);
215 }
216
217 @Override
218 public void onBackPressed()
219 {
220 executeDone();
221 super.onBackPressed();
222 }
223
224 private void executeDone()
225 {
226 Intent resultIntent = new Intent();
227 resultIntent.putExtra("username", TextEntryActivity.this.u.getText().toString());
228 resultIntent.putExtra("password", TextEntryActivity.this.p.getText().toString());
229 setResult(Activity.RESULT_OK, resultIntent);
230 finish();
231 }
232
233 }

   
Visit the aagtl Website