1 package de
.rmdir
.ms2debounce
;
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
.widget
.Button
;
11 import android
.widget
.CheckBox
;
12 import android
.view
.View
;
13 import android
.view
.Menu
;
14 import android
.view
.MenuInflater
;
15 import android
.view
.MenuItem
;
17 public class MS2Debounce
extends Activity
19 private DebounceModuleHelper module
;
24 module
= new DebounceModuleHelper(this);
28 public void onCreate(Bundle savedInstanceState
)
30 super.onCreate(savedInstanceState
);
32 //if (!module.isLoaded()) {
33 // module.loadModule();
36 setContentView(R
.layout
.main
);
40 private void updateUI() {
41 TextView text
= (TextView
)findViewById(R
.id
.text
);
45 boolean loaded
= module
.isLoaded();
46 boolean safe_to_load
= module
.is_safe_to_load();
48 text
.setText("Current status:\n\nModule loaded: " + loaded
+ "\ndebounce_delay: " + module
.getDelay() + "ms\nsafe_to_load: " + safe_to_load
);
50 Button reload
= (Button
)findViewById(R
.id
.reload
);
52 reload
.setEnabled(true);
54 reload
.setEnabled(false);
57 Button load
= (Button
)findViewById(R
.id
.load
);
59 load
.setEnabled(false);
61 load
.setEnabled(true);
64 Button unload
= (Button
)findViewById(R
.id
.unload
);
66 unload
.setEnabled(true);
68 unload
.setEnabled(false);
71 CheckBox on_boot
= (CheckBox
)findViewById(R
.id
.on_boot
);
73 on_boot
.setEnabled(true);
75 on_boot
.setEnabled(false);
79 private void disableUI() {
80 Button reload
= (Button
)findViewById(R
.id
.reload
);
81 reload
.setEnabled(false);
83 Button load
= (Button
)findViewById(R
.id
.load
);
84 load
.setEnabled(false);
86 Button unload
= (Button
)findViewById(R
.id
.unload
);
87 unload
.setEnabled(false);
89 CheckBox on_boot
= (CheckBox
)findViewById(R
.id
.on_boot
);
90 on_boot
.setEnabled(false);
93 public void loadModule(View view
) {
95 if (!module
.isLoaded()) {
101 public void unloadModule(View view
) {
103 if (module
.isLoaded()) {
104 module
.unloadModule();
109 public void reloadModule(View view
) {
111 if (module
.isLoaded()) {
112 module
.unloadModule();
114 if (!module
.isLoaded()) {
121 public boolean onCreateOptionsMenu(Menu menu
) {
122 MenuInflater inflater
= getMenuInflater();
123 inflater
.inflate(R
.menu
.main
, menu
);
128 public boolean onOptionsItemSelected(MenuItem item
) {
129 switch (item
.getItemId()) {
134 return super.onOptionsItemSelected(item
);
138 protected Dialog
onCreateDialog(int id
) {
141 AlertDialog
.Builder about
= new AlertDialog
.Builder(this);
142 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")
144 .setPositiveButton("Ok", new DialogInterface
.OnClickListener() {
145 public void onClick(DialogInterface dialog
, int id
) {
149 dlg
= about
.create();