forked from PeterCxy/OpenEUICC
Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
4d8b8e8fb5 |
3 changed files with 27 additions and 53 deletions
2
.idea/.gitignore
generated
vendored
2
.idea/.gitignore
generated
vendored
|
@ -2,7 +2,7 @@
|
||||||
/caches
|
/caches
|
||||||
/libraries
|
/libraries
|
||||||
/assetWizardSettings.xml
|
/assetWizardSettings.xml
|
||||||
/deploymentTargetDropDown.xml
|
/deploymentTarget*.xml
|
||||||
/gradle.xml
|
/gradle.xml
|
||||||
/misc.xml
|
/misc.xml
|
||||||
/modules.xml
|
/modules.xml
|
||||||
|
|
37
.idea/deploymentTargetSelector.xml
generated
37
.idea/deploymentTargetSelector.xml
generated
|
@ -1,37 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetSelector">
|
|
||||||
<selectionStates>
|
|
||||||
<SelectionState runConfigName="app-unpriv">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app-unpriv.androidTest">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app-unpriv.main">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app-unpriv.unitTest">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app.unitTest">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app.androidTest">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="app.main">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="workspace.OpenEUICC.app-unpriv">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="workspace.OpenEUICC.app">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
</selectionStates>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -34,7 +34,7 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
||||||
// Show / hide developer preference based on whether it is enabled
|
// Show / hide developer preference based on whether it is enabled
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
preferenceRepository.developerOptionsEnabledFlow
|
preferenceRepository.developerOptionsEnabledFlow
|
||||||
.onEach(developerPref::setVisible)
|
.onEach { developerPref.isVisible = it }
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,30 +100,41 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
private fun onAppVersionClicked(pref: Preference): Boolean {
|
private fun onAppVersionClicked(pref: Preference): Boolean {
|
||||||
if (developerPref.isVisible) return false
|
if (developerPref.isVisible) return false
|
||||||
|
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
numClicks = if (now - lastClickTimestamp >= 1000) 1 else numClicks + 1
|
if (now - lastClickTimestamp >= 1000) {
|
||||||
|
numClicks = 1
|
||||||
|
} else {
|
||||||
|
numClicks++
|
||||||
|
}
|
||||||
lastClickTimestamp = now
|
lastClickTimestamp = now
|
||||||
|
|
||||||
|
if (numClicks == 7) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
preferenceRepository.developerOptionsEnabledFlow.updatePreference(numClicks >= 7)
|
preferenceRepository.developerOptionsEnabledFlow.updatePreference(true)
|
||||||
}
|
|
||||||
|
|
||||||
val toastText = when {
|
|
||||||
numClicks == 7 -> getString(R.string.developer_options_enabled)
|
|
||||||
numClicks > 1 -> getString(R.string.developer_options_steps, 7 - numClicks)
|
|
||||||
else -> return true
|
|
||||||
}
|
|
||||||
|
|
||||||
lastToast?.cancel()
|
lastToast?.cancel()
|
||||||
lastToast = Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT)
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
R.string.developer_options_enabled,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
} else if (numClicks > 1) {
|
||||||
|
lastToast?.cancel()
|
||||||
|
lastToast = Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
getString(R.string.developer_options_steps, 7 - numClicks),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
lastToast!!.show()
|
lastToast!!.show()
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun CheckBoxPreference.bindBooleanFlow(flow: PreferenceFlowWrapper<Boolean>) {
|
protected fun CheckBoxPreference.bindBooleanFlow(flow: PreferenceFlowWrapper<Boolean>) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
flow.collect(::setChecked)
|
flow.collect { isChecked = it }
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue