Commit 3af75a2b authored by Ricki Hirner's avatar Ricki Hirner Committed by Ricki Hirner

CalDAV/CardDAV service discovery with SRV/TXT records

* Structural changes in the strings file (for translations)
parent 2560ec4c
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<GridLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:columnCount="2"
android:padding="10dp"
android:useDefaultMargins="true" >
<TextView
android:layout_columnSpan="2"
android:layout_gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/login_email_description" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/login_email_address" />
<EditText
android:id="@+id/email_address"
android:layout_gravity="fill_horizontal"
android:inputType="textNoSuggestions|textEmailAddress"
android:imeOptions="actionNext"
android:layout_width="0dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:hint="myaccount@icloud.com" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/login_password" />
<EditText
android:id="@+id/password"
android:layout_gravity="fill_horizontal"
android:inputType="textPassword"
android:imeOptions="actionGo"
android:layout_width="0dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:text="" />
</GridLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:useDefaultMargins="true" >
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="@+id/login_type_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/login_type_email" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/login_type_email_description" />
<RadioButton
android:id="@+id/login_type_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_type_url" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/login_type_url_description" />
</RadioGroup>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_width="match_parent"
android:layout_height="match_parent" >
<GridLayout
android:layout_width="fill_parent"
......@@ -15,23 +15,23 @@
android:layout_columnSpan="2"
android:layout_gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/root_url" />
android:text="@string/login_base_url" />
<Spinner
android:id="@+id/login_scheme"
android:layout_width="wrap_content"
android:layout_gravity="left"
android:entries="@array/uri_scheme" />
android:entries="@array/login_url_scheme" />
<EditText
android:id="@+id/login_authority_path"
android:id="@+id/login_host_path"
android:layout_gravity="fill_horizontal"
android:imeOptions="flagForceAscii|actionNext"
android:inputType="textUri"
android:layout_width="0dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal"
android:text="" />
android:hint="my.webhost.com" />
<TextView
android:id="@+id/http_warning"
......@@ -42,11 +42,11 @@
android:drawableLeft="@drawable/alerts_and_states_warning"
android:drawablePadding="10dp"
android:padding="10dp"
android:text="@string/http_warning" />
android:text="@string/login_http_warning" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/user_name" />
android:text="@string/login_user_name" />
<EditText
android:id="@+id/userName"
......@@ -60,7 +60,7 @@
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/password" />
android:text="@string/login_password" />
<EditText
android:id="@+id/password"
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/next"
android:icon="@drawable/navigation_forward"
android:showAsAction="always|withText"
android:title="@string/next">
</item>
</menu>
\ No newline at end of file
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"Si no feu servir cap encriptació (HTTPS), altres usuaris poden interceptar fàcilment les vostres credencials, contactes i events."</string>
<string name="user_name">Nom d\'usuari:</string>
<string name="password">Contrasenya:</string>
<string name="root_url">URL Arrel (les coleccions es detecten automàticament):</string>
<string name="login_http_warning">"Si no feu servir cap encriptació (HTTPS), altres usuaris poden interceptar fàcilment les vostres credencials, contactes i events."</string>
<string name="login_user_name">Nom d\'usuari:</string>
<string name="login_password">Contrasenya:</string>
<string name="login_base_url">URL Arrel (les coleccions es detecten automàticament):</string>
<string name="next">Següent</string>
<string name="help">Ajuda</string>
<string name="invalid_base_url">URL base invàlida: </string>
<string name="title_select_collections">DAVdroid: Seleccioneu col·leccions</string>
<string name="exception_io">Error de E/S: %s</string>
<string name="login_invalid_base_url">URL base invàlida: </string>
<string name="select_collections">DAVdroid: Seleccioneu col·leccions</string>
<string name="login_exception_io">Error de E/S: %s</string>
<string name="exception_uri_syntax">URI invàlida: %s</string>
<string name="exception_incapable_resource">Missing capabilities: %s</string>
<string name="neither_caldav_nor_carddav">Ni CalDAV ni CardDAV estan disponibles</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"Pokud nepoužijete šifrované připojení (HTTPS), ostatní budou moci lehce získat vaše přihlašovací údaje, kontakty a události."</string>
<string name="user_name">Uživatelské jméno:</string>
<string name="password">Heslo:</string>
<string name="root_url">Kořenová URL (sbírky budou detekovány automaticky):</string>
<string name="login_http_warning">"Pokud nepoužijete šifrované připojení (HTTPS), ostatní budou moci lehce získat vaše přihlašovací údaje, kontakty a události."</string>
<string name="login_user_name">Uživatelské jméno:</string>
<string name="login_password">Heslo:</string>
<string name="login_base_url">Kořenová URL (sbírky budou detekovány automaticky):</string>
<string name="next">Další</string>
<string name="help">Pomoc</string>
<string name="invalid_base_url">Neplatná základní URL: </string>
<string name="title_select_collections">DAVdroid: Vybrat sbírky</string>
<string name="exception_io">I/O chyba: %s</string>
<string name="login_invalid_base_url">Neplatná základní URL: </string>
<string name="select_collections">DAVdroid: Vybrat sbírky</string>
<string name="login_exception_io">I/O chyba: %s</string>
<string name="exception_uri_syntax">Neplatné URI: %s</string>
<string name="exception_incapable_resource">Chybějící možnosti: %s</string>
<string name="neither_caldav_nor_carddav">V tomto umístění není CalDAV-/CardDAV služba dostupná.</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="http_warning">Ohne Verschlüsselung (HTTPS) können Ihre Zugangsdaten, Kontakte und Termine leicht abgefangen werden.</string>
<string name="user_name">Benutzername:</string>
<string name="password">Passwort:</string>
<string name="root_url">Basis-URL (Ordner werden automatisch gefunden):</string>
<string name="login_http_warning">Ohne Verschlüsselung (HTTPS) können Ihre Zugangsdaten, Kontakte und Termine leicht abgefangen werden.</string>
<string name="login_user_name">Benutzername:</string>
<string name="login_password">Passwort:</string>
<string name="login_base_url">Basis-URL (Ordner werden automatisch gefunden):</string>
<string name="next">Weiter</string>
<string name="help">Hilfe</string>
<string name="title_select_collections">DAVdroid: Ordner auswählen</string>
<string name="invalid_base_url">Ungültiger Basis-URL: </string>
<string name="exception_io">E/A-Fehler: %s</string>
<string name="select_collections">DAVdroid: Ordner auswählen</string>
<string name="login_invalid_base_url">Ungültiger Basis-URL: </string>
<string name="login_exception_io">E/A-Fehler: %s</string>
<string name="exception_uri_syntax">Ungültiger URI: %s</string>
<string name="exception_incapable_resource">Fehlende Server-Unterstützung: %s</string>
<string name="neither_caldav_nor_carddav">An dieser Adresse konnte kein CalDAV- oder CardDAV-Dienst gefunden werden.</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"Si no usas encriptación (HTTPS), otras personas pueden interceptar fácilmente tus datos de ingreso, contactos y eventos."</string>
<string name="user_name">Nombre de usuario:</string>
<string name="password">Contraseña:</string>
<string name="root_url">URL raiz (colecciones autodetectadas):</string>
<string name="login_http_warning">"Si no usas encriptación (HTTPS), otras personas pueden interceptar fácilmente tus datos de ingreso, contactos y eventos."</string>
<string name="login_user_name">Nombre de usuario:</string>
<string name="login_password">Contraseña:</string>
<string name="login_base_url">URL raiz (colecciones autodetectadas):</string>
<string name="next">Siguiente</string>
<string name="help">Ayuda</string>
<string name="invalid_base_url">URL base no válida: </string>
<string name="title_select_collections">DAVdroid: Selecciona las colecciones</string>
<string name="exception_io">I/O error: %s</string>
<string name="login_invalid_base_url">URL base no válida: </string>
<string name="select_collections">DAVdroid: Selecciona las colecciones</string>
<string name="login_exception_io">I/O error: %s</string>
<string name="exception_uri_syntax">URI no válida: %s</string>
<string name="exception_incapable_resource">Se han perdido capacidades: %s</string>
<string name="neither_caldav_nor_carddav">Ni CalDAV ni CardDAV están disponibles</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">Si vous n\'utilisez pas de chiffrement(HTTPS), d\'autres personnes peuvent facilement intercepter vos informations de connexion, contacts et événements.</string>
<string name="user_name">Utilisateur:</string>
<string name="password">Mot de passe:</string>
<string name="root_url">URL racine(les collections seront autodétectées):</string>
<string name="login_http_warning">Si vous n\'utilisez pas de chiffrement(HTTPS), d\'autres personnes peuvent facilement intercepter vos informations de connexion, contacts et événements.</string>
<string name="login_user_name">Utilisateur:</string>
<string name="login_password">Mot de passe:</string>
<string name="login_base_url">URL racine(les collections seront autodétectées):</string>
<string name="next">Suivant</string>
<string name="help">Aide</string>
<string name="invalid_base_url">Racine de l\'URL incorrecte:</string>
<string name="title_select_collections">DAVdroid: Sélectionnez les collections</string>
<string name="exception_io">Erreur I/O: %s</string>
<string name="login_invalid_base_url">Racine de l\'URL incorrecte:</string>
<string name="select_collections">DAVdroid: Sélectionnez les collections</string>
<string name="login_exception_io">Erreur I/O: %s</string>
<string name="exception_uri_syntax">URI incorrecte: %s</string>
<string name="exception_incapable_resource">Capacités manquantes: %s</string>
<string name="neither_caldav_nor_carddav">Aucun CalDAV ou CardDAV disponible</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"Titkosítás (HTTPS) nélkül a bejelentkezési azonosítókat, névjegyeket és eseményeket könnyen megismerhetik mások is."</string>
<string name="user_name">Felhasználónév:</string>
<string name="password">Jelszó:</string>
<string name="root_url">Fiók URL (a gyűjtemények detektálása automatikus):</string>
<string name="login_http_warning">"Titkosítás (HTTPS) nélkül a bejelentkezési azonosítókat, névjegyeket és eseményeket könnyen megismerhetik mások is."</string>
<string name="login_user_name">Felhasználónév:</string>
<string name="login_password">Jelszó:</string>
<string name="login_base_url">Fiók URL (a gyűjtemények detektálása automatikus):</string>
<string name="next">Tovább</string>
<string name="help">Súgó</string>
<string name="invalid_base_url">A fiók URL hibás: </string>
<string name="title_select_collections">DAVdroid: Gyűjtemény kiválasztása</string>
<string name="exception_io">I/O hiba: %s</string>
<string name="login_invalid_base_url">A fiók URL hibás: </string>
<string name="select_collections">DAVdroid: Gyűjtemény kiválasztása</string>
<string name="login_exception_io">I/O hiba: %s</string>
<string name="exception_uri_syntax">Érvénytelen URI: %s</string>
<string name="exception_incapable_resource">Hiányzó képesség: %s</string>
<string name="neither_caldav_nor_carddav">Nincs CalDAV-/CardDAV szolgáltatás a megadott helyen.</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"Ако не користите шифровање (ХТТПС), други људи вам лако могу пресрести детаље пријаве, контакте и догађаје."</string>
<string name="user_name">Корисничко име:</string>
<string name="password">Лозинка:</string>
<string name="root_url">Корени УРЛ (збирке ће бити аутоматски откривене):</string>
<string name="login_http_warning">"Ако не користите шифровање (ХТТПС), други људи вам лако могу пресрести детаље пријаве, контакте и догађаје."</string>
<string name="login_user_name">Корисничко име:</string>
<string name="login_password">Лозинка:</string>
<string name="login_base_url">Корени УРЛ (збирке ће бити аутоматски откривене):</string>
<string name="next">Следеће</string>
<string name="help">Помоћ</string>
<string name="invalid_base_url">Неисправан основни УРИ: </string>
<string name="title_select_collections">ДАВдроид: Изаберите збирке</string>
<string name="exception_io">И/О грешка: %s</string>
<string name="login_invalid_base_url">Неисправан основни УРИ: </string>
<string name="select_collections">ДАВдроид: Изаберите збирке</string>
<string name="login_exception_io">И/О грешка: %s</string>
<string name="exception_uri_syntax">Неисправан УРИ: %s</string>
<string name="exception_incapable_resource">Недостају могућности: %s</string>
<string name="neither_caldav_nor_carddav">Нема доступног КалДАВ/КардДАВ сервиса на овој локацији.</string>
......
......@@ -9,15 +9,15 @@
<item>https://</item>
</string-array>
<string name="http_warning">"如果不使用加密连接 (HTTPS),其他人能很容易获取到你的登录信息、通讯录和日程。"</string>
<string name="user_name">用户名:</string>
<string name="password">密码:</string>
<string name="root_url">服务器根地址(集合会自动检测):</string>
<string name="login_http_warning">"如果不使用加密连接 (HTTPS),其他人能很容易获取到你的登录信息、通讯录和日程。"</string>
<string name="login_user_name">用户名:</string>
<string name="login_password">密码:</string>
<string name="login_base_url">服务器根地址(集合会自动检测):</string>
<string name="next">继续</string>
<string name="help">帮助</string>
<string name="invalid_base_url">基准地址无效: </string>
<string name="title_select_collections">DAVdroid: 选择同步项</string>
<string name="exception_io">I/O error: %s</string>
<string name="login_invalid_base_url">基准地址无效: </string>
<string name="select_collections">DAVdroid: 选择同步项</string>
<string name="login_exception_io">I/O error: %s</string>
<string name="exception_uri_syntax">URI 无效: %s</string>
<string name="exception_incapable_resource">服务器缺少功能: %s</string>
<string name="neither_caldav_nor_carddav">此服务器地址上没有可用的 CalDAV-/CardDAV 服务。</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- common strings -->
<string name="app_name">DAVdroid</string>
<string name="menu_settings">Settings</string>
<string-array name="uri_scheme">
<item>http://</item>
<item>https://</item>
<item>mailto:</item>
</string-array>
<string name="http_warning">"If you don't use encryption (HTTPS), other people may easily intercept your login details, contacts and events."</string>
<string name="user_name">User name:</string>
<string name="password">Password:</string>
<string name="root_url">Root URL (collections will be auto-detected):</string>
<string name="next">Next</string>
<string name="help">Help</string>
<string name="invalid_base_url">Invalid base URL: </string>
<string name="title_select_collections">DAVdroid: Select collections</string>
<string name="exception_http">HTTP error: %s</string>
<string name="exception_incapable_resource">Missing capabilities: %s</string>
<string name="exception_io">I/O error: %s</string>
<string name="exception_uri_syntax">Invalid URI: %s</string>
<string name="exception_incapable_resource">Missing capabilities: %s</string>
<string name="neither_caldav_nor_carddav">No CalDAV-/CardDAV service is available at this location.</string>
<string name="add_account">Add account</string>
<string name="querying_server">Querying server. Please wait…</string>
<string name="exception_http">HTTP error: %s</string>
<string name="what_to_sync">Which collections shall be synchronized?</string>
<string name="address_books">Address books</string>
<string name="calendars">Calendars</string>
<string name="select_address_book">Select up to one address book (tap again to unselect):</string>
<string name="select_calendars">Select your calendars:</string>
<string name="auth_preemptive">Preemptive authentication (recommended, but incompatible with Digest auth)</string>
<string name="davdroid_help">DAVdroid Help</string>
<string name="show_sync_settings">Manage sync accounts</string>
<string name="show_website">DAVdroid Web site</string>
<!-- MainActivity -->
<string name="html_main_workaround"><![CDATA[
<p>Thank you for buying DAVdroid via Google Play and thus supporting the project. Unfortunately, there are two issues with Google Play:</p>
......@@ -108,6 +86,41 @@
* <a href="http://simple.sourceforge.net/">Simple XML Serialization</a><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a><br/>
* <a href="http://projectlombok.org/">Project Lombok</a><a href="http://opensource.org/licenses/mit-license.php">MIT License</a></p>
]]></string>
<!-- AddAccountActivity -->
<string name="login_type_email">Login with email address</string>
<string name="login_type_email_description">Service details will be auto-detected by domain name. Example: myaccount@icloud.com</string>
<string name="login_type_url">Login with URL and user name</string>
<string name="login_type_url_description">Service details will be auto-detected by initial URL and user name. Mostly used for self-hosted services.</string>
<string name="login_password">Password:</string>
<string name="login_email_description">Please enter your email address. Its domain name will be used to auto-detect service settings.</string>
<string name="login_email_address">Email:</string>
<string-array name="login_url_scheme">
<item>http://</item>
<item>https://</item>
</string-array>
<string name="login_http_warning">"If you don't use encryption (HTTPS), other people may easily intercept your login details, contacts and events."</string>
<string name="login_user_name">User name:</string>
<string name="login_base_url">Base URL (collections will be auto-detected):</string>
<string name="login_invalid_base_url">Invalid base URL: </string>
<string name="select_collections">DAVdroid: Select collections</string>
<string name="neither_caldav_nor_carddav">No CalDAV-/CardDAV service is available at this location.</string>
<string name="add_account">Add account</string>
<string name="querying_server">Querying server. Please wait…</string>
<string name="what_to_sync">Which collections shall be synchronized?</string>
<string name="address_books">Address books</string>
<string name="calendars">Calendars</string>
<string name="select_address_book">Select up to one address book (tap again to unselect):</string>
<string name="select_calendars">Select your calendars:</string>
<string name="auth_preemptive">Preemptive authentication (recommended, but incompatible with Digest auth)</string>
<string name="davdroid_help">DAVdroid Help</string>
<string name="show_sync_settings">Manage sync accounts</string>
<string name="show_website">DAVdroid Web site</string>
<string name="account_details">Account details</string>
<string name="account_name">Account name:</string>
......@@ -117,6 +130,7 @@
<string name="account_name_info">"Use your email address as account name because Android will use the account name as ORGANIZER field for events you create. You can't have two accounts with the same name.</string>
<string name="read_only">read-only</string>
<string name="menu_settings">Settings</string>
<string name="general_settings">General settings</string>
<string name="debug_settings">Debug settings</string>
<string name="disable_http_compression">Disable HTTP compression</string>
......@@ -126,5 +140,5 @@
<string name="network_logging_enabled">All network traffic is being logged verbosely (debug mode)</string>
<string name="network_logging_disabled">Network traffic is not being logged</string>
<string name="report_an_issue">Report an issue</string>
</resources>
......@@ -151,7 +151,7 @@ public class DavResourceFinder implements Closeable {
* @throws MalformedURLException when the user-given URI is invalid
* @throws UnknownServiceURLException when no intial service URL could be determined
*/
URL getInitialURL(ServerInfo serverInfo, String serviceName) throws URISyntaxException, MalformedURLException {
public URL getInitialContextURL(ServerInfo serverInfo, String serviceName) throws URISyntaxException, MalformedURLException {
String scheme = null,
domain = null;
int port = -1;
......@@ -220,7 +220,7 @@ public class DavResourceFinder implements Closeable {
* @return WebDavResource of current-user-principal for the given service, or null if it can't be found
*/
WebDavResource getCurrentUserPrincipal(ServerInfo serverInfo, String serviceName) throws URISyntaxException, IOException, NotAuthorizedException {
URL initialURL = getInitialURL(serverInfo, serviceName);
URL initialURL = getInitialContextURL(serverInfo, serviceName);
// determine base URL (host name and initial context path)
WebDavResource base = new WebDavResource(httpClient,
......@@ -235,12 +235,14 @@ public class DavResourceFinder implements Closeable {
if (wellKnown.getCurrentUserPrincipal() != null)
return new WebDavResource(wellKnown, wellKnown.getCurrentUserPrincipal());
} catch (NotAuthorizedException e) {
Log.d(TAG, "Well-known " + serviceName + " service detection not authorized", e);
Log.w(TAG, "Not authorized for well-known " + serviceName + " service detection", e);
throw e;
} catch (URISyntaxException e) {
Log.w(TAG, "Well-known" + serviceName + " service detection failed because of invalid URIs", e);
} catch (HttpException e) {
Log.d(TAG, "Well-known " + serviceName + " service detection failed with HTTP error", e);
} catch (DavException e) {
Log.d(TAG, "Well-known " + serviceName + " service detection failed at DAV level", e);
Log.w(TAG, "Well-known " + serviceName + " service detection failed with unexpected DAV response", e);
}
// fall back to user-given initial context path
......@@ -249,18 +251,18 @@ public class DavResourceFinder implements Closeable {
if (base.getCurrentUserPrincipal() != null)
return new WebDavResource(base, base.getCurrentUserPrincipal());
} catch (NotAuthorizedException e) {
Log.d(TAG, "Not authorized for querying principal for " + serviceName + " service", e);
Log.e(TAG, "Not authorized for querying principal", e);
throw e;
} catch (HttpException e) {
Log.d(TAG, "HTTP error when querying principal for " + serviceName + " service", e);
Log.e(TAG, "HTTP error when querying principal", e);
} catch (DavException e) {
Log.d(TAG, "DAV error when querying principal for " + serviceName + " service", e);
Log.e(TAG, "DAV error when querying principal", e);
}
Log.i(TAG, "Couldn't find current-user-principal for service " + serviceName);
return null;
}
private static boolean checkHomesetCapabilities(WebDavResource resource, String davCapability) throws URISyntaxException, IOException {
public static boolean checkHomesetCapabilities(WebDavResource resource, String davCapability) throws URISyntaxException, IOException {
// check for necessary capabilities
try {
resource.options();
......
......@@ -27,7 +27,7 @@ public class AddAccountActivity extends Activity {
if (savedInstanceState == null) { // first call
getFragmentManager().beginTransaction()
.add(R.id.fragment_container, new EnterCredentialsFragment(), "enter_credentials")
.add(R.id.fragment_container, new LoginTypeFragment(), "login_type")
.commit();
}
}
......
......@@ -19,7 +19,7 @@ import android.view.MenuItem;
import at.bitfire.davdroid.R;
public class GeneralSettingsActivity extends Activity {
final static String URL_REPORT_ISSUE = "https://github.com/rfc2822/davdroid/blob/master/CONTRIBUTING.md";
final static String URL_REPORT_ISSUE = "https://github.com/bitfireAT/davdroid/blob/master/CONTRIBUTING.md#reporting-issues";
@Override
public void onCreate(Bundle savedInstanceState) {
......
package at.bitfire.davdroid.syncadapter;
import java.net.URI;
import java.net.URISyntaxException;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import at.bitfire.davdroid.R;
public class LoginEmailFragment extends Fragment implements TextWatcher {
protected EditText editEmail, editPassword;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.login_email, container, false);
editEmail = (EditText)v.findViewById(R.id.email_address);
editEmail.addTextChangedListener(this);
editPassword = (EditText)v.findViewById(R.id.password);
editPassword.addTextChangedListener(this);
setHasOptionsMenu(true);
return v;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.only_next, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.next:
FragmentTransaction ft = getFragmentManager().beginTransaction();
Bundle args = new Bundle();
String email = editEmail.getText().toString();
args.putString(QueryServerDialogFragment.EXTRA_BASE_URI, "mailto:" + email);
args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, email);
args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, true);
DialogFragment dialog = new QueryServerDialogFragment();
dialog.setArguments(args);
dialog.show(ft, QueryServerDialogFragment.class.getName());
break;
default:
return false;
}
return true;
}
// input validation
@Override
public void onPrepareOptionsMenu(Menu menu) {
boolean passwordOk = editPassword.getText().length() > 0,
emailOk = false;
String email = editEmail.getText().toString();
try {
URI uri = new URI("mailto:" + email);
if (uri.isOpaque()) {
int pos = email.lastIndexOf("@");
emailOk = pos != -1;
}
} catch (URISyntaxException e) {
// invalid mailto: URI
}
MenuItem item = menu.findItem(R.id.next);
item.setEnabled(emailOk && passwordOk);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
getActivity().invalidateOptionsMenu();
}
@Override
public void afterTextChanged(Editable s) {
}
}
package at.bitfire.davdroid.syncadapter;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import at.bitfire.davdroid.R;
public class LoginTypeFragment extends Fragment {
protected RadioButton btnTypeEmail, btnTypeURL;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.login_type, container, false);
btnTypeEmail = (RadioButton)v.findViewById(R.id.login_type_email);
btnTypeURL = (RadioButton)v.findViewById(R.id.login_type_url);
setHasOptionsMenu(true);
return v;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.only_next, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.next:
Fragment loginFragment = btnTypeEmail.isChecked() ? new LoginEmailFragment() : new LoginURLFragment();
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, loginFragment)
.addToBackStack(null)
.commitAllowingStateLoss();
return true;
default:
return false;
}
}
}
......@@ -7,6 +7,11 @@
******************************************************************************/
package at.bitfire.davdroid.syncadapter;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.lang.StringUtils;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
......@@ -27,19 +32,20 @@ import android.widget.EditText;