Lint fixes

pull/543/head
Marc Leclair 2 years ago committed by mergify[bot]
parent ed45675755
commit 0da739930c

@ -65,15 +65,20 @@ class ProfilerStopDialogFragment : DialogFragment() {
private fun StopProfilerCard() {
val viewStateObserver = remember { mutableStateOf(CardState.UrlWarningState) }
Dialog(onDismissRequest = {
// In the waiting state, we do not want the users to be able to click away from the dialogue
// since the user needs to wait for the profiler data to be ready and we don't want to handle
// the process in the background.
if (viewStateObserver.value != CardState.WaitForProfilerState) {
profilerViewModel.setProfilerState(requireContext().components.core.engine.profiler!!.isProfilerActive())
this@ProfilerStopDialogFragment.dismiss()
Dialog(
onDismissRequest = {
// In the waiting state, we do not want the users to be able to click away from the dialogue
// since the user needs to wait for the profiler data to be ready and we don't want to handle
// the process in the background.
if (viewStateObserver.value != CardState.WaitForProfilerState) {
profilerViewModel.setProfilerState(
requireContext()
.components.core.engine.profiler!!.isProfilerActive()
)
this@ProfilerStopDialogFragment.dismiss()
}
}
}) {
) {
when (viewStateObserver.value) {
CardState.UrlWarningState -> {
UrlWarningCard(viewStateObserver)
@ -111,7 +116,7 @@ class ProfilerStopDialogFragment : DialogFragment() {
) {
TextButton(
onClick = {
displayToastAndDismiss(R.string.profile_stop_dialogue_cancel_save)
displayToastAndDismiss(R.string.profile_stop_dialogue_cancel_save)
}
) {
Text(stringResource(R.string.profiler_start_cancel))

@ -14,14 +14,9 @@ import mozilla.components.concept.fetch.Response
import org.json.JSONObject
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import java.io.BufferedReader
import java.io.ByteArrayInputStream
import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStreamReader
import java.util.zip.GZIPInputStream
private const val PROFILER_API = "https://api.profiler.firefox.com/compressed-store"
private const val PROFILER_SERVER_HEADER = "application/vnd.firefox-profiler+json;version=1.0"
@ -80,7 +75,7 @@ enum class ProfilerSettings(val threads: Array<String>, val features: Array<Stri
object ProfilerUtils {
private fun saveProfileUrlToClipboardAndToast(profileResult: ByteArray, context: Context): String {
//The profile is saved to a temporary file since our fetch API takes a file or a string.
// The profile is saved to a temporary file since our fetch API takes a file or a string.
// Converting the ByteArray to a String would hurt the encoding, which we need to preserve.
val outputFile = createTemporaryFile(profileResult, context)
val response = networkCallToProfilerServer(outputFile, context)

@ -8,14 +8,23 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
/**
* [ViewModel] to keep track of the profiler state
*/
class ProfilerViewModel : ViewModel() {
var isProfilerActive : MutableLiveData<Boolean> = MutableLiveData()
var isProfilerActive: MutableLiveData<Boolean> = MutableLiveData()
/**
* @return profiler status
*/
fun getProfilerState(): LiveData<Boolean> {
return isProfilerActive
}
fun setProfilerState(isActive: Boolean){
/**
* @param isActive whether the profiler is active or not
*/
fun setProfilerState(isActive: Boolean) {
isProfilerActive.value = isActive
}
}
}

@ -151,9 +151,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
profilerViewModel.getProfilerState().observe(this, Observer<Boolean>{
updateProfilerUI(it)
})
profilerViewModel.getProfilerState().observe(
this,
Observer<Boolean> {
updateProfilerUI(it)
}
)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@ -497,7 +500,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
findPreference<Preference>(
getPreferenceKey(R.string.pref_key_secret_debug_info)
)?.isVisible = showSecretDebugMenuThisSession
preferenceStartProfiler?.isVisible = showSecretDebugMenuThisSession && (requireContext().components.core.engine.profiler?.isProfilerActive() != null)
preferenceStartProfiler?.isVisible = showSecretDebugMenuThisSession &&
(requireContext().components.core.engine.profiler?.isProfilerActive() != null)
}
setupAmoCollectionOverridePreference(requireContext().settings())
setupAllowDomesticChinaFxaServerPreference()
@ -660,7 +664,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
return browsers.isFirefoxDefaultBrowser
}
private fun updateProfilerUI(profilerStatus: Boolean){
private fun updateProfilerUI(profilerStatus: Boolean) {
if (profilerStatus) {
findPreference<Preference>(getPreferenceKey(R.string.pref_key_start_profiler))?.title =
resources.getString(R.string.profiler_stop)

Loading…
Cancel
Save