Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.odk.collect.android.support.pages.FormEntryPage
import org.odk.collect.android.support.pages.MainMenuPage
import org.odk.collect.android.support.pages.OkDialog
import org.odk.collect.android.support.rules.CollectTestRule
import org.odk.collect.android.support.rules.EnableQuestionWidgetLongPressRule
import org.odk.collect.android.support.rules.TestRuleChain

@RunWith(AndroidJUnit4::class)
Expand All @@ -17,7 +18,9 @@ class CatchFormDesignExceptionsTest {
private val rule = CollectTestRule()

@get:Rule
val ruleChain: RuleChain = TestRuleChain.chain().around(rule)
val ruleChain: RuleChain = TestRuleChain.chain()
.around(EnableQuestionWidgetLongPressRule())
.around(rule)

@Test // https://github.com/getodk/collect/issues/4750
fun whenFormHasFatalErrors_explanationDialogShouldBeDisplayedAndSurviveActivityRecreationAndTheFormShouldBeClosedAfterClickingOK() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.rules.RuleChain;
import org.odk.collect.android.R;
import org.odk.collect.android.support.rules.BlankFormTestRule;
import org.odk.collect.android.support.rules.EnableQuestionWidgetLongPressRule;
import org.odk.collect.android.support.rules.TestRuleChain;

public class ContextMenuTest {
Expand All @@ -14,6 +15,7 @@ public class ContextMenuTest {

@Rule
public RuleChain copyFormChain = TestRuleChain.chain()
.around(new EnableQuestionWidgetLongPressRule())
.around(activityTestRule);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.odk.collect.android.R
import org.odk.collect.android.storage.StoragePathProvider
import org.odk.collect.android.support.pages.FormEntryPage
import org.odk.collect.android.support.pages.ProjectSettingsPage
import org.odk.collect.android.support.rules.EnableQuestionWidgetLongPressRule
import org.odk.collect.android.support.rules.FormEntryActivityTestRule
import org.odk.collect.android.support.rules.TestRuleChain.chain
import org.odk.collect.androidtest.RecordedIntentsRule
Expand All @@ -29,6 +30,7 @@ class FieldListUpdateTest {
@get:Rule
var copyFormChain: RuleChain = chain()
.around(RecordedIntentsRule())
.around(EnableQuestionWidgetLongPressRule())
.around(rule)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class FakeClickableMapFragment : Fragment(), MapFragment {
var done = false

Handler(Looper.getMainLooper()).post {
featureClickListener?.onFeature(featureId)
featureClickListener!!.onFeature(featureId)
done = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.odk.collect.android.support.rules

import org.junit.rules.ExternalResource
import org.odk.collect.android.widgets.QuestionWidget

class EnableQuestionWidgetLongPressRule : ExternalResource() {
override fun before() {
QuestionWidget.longPressClear = true
}

override fun after() {
QuestionWidget.longPressClear = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.odk.collect.android.injection.config.AppDependencyComponent
import org.odk.collect.android.injection.config.AppDependencyModule
import org.odk.collect.android.support.CollectHelpers
import org.odk.collect.android.views.DecoratedBarcodeView
import org.odk.collect.android.widgets.QuestionWidget
import org.odk.collect.androidshared.ui.SnackbarUtils
import org.odk.collect.androidshared.ui.ToastUtils
import org.odk.collect.androidshared.ui.multiclicksafe.MultiClickGuard
Expand All @@ -36,6 +37,7 @@ private class ResetStateStatement(
private fun setTestState() {
MultiClickGuard.test = true
DecoratedBarcodeView.test = true
QuestionWidget.longPressClear = false
ToastUtils.alertStore.enabled = true
SnackbarUtils.alertStore.enabled = true
BottomSheetBehavior.DRAGGING_ENABLED = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

public abstract class QuestionWidget extends FrameLayout implements Widget {

public static Boolean longPressClear = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gates the whole long-press menu (it also has "delete repeat group"), not just clearing answers - maybe longPressMenuEnabled?


private final FormEntryPrompt formEntryPrompt;
private final AudioVideoImageTextLabel audioVideoImageTextLabel;
protected final QuestionDetails questionDetails;
Expand Down Expand Up @@ -133,7 +135,7 @@ public QuestionWidget(Context context, Dependencies dependencies, QuestionDetail
errorLayout = findViewById(R.id.error_message_container);
setupGuidanceTextAndLayout(helpTextLayout.findViewById(R.id.guidance_text_view), formEntryPrompt);

if (context instanceof Activity && !questionDetails.isReadOnly()) {
if (longPressClear && context instanceof Activity && !questionDetails.isReadOnly()) {
registerToClearAnswerOnLongPress((Activity) context, this);
}

Expand Down