From d9c8867c0b5d8092bd43b8447f58c6f482c634d0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 3 Apr 2019 12:10:02 +0200 Subject: [PATCH] Introduce common parent for PreferenceFragment --- .../core/platform/VectorPreferenceFragment.kt | 40 +++++++++++++++++++ ...sAdvancedNotificationPreferenceFragment.kt | 4 +- .../VectorSettingsPreferencesFragment.kt | 3 +- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 vector/src/main/java/im/vector/riotredesign/core/platform/VectorPreferenceFragment.kt diff --git a/vector/src/main/java/im/vector/riotredesign/core/platform/VectorPreferenceFragment.kt b/vector/src/main/java/im/vector/riotredesign/core/platform/VectorPreferenceFragment.kt new file mode 100644 index 0000000000..f9f327d34e --- /dev/null +++ b/vector/src/main/java/im/vector/riotredesign/core/platform/VectorPreferenceFragment.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotredesign.core.platform + +import androidx.annotation.CallSuper +import androidx.preference.PreferenceFragmentCompat +import timber.log.Timber + +abstract class VectorPreferenceFragment : PreferenceFragmentCompat() { + + val vectorActivity: RiotActivity by lazy { + activity as RiotActivity + } + + /* ========================================================================================== + * Life cycle + * ========================================================================================== */ + + @CallSuper + override fun onResume() { + super.onResume() + + Timber.d("onResume Fragment ${this.javaClass.simpleName}") + } + +} \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt index 980859dd2b..20cecdf8f5 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsAdvancedNotificationPreferenceFragment.kt @@ -24,19 +24,19 @@ import android.os.Parcelable import android.view.View import androidx.core.content.edit import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager import im.vector.matrix.android.api.session.Session import im.vector.riotredesign.R import im.vector.riotredesign.core.extensions.withArgs import im.vector.riotredesign.core.platform.RiotActivity +import im.vector.riotredesign.core.platform.VectorPreferenceFragment import im.vector.riotredesign.core.preference.BingRule import im.vector.riotredesign.core.preference.BingRulePreference import im.vector.riotredesign.features.notifications.NotificationUtils import im.vector.riotredesign.features.notifications.supportNotificationChannels import org.koin.android.ext.android.inject -class VectorSettingsAdvancedNotificationPreferenceFragment : PreferenceFragmentCompat() { +class VectorSettingsAdvancedNotificationPreferenceFragment : VectorPreferenceFragment() { // members private val mSession by inject() diff --git a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsPreferencesFragment.kt index 24df2bf57b..474b2aaf90 100755 --- a/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/settings/VectorSettingsPreferencesFragment.kt @@ -47,6 +47,7 @@ import im.vector.riotredesign.R import im.vector.riotredesign.core.extensions.showPassword import im.vector.riotredesign.core.extensions.withArgs import im.vector.riotredesign.core.platform.SimpleTextWatcher +import im.vector.riotredesign.core.platform.VectorPreferenceFragment import im.vector.riotredesign.core.preference.BingRule import im.vector.riotredesign.core.preference.ProgressBarPreference import im.vector.riotredesign.core.preference.UserAvatarPreference @@ -57,7 +58,7 @@ import org.koin.android.ext.android.inject import java.lang.ref.WeakReference import java.util.* -class VectorSettingsPreferencesFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { +class VectorSettingsPreferencesFragment : VectorPreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener { // members private val mSession by inject()