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
.EditText
;
11 import android
.widget
.Button
;
12 import android
.widget
.CheckBox
;
13 import android
.view
.View
;
14 import android
.view
.Menu
;
15 import android
.view
.MenuInflater
;
16 import android
.view
.MenuItem
;
18 public class MS2Debounce
extends Activity
20 private DebounceModuleHelper module
;
25 module
= new DebounceModuleHelper(this);
29 public void onCreate(Bundle savedInstanceState
)
31 super.onCreate(savedInstanceState
);
33 //if (!module.isLoaded()) {
34 // module.loadModule();
37 setContentView(R
.layout
.main
);
41 private void updateUI() {
44 boolean loaded
= module
.isLoaded();
45 boolean safe_to_load
= module
.is_safe_to_load();
47 TextView text
= (TextView
)findViewById(R
.id
.text
);
48 text
.setText("Current status:\n\nModule loaded: " + loaded
+ "\ndebounce_delay: " + module
.getDelay() + "ms\nsafe_to_load: " + safe_to_load
);
50 //EditText textDelay = (EditText)findViewById(R.id.debounce_delay);
51 //textDelay.setText(module.getSavedDelay());
53 Button reload
= (Button
)findViewById(R
.id
.reload
);
55 reload
.setEnabled(true);
57 reload
.setEnabled(false);
60 Button load
= (Button
)findViewById(R
.id
.load
);
62 load
.setEnabled(false);
64 load
.setEnabled(true);
67 Button unload
= (Button
)findViewById(R
.id
.unload
);
69 unload
.setEnabled(true);
71 unload
.setEnabled(false);
74 CheckBox on_boot
= (CheckBox
)findViewById(R
.id
.on_boot
);
76 on_boot
.setEnabled(true);
78 on_boot
.setEnabled(false);
82 private void disableUI() {
83 Button reload
= (Button
)findViewById(R
.id
.reload
);
84 reload
.setEnabled(false);
86 Button load
= (Button
)findViewById(R
.id
.load
);
87 load
.setEnabled(false);
89 Button unload
= (Button
)findViewById(R
.id
.unload
);
90 unload
.setEnabled(false);
92 CheckBox on_boot
= (CheckBox
)findViewById(R
.id
.on_boot
);
93 on_boot
.setEnabled(false);
96 public void loadModule(View view
) {
98 if (!module
.isLoaded()) {
104 public void unloadModule(View view
) {
106 if (module
.isLoaded()) {
107 module
.unloadModule();
112 public void reloadModule(View view
) {
114 if (module
.isLoaded()) {
115 module
.unloadModule();
117 if (!module
.isLoaded()) {
124 public boolean onCreateOptionsMenu(Menu menu
) {
125 MenuInflater inflater
= getMenuInflater();
126 inflater
.inflate(R
.menu
.main
, menu
);
131 public boolean onOptionsItemSelected(MenuItem item
) {
132 switch (item
.getItemId()) {
137 return super.onOptionsItemSelected(item
);
141 protected Dialog
onCreateDialog(int id
) {
144 AlertDialog
.Builder about
= new AlertDialog
.Builder(this);
145 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")
147 .setPositiveButton("Ok", new DialogInterface
.OnClickListener() {
148 public void onClick(DialogInterface dialog
, int id
) {
152 dlg
= about
.create();