From 534e48e2c8d16f737e6f58a45e3ddde67104d16c Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Fri, 29 May 2020 01:10:12 +0200 Subject: [PATCH] Upgrades dependencies. Enhanced login screen appearance. Fixed a seriously dumb issue where we would not transmit the token to the server. --- app/build.gradle.kts | 16 ++++++++++------ .../apognu/otter/activities/LoginActivity.kt | 4 ++-- .../apognu/otter/repositories/HttpUpstream.kt | 4 ++-- .../com/github/apognu/otter/utils/Data.kt | 1 + .../com/github/apognu/otter/utils/Util.kt | 2 +- .../main/play/release-notes/en-US/beta.txt | 2 +- .../main/play/release-notes/fr-FR/beta.txt | 2 +- app/src/main/res/layout/activity_login.xml | 19 ++++++++++++------- app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 10 files changed, 32 insertions(+), 20 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8d2659f..615c209 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -61,6 +61,10 @@ android { } buildTypes { + getByName("debug") { + isDebuggable = true + } + getByName("release") { if (props.hasProperty("signing.store")) { signingConfig = signingConfigs.getByName("release") @@ -92,17 +96,17 @@ play { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.60") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2") implementation("androidx.appcompat:appcompat:1.1.0") - implementation("androidx.core:core-ktx:1.2.0-beta01") - implementation("androidx.coordinatorlayout:coordinatorlayout:1.0.0") - implementation("androidx.preference:preference:1.1.0") - implementation("androidx.recyclerview:recyclerview:1.0.0") + implementation("androidx.core:core-ktx:1.4.0-alpha01") + implementation("androidx.coordinatorlayout:coordinatorlayout:1.1.0") + implementation("androidx.preference:preference:1.1.1") + implementation("androidx.recyclerview:recyclerview:1.1.0") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") - implementation("com.google.android.material:material:1.2.0-alpha01") + implementation("com.google.android.material:material:1.2.0-alpha06") implementation("com.android.support.constraint:constraint-layout:1.1.3") implementation("com.google.android.exoplayer:exoplayer:2.10.5") diff --git a/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt b/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt index 682d128..7a0240e 100644 --- a/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt +++ b/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt @@ -19,7 +19,7 @@ import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch -data class FwCredentials(val token: String, val non_field_errors: List) +data class FwCredentials(val token: String, val non_field_errors: List?) class LoginActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -111,7 +111,7 @@ class LoginActivity : AppCompatActivity() { hostname_field.error = null username_field.error = null - if (error != null && error.non_field_errors.isNotEmpty()) { + if (error != null && error.non_field_errors?.isNotEmpty() == true) { username_field.error = error.non_field_errors[0] } else { hostname_field.error = result.error.localizedMessage diff --git a/app/src/main/java/com/github/apognu/otter/repositories/HttpUpstream.kt b/app/src/main/java/com/github/apognu/otter/repositories/HttpUpstream.kt index 620a4e6..23010db 100644 --- a/app/src/main/java/com/github/apognu/otter/repositories/HttpUpstream.kt +++ b/app/src/main/java/com/github/apognu/otter/repositories/HttpUpstream.kt @@ -68,7 +68,7 @@ class HttpUpstream>(val behavior: Behavior, pr suspend fun get(url: String): Result { val request = Fuel.get(mustNormalizeUrl(url)).apply { if (!Settings.isAnonymous()) { - header("Authorization", "Bearer ${Settings.isAnonymous()}") + header("Authorization", "Bearer ${Settings.getAccessToken()}") } } @@ -85,7 +85,7 @@ class HttpUpstream>(val behavior: Behavior, pr return if (HTTP.refresh()) { val request = Fuel.get(mustNormalizeUrl(url)).apply { if (!Settings.isAnonymous()) { - header("Authorization", "Bearer ${Settings.isAnonymous()}") + header("Authorization", "Bearer ${Settings.getAccessToken()}") } } diff --git a/app/src/main/java/com/github/apognu/otter/utils/Data.kt b/app/src/main/java/com/github/apognu/otter/utils/Data.kt index 9210464..eef31c5 100644 --- a/app/src/main/java/com/github/apognu/otter/utils/Data.kt +++ b/app/src/main/java/com/github/apognu/otter/utils/Data.kt @@ -1,6 +1,7 @@ package com.github.apognu.otter.utils import android.content.Context +import android.util.Log import com.github.apognu.otter.activities.FwCredentials import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.FuelError diff --git a/app/src/main/java/com/github/apognu/otter/utils/Util.kt b/app/src/main/java/com/github/apognu/otter/utils/Util.kt index 1e262df..0cd411b 100644 --- a/app/src/main/java/com/github/apognu/otter/utils/Util.kt +++ b/app/src/main/java/com/github/apognu/otter/utils/Util.kt @@ -52,6 +52,6 @@ fun toDurationString(seconds: Long): String { object Settings { fun hasAccessToken() = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).contains("access_token") - fun getAccessToken() = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).getString("access_token", "") + fun getAccessToken(): String = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).getString("access_token", "") fun isAnonymous() = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).getBoolean("anonymous", false) } \ No newline at end of file diff --git a/app/src/main/play/release-notes/en-US/beta.txt b/app/src/main/play/release-notes/en-US/beta.txt index 8f75704..9860e61 100644 --- a/app/src/main/play/release-notes/en-US/beta.txt +++ b/app/src/main/play/release-notes/en-US/beta.txt @@ -1 +1 @@ -We fixed a blocking issue that would crash the app right after login. +Several performance and UX improvements, added preliminary support for landscape mode, and sort track by album position. diff --git a/app/src/main/play/release-notes/fr-FR/beta.txt b/app/src/main/play/release-notes/fr-FR/beta.txt index 9fda811..1824a24 100644 --- a/app/src/main/play/release-notes/fr-FR/beta.txt +++ b/app/src/main/play/release-notes/fr-FR/beta.txt @@ -1 +1 @@ -Nous avons corrigé un bug où l'app crashait après le login. +De multiples améliorations d'UX et de performances, ajout initial du support du mode paysage, and tri des pistes par leur position dans l'album. diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 2209e8d..ea603a4 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -29,19 +29,20 @@ + android:text="@string/login_anonymous" + android:textColor="@android:color/white" /> diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index dc8cb14..383c4bd 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -12,6 +12,7 @@ #caffffff #53bce7 + #304A5A #000000 #ffffff diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 2c29aa5..8e69b24 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -15,6 +15,7 @@ @color/colorPrimary @color/colorPrimary + #22648E #ffffff #000000