Browse files

Merge branch 'master' into wizard_cleanup

Conflicts:
	src/com/matburt/mobileorg/Settings/WizardActivity.java
  • Loading branch information...
2 parents d44089f + 8ef0f88 commit 0577cdbdc4aeb631a8f4fc82cd7720f7f9595597 @hdweiss hdweiss committed Dec 9, 2012
View
22 res/layout/wizard_ssh.xml
@@ -53,6 +53,26 @@
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:text="@string/ssh_inform_choose_pub_file"
+ android:textSize="20dp"/>
+ <Button
+ android:layout_marginTop="20dp"
+ android:id="@+id/wizard_ssh_choose_pub_file"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/ssh_choose_file_button"
+ android:textSize="20dp"/>
+ <TextView
+ android:id="@+id/wizard_ssh_pub_file_actual"
+ android:paddingTop="10dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:textSize="20dp"/>
+ <TextView
+ android:paddingTop="10dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:text="@string/path"
android:textSize="20dp"/>
<EditText
@@ -103,4 +123,4 @@
/>
<include layout="@layout/wizard_navbar_last"/>
</LinearLayout>
-</ScrollView>
+</ScrollView>
View
4 res/values/strings.xml
@@ -106,6 +106,8 @@
<string name="log_in_to_ubuntuone">Log in to Ubuntu One</string>
<string name="log_in_to_webdav">Log in to your WebDAV server</string>
<string name="log_in_to_ssh">Log in to your SSH server</string>
+ <string name="ssh_inform_choose_pub_file">OR select a file containing your *private* key (requires a file explorer program to be installed)</string>
+ <string name="ssh_choose_file_button">Select your *private* key file</string>
<string name="null_sync_description">This is a capture only synchronizer. It will not attempt to synchronize to any source.</string>
<string name="dropbox_login_info">This will redirect you to a login form. After logging in it will return you to this screen to continue.</string>
<string name="url">URL</string>
@@ -198,4 +200,4 @@
<string name="title_index_file_path">Full local path to index.org</string>
<string name="summary_web_url">Full URL path to your index.org file</string>
-</resources>
+</resources>
View
7 src/com/matburt/mobileorg/Gui/Capture/PayloadFragment.java
@@ -82,7 +82,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
EditActivity editActivity = (EditActivity) getActivity();
OrgNode node = editActivity.getOrgNode();
- this.payload = node.getOrgNodePayload();
+ this.payload = new OrgNodePayload(node.getOrgNodePayload().get());
if(savedInstanceState != null)
restoreInstanceState(savedInstanceState);
@@ -109,13 +109,12 @@ public void restoreInstanceState(Bundle savedInstanceState) {
if(savedInstanceState != null) {
String payloadString = savedInstanceState.getString(PAYLOAD);
boolean isEditing = savedInstanceState.getBoolean(EDITING);
+ this.payload.set(payloadString);
if(isEditing)
switchToEdit(payloadString);
- else {
- this.payload.set(payloadString);
+ else
switchToView();
- }
}
}
View
15 src/com/matburt/mobileorg/Gui/Wizard/WizardActivity.java
@@ -1,11 +1,13 @@
package com.matburt.mobileorg.Gui.Wizard;
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.Gui.Wizard.Wizards.SSHWizard;
import com.matburt.mobileorg.Gui.Wizard.Wizards.Wizard;
import com.matburt.mobileorg.util.OrgUtils;
@@ -53,6 +55,19 @@ protected void onResume() {
if(activeWizard != null)
activeWizard.refresh();
}
+
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == SSHWizard.SSH_CHOOSE_PUB) {
+ if (resultCode == RESULT_OK) {
+ String filePath = data.getData().getPath();
+
+ if (activeWizard instanceof SSHWizard)
+ ((SSHWizard) activeWizard).setPubFile(filePath);
+ }
+ }
+ }
@Override
public void onCheckedChanged(RadioGroup arg, int checkedId) {
View
34 src/com/matburt/mobileorg/Gui/Wizard/Wizards/SSHWizard.java
@@ -1,6 +1,8 @@
package com.matburt.mobileorg.Gui.Wizard.Wizards;
+import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.HandlerThread;
import android.preference.PreferenceManager;
@@ -9,18 +11,23 @@
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.TextView;
import com.matburt.mobileorg.R;
import com.matburt.mobileorg.Gui.Wizard.WizardView;
import com.matburt.mobileorg.Synchronizers.SSHSynchronizer;
public class SSHWizard extends Wizard {
-
+ public static final int SSH_CHOOSE_PUB = 1;
+
private EditText sshUser;
private EditText sshPass;
private EditText sshPath;
private EditText sshHost;
private EditText sshPort;
+
+ private TextView sshPubFileActual;
+ private final String pubFileActual = sshPubFileActual.getText().toString();
public SSHWizard(WizardView wizardView, Context context) {
super(wizardView, context);
@@ -41,6 +48,22 @@ public View createSSHConfig() {
sshPath = (EditText) view.findViewById(R.id.wizard_ssh_path);
sshHost = (EditText) view.findViewById(R.id.wizard_ssh_host);
sshPort = (EditText) view.findViewById(R.id.wizard_ssh_port);
+ sshPubFileActual = (TextView) view
+ .findViewById(R.id.wizard_ssh_pub_file_actual);
+ Button sshPubFileSelect = (Button) view
+ .findViewById(R.id.wizard_ssh_choose_pub_file);
+ sshPubFileSelect.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.setType("file/*");
+ ((Activity)context).startActivityForResult(intent, SSH_CHOOSE_PUB);
+ } catch (Exception e) {
+ }
+ }
+ });
+
Button webdavLoginButton = (Button) view
.findViewById(R.id.wizard_ssh_login_button);
@@ -57,7 +80,6 @@ public void onClick(View v) {
wizardView.enablePage(1);
return view;
}
-
private void loginSSH() {
final String pathActual = sshPath.getText().toString();
@@ -83,7 +105,7 @@ private void loginSSH() {
public void run() {
SSHSynchronizer sds = new SSHSynchronizer(context);
String extra = sds.testConnection(pathActual, userActual,
- passActual, hostActual, portActual);
+ passActual, hostActual, portActual, pubFileActual);
if (extra != null) {
showToastRemote("Login failed: " + extra);
return;
@@ -94,6 +116,10 @@ public void run() {
loginThread.start();
}
+ public void setPubFile(String pubfile) {
+ this.sshPubFileActual.setText(pubfile);
+ }
+
public void saveSettings() {
SharedPreferences appSettings = PreferenceManager
.getDefaultSharedPreferences(context);
@@ -111,6 +137,8 @@ public void saveSettings() {
editor.putString("scpPort", sshPort.getText().toString());
}
+ editor.putString("scpPubFile", sshPubFileActual.getText().toString());
+
editor.commit();
}
}
View
17 src/com/matburt/mobileorg/Synchronizers/SSHSynchronizer.java
@@ -26,6 +26,7 @@
private String path;
private String pass;
private int port;
+ private String pubFile;
private Session session;
@@ -37,6 +38,7 @@ public SSHSynchronizer(Context context) {
path = appSettings.getString("scpPath", "");
user = appSettings.getString("scpUser", "");
host = appSettings.getString("scpHost", "");
+ pubFile = appSettings.getString("scpPubFile", "");
String tmpPort = appSettings.getString("scpPort", "");
if (tmpPort.equals("")) {
port = 22;
@@ -53,12 +55,13 @@ public SSHSynchronizer(Context context) {
}
}
- public String testConnection(String path, String user, String pass, String host, int port) {
+ public String testConnection(String path, String user, String pass, String host, int port, String pubFile) {
this.path = path;
this.user = user;
this.pass = pass;
this.host = host;
this.port = port;
+ this.pubFile = pubFile;
if (this.path.indexOf("index.org") < 0) {
Log.i("MobileOrg", "Invalid ssh path, must point to index.org");
@@ -68,7 +71,7 @@ public String testConnection(String path, String user, String pass, String host,
if (this.path.equals("") ||
this.user.equals("") ||
this.host.equals("") ||
- this.pass.equals("")) {
+ (this.pass.equals("") && this.pubFile.equals(""))) {
Log.i("MobileOrg", "Test Connection Failed for not being configured");
return "Missing configuration values";
}
@@ -112,7 +115,8 @@ public boolean isConfigured() {
if (this.appSettings.getString("scpPath", "").equals("") ||
this.appSettings.getString("scpUser", "").equals("") ||
this.appSettings.getString("scpHost", "").equals("") ||
- this.appSettings.getString("scpPass", "").equals(""))
+ (this.appSettings.getString("scpPass", "").equals("") &&
+ this.appSettings.getString("scpPubFile", "").equals("")))
return false;
return true;
}
@@ -121,7 +125,12 @@ public void connect() throws JSchException {
JSch jsch = new JSch();
try {
session = jsch.getSession(user, host, port);
- session.setPassword(pass);
+ if (!pubFile.equals("")) {
+ jsch.addIdentity(pubFile);
+ }
+ else {
+ session.setPassword(pass);
+ }
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");

0 comments on commit 0577cdb

Please sign in to comment.