From c3c4dab9f3e16ce7154f301581bd9eb5d4b2e0ac Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 13:28:52 +0200 Subject: [PATCH 01/15] Removed useless semicolon --- metal-only-client-library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metal-only-client-library/build.gradle b/metal-only-client-library/build.gradle index 18e6b8f2..39a7cb04 100644 --- a/metal-only-client-library/build.gradle +++ b/metal-only-client-library/build.gradle @@ -55,7 +55,7 @@ android { if(project.hasProperty("metalonly.fabric.io") && new File(project.property("metalonly.fabric.io") + ".gradle").exists()) { - apply from: project.property("metalonly.fabric.io") + ".gradle"; + apply from: project.property("metalonly.fabric.io") + ".gradle" println("Applied fabric.io / crashlytics settings.") }else{ println("Project does not have fabric.io / crashlytics settings.") From 6a91ae763c86b62121ecd0f121e75b44e41bdde5 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 13:28:55 +0200 Subject: [PATCH 02/15] Switched to okhttp request factory --- .../MetalOnlyClientImplementation.kt | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt index 7eb8d018..56e8df9e 100644 --- a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt +++ b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt @@ -6,6 +6,7 @@ import org.androidannotations.annotations.EBean import org.androidannotations.annotations.SystemService import org.androidannotations.rest.spring.annotations.RestService import org.springframework.http.client.HttpComponentsClientHttpRequestFactory +import org.springframework.http.client.OkHttpClientHttpRequestFactory import org.springframework.http.client.SimpleClientHttpRequestFactory import org.springframework.web.client.RestClientException @@ -26,24 +27,13 @@ open class MetalOnlyClientImplementation : MetalOnlyClient { @AfterInject internal fun adaptApiSettings() { - changeTimeout() - disableKeepAlive() - } - - private fun changeTimeout() { - val requestFactory = api!!.restTemplate.requestFactory + val requestFactory = OkHttpClientHttpRequestFactory() + requestFactory.setConnectTimeout(TIME_OUT) + requestFactory.setReadTimeout(TIME_OUT) - if (requestFactory is SimpleClientHttpRequestFactory) { - val factory = requestFactory + api!!.restTemplate.requestFactory = requestFactory - factory.setConnectTimeout(TIME_OUT) - factory.setReadTimeout(TIME_OUT) - } else if (requestFactory is HttpComponentsClientHttpRequestFactory) { - val factory = requestFactory - - factory.setReadTimeout(TIME_OUT) - factory.setConnectTimeout(TIME_OUT) - } + disableKeepAlive() } private fun disableKeepAlive() { From c5627d68f3d9859421f9c57ff405906dc787b981 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 14:00:20 +0200 Subject: [PATCH 03/15] Fixed linting errors --- .../android/metalonly/player/utils/FeedbackMailer.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/utils/FeedbackMailer.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/utils/FeedbackMailer.kt index 24ae2974..0b858f7d 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/utils/FeedbackMailer.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/utils/FeedbackMailer.kt @@ -13,7 +13,6 @@ import org.androidannotations.annotations.RootContext import org.androidannotations.annotations.res.StringRes import java.io.File - @EBean open class FeedbackMailer { @RootContext @@ -39,15 +38,12 @@ open class FeedbackMailer { "Android: ${Build.VERSION.RELEASE}\n" + "Model: ${Build.MODEL}" - - - val emailIntent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:")) emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mailaddress_codingspezis)) emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject) emailIntent.putExtra(Intent.EXTRA_TEXT, body) HyperLog.e("FeedbackMailer", "Sending mail") - if(logfile != null) { + if (logfile != null) { HyperLog.e("FeedbackMailer", "Sending mail with attachement") emailIntent.putExtra(Intent.EXTRA_STREAM, logFileUri) } From 233d6b1e088fa418a26f9b6f9c0cd806a7eefd9a Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 14:26:25 +0200 Subject: [PATCH 04/15] Inlined okhttp version --- build.gradle | 1 - metal-only-client-library/build.gradle | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 615d7cbd..afac76ad 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ buildscript { junit_version = "4.12" kotlin_version = "1.1.3-2" ktlint_version = "0.9.0" - okhttp_version = "3.7.0" slf4jAndroid_version = "1.7.25" spring_android_rest_template_version = "2.0.0.M3" support_v4_version = "25.3.0" diff --git a/metal-only-client-library/build.gradle b/metal-only-client-library/build.gradle index 39a7cb04..ba50ba00 100644 --- a/metal-only-client-library/build.gradle +++ b/metal-only-client-library/build.gradle @@ -76,7 +76,8 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile 'com.hypertrack:hyperlog:0.0.9' - compile "com.squareup.okhttp3:okhttp:$okhttp_version" + compile "com.squareup.okhttp3:okhttp:3.10.0" + compile "org.springframework.android:spring-android-rest-template:$spring_android_rest_template_version" compile "org.androidannotations:androidannotations-api:$androidannotations_version" compile "org.androidannotations:rest-spring-api:$androidannotations_version" From 0858e3c3cb8e3c9433a55b55fe0bd2c5857375f0 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 14:26:52 +0200 Subject: [PATCH 05/15] Solved: null safe call chain --- .../com/github/ironjan/metalonly/client_library/WishSender.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt index 60ea9b35..f25e4c2b 100644 --- a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt +++ b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt @@ -62,8 +62,8 @@ class WishSender { try { val response = client.newCall(request).execute() - val responseBody = response.body().string() - if (response.code() == 200 && responseBody.contains(BuildConfig.WISH_SUCCESS)) { + val isSuccessResponseBody = response.body()?.string()?.contains(BuildConfig.WISH_SUCCESS)?: false + if (response.code() == 200 && isSuccessResponseBody) { callback.onSuccess() } else { callback.onFail() From ad413fbe7c28867a31b87da249b33dc23e7ee50e Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 14:37:48 +0200 Subject: [PATCH 06/15] Updated dependencies --- app/build.gradle | 4 ++-- build.gradle | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 354173e5..9c7f2c39 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -108,8 +108,8 @@ dependencies { compile "com.android.support:appcompat-v7:$appcompat_v7_version" compile "com.android.support:support-v4:$support_v4_version" - compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { - transitive = true; + compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') { + transitive = true } compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile 'com.hypertrack:hyperlog:0.0.9' diff --git a/build.gradle b/build.gradle index afac76ad..acc91a74 100644 --- a/build.gradle +++ b/build.gradle @@ -12,12 +12,12 @@ buildscript { // Dependency versions appcompat_v7_version = "25.3.0" - androidannotations_version = "4.3.1" + androidannotations_version = "4.4.0" espresso_version = "2.2.2" - jackson_version = "2.9.1" + jackson_version = "2.9.5" junit_version = "4.12" - kotlin_version = "1.1.3-2" - ktlint_version = "0.9.0" + kotlin_version = "1.2.41" + ktlint_version = "0.22.0" slf4jAndroid_version = "1.7.25" spring_android_rest_template_version = "2.0.0.M3" support_v4_version = "25.3.0" @@ -31,6 +31,7 @@ buildscript { repositories { jcenter() maven { url 'https://maven.google.com' } + maven { url 'https://repo.spring.io/libs-milestone' } maven { url 'http://repo1.maven.org/maven2' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://maven.fabric.io/public' } @@ -39,7 +40,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta7' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' // We recommend changing it to the latest version from our changelog: // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin From 1c5b672913a3263c025cef7be37ddca8d9ce9b91 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 15:00:41 +0200 Subject: [PATCH 07/15] Some library downgrades --- build.gradle | 9 +++++---- metal-only-client-library/build.gradle | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index acc91a74..d7c03ab0 100644 --- a/build.gradle +++ b/build.gradle @@ -11,16 +11,17 @@ buildscript { jdk_compatibility = "1.8" // Dependency versions - appcompat_v7_version = "25.3.0" + appcompat_v7_version = "27.1.1" + support_v4_version = "27.1.1" + androidannotations_version = "4.4.0" - espresso_version = "2.2.2" + espresso_version = "3.0.2" jackson_version = "2.9.5" - junit_version = "4.12" + junit_version = "4.12" kotlin_version = "1.2.41" ktlint_version = "0.22.0" slf4jAndroid_version = "1.7.25" spring_android_rest_template_version = "2.0.0.M3" - support_v4_version = "25.3.0" // Travis Speedup // allows for -Dpre-dex=false to be set diff --git a/metal-only-client-library/build.gradle b/metal-only-client-library/build.gradle index ba50ba00..839c8497 100644 --- a/metal-only-client-library/build.gradle +++ b/metal-only-client-library/build.gradle @@ -76,7 +76,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile 'com.hypertrack:hyperlog:0.0.9' - compile "com.squareup.okhttp3:okhttp:3.10.0" + compile "com.squareup.okhttp:okhttp:2.7.5" // Version 3.x is incompatible with spring-android-rest-template compile "org.springframework.android:spring-android-rest-template:$spring_android_rest_template_version" compile "org.androidannotations:androidannotations-api:$androidannotations_version" From 9d85a7e4833e7bdea68cd161b94ca7d2326384f9 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 15:01:04 +0200 Subject: [PATCH 08/15] Checking for null and doing explicit !! for casting --- .../player/favorites/FavoritesFragment.kt | 14 ++++++++--- .../metalonly/player/plan/PlanFragment.kt | 23 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt index c4ac4594..4605db04 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt @@ -48,8 +48,12 @@ open class FavoritesFragment : Fragment() { @AfterViews internal fun bindContent() { - favoritesSaver = SongSaver(activity, JSON_FILE_FAV, -1) - adapter = SongAdapterFavorites(activity, ArrayList(0)) + if (activity == null) { + return + } + + favoritesSaver = SongSaver(activity!!, JSON_FILE_FAV, -1) + adapter = SongAdapterFavorites(activity!!, ArrayList(0)) list!!.adapter = adapter list!!.emptyView = empty displayFavorites() @@ -179,7 +183,11 @@ open class FavoritesFragment : Fragment() { @OptionsItem(R.id.mnu_deleteall) internal fun deleteAllClicked() { - askSureDelete(activity, OnClickListener { dialog, action -> + if (activity == null) { + return + } + + askSureDelete(activity!!, OnClickListener { dialog, action -> favoritesSaver!!.clear() displayFavorites() }, null) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanFragment.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanFragment.kt index f9b4916b..d81fda1c 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanFragment.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanFragment.kt @@ -73,9 +73,12 @@ open class PlanFragment : Fragment() { @Background internal open fun loadPlan() { try { - if (context == null) return + if (context == null) { + return + } + HyperLog.d(TAG, "loadPlan()") - apiResponseReceived(MetalOnlyClient.getClient(context).getPlan()) + apiResponseReceived(MetalOnlyClient.getClient(context!!).getPlan()) } catch (e: NoInternetException) { HyperLog.d(TAG, "loadPlan() - no internet") updateEmptyViewOnFailure(no_internet) @@ -107,7 +110,13 @@ open class PlanFragment : Fragment() { val shows = plan.entries val listItems = planEntryToItemConverter!!.convertToPlan(shows) - val adapter = PlanAdapter(activity, listItems) + + if (activity == null) { + HyperLog.e("PlanFragment", "Activity was null") + return + } + + val adapter = PlanAdapter(activity!!, listItems) list!!.adapter = adapter list!!.setSelection(planEntryToItemConverter!!.todayStartIndex()) @@ -127,8 +136,14 @@ open class PlanFragment : Fragment() { internal fun entryClicked(item: Any) { if (item is PlanRealEntryItem) { val entryItem = item + + if (activity == null) { + HyperLog.e("PlanFragment", "Activity was null in entryClicked") + return + } + val builder = AlertDialog.Builder(activity) - builder.setItems(R.array.plan_options_array, PlanEntryClickListener(entryItem.showInformation!!, activity)) + builder.setItems(R.array.plan_options_array, PlanEntryClickListener(entryItem.showInformation!!, activity!!)) builder.show() } From 64a7f2b716b06541ea8c3f925ab45c798e84e256 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 15:01:12 +0200 Subject: [PATCH 09/15] Downgrade of okhttp --- .../ironjan/metalonly/client_library/WishSender.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt index f25e4c2b..de10bd51 100644 --- a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt +++ b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt @@ -1,10 +1,10 @@ package com.github.ironjan.metalonly.client_library import android.text.TextUtils -import okhttp3.MultipartBody -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.RequestBody +import com.squareup.okhttp.MultipartBuilder +import com.squareup.okhttp.OkHttpClient +import com.squareup.okhttp.Request +import com.squareup.okhttp.RequestBody import java.io.IOException /** @@ -35,8 +35,7 @@ class WishSender { * TODO Fix this */ fun send() { - var requestBodyBuilder = MultipartBody.Builder() - .setType(MultipartBody.FORM) + var requestBodyBuilder = MultipartBuilder().type(MultipartBuilder.FORM) if (!TextUtils.isEmpty(nick)) { requestBodyBuilder = requestBodyBuilder.addFormDataPart(KEY_NICK, nick) From 19024e340b9a1b3fdacca52362f70d84c001d823 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 17:07:01 +0200 Subject: [PATCH 10/15] Fixed test --- .../metalonly/player/StreamActivity_Navigation_Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/androidTest/java/com/codingspezis/android/metalonly/player/StreamActivity_Navigation_Test.java b/app/src/androidTest/java/com/codingspezis/android/metalonly/player/StreamActivity_Navigation_Test.java index 778e4edf..a72157d2 100644 --- a/app/src/androidTest/java/com/codingspezis/android/metalonly/player/StreamActivity_Navigation_Test.java +++ b/app/src/androidTest/java/com/codingspezis/android/metalonly/player/StreamActivity_Navigation_Test.java @@ -64,7 +64,7 @@ public void wishActivity_Navigation_Test(){ @Test public void favoritesActivity_Navigation_Test(){ ViewInteraction actionMenuItemView = onView( - allOf(withId(R.id.mnu_favorites), withText(R.string.menu_favorites), withContentDescription(R.string.menu_favorites), isDisplayed())); + allOf(withText(R.string.menu_favorites), isDisplayed())); actionMenuItemView.perform(click()); intended(hasComponent(new ComponentName(getTargetContext(), FavoritesActivity_.class))); From 21e07152dda52d4421d5fe11902bbe8450adacfc Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 17:08:56 +0200 Subject: [PATCH 11/15] Applied ktlintFormat --- .../player/crashlytics/CrashlyticsPrefs.kt | 2 +- .../donation/CurrencyFormatInputFilter.kt | 10 ++++++++-- .../player/donation/PayPalDonationFragment.kt | 1 - .../player/favorites/FavoritesFragment.kt | 1 - .../metalonly/player/favorites/SongSaver.kt | 10 +++++----- .../player/fragments/AboutFragment.kt | 1 - .../metalonly/player/plan/PlanAdapter.kt | 1 - .../metalonly/player/plan/PlanFragment.kt | 2 -- .../android/metalonly/player/plan/PlanItem.kt | 1 - .../metalonly/player/plan/PlanRealEntryItem.kt | 1 - .../metalonly/player/plan/PlanSectionItem.kt | 1 - .../stream/track_info/ShowInfoFetcher.kt | 1 - .../player/utils/CopyStreamImplementation.kt | 1 - .../metalonly/player/utils/FeedbackMailer.kt | 1 - .../metalonly/player/utils/FileCache.kt | 2 -- .../metalonly/player/utils/ImageLoader.kt | 4 ++-- .../android/metalonly/player/views/Marquee.kt | 7 +++++-- .../metalonly/player/core/HistoricTrack.kt | 18 +++++++++--------- .../metalonly/player/core/SimpleTrack.kt | 6 ++++-- .../player/stream/metadata/Metadata.kt | 1 - .../player/stream/metadata/MetadataFactory.kt | 2 -- 21 files changed, 34 insertions(+), 40 deletions(-) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/crashlytics/CrashlyticsPrefs.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/crashlytics/CrashlyticsPrefs.kt index 95f1d562..d34ec1a4 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/crashlytics/CrashlyticsPrefs.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/crashlytics/CrashlyticsPrefs.kt @@ -6,7 +6,7 @@ import org.androidannotations.annotations.sharedpreferences.SharedPref /** * User settings for sending crash reports. Use with the `@Pref CrashlyticsPrefs_`. */ -@SharedPref(value=SharedPref.Scope.UNIQUE) +@SharedPref(value = SharedPref.Scope.UNIQUE) interface CrashlyticsPrefs { /** * @return `true`, if the user disabled sending crash reports. `false` on default. diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/CurrencyFormatInputFilter.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/CurrencyFormatInputFilter.kt index 163ea38c..d197cf02 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/CurrencyFormatInputFilter.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/CurrencyFormatInputFilter.kt @@ -13,8 +13,14 @@ class CurrencyFormatInputFilter : InputFilter { internal var mPattern = Pattern.compile("(0|[1-9]+[0-9]*)?(\\.[0-9]{0,2})?") - override fun filter(source: CharSequence, start: Int, end: Int, - dest: Spanned, dstart: Int, dend: Int): CharSequence? { + override fun filter( + source: CharSequence, + start: Int, + end: Int, + dest: Spanned, + dstart: Int, + dend: Int + ): CharSequence? { val result = dest.subSequence(0, dstart).toString() + source.toString() dest.subSequence(dend, dest.length) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/PayPalDonationFragment.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/PayPalDonationFragment.kt index d46f8844..1b88fbf9 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/PayPalDonationFragment.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/donation/PayPalDonationFragment.kt @@ -121,5 +121,4 @@ open class PayPalDonationFragment : Fragment() { super.onPause() } - } diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt index 4605db04..6627ff45 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/FavoritesFragment.kt @@ -229,5 +229,4 @@ open class FavoritesFragment : Fragment() { alert.show() } } - } diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/SongSaver.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/SongSaver.kt index 63f40ac1..8433a84b 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/SongSaver.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/favorites/SongSaver.kt @@ -22,8 +22,11 @@ import java.util.LinkedList * @param limit maximum of songs (FIFO) - if value <= 0 songs are unlimited */ -class SongSaver(private val context: Context, - private val fileName: String, limit: Int) { +class SongSaver( + private val context: Context, + private val fileName: String, + limit: Int +) { private var limit: Int = 0 private val trackList: LinkedList // main data private var changes: Boolean = false // is there share to save? @@ -76,7 +79,6 @@ class SongSaver(private val context: Context, } catch (e: JSONException) { e.printStackTrace() } - } /** @@ -108,7 +110,6 @@ class SongSaver(private val context: Context, } catch (e: IOException) { e.printStackTrace() } - } } @@ -239,5 +240,4 @@ class SongSaver(private val context: Context, val JSON_STRING_THUMB = "thumb" val JSON_LONG_DATE = "date" } - } \ No newline at end of file diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/fragments/AboutFragment.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/fragments/AboutFragment.kt index 152bc2c7..02672281 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/fragments/AboutFragment.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/fragments/AboutFragment.kt @@ -70,5 +70,4 @@ open class AboutFragment : Fragment() { prefs!!.edit().isCrashlyticsDisabled.put(isCrashlyticsDisabled).apply() super.onPause() } - } diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanAdapter.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanAdapter.kt index 1779034c..951c4db1 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanAdapter.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/plan/PlanAdapter.kt @@ -40,5 +40,4 @@ class PlanAdapter(private val context: Context, private val data: ArrayList = LinkedBlockingQueue() + private val downloadQueue: BlockingQueue = LinkedBlockingQueue() private val imageViews = Collections.synchronizedMap(WeakHashMap()) @@ -138,7 +138,7 @@ class ImageLoader private constructor(context: Context) { /** * Gets a singleton instance of the ImageLoader for usage. */ - fun instance(context: Context) : ImageLoader { + fun instance(context: Context): ImageLoader { synchronized(lock) { if (INSTANCE == null) { INSTANCE = ImageLoader(context.applicationContext) diff --git a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/views/Marquee.kt b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/views/Marquee.kt index 0e586d13..dcc4de69 100644 --- a/app/src/main/kotlin/com/codingspezis/android/metalonly/player/views/Marquee.kt +++ b/app/src/main/kotlin/com/codingspezis/android/metalonly/player/views/Marquee.kt @@ -22,8 +22,11 @@ class Marquee(context: Context, attrs: AttributeSet) : AppCompatTextView(context gravity = Gravity.CENTER_HORIZONTAL } - override fun onFocusChanged(focused: Boolean, direction: Int, - previouslyFocusedRect: Rect?) { + override fun onFocusChanged( + focused: Boolean, + direction: Int, + previouslyFocusedRect: Rect? + ) { if (focused) { super.onFocusChanged(focused, direction, previouslyFocusedRect) } diff --git a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/HistoricTrack.kt b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/HistoricTrack.kt index e6684f24..83735946 100644 --- a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/HistoricTrack.kt +++ b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/HistoricTrack.kt @@ -2,10 +2,12 @@ package com.codingspezis.android.metalonly.player.core import java.util.Comparator -data class HistoricTrack(override val artist: String, - override val title: String, - val thumbRaw: String, - override val playedAtAsLong: Long) +data class HistoricTrack( + override val artist: String, + override val title: String, + val thumbRaw: String, + override val playedAtAsLong: Long +) : Track, HistoricTrackExtension, Comparable { override val moderator: String = thumbRaw.replace(" OnAir", "") @@ -23,9 +25,9 @@ data class HistoricTrack(override val artist: String, fun limitedEquals(other: HistoricTrack?): Boolean { if (other == null) return false else - return artist == other.artist - && moderator == other.moderator - && title == other.title + return artist == other.artist && + moderator == other.moderator && + title == other.title } override fun compareTo(other: HistoricTrack): Int { @@ -36,7 +38,5 @@ data class HistoricTrack(override val artist: String, override fun compare(o1: HistoricTrack, o2: HistoricTrack): Int { return -o1.compareTo(o2) } - } - } diff --git a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/SimpleTrack.kt b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/SimpleTrack.kt index 7d1c09d9..a19460c1 100644 --- a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/SimpleTrack.kt +++ b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/core/SimpleTrack.kt @@ -1,5 +1,7 @@ package com.codingspezis.android.metalonly.player.core -data class SimpleTrack(override val artist: String, - override val title: String) +data class SimpleTrack( + override val artist: String, + override val title: String +) : Track \ No newline at end of file diff --git a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/Metadata.kt b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/Metadata.kt index 93a6cb32..7d070d78 100644 --- a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/Metadata.kt +++ b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/Metadata.kt @@ -14,5 +14,4 @@ data class Metadata internal constructor(val moderator: String, val genre: Strin return HistoricTrack(interpret, title, moderator, date) } - } \ No newline at end of file diff --git a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/MetadataFactory.kt b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/MetadataFactory.kt index 7064dac8..70434408 100644 --- a/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/MetadataFactory.kt +++ b/core/src/main/kotlin/com/codingspezis/android/metalonly/player/stream/metadata/MetadataFactory.kt @@ -36,11 +36,9 @@ object MetadataFactory { val interpret: String = data.substring(0, data.indexOf(" - ")).trim { it <= ' ' } val title: String = data.substring(data.indexOf(" - ") + 2).trim { it <= ' ' } return createMetadata(moderator, genre, interpret, title) - } catch (e: Exception) { return DEFAULT_METADATA } - } /** From f5c619ddf4b93d3f279a55432194cc64603c328d Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sat, 28 Apr 2018 17:20:14 +0200 Subject: [PATCH 12/15] Prepared v0.6.19-5 --- app/CHANGELOG-de.md | 3 +++ app/CHANGELOG.md | 3 +++ app/build.gradle | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/CHANGELOG-de.md b/app/CHANGELOG-de.md index 56ae44f7..9b5b85c6 100644 --- a/app/CHANGELOG-de.md +++ b/app/CHANGELOG-de.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.6.19-5] +Using OkHttp to do the API requests. Potential fix for [#165](https://github.com/ironjan/metal-only/issues/165). + ## [0.6.19-1] Added Hyperlog (Debug build). diff --git a/app/CHANGELOG.md b/app/CHANGELOG.md index 7de661b8..0ce2096e 100644 --- a/app/CHANGELOG.md +++ b/app/CHANGELOG.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.6.19-5] +Using OkHttp to do the API requests. Potential fix for [#165](https://github.com/ironjan/metal-only/issues/165). + ## [0.6.19-1] Added Hyperlog (Debug build). diff --git a/app/build.gradle b/app/build.gradle index 9c7f2c39..c3163cfc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ def versionMajor = 0 // incompatible API changes def versionMinor = 6 // added functionality in a backwards-compatible manner def versionPatch = 19 // backwards-compatible bug fixes -def versionBuild = 1 // bump for dogfood builds, public betas, etc. +def versionBuild = 5 // bump for dogfood builds, public betas, etc. apply plugin: "com.android.application" apply plugin: "kotlin-android" @@ -64,7 +64,7 @@ android { if (project.hasProperty("metalonly.signing") && new File(project.property("metalonly.signing") + ".gradle").exists()) { - apply from: project.property("metalonly.signing") + ".gradle"; + apply from: project.property("metalonly.signing") + ".gradle" println("Applied production signing config") } else{ From 03a025b67e38d6d555b0b4f5659a5b767314d4f2 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sun, 29 Apr 2018 15:50:45 +0200 Subject: [PATCH 13/15] Added more logging to client library --- .../MetalOnlyClientImplementation.kt | 8 +++++++ .../metalonly/client_library/WishSender.kt | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt index 56e8df9e..8e6447b4 100644 --- a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt +++ b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/MetalOnlyClientImplementation.kt @@ -1,6 +1,7 @@ package com.github.ironjan.metalonly.client_library import android.net.ConnectivityManager +import com.hypertrack.hyperlog.HyperLog import org.androidannotations.annotations.AfterInject import org.androidannotations.annotations.EBean import org.androidannotations.annotations.SystemService @@ -25,8 +26,11 @@ open class MetalOnlyClientImplementation : MetalOnlyClient { @SystemService internal var cm: ConnectivityManager? = null + private val TAG: String = "MetalOnlyClientImplementation" + @AfterInject internal fun adaptApiSettings() { + HyperLog.d(TAG, "adaptApiSettings() - started") val requestFactory = OkHttpClientHttpRequestFactory() requestFactory.setConnectTimeout(TIME_OUT) requestFactory.setReadTimeout(TIME_OUT) @@ -34,6 +38,8 @@ open class MetalOnlyClientImplementation : MetalOnlyClient { api!!.restTemplate.requestFactory = requestFactory disableKeepAlive() + + HyperLog.d(TAG, "adaptApiSettings() - completed") } private fun disableKeepAlive() { @@ -57,7 +63,9 @@ open class MetalOnlyClientImplementation : MetalOnlyClient { } private fun checkConnectivity() { + HyperLog.d(TAG, "checkConnectivity() - started") if (hasNoInternetConnection()) { + HyperLog.d(TAG, "checkConnectivity() - no connection, throwing NoInternetException") throw NoInternetException() } } diff --git a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt index de10bd51..10022370 100644 --- a/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt +++ b/metal-only-client-library/src/main/kotlin/com/github/ironjan/metalonly/client_library/WishSender.kt @@ -1,6 +1,7 @@ package com.github.ironjan.metalonly.client_library import android.text.TextUtils +import com.hypertrack.hyperlog.HyperLog import com.squareup.okhttp.MultipartBuilder import com.squareup.okhttp.OkHttpClient import com.squareup.okhttp.Request @@ -18,6 +19,8 @@ class WishSender { private val callback: Callback + private val TAG: String = "WishSender" + constructor(callback: Callback, nick: String, greet: String, artist: String? = null, title: String? = null) { this.nick = nick this.artist = artist @@ -28,6 +31,7 @@ class WishSender { val client = OkHttpClient() + /** * Sends the wish request. Note that this method does not yet handle all error cases: * - Bitte Wunsch/Gruss und einen Nick angeben @@ -35,6 +39,7 @@ class WishSender { * TODO Fix this */ fun send() { + HyperLog.d(TAG, "send() - Starting to build request.") var requestBodyBuilder = MultipartBuilder().type(MultipartBuilder.FORM) if (!TextUtils.isEmpty(nick)) { @@ -58,16 +63,23 @@ class WishSender { .method("POST", RequestBody.create(null, ByteArray(0))) .post(requestBody) .build() + + + HyperLog.d(TAG, "send() - Built request. Sending...") try { val response = client.newCall(request).execute() - val isSuccessResponseBody = response.body()?.string()?.contains(BuildConfig.WISH_SUCCESS)?: false + HyperLog.d(TAG, "send() - Received response.") + val isSuccessResponseBody = response.body()?.string()?.contains(BuildConfig.WISH_SUCCESS) ?: false if (response.code() == 200 && isSuccessResponseBody) { - callback.onSuccess() - } else { - callback.onFail() - } + HyperLog.d(TAG, "send() - Response was 'success'. Doing onSuccess-callback.") + callback.onSuccess() + } else { + HyperLog.d(TAG, "send() - Response was 'failure'. Doing onFail-callback.") + callback.onFail() + } } catch (e: IOException) { + HyperLog.d(TAG, "send() - Got an IOException. Doing onException-callback.") callback.onException(e) } } From f5aedc4fc9367b99b0d723fd1cdcde9bbd5f15f1 Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sun, 29 Apr 2018 15:55:33 +0200 Subject: [PATCH 14/15] More logging in WishFragment --- .../metalonly/player/wish/WishFragment.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/codingspezis/android/metalonly/player/wish/WishFragment.java b/app/src/main/java/com/codingspezis/android/metalonly/player/wish/WishFragment.java index 852945ed..1ad5eeee 100644 --- a/app/src/main/java/com/codingspezis/android/metalonly/player/wish/WishFragment.java +++ b/app/src/main/java/com/codingspezis/android/metalonly/player/wish/WishFragment.java @@ -23,6 +23,7 @@ import com.codingspezis.android.metalonly.player.wish.WishPrefs_.WishPrefsEditor_; import com.github.ironjan.metalonly.client_library.MetalOnlyClient; import com.github.ironjan.metalonly.client_library.NoInternetException; +import com.github.ironjan.metalonly.client_library.Stats; import com.github.ironjan.metalonly.client_library.WishSender; import com.hypertrack.hyperlog.HyperLog; @@ -98,20 +99,24 @@ public class WishFragment extends Fragment implements WishSender.Callback { @AfterViews @Background void loadAllowedActions() { + HyperLog.d(TAG, "loadAllowedActions() - started"); FragmentActivity activity = getActivity(); - if (activity == null) return; + if (activity == null) { + HyperLog.d(TAG, "loadAllowedActions() - activity was null, early return"); + return; + } if (HTTPGrabber.isOnline(activity)) { showLoading(true); try { - Context context = getContext(); - if (context == null) { - return; - } - updateStats(MetalOnlyClient.Companion.getClient(context).getStats()); + HyperLog.d(TAG, "loadAllowedActions() - doing actual request"); + Stats stats = MetalOnlyClient.Companion.getClient(activity).getStats(); + HyperLog.d(TAG, "loadAllowedActions() - got a response, updating stats"); + updateStats(stats); } catch (NoInternetException | RestClientException e) { + HyperLog.e(TAG, "loadAllowedActions() - loading failed:", e); loadingAllowedActionsFailed(); } } else { From c3357d0aa09f5a8b96a9c01bad1c70206b56bb4d Mon Sep 17 00:00:00 2001 From: Jan Lippert Date: Sun, 29 Apr 2018 15:58:44 +0200 Subject: [PATCH 15/15] Prepared v0.6.19-6 --- app/CHANGELOG-de.md | 3 +++ app/CHANGELOG.md | 3 +++ app/build.gradle | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/CHANGELOG-de.md b/app/CHANGELOG-de.md index 9b5b85c6..348c4560 100644 --- a/app/CHANGELOG-de.md +++ b/app/CHANGELOG-de.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.6.19-6] +Added more logging in wish functionality. + ## [0.6.19-5] Using OkHttp to do the API requests. Potential fix for [#165](https://github.com/ironjan/metal-only/issues/165). diff --git a/app/CHANGELOG.md b/app/CHANGELOG.md index 0ce2096e..67948efd 100644 --- a/app/CHANGELOG.md +++ b/app/CHANGELOG.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.6.19-6] +Added more logging in wish functionality. + ## [0.6.19-5] Using OkHttp to do the API requests. Potential fix for [#165](https://github.com/ironjan/metal-only/issues/165). diff --git a/app/build.gradle b/app/build.gradle index c3163cfc..c9b18b70 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ def versionMajor = 0 // incompatible API changes def versionMinor = 6 // added functionality in a backwards-compatible manner def versionPatch = 19 // backwards-compatible bug fixes -def versionBuild = 5 // bump for dogfood builds, public betas, etc. +def versionBuild = 6 // bump for dogfood builds, public betas, etc. apply plugin: "com.android.application" apply plugin: "kotlin-android"