Browse Source

Auto enable Trust All Certs for Deluge RPC Adapter

pull/426/head
Alon Albert 7 years ago
parent
commit
58fcc6e060
  1. 33
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  2. 1
      app/src/main/res/values/strings.xml

33
app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -25,9 +25,11 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.TextUtils;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
@ -45,8 +47,12 @@ import org.transdroid.daemon.Daemon;
public class ServerSettingsActivity extends KeyBoundPreferencesActivity { public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
private static final int DIALOG_CONFIRMREMOVE = 0; private static final int DIALOG_CONFIRMREMOVE = 0;
private static final int DIALOG_DELUGE_RPC_SSL = 1;
private EditTextPreference extraPass, folder, downloadDir, excludeFilter, includeFilter; private EditTextPreference extraPass, folder, downloadDir, excludeFilter, includeFilter;
private ListPreference serverType;
private CheckBoxPreference serverSslEnabled;
private CheckBoxPreference serverSslTrustAll;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -57,7 +63,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
// Load the raw preferences to show in this screen // Load the raw preferences to show in this screen
init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxNormalServer()); init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxNormalServer());
initTextPreference("server_name"); initTextPreference("server_name");
initListPreference("server_type"); serverType = initListPreference("server_type");
initTextPreference("server_address"); initTextPreference("server_address");
initTextPreference("server_port"); initTextPreference("server_port");
initTextPreference("server_user"); initTextPreference("server_user");
@ -77,9 +83,24 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("server_ftpurl"); initTextPreference("server_ftpurl");
initTextPreference("server_ftppass"); initTextPreference("server_ftppass");
initBooleanPreference("server_disableauth"); initBooleanPreference("server_disableauth");
initBooleanPreference("server_sslenabled"); serverSslEnabled = initBooleanPreference("server_sslenabled");
initBooleanPreference("server_ssltrustall", false, "server_sslenabled"); serverSslTrustAll = initBooleanPreference("server_ssltrustall", false, "server_sslenabled");
initTextPreference("server_ssltrustkey", null, "server_sslenabled"); initTextPreference("server_ssltrustkey", null, "server_sslenabled");
serverType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
if (Daemon.fromCode(o.toString()) == Daemon.DelugeRpc) {
serverSslEnabled.setChecked(true);
serverSslTrustAll.setChecked(true);
showDialog(DIALOG_DELUGE_RPC_SSL);
} else {
serverSslEnabled.setChecked(false);
serverSslTrustAll.setChecked(false);
}
return true;
}
});
onPreferencesChanged(); onPreferencesChanged();
} }
@ -108,6 +129,10 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
finish(); finish();
} }
}).setNegativeButton(android.R.string.cancel, null).create(); }).setNegativeButton(android.R.string.cancel, null).create();
case DIALOG_DELUGE_RPC_SSL:
return new AlertDialog.Builder(this).setMessage(R.string.pref_deluge_rpc_ssl)
.setNeutralButton(android.R.string.ok, null)
.create();
} }
return null; return null;
} }

1
app/src/main/res/values/strings.xml

@ -486,5 +486,6 @@
<string name="system_librarieslabel">Some code/libraries are used in the project:</string> <string name="system_librarieslabel">Some code/libraries are used in the project:</string>
<string name="system_libraries" translatable="false">AndroidAnnotations\n \u00A0 http://androidannotations.org/\n \u00A0 Pierre-Yves Ricau (eBusinessInformations) et al. \n \u00A0 Apache License, Version 2.0\nMaterial Dialogs\n \u00A0 https://github.com/afollestad/material-dialogs\n \u00A0 Aidan Follestad et al. \n \u00A0 MIT License\nSnackbar\n \u00A0 https://github.com/nispok/snackbar\n \u00A0 William Mora et al. \n \u00A0 MIT License\nFloatingActionButton\n \u00A0 https://github.com/futuresimple/android-floating-action-button\n \u00A0 Jerzy Chałupski et al. \n \u00A0 Apache License, Version 2.0\nBase16Encoder\n \u00A0 http://openjpa.apache.org/\n \u00A0 Marc Prud\'hommeaux \n \u00A0 Apache OpenJPA\n MultipartEntity \n \u00A0 Apache Software Foundation \n \u00A0 Apache License, Version 2.0\nRssParser (learning-android)\n \u00A0 http://github.com/digitalspaghetti/learning-android\n \u00A0 Tane Piper \n \u00A0 Public Domain\nBase64\n \u00A0 http://iharder.net/base64\n \u00A0 Robert Harder \n \u00A0 Public Domain\naXMLRPC\n \u00A0 https://github.com/timroes/aXMLRPC\n \u00A0 Tim Roes \n \u00A0 MIT License\nandroid-ColorPickerPreference\n \u00A0 https://github.com/attenzione/android-ColorPickerPreference\n \u00A0 Daniel Nilsson and Sergey Margaritov \n \u00A0 Apache License, Version 2.0\nFunnel icon\n \u00A0 http://thenounproject.com/noun/funnel/#icon-No5608\n \u00A0 Naomi Atkinson from The Noun Project\n \u00A0 Creative Commons Attribution 3.0</string> <string name="system_libraries" translatable="false">AndroidAnnotations\n \u00A0 http://androidannotations.org/\n \u00A0 Pierre-Yves Ricau (eBusinessInformations) et al. \n \u00A0 Apache License, Version 2.0\nMaterial Dialogs\n \u00A0 https://github.com/afollestad/material-dialogs\n \u00A0 Aidan Follestad et al. \n \u00A0 MIT License\nSnackbar\n \u00A0 https://github.com/nispok/snackbar\n \u00A0 William Mora et al. \n \u00A0 MIT License\nFloatingActionButton\n \u00A0 https://github.com/futuresimple/android-floating-action-button\n \u00A0 Jerzy Chałupski et al. \n \u00A0 Apache License, Version 2.0\nBase16Encoder\n \u00A0 http://openjpa.apache.org/\n \u00A0 Marc Prud\'hommeaux \n \u00A0 Apache OpenJPA\n MultipartEntity \n \u00A0 Apache Software Foundation \n \u00A0 Apache License, Version 2.0\nRssParser (learning-android)\n \u00A0 http://github.com/digitalspaghetti/learning-android\n \u00A0 Tane Piper \n \u00A0 Public Domain\nBase64\n \u00A0 http://iharder.net/base64\n \u00A0 Robert Harder \n \u00A0 Public Domain\naXMLRPC\n \u00A0 https://github.com/timroes/aXMLRPC\n \u00A0 Tim Roes \n \u00A0 MIT License\nandroid-ColorPickerPreference\n \u00A0 https://github.com/attenzione/android-ColorPickerPreference\n \u00A0 Daniel Nilsson and Sergey Margaritov \n \u00A0 Apache License, Version 2.0\nFunnel icon\n \u00A0 http://thenounproject.com/noun/funnel/#icon-No5608\n \u00A0 Naomi Atkinson from The Noun Project\n \u00A0 Creative Commons Attribution 3.0</string>
<string name="system_description">Manage your torrents from your Android device</string> <string name="system_description">Manage your torrents from your Android device</string>
<string name="pref_deluge_rpc_ssl">Deluge RPC server uses a Self Signed Certificate by default. Advanced settings have been automatically changed to accept all certificates. If you want to change this, please see Advanced Settings.</string>
</resources> </resources>

Loading…
Cancel
Save