1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-11-15 19:48:56 +00:00

now it compiles

This commit is contained in:
Greg Alexander 2016-06-19 16:12:19 -04:00
parent 84f9f31c14
commit 31fd0b37d0
5 changed files with 32 additions and 20 deletions

View File

@ -1,13 +1,18 @@
package org.galexander.sshd;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.InputType;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.widget.EditText;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class AuthKeys extends Activity {
private EditText authtext;
@ -34,16 +39,16 @@ public class AuthKeys extends Activity {
AlertDialog.Builder ab = new AlertDialog.Builder(this);
ab.setTitle("Fetch authorized_keys");
final EditText url = new EditText(this);
url.setInputType(EditText.TYPE_CLASS_TEXT |
EditText.TYPE_TEXT_VARIATION_URI);
url.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_URI);
ab.setView(url);
ab.setPositiveButton("OK",
new DialogInterface.onClickListener() {
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int which) {
start_fetch(url.getText().toString());
} });
ab.setNegativeButton("Cancel",
new DialogInterface.onClickListener() {
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int which) {
d.cancel();
} });
@ -62,7 +67,7 @@ public class AuthKeys extends Activity {
private void save_authtext() {
String s = get_authtext();
if ((authtext_orig_str != null) && (s != null) &&
if ((authtext_orig != null) && (s != null) &&
!s.equals(authtext_orig)) {
Intent i = new Intent(this, AuthKeysSave.class);
i.putExtra("s", s);
@ -102,8 +107,9 @@ public class AuthKeys extends Activity {
private void start_fetch(String url) {
Intent i = new Intent(this, AuthKeysFetch.class);
i.putExtra("url", url.getText().toString());
i.putExtra("m", Messenger m = new Messenger(new Handler() {
final Context ctx = this;
i.putExtra("url", url);
i.putExtra("m", new Messenger(new Handler() {
public void handleMessage(Message msg) {
Object o = msg.obj;
if (o == null) {
@ -116,7 +122,7 @@ public class AuthKeys extends Activity {
append_authtext(s);
} else {
/* s must be an error message */
Toast.makeText(this, s,
Toast.makeText(ctx, s,
Toast.LENGTH_LONG).show();
}
} } ));

View File

@ -4,18 +4,19 @@ import android.app.IntentService;
import android.content.Intent;
import android.os.Message;
import android.os.Messenger;
import java.io.InputStream;
import java.net.URL;
import java.net.HttpURLConnection;
public class AuthKeysSave extends IntentService {
public AuthKeysSave() {
super("SimpleSSHDAuthKeysSave");
public class AuthKeysFetch extends IntentService {
public AuthKeysFetch() {
super("SimpleSSHDAuthKeysFetch");
}
protected void onHandleIntent(Intent i) {
Messenger m = (Messenger)i.getExtra("m");
Message msg = m.obtain();
String url = i.getStringExtra("url", null);
Messenger m = (Messenger)i.getParcelableExtra("m");
Message msg = Message.obtain();
String url = i.getStringExtra("url");
String result = "";
byte[] b = new byte[1024];
@ -26,7 +27,7 @@ public class AuthKeysSave extends IntentService {
}
URL u = new URL(url);
HttpURLConnection conn = (HttpURLConnection)
url.openConnection();
u.openConnection();
try {
InputStream in = conn.getInputStream();
try {

View File

@ -2,6 +2,10 @@ package org.galexander.sshd;
import android.app.Activity;
import android.os.AsyncTask;
import android.widget.Toast;
import java.io.File;
import java.io.FileInputStream;
public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
private AuthKeys act = null;
@ -13,8 +17,8 @@ public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
}
AuthKeysLoad(AuthKeys act_) {
act = act_;
super();
act = act_;
}
protected Void doInBackground(Void... v) {

View File

@ -10,7 +10,7 @@ public class AuthKeysSave extends IntentService {
super("SimpleSSHDAuthKeysSave");
}
protected void onHandleIntent(Intent i) {
String s = i.getStringExtra("s", null);
String s = i.getStringExtra("s");
if (s == null) {
return;
}

View File

@ -11,6 +11,7 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
@ -226,12 +227,12 @@ public class SimpleSSHD extends Activity
}
/* called from AuthKeysSave (in its own worker thread) if it fails */
public static void toast(String s) {
public static void toast(final String s) {
synchronized (lock) {
if (curr != null) {
curr.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(this, s,
Toast.makeText(curr, s,
Toast.LENGTH_LONG).show();
} });
} else {