From e933053e743184b2ee9892a3dfa792467b375cb7 Mon Sep 17 00:00:00 2001 From: Jean-bernard Damiano Date: Tue, 24 Apr 2018 13:24:09 +0200 Subject: [PATCH] fix issue with api 21 --- .../comcrashlyticssdkandroid_crashlytics.iml | 2 +- mainActivity/build.gradle | 2 +- mainActivity/src/main/AndroidManifest.xml | 2 +- .../sierrawireless/avphone/AvPhoneFragment.kt | 15 +++++++++++++++ .../com/sierrawireless/avphone/HomeFragment.kt | 16 +++++++++++++++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/comcrashlyticssdkandroid_crashlytics/comcrashlyticssdkandroid_crashlytics.iml b/comcrashlyticssdkandroid_crashlytics/comcrashlyticssdkandroid_crashlytics.iml index 192d03a..e707c79 100644 --- a/comcrashlyticssdkandroid_crashlytics/comcrashlyticssdkandroid_crashlytics.iml +++ b/comcrashlyticssdkandroid_crashlytics/comcrashlyticssdkandroid_crashlytics.iml @@ -27,6 +27,6 @@ - + \ No newline at end of file diff --git a/mainActivity/build.gradle b/mainActivity/build.gradle index 0b5d68a..01e5020 100644 --- a/mainActivity/build.gradle +++ b/mainActivity/build.gradle @@ -29,7 +29,7 @@ android { applicationId 'com.sierrawireless.avphone' minSdkVersion 22 targetSdkVersion 27 - versionName '2.1.4' + versionName '2.1.5' } buildTypes { diff --git a/mainActivity/src/main/AndroidManifest.xml b/mainActivity/src/main/AndroidManifest.xml index 697d120..8024f1f 100644 --- a/mainActivity/src/main/AndroidManifest.xml +++ b/mainActivity/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="53"> diff --git a/mainActivity/src/main/java/com/sierrawireless/avphone/AvPhoneFragment.kt b/mainActivity/src/main/java/com/sierrawireless/avphone/AvPhoneFragment.kt index 107d035..47d5bf4 100644 --- a/mainActivity/src/main/java/com/sierrawireless/avphone/AvPhoneFragment.kt +++ b/mainActivity/src/main/java/com/sierrawireless/avphone/AvPhoneFragment.kt @@ -1,9 +1,12 @@ package com.sierrawireless.avphone +import android.annotation.TargetApi +import android.app.Activity import android.app.Fragment import android.content.Context import android.content.Intent import android.text.Spanned +import android.util.Log import android.view.View import android.widget.TextView import com.sierrawireless.avphone.activity.AuthorizationActivity @@ -21,6 +24,18 @@ abstract class AvPhoneFragment : Fragment(), IMessageDisplayer { abstract var errorMessageView: TextView? + + @Suppress("OverridingDeprecatedMember") + override fun onAttach(activity: Activity) { + super.onAttach(activity) + + if (activity is AuthenticationManager) { + authManager = activity + } + + } + + @TargetApi(23) override fun onAttach(context: Context) { super.onAttach(context) diff --git a/mainActivity/src/main/java/com/sierrawireless/avphone/HomeFragment.kt b/mainActivity/src/main/java/com/sierrawireless/avphone/HomeFragment.kt index dca3667..edfbc4b 100644 --- a/mainActivity/src/main/java/com/sierrawireless/avphone/HomeFragment.kt +++ b/mainActivity/src/main/java/com/sierrawireless/avphone/HomeFragment.kt @@ -1,5 +1,7 @@ package com.sierrawireless.avphone +import android.annotation.TargetApi +import android.app.Activity import android.content.Context import android.content.Intent import android.os.Build @@ -15,6 +17,7 @@ import com.sierrawireless.avphone.activity.MainActivity import com.sierrawireless.avphone.auth.AuthUtils import com.sierrawireless.avphone.auth.Authentication import com.sierrawireless.avphone.message.IMessageDisplayer +import com.sierrawireless.avphone.service.MonitorServiceManager import com.sierrawireless.avphone.task.IAsyncTaskFactory import com.sierrawireless.avphone.task.SyncWithAvListener import com.sierrawireless.avphone.task.SyncWithAvParams @@ -45,6 +48,16 @@ class HomeFragment : AvPhoneFragment(), IMessageDisplayer { } } + @Suppress("OverridingDeprecatedMember") + override fun onAttach(activity: Activity) { + super.onAttach(activity) + + + syncListener = activity as SyncWithAvListener + + } + + @TargetApi(23) override fun onAttach(context: Context) { super.onAttach(context) @@ -52,6 +65,7 @@ class HomeFragment : AvPhoneFragment(), IMessageDisplayer { syncListener = context as SyncWithAvListener } + @SuppressWarnings("deprecation") override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -110,7 +124,7 @@ class HomeFragment : AvPhoneFragment(), IMessageDisplayer { val avPhonePrefs = PreferenceUtils.getAvPhonePrefs(activity) // Without task factory, try later - if (taskFactory == null) { + if (taskFactory == null || authManager == null) { authForSync = auth retrySync = true return