mirror of
http://galexander.org/git/simplesshd.git
synced 2024-11-27 09:48:08 +00:00
and there's the start/stop button implementation
This commit is contained in:
parent
9cac7ed132
commit
8ced3ab635
@ -29,16 +29,32 @@ public class SimpleSSHD extends Activity
|
||||
|
||||
public void onResume() {
|
||||
load_prefs();
|
||||
/* XXX - update startstop_view */
|
||||
update_startstop();
|
||||
SimpleSSHDService.activity = this;
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
SimpleSSHDService.activity = null;
|
||||
save_prefs();
|
||||
}
|
||||
|
||||
public void update_startstop() {
|
||||
if (SimpleSSHDService.is_started()) {
|
||||
startstop_view.setText("STOP");
|
||||
startstop_view.setTextColor(0xFFFF8888);
|
||||
} else {
|
||||
startstop_view.setText("START");
|
||||
startstop_view.setTextColor(0xFF88FF88);
|
||||
}
|
||||
}
|
||||
|
||||
private void startstop_clicked(View v) {
|
||||
save_prefs();
|
||||
/* XXX */
|
||||
Intent i = new Intent(this, SimpleSSHDService.class);
|
||||
if (SimpleSSHDService.is_started() {
|
||||
i.putExtra("stop", true);
|
||||
}
|
||||
startService(i);
|
||||
}
|
||||
|
||||
private void load_prefs() {
|
||||
|
@ -6,6 +6,7 @@ import android.os.IBinder;
|
||||
|
||||
public class SimpleSSHDService extends Service {
|
||||
public static int sshd_pid = 0;
|
||||
public static SimpleSSHD activity = null;
|
||||
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if ((intent == null) ||
|
||||
@ -14,9 +15,15 @@ public class SimpleSSHDService extends Service {
|
||||
stop_sshd();
|
||||
}
|
||||
start_sshd();
|
||||
if (activity != null) {
|
||||
activity.update_startstop();
|
||||
}
|
||||
return START_STICKY;
|
||||
} else {
|
||||
stop_sshd();
|
||||
if (activity != null) {
|
||||
activity.update_startstop();
|
||||
}
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user