]>
Commit | Line | Data |
---|---|---|
1 | package de.rmdir.ms2debounce; | |
2 | ||
3 | import android.app.Activity; | |
4 | import android.app.Dialog; | |
5 | import android.app.AlertDialog; | |
6 | import android.os.Bundle; | |
7 | import android.content.Intent; | |
8 | import android.content.DialogInterface; | |
9 | import android.widget.TextView; | |
10 | import android.view.Menu; | |
11 | import android.view.MenuInflater; | |
12 | import android.view.MenuItem; | |
13 | ||
14 | public class MS2Debounce extends Activity | |
15 | { | |
16 | @Override | |
17 | public void onCreate(Bundle savedInstanceState) | |
18 | { | |
19 | super.onCreate(savedInstanceState); | |
20 | ||
21 | DebounceModuleHelper module = new DebounceModuleHelper(this); | |
22 | ||
23 | if (!module.isLoaded()) { | |
24 | module.loadModule(); | |
25 | } | |
26 | ||
27 | setContentView(R.layout.main); | |
28 | ||
29 | TextView text = (TextView)findViewById(R.id.text); | |
30 | text.setText("You will soon be able to set the debounce_delay here.\nModule loaded: " + module.isLoaded() + "\ndebounce_delay: " + module.getDelay() + "ms\nsafe_to_load: " + module.is_safe_to_load()); | |
31 | } | |
32 | ||
33 | @Override | |
34 | public boolean onCreateOptionsMenu(Menu menu) { | |
35 | MenuInflater inflater = getMenuInflater(); | |
36 | inflater.inflate(R.menu.main, menu); | |
37 | return true; | |
38 | } | |
39 | ||
40 | @Override | |
41 | public boolean onOptionsItemSelected(MenuItem item) { | |
42 | switch (item.getItemId()) { | |
43 | case R.id.about: | |
44 | showDialog(42); | |
45 | return true; | |
46 | default: | |
47 | return super.onOptionsItemSelected(item); | |
48 | } | |
49 | } | |
50 | ||
51 | protected Dialog onCreateDialog(int id) { | |
52 | Dialog dlg = null; | |
53 | ||
54 | AlertDialog.Builder about = new AlertDialog.Builder(this); | |
55 | about.setMessage("Milestone 2 Debounce\n\n(C) 2011 Michael Gernoth <michael@gernoth.net>\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA") | |
56 | .setCancelable(true) | |
57 | .setPositiveButton("Ok", new DialogInterface.OnClickListener() { | |
58 | public void onClick(DialogInterface dialog, int id) { | |
59 | dialog.cancel(); | |
60 | } | |
61 | }); | |
62 | dlg = about.create(); | |
63 | ||
64 | return dlg; | |
65 | } | |
66 | } |