-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block settings that restart the app when in form entry #6488
Changes from all commits
694c6ea
c3a4113
4c03c99
0543f6e
0232a5e
41a9d5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.odk.collect.android.feature.settings | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.RuleChain | ||
import org.junit.runner.RunWith | ||
import org.odk.collect.android.support.rules.CollectTestRule | ||
import org.odk.collect.android.support.rules.TestRuleChain | ||
import org.odk.collect.strings.R | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FormEntrySettingsTest { | ||
|
||
private val rule = CollectTestRule() | ||
|
||
@get:Rule | ||
val chain: RuleChain = TestRuleChain.chain().around(rule) | ||
|
||
@Test | ||
fun settingsThatResetAppAreBlocked() { | ||
rule.startAtMainMenu() | ||
.copyForm("one-question.xml") | ||
.startBlankForm("One Question") | ||
.clickOptionsIcon() | ||
.clickProjectSettings() | ||
.assertDisabled(R.string.project_management_section_title) | ||
|
||
.clickOnUserInterface() | ||
.assertDisabled(R.string.app_theme) | ||
.assertDisabled(R.string.language) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import android.view.MenuInflater | |
import android.view.MenuItem | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.os.bundleOf | ||
import androidx.preference.Preference | ||
import org.odk.collect.android.R | ||
import org.odk.collect.android.injection.DaggerUtils | ||
|
@@ -33,7 +34,7 @@ import org.odk.collect.androidshared.data.Consumable | |
import org.odk.collect.androidshared.ui.DialogFragmentUtils | ||
import org.odk.collect.androidshared.ui.multiclicksafe.MultiClickGuard | ||
|
||
class ProjectPreferencesFragment : | ||
class ProjectPreferencesFragment(private val inFormEntry: Boolean) : | ||
BaseProjectPreferencesFragment(), | ||
Preference.OnPreferenceClickListener { | ||
|
||
|
@@ -66,16 +67,27 @@ class ProjectPreferencesFragment : | |
findPreference<Preference>(EXPERIMENTAL_PREFERENCE_KEY)!!.onPreferenceClickListener = this | ||
findPreference<Preference>(UNLOCK_PROTECTED_SETTINGS_PREFERENCE_KEY)!!.onPreferenceClickListener = this | ||
findPreference<Preference>(CHANGE_ADMIN_PASSWORD_PREFERENCE_KEY)!!.onPreferenceClickListener = this | ||
findPreference<Preference>(PROJECT_MANAGEMENT_PREFERENCE_KEY)!!.onPreferenceClickListener = this | ||
findPreference<Preference>(ACCESS_CONTROL_PREFERENCE_KEY)!!.onPreferenceClickListener = this | ||
findPreference<Preference>(PROJECT_MANAGEMENT_PREFERENCE_KEY)!!.also { | ||
it.onPreferenceClickListener = this | ||
if (inFormEntry) { | ||
it.isEnabled = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could it be made clearer that these settings are disabled? The visual effect feels off - the title isn't grayed out, only the summary, which makes it hard to notice the difference at first glance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally agree! We can tweak that if we need, so I'd vote we go with this for now and follow up if we're still unhappy with it. |
||
it.setSummary(org.odk.collect.strings.R.string.setting_not_available_during_form_entry) | ||
} | ||
} | ||
} | ||
|
||
override fun onPreferenceClick(preference: Preference): Boolean { | ||
if (MultiClickGuard.allowClick(javaClass.name)) { | ||
when (preference.key) { | ||
PROTOCOL_PREFERENCE_KEY -> displayPreferences(ServerPreferencesFragment()) | ||
PROJECT_DISPLAY_PREFERENCE_KEY -> displayPreferences(ProjectDisplayPreferencesFragment()) | ||
USER_INTERFACE_PREFERENCE_KEY -> displayPreferences(UserInterfacePreferencesFragment()) | ||
USER_INTERFACE_PREFERENCE_KEY -> { | ||
val fragment = UserInterfacePreferencesFragment() | ||
fragment.arguments = | ||
grzesiek2010 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bundleOf(UserInterfacePreferencesFragment.ARG_IN_FORM_ENTRY to inFormEntry) | ||
displayPreferences(fragment) | ||
} | ||
MAPS_PREFERENCE_KEY -> displayPreferences(MapsPreferencesFragment()) | ||
FORM_MANAGEMENT_PREFERENCE_KEY -> displayPreferences(FormManagementPreferencesFragment()) | ||
USER_AND_DEVICE_IDENTITY_PREFERENCE_KEY -> displayPreferences(IdentityPreferencesFragment()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the below case) don't have tests and as far as I'm aware, we don't know how they happen. Crashing means we don't have to deal with form session/lock clean up, and I actually think it's a better experience now that we show the crash message on the next relaunch than mysteriously returning to the Main Menu without warning.