Add a checkbox to allow cleartext connections to a Funkwhale instance. Should close #6.

This commit is contained in:
Antoine POPINEAU 2020-06-20 16:52:41 +02:00
parent 66c7915307
commit 1b98850a9c
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
5 changed files with 26 additions and 10 deletions

View File

@ -14,7 +14,8 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<!-- <meta-data <!-- <meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"

View File

@ -50,11 +50,23 @@ class LoginActivity : AppCompatActivity() {
if (hostname.isEmpty()) throw Exception(getString(R.string.login_error_hostname)) if (hostname.isEmpty()) throw Exception(getString(R.string.login_error_hostname))
Uri.parse(hostname).apply { Uri.parse(hostname).apply {
if (scheme == "http") { if (!cleartext.isChecked && scheme == "http") {
throw Exception(getString(R.string.login_error_hostname_https)) throw Exception(getString(R.string.login_error_hostname_https))
} }
if (scheme == null) hostname = "https://$hostname" if (scheme == null) {
hostname = when (cleartext.isChecked) {
true -> "http://$hostname"
false -> "https://$hostname"
}
}
}
hostname_field.error = ""
when (anonymous.isChecked) {
false -> authedLogin(hostname, username, password)
true -> anonymousLogin(hostname)
} }
} catch (e: Exception) { } catch (e: Exception) {
val message = val message =
@ -63,13 +75,6 @@ class LoginActivity : AppCompatActivity() {
hostname_field.error = message hostname_field.error = message
} }
hostname_field.error = ""
when (anonymous.isChecked) {
false -> authedLogin(hostname, username, password)
true -> anonymousLogin(hostname)
}
} }
} }

View File

@ -50,6 +50,14 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/cleartext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:buttonTint="@android:color/white"
android:text="@string/login_cleartext"
android:textColor="@android:color/white" />
<com.google.android.material.checkbox.MaterialCheckBox <com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/anonymous" android:id="@+id/anonymous"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -2,6 +2,7 @@
<resources> <resources>
<string name="login_welcome">Veuillez saisir les détails de votre instance Funkwhale pour accéder à son contenu</string> <string name="login_welcome">Veuillez saisir les détails de votre instance Funkwhale pour accéder à son contenu</string>
<string name="login_hostname">Nom d\'hôte</string> <string name="login_hostname">Nom d\'hôte</string>
<string name="login_cleartext">Autoriser les connexions non chiffrées (HTTP)</string>
<string name="login_anonymous">Authentification anonyme</string> <string name="login_anonymous">Authentification anonyme</string>
<string name="login_username">Nom d\'utilisateur</string> <string name="login_username">Nom d\'utilisateur</string>
<string name="login_password">Mot de passe</string> <string name="login_password">Mot de passe</string>

View File

@ -3,6 +3,7 @@
<string name="app_name" translatable="false">Otter</string> <string name="app_name" translatable="false">Otter</string>
<string name="login_welcome">Please enter the details of your Funkwhale instance to access its content</string> <string name="login_welcome">Please enter the details of your Funkwhale instance to access its content</string>
<string name="login_hostname">Host name</string> <string name="login_hostname">Host name</string>
<string name="login_cleartext">Allow cleartext traffic (HTTP)</string>
<string name="login_anonymous">Anonymous authentication</string> <string name="login_anonymous">Anonymous authentication</string>
<string name="login_username">Username</string> <string name="login_username">Username</string>
<string name="login_password">Password</string> <string name="login_password">Password</string>