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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Sun Aug 5 13:48:36 2012 UTC (11 years, 8 months ago) by zoffadmin
File size: 5799 byte(s)
initial import of aagtl source code
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.cc <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
24 import android.app.Activity;
25 import android.content.Intent;
26 import android.os.Bundle;
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.RadioButton;
36 import android.widget.RadioGroup;
37 import android.widget.RelativeLayout;
38 import android.widget.TextView;
39 import android.widget.RelativeLayout.LayoutParams;
40
41 public class PostLogEntryActivity extends Activity
42 {
43 private EditText msg;
44 private RadioButton log_type_found;
45 private RadioButton log_type_not_found;
46 private RadioButton log_type_note;
47
48 private RadioGroup group_log_type;
49
50 public RelativeLayout mainscreen_map_view;
51
52 @Override
53 protected void onCreate(Bundle savedInstanceState)
54 {
55 super.onCreate(savedInstanceState);
56
57 getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
58 WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
59 LinearLayout panel = new LinearLayout(this);
60 panel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
61 panel.setOrientation(LinearLayout.VERTICAL);
62
63 // log type selection:
64 TextView lbllogtype = new TextView(this);
65 lbllogtype.setText("Logtype");
66 lbllogtype.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f);
67 lbllogtype.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
68 LayoutParams.WRAP_CONTENT));
69
70
71 log_type_found = new RadioButton(this);
72 log_type_found.setText(GeocacheCoordinate.LOG_AS_HASH.get(GeocacheCoordinate.LOG_AS_FOUND));
73 log_type_found.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
74 LayoutParams.WRAP_CONTENT));
75
76 log_type_not_found = new RadioButton(this);
77 log_type_not_found.setText(GeocacheCoordinate.LOG_AS_HASH
78 .get(GeocacheCoordinate.LOG_AS_NOTFOUND));
79 log_type_not_found.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
80 LayoutParams.WRAP_CONTENT));
81
82 log_type_note = new RadioButton(this);
83 log_type_note.setText(GeocacheCoordinate.LOG_AS_HASH.get(GeocacheCoordinate.LOG_AS_NOTE));
84 log_type_note.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
85 LayoutParams.WRAP_CONTENT));
86
87 group_log_type = new RadioGroup(this);
88 group_log_type.addView(log_type_found);
89 group_log_type.addView(log_type_not_found);
90 group_log_type.addView(log_type_note);
91
92 log_type_found.setChecked(true);
93 log_type_not_found.setChecked(false);
94 log_type_note.setChecked(false);
95
96
97 // Userid : label and text field
98 TextView lblUserid = new TextView(this);
99 lblUserid.setText("Fieldnote");
100 lblUserid.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f);
101 lblUserid.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
102 LayoutParams.WRAP_CONTENT));
103
104 msg = new EditText(this);
105 msg.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
106 // ttfUserid.setText("a");
107
108 // login button
109 final Button btnLogin = new Button(this);
110 btnLogin.setText("Save");
111 btnLogin
112 .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
113 btnLogin.setGravity(Gravity.CENTER);
114 btnLogin.setOnClickListener(new OnClickListener()
115 {
116 public void onClick(View v)
117 {
118 int l_type = GeocacheCoordinate.LOG_AS_FOUND;
119 if (log_type_found.isChecked() == true)
120 {
121 l_type = GeocacheCoordinate.LOG_AS_FOUND;
122 }
123 else if (log_type_not_found.isChecked() == true)
124 {
125 l_type = GeocacheCoordinate.LOG_AS_NOTFOUND;
126 }
127 else if (log_type_note.isChecked() == true)
128 {
129 l_type = GeocacheCoordinate.LOG_AS_NOTE;
130 }
131 executeDone(l_type);
132 }
133 });
134
135
136 // title
137 try
138 {
139 String s = getIntent().getExtras().getString("title");
140 if (s.length() > 0)
141 {
142 this.setTitle(s);
143 }
144 }
145 catch (Exception e)
146 {
147 }
148
149 // fieldnote text
150 try
151 {
152 msg = new EditText(this);
153 msg.setText(getIntent().getExtras().getString("msg"));
154 }
155 catch (Exception e)
156 {
157 }
158
159
160 // actually adding the views (that have layout set on them) to the panel
161 // selection of log type
162 panel.addView(lbllogtype);
163 panel.addView(group_log_type);
164 // fieldnote text
165 panel.addView(lblUserid);
166 panel.addView(msg);
167 // savebutton
168 panel.addView(btnLogin);
169
170 setContentView(panel);
171
172 }
173
174 @Override
175 public void onBackPressed()
176 {
177 executeDone(GeocacheCoordinate.LOG_AS_FOUND);
178 super.onBackPressed();
179 }
180
181 private void executeDone(int logtype)
182 {
183 Intent resultIntent = new Intent();
184 resultIntent.putExtra("msg", PostLogEntryActivity.this.msg.getText().toString());
185 resultIntent.putExtra("logtype", logtype);
186 setResult(Activity.RESULT_OK, resultIntent);
187 finish();
188 }
189
190
191 }

   
Visit the aagtl Website