Browse Source

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

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
1b98850a9c
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 3
      app/src/main/AndroidManifest.xml
  2. 23
      app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt
  3. 8
      app/src/main/res/layout/activity_login.xml
  4. 1
      app/src/main/res/values-fr/strings.xml
  5. 1
      app/src/main/res/values/strings.xml

3
app/src/main/AndroidManifest.xml

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

23
app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt

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

8
app/src/main/res/layout/activity_login.xml

@ -50,6 +50,14 @@ @@ -50,6 +50,14 @@
</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
android:id="@+id/anonymous"
android:layout_width="match_parent"

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
<resources>
<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_cleartext">Autoriser les connexions non chiffrées (HTTP)</string>
<string name="login_anonymous">Authentification anonyme</string>
<string name="login_username">Nom d\'utilisateur</string>
<string name="login_password">Mot de passe</string>

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

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
<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_hostname">Host name</string>
<string name="login_cleartext">Allow cleartext traffic (HTTP)</string>
<string name="login_anonymous">Anonymous authentication</string>
<string name="login_username">Username</string>
<string name="login_password">Password</string>

Loading…
Cancel
Save