<CheckBoxPreference android:title="Device administration" android:summaryOn="Device administration is enabled." android:key="admin" android:summaryOff="Device administration is disabled. Some commands require device administration."/>
<CheckBoxPreference android:key="foreground" android:title="Run service in foreground" android:summaryOn="The FonBot service is kept in foreground. " android:summaryOff="The FonBot service is not kept in foreground."/>
<CheckBoxPreference android:key="system" android:summaryOff="FonBot is not a system app. Changing this requires root and busybox" android:title="System App" android:summaryOn="FonBot is a system app. Changing this requires root and busybox"/>
-
+
+ <EditTextPreference android:dialogTitle="Server protocol" android:title="Server protocol" android:dialogMessage="Server protocol. Do not change unless you know what you are doing!" android:key="protocol" android:defaultValue="https" android:summary="https"/>
<EditTextPreference android:dialogTitle="Server hostname" android:title="Server hostname" android:dialogMessage="Server hostname. Do not change unless you know what you are doing!" android:key="hostname" android:defaultValue="fonbot.ieval.ro" android:summary="fonbot.ieval.ro"/>
<EditTextPreference android:dialogMessage="Server port. Do not change unless you know what you are doing!" android:dialogTitle="Server port" android:title="Server port" android:summary="443" android:defaultValue="7777" android:key="port"/>
</PreferenceScreen>
}
});
+ final EditTextPreference protocolPreference=(EditTextPreference) findPreference("protocol");
+ protocolPreference.setSummary(protocolPreference.getText());
+ protocolPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(final @Nullable Preference preference, final @Nullable Object newValue) {
+ if(newValue==null)
+ return false;
+
+ protocolPreference.setSummary(newValue.toString());
+ return true;
+ }
+ });
+
final EditTextPreference hostnamePreference=(EditTextPreference) findPreference("hostname");
hostnamePreference.setSummary(hostnamePreference.getText());
hostnamePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
* @throws MalformedURLException if the user preferences create an invalid URL
*/
public static URL getServerURL(final Context context, final String path) throws MalformedURLException{
+ final String protocol=PreferenceManager.getDefaultSharedPreferences(context).getString("protocol", "https");
final String hostname=PreferenceManager.getDefaultSharedPreferences(context).getString("hostname", "fonbot.ieval.ro");
final int port=Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("port", "443"));
- final URL url=new URL("http", hostname, port, path);
+ final URL url=new URL(protocol, hostname, port, path);
return url;
}