diff --git a/collect_app/src/main/java/org/odk/collect/android/formentry/FormEndView.java b/collect_app/src/main/java/org/odk/collect/android/formentry/FormEndView.java index be5e5ee57d6..fed2413b9bb 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formentry/FormEndView.java +++ b/collect_app/src/main/java/org/odk/collect/android/formentry/FormEndView.java @@ -1,9 +1,12 @@ package org.odk.collect.android.formentry; import android.content.Context; +import android.content.Intent; +import android.net.Uri; import android.text.Editable; import android.text.InputFilter; import android.text.TextWatcher; +import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; @@ -35,6 +38,11 @@ private void init(Context context, boolean instanceComplete) { ((TextView) findViewById(R.id.description)).setText(context.getString(R.string.save_enter_data_description, formTitle)); EditText saveAs = findViewById(R.id.save_name); + saveAs.setOnFocusChangeListener((view, isFocused) -> { + if (isFocused) { + findViewById(R.id.manual_name_warning).setVisibility(View.VISIBLE); + } + }); // disallow carriage returns in the name InputFilter returnFilter = (source, start, end, dest, dstart, dend) -> FormNameUtils.normalizeFormName(source.toString().substring(start, end), true); @@ -62,6 +70,13 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { findViewById(R.id.save_exit_button).setOnClickListener(v -> { listener.onSaveClicked(markAsFinalized.isChecked()); }); + + findViewById(R.id.instance_name_learn_more).setOnClickListener(v -> { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setData(Uri.parse("https://forum.getodk.org/t/collect-manual-instance-naming-will-be-removed-in-v2023-2/40313")); + context.startActivity(intent); + }); } @Override diff --git a/collect_app/src/main/res/layout/form_entry_end.xml b/collect_app/src/main/res/layout/form_entry_end.xml index 09c73645fe0..ff757f67fa2 100644 --- a/collect_app/src/main/res/layout/form_entry_end.xml +++ b/collect_app/src/main/res/layout/form_entry_end.xml @@ -9,10 +9,12 @@ the specific language governing permissions and limitations under the License. --> + + + + + + + + + + + + + #121212 + #41484d #FFFFFF false diff --git a/collect_app/src/main/res/values/colors.xml b/collect_app/src/main/res/values/colors.xml index 6c32aebb7a0..9727a988d5f 100644 --- a/collect_app/src/main/res/values/colors.xml +++ b/collect_app/src/main/res/values/colors.xml @@ -8,6 +8,7 @@ #ffffff #FFFFFF + #dce3e9 #000000 true diff --git a/collect_app/src/main/res/values/theme.xml b/collect_app/src/main/res/values/theme.xml index 059163d6e98..a2cff766d71 100644 --- a/collect_app/src/main/res/values/theme.xml +++ b/collect_app/src/main/res/values/theme.xml @@ -50,11 +50,15 @@ + @color/colorSurfaceVariant ?colorPrimary ?colorOnPrimary + ?textAppearanceBody1 @style/TextAppearance.Material3.LabelLarge + + @style/ShapeAppearance.Material3.Corner.Medium diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt new file mode 100644 index 00000000000..71d796140ba --- /dev/null +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt @@ -0,0 +1,62 @@ +package org.odk.collect.android.formentry + +import android.app.Application +import android.content.Intent +import android.net.Uri +import android.view.View +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test +import org.junit.runner.RunWith +import org.odk.collect.android.R +import org.robolectric.Shadows.shadowOf + +@RunWith(AndroidJUnit4::class) +class FormEndViewTest { + + private val context: Application = + ApplicationProvider.getApplicationContext().also { + it.setTheme(R.style.Theme_Material3_Light) + } + + @Test + fun `focusing on save as field shows warning`() { + val formEndView = FormEndView( + context, + null, + null, + false, + null + ) + + val warningView = formEndView.findViewById(R.id.manual_name_warning) + assertThat(warningView.visibility, equalTo(View.GONE)) + + formEndView.findViewById(R.id.save_name).requestFocus() + assertThat(warningView.visibility, equalTo(View.VISIBLE)) + } + + @Test + fun `clicking learn more in warning opens forum post`() { + val formEndView = FormEndView( + context, + null, + null, + false, + null + ) + + formEndView.findViewById(R.id.save_name).requestFocus() + formEndView.findViewById(R.id.instance_name_learn_more).performClick() + + val intent = shadowOf(context).nextStartedActivity + assertThat(intent.action, equalTo(Intent.ACTION_VIEW)) + assertThat(intent.flags, equalTo(Intent.FLAG_ACTIVITY_NEW_TASK)) + assertThat( + intent.data, + equalTo(Uri.parse("https://forum.getodk.org/t/collect-manual-instance-naming-will-be-removed-in-v2023-2/40313")) + ) + } +} diff --git a/strings/src/main/res/values/strings.xml b/strings/src/main/res/values/strings.xml index cc79bb7989d..8bbfbc9f38b 100644 --- a/strings/src/main/res/values/strings.xml +++ b/strings/src/main/res/values/strings.xml @@ -166,6 +166,8 @@ Saved name must not be blank! Mark form as finalized Save Form and Exit + Soon manually naming forms will be removed. Form design needs to be updated. + Learn more Sorry, form save failed! Form successfully saved!