mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
Moving the new setting inside debug screen
This commit is contained in:
parent
12405527e1
commit
250ee1faa1
15 changed files with 270 additions and 35 deletions
|
@ -10,6 +10,7 @@
|
||||||
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
|
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
|
||||||
<activity android:name=".features.debug.features.DebugFeaturesSettingsActivity" />
|
<activity android:name=".features.debug.features.DebugFeaturesSettingsActivity" />
|
||||||
<activity android:name=".features.debug.DebugMenuActivity" />
|
<activity android:name=".features.debug.DebugMenuActivity" />
|
||||||
|
<activity android:name=".features.debug.leak.DebugMemoryLeaksActivity" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
|
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
|
||||||
|
|
|
@ -37,6 +37,7 @@ import im.vector.app.core.utils.toast
|
||||||
import im.vector.app.databinding.ActivityDebugMenuBinding
|
import im.vector.app.databinding.ActivityDebugMenuBinding
|
||||||
import im.vector.app.features.debug.analytics.DebugAnalyticsActivity
|
import im.vector.app.features.debug.analytics.DebugAnalyticsActivity
|
||||||
import im.vector.app.features.debug.features.DebugFeaturesSettingsActivity
|
import im.vector.app.features.debug.features.DebugFeaturesSettingsActivity
|
||||||
|
import im.vector.app.features.debug.leak.DebugMemoryLeaksActivity
|
||||||
import im.vector.app.features.debug.sas.DebugSasEmojiActivity
|
import im.vector.app.features.debug.sas.DebugSasEmojiActivity
|
||||||
import im.vector.app.features.debug.settings.DebugPrivateSettingsActivity
|
import im.vector.app.features.debug.settings.DebugPrivateSettingsActivity
|
||||||
import im.vector.app.features.qrcode.QrCodeScannerActivity
|
import im.vector.app.features.qrcode.QrCodeScannerActivity
|
||||||
|
@ -86,6 +87,7 @@ class DebugMenuActivity : VectorBaseActivity<ActivityDebugMenuBinding>() {
|
||||||
views.debugAnalytics.setOnClickListener {
|
views.debugAnalytics.setOnClickListener {
|
||||||
startActivity(Intent(this, DebugAnalyticsActivity::class.java))
|
startActivity(Intent(this, DebugAnalyticsActivity::class.java))
|
||||||
}
|
}
|
||||||
|
views.debugMemoryLeaks.setOnClickListener { openMemoryLeaksSettings() }
|
||||||
views.debugTestTextViewLink.setOnClickListener { testTextViewLink() }
|
views.debugTestTextViewLink.setOnClickListener { testTextViewLink() }
|
||||||
views.debugOpenButtonStylesLight.setOnClickListener {
|
views.debugOpenButtonStylesLight.setOnClickListener {
|
||||||
startActivity(Intent(this, DebugVectorButtonStylesLightActivity::class.java))
|
startActivity(Intent(this, DebugVectorButtonStylesLightActivity::class.java))
|
||||||
|
@ -130,6 +132,10 @@ class DebugMenuActivity : VectorBaseActivity<ActivityDebugMenuBinding>() {
|
||||||
startActivity(Intent(this, DebugPrivateSettingsActivity::class.java))
|
startActivity(Intent(this, DebugPrivateSettingsActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openMemoryLeaksSettings() {
|
||||||
|
startActivity(Intent(this, DebugMemoryLeaksActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
private fun renderQrCode(text: String) {
|
private fun renderQrCode(text: String) {
|
||||||
views.debugQrCode.setData(text)
|
views.debugQrCode.setData(text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
import im.vector.app.core.di.MavericksViewModelComponent
|
import im.vector.app.core.di.MavericksViewModelComponent
|
||||||
import im.vector.app.core.di.MavericksViewModelKey
|
import im.vector.app.core.di.MavericksViewModelKey
|
||||||
import im.vector.app.features.debug.analytics.DebugAnalyticsViewModel
|
import im.vector.app.features.debug.analytics.DebugAnalyticsViewModel
|
||||||
|
import im.vector.app.features.debug.leak.DebugMemoryLeaksViewModel
|
||||||
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewModel
|
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewModel
|
||||||
|
|
||||||
@InstallIn(MavericksViewModelComponent::class)
|
@InstallIn(MavericksViewModelComponent::class)
|
||||||
|
@ -39,4 +40,10 @@ interface MavericksViewModelDebugModule {
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@MavericksViewModelKey(DebugPrivateSettingsViewModel::class)
|
@MavericksViewModelKey(DebugPrivateSettingsViewModel::class)
|
||||||
fun debugPrivateSettingsViewModelFactory(factory: DebugPrivateSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
fun debugPrivateSettingsViewModelFactory(factory: DebugPrivateSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@MavericksViewModelKey(DebugMemoryLeaksViewModel::class)
|
||||||
|
fun debugMemoryLeaksViewModelFactory(factory: DebugMemoryLeaksViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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.app.features.debug.leak
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import im.vector.app.core.extensions.addFragment
|
||||||
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
|
import im.vector.app.databinding.ActivitySimpleBinding
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class DebugMemoryLeaksActivity : VectorBaseActivity<ActivitySimpleBinding>() {
|
||||||
|
|
||||||
|
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
|
override fun initUiAndData() {
|
||||||
|
if (isFirstCreation()) {
|
||||||
|
addFragment(
|
||||||
|
views.simpleFragmentContainer,
|
||||||
|
DebugMemoryLeaksFragment::class.java
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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.app.features.debug.leak
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import im.vector.app.core.epoxy.onClick
|
||||||
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
|
import im.vector.app.databinding.FragmentDebugMemoryLeaksBinding
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class DebugMemoryLeaksFragment : VectorBaseFragment<FragmentDebugMemoryLeaksBinding>() {
|
||||||
|
|
||||||
|
private val viewModel: DebugMemoryLeaksViewModel by fragmentViewModel()
|
||||||
|
|
||||||
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentDebugMemoryLeaksBinding {
|
||||||
|
return FragmentDebugMemoryLeaksBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
setViewListeners()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setViewListeners() {
|
||||||
|
views.enableMemoryLeakAnalysis.onClick {
|
||||||
|
viewModel.handle(DebugMemoryLeaksViewActions.EnableMemoryLeaksAnalysis(views.enableMemoryLeakAnalysis.isChecked))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun invalidate() = withState(viewModel) { viewState ->
|
||||||
|
views.enableMemoryLeakAnalysis.isChecked = viewState.isMemoryLeaksAnalysisEnabled
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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.app.features.debug.leak
|
||||||
|
|
||||||
|
import im.vector.app.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
|
sealed interface DebugMemoryLeaksViewActions : VectorViewModelAction {
|
||||||
|
data class EnableMemoryLeaksAnalysis(val isEnabled: Boolean) : DebugMemoryLeaksViewActions
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 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.app.features.debug.leak
|
||||||
|
|
||||||
|
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||||
|
import dagger.assisted.Assisted
|
||||||
|
import dagger.assisted.AssistedFactory
|
||||||
|
import dagger.assisted.AssistedInject
|
||||||
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
|
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||||
|
import im.vector.app.core.platform.EmptyViewEvents
|
||||||
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
|
import im.vector.app.leakcanary.LeakCanaryProxy
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class DebugMemoryLeaksViewModel @AssistedInject constructor(
|
||||||
|
@Assisted initialState: DebugMemoryLeaksViewState,
|
||||||
|
private val vectorPreferences: VectorPreferences,
|
||||||
|
private val leakCanaryProxy: LeakCanaryProxy,
|
||||||
|
) : VectorViewModel<DebugMemoryLeaksViewState, DebugMemoryLeaksViewActions, EmptyViewEvents>(initialState) {
|
||||||
|
|
||||||
|
@AssistedFactory
|
||||||
|
interface Factory : MavericksAssistedViewModelFactory<DebugMemoryLeaksViewModel, DebugMemoryLeaksViewState> {
|
||||||
|
override fun create(initialState: DebugMemoryLeaksViewState): DebugMemoryLeaksViewModel
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : MavericksViewModelFactory<DebugMemoryLeaksViewModel, DebugMemoryLeaksViewState> by hiltMavericksViewModelFactory()
|
||||||
|
|
||||||
|
init {
|
||||||
|
viewModelScope.launch {
|
||||||
|
refreshStateFromPreferences()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handle(action: DebugMemoryLeaksViewActions) {
|
||||||
|
when (action) {
|
||||||
|
is DebugMemoryLeaksViewActions.EnableMemoryLeaksAnalysis -> handleEnableMemoryLeaksAnalysis(action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleEnableMemoryLeaksAnalysis(action: DebugMemoryLeaksViewActions.EnableMemoryLeaksAnalysis) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
vectorPreferences.enableMemoryLeakAnalysis(action.isEnabled)
|
||||||
|
leakCanaryProxy.enable(action.isEnabled)
|
||||||
|
refreshStateFromPreferences()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun refreshStateFromPreferences() {
|
||||||
|
setState { copy(isMemoryLeaksAnalysisEnabled = vectorPreferences.isMemoryLeakAnalysisEnabled()) }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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.app.features.debug.leak
|
||||||
|
|
||||||
|
import com.airbnb.mvrx.MavericksState
|
||||||
|
|
||||||
|
data class DebugMemoryLeaksViewState(
|
||||||
|
val isMemoryLeaksAnalysisEnabled: Boolean = false
|
||||||
|
) : MavericksState
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/coordinatorLayout"
|
android:id="@+id/coordinatorLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -8,8 +9,11 @@
|
||||||
tools:ignore="HardcodedText">
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
android:id="@+id/scrollView2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_anchor="@+id/scrollView2"
|
||||||
|
app:layout_anchorGravity="center">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -38,6 +42,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Analytics" />
|
android:text="Analytics" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/debug_memory_leaks"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Memory leaks" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/debug_test_text_view_link"
|
android:id="@+id/debug_test_text_view_link"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
32
vector/src/debug/res/layout/fragment_debug_memory_leaks.xml
Normal file
32
vector/src/debug/res/layout/fragment_debug_memory_leaks.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/coordinatorLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".features.debug.settings.DebugPrivateSettingsActivity"
|
||||||
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@drawable/linear_divider"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/layout_horizontal_margin"
|
||||||
|
android:showDividers="middle">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/enableMemoryLeakAnalysis"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Enable memory leak analysis" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -150,7 +150,6 @@ import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRul
|
||||||
import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment
|
import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment
|
||||||
import im.vector.app.features.roomprofile.uploads.files.RoomUploadsFilesFragment
|
import im.vector.app.features.roomprofile.uploads.files.RoomUploadsFilesFragment
|
||||||
import im.vector.app.features.roomprofile.uploads.media.RoomUploadsMediaFragment
|
import im.vector.app.features.roomprofile.uploads.media.RoomUploadsMediaFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsAdvancedSettingsFragment
|
|
||||||
import im.vector.app.features.settings.VectorSettingsGeneralFragment
|
import im.vector.app.features.settings.VectorSettingsGeneralFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsHelpAboutFragment
|
import im.vector.app.features.settings.VectorSettingsHelpAboutFragment
|
||||||
import im.vector.app.features.settings.VectorSettingsLabsFragment
|
import im.vector.app.features.settings.VectorSettingsLabsFragment
|
||||||
|
@ -625,11 +624,6 @@ interface FragmentModule {
|
||||||
@FragmentKey(VectorSettingsSecurityPrivacyFragment::class)
|
@FragmentKey(VectorSettingsSecurityPrivacyFragment::class)
|
||||||
fun bindVectorSettingsSecurityPrivacyFragment(fragment: VectorSettingsSecurityPrivacyFragment): Fragment
|
fun bindVectorSettingsSecurityPrivacyFragment(fragment: VectorSettingsSecurityPrivacyFragment): Fragment
|
||||||
|
|
||||||
@Binds
|
|
||||||
@IntoMap
|
|
||||||
@FragmentKey(VectorSettingsAdvancedSettingsFragment::class)
|
|
||||||
fun bindVectorSettingsAdvancedSettingsFragment(fragment: VectorSettingsAdvancedSettingsFragment): Fragment
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@FragmentKey(VectorSettingsHelpAboutFragment::class)
|
@FragmentKey(VectorSettingsHelpAboutFragment::class)
|
||||||
|
|
|
@ -168,6 +168,7 @@ class VectorPreferences @Inject constructor(
|
||||||
private const val SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY = "SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY"
|
private const val SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY = "SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY"
|
||||||
private const val SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY"
|
private const val SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY"
|
||||||
private const val SETTINGS_DEVELOPER_MODE_SHOW_INFO_ON_SCREEN_KEY = "SETTINGS_DEVELOPER_MODE_SHOW_INFO_ON_SCREEN_KEY"
|
private const val SETTINGS_DEVELOPER_MODE_SHOW_INFO_ON_SCREEN_KEY = "SETTINGS_DEVELOPER_MODE_SHOW_INFO_ON_SCREEN_KEY"
|
||||||
|
// TODO make it private
|
||||||
const val SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY = "SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY"
|
const val SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY = "SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY"
|
||||||
|
|
||||||
const val SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY = "SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY"
|
const val SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY = "SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY"
|
||||||
|
@ -370,8 +371,14 @@ class VectorPreferences @Inject constructor(
|
||||||
return buildMeta.isDebug || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false))
|
return buildMeta.isDebug || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun enableMemoryLeakAnalysis(isEnabled: Boolean) {
|
||||||
|
defaultPrefs.edit(commit = true) {
|
||||||
|
putBoolean(SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY, isEnabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isMemoryLeakAnalysisEnabled(): Boolean {
|
fun isMemoryLeakAnalysisEnabled(): Boolean {
|
||||||
return buildMeta.isDebug && developerMode() && defaultPrefs.getBoolean(SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY, false)
|
return buildMeta.isDebug && defaultPrefs.getBoolean(SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun didAskUserToEnableSessionPush(): Boolean {
|
fun didAskUserToEnableSessionPush(): Boolean {
|
||||||
|
|
|
@ -19,19 +19,15 @@ package im.vector.app.features.settings
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.SeekBarPreference
|
import androidx.preference.SeekBarPreference
|
||||||
import im.vector.app.BuildConfig
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseActivity
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
import im.vector.app.core.preference.VectorPreferenceCategory
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import im.vector.app.core.preference.VectorSwitchPreference
|
import im.vector.app.core.preference.VectorSwitchPreference
|
||||||
import im.vector.app.features.analytics.plan.MobileScreen
|
import im.vector.app.features.analytics.plan.MobileScreen
|
||||||
import im.vector.app.features.rageshake.RageShake
|
import im.vector.app.features.rageshake.RageShake
|
||||||
import im.vector.app.leakcanary.LeakCanaryProxy
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsAdvancedSettingsFragment @Inject constructor(
|
class VectorSettingsAdvancedSettingsFragment @Inject constructor() : VectorSettingsBaseFragment() {
|
||||||
private val leakCanaryProxy: LeakCanaryProxy,
|
|
||||||
) : VectorSettingsBaseFragment() {
|
|
||||||
|
|
||||||
override var titleRes = R.string.settings_advanced_settings
|
override var titleRes = R.string.settings_advanced_settings
|
||||||
override val preferenceXmlRes = R.xml.vector_settings_advanced_settings
|
override val preferenceXmlRes = R.xml.vector_settings_advanced_settings
|
||||||
|
@ -87,17 +83,5 @@ class VectorSettingsAdvancedSettingsFragment @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
findPreference<VectorPreferenceCategory>("SETTINGS_RAGE_SHAKE_CATEGORY_KEY")!!.isVisible = false
|
findPreference<VectorPreferenceCategory>("SETTINGS_RAGE_SHAKE_CATEGORY_KEY")!!.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
bindMemoryLeakSetting()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun bindMemoryLeakSetting() {
|
|
||||||
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY)?.let { pref ->
|
|
||||||
pref.isVisible = BuildConfig.DEBUG
|
|
||||||
pref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
|
||||||
leakCanaryProxy.enable(newValue as? Boolean ?: false)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2185,9 +2185,6 @@
|
||||||
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name -->
|
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name -->
|
||||||
<string name="settings_developer_mode_fail_fast_summary">${app_name} may crash more often when an unexpected error occurs</string>
|
<string name="settings_developer_mode_fail_fast_summary">${app_name} may crash more often when an unexpected error occurs</string>
|
||||||
|
|
||||||
<string name="settings_enable_memory_leak_analysis_title">Enable memory leak analysis</string>
|
|
||||||
<string name="settings_enable_memory_leak_analysis_summary">App performances may be impacted when enabled.</string>
|
|
||||||
|
|
||||||
<string name="settings_developer_mode_show_info_on_screen_title">Show debug info on screen</string>
|
<string name="settings_developer_mode_show_info_on_screen_title">Show debug info on screen</string>
|
||||||
<string name="settings_developer_mode_show_info_on_screen_summary">Show some useful info to help debugging the application</string>
|
<string name="settings_developer_mode_show_info_on_screen_summary">Show some useful info to help debugging the application</string>
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,6 @@
|
||||||
android:summary="@string/settings_developer_mode_fail_fast_summary"
|
android:summary="@string/settings_developer_mode_fail_fast_summary"
|
||||||
android:title="@string/settings_developer_mode_fail_fast_title" />
|
android:title="@string/settings_developer_mode_fail_fast_title" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorSwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:dependency="SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY"
|
|
||||||
android:key="SETTINGS_ENABLE_MEMORY_LEAK_ANALYSIS_KEY"
|
|
||||||
android:summary="@string/settings_enable_memory_leak_analysis_summary"
|
|
||||||
android:title="@string/settings_enable_memory_leak_analysis_title" />
|
|
||||||
|
|
||||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreferenceCategory
|
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
|
|
Loading…
Reference in a new issue