Skip to content
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

Make sure form end buttons grow together #5944

Merged
merged 4 commits into from
Feb 1, 2024
Merged
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 @@ -104,7 +104,7 @@ class AuditTest {
.pressBack(MainMenuPage())
.startBlankForm("One Question Audit")
.fillOut(FormEntryPage.QuestionAndAnswer("what is your age", "31"))
.killAndReopenApp(MainMenuPage())
.killAndReopenApp(rule, MainMenuPage())
.startBlankForm("One Question Audit")
.swipeToEndScreen()
.clickFinalize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BulkFinalizationTest {

.clickDrafts()
.clickOnForm("One Question")
.killAndReopenApp(MainMenuPage())
.killAndReopenApp(rule, MainMenuPage())

.clickDrafts(false)
.clickFinalizeAll(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import static org.hamcrest.core.AllOf.allOf;

import android.app.Activity;
import android.content.Intent;
import android.view.ContextThemeWrapper;
import android.view.View;

import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.platform.app.InstrumentationRegistry;

import org.hamcrest.Matcher;
import org.odk.collect.android.BuildConfig;

public final class ActivityHelpers {

Expand Down Expand Up @@ -48,4 +51,14 @@ public void perform(UiController uiController, View view) {
onView(allOf(withId(android.R.id.content), isDisplayed())).perform(getActivityViewAction);
return currentActivity[0];
}

public static Intent getLaunchIntent() {
Intent launchIntentForPackage = InstrumentationRegistry.getInstrumentation()
.getTargetContext()
.getPackageManager()
.getLaunchIntentForPackage(BuildConfig.APPLICATION_ID);

launchIntentForPackage.addCategory(Intent.CATEGORY_LAUNCHER);
return launchIntentForPackage;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.odk.collect.android.support.pages

import android.app.Activity
import android.app.Application
import android.content.pm.ActivityInfo
import android.view.View
Expand Down Expand Up @@ -47,12 +48,14 @@ import org.odk.collect.android.BuildConfig
import org.odk.collect.android.R
import org.odk.collect.android.application.Collect
import org.odk.collect.android.storage.StoragePathProvider
import org.odk.collect.android.support.ActivityHelpers.getLaunchIntent
import org.odk.collect.android.support.CollectHelpers
import org.odk.collect.android.support.WaitFor.wait250ms
import org.odk.collect.android.support.WaitFor.waitFor
import org.odk.collect.android.support.actions.RotateAction
import org.odk.collect.android.support.matchers.CustomMatchers.withIndex
import org.odk.collect.androidshared.ui.ToastUtils.popRecordedToasts
import org.odk.collect.androidtest.ActivityScenarioLauncherRule
import org.odk.collect.strings.localization.getLocalizedQuantityString
import org.odk.collect.strings.localization.getLocalizedString
import org.odk.collect.testshared.EspressoHelpers
Expand Down Expand Up @@ -492,7 +495,7 @@ abstract class Page<T : Page<T>> {
return destination!!.assertOnPage()
}

fun <D : Page<D>?> killAndReopenApp(destination: D): D {
fun <D : Page<D>> killAndReopenApp(rule: ActivityScenarioLauncherRule, destination: D): D {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

// kill
Expand All @@ -504,11 +507,8 @@ abstract class Page<T : Page<T>> {
}

// reopen
InstrumentationRegistry.getInstrumentation().targetContext.apply {
val intent = packageManager.getLaunchIntentForPackage(BuildConfig.APPLICATION_ID)!!
startActivity(intent)
}
return destination!!.assertOnPage()
rule.launch<Activity>(getLaunchIntent())
return destination.assertOnPage()
}

fun assertNoOptionsMenu(): T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package org.odk.collect.android.support.rules

import android.app.Activity
import android.app.Instrumentation
import android.content.Context
import android.content.Intent
import androidx.test.core.app.ApplicationProvider
import org.odk.collect.android.BuildConfig.APPLICATION_ID
import org.odk.collect.android.external.AndroidShortcutsActivity
import org.odk.collect.android.support.ActivityHelpers.getLaunchIntent
import org.odk.collect.android.support.StubOpenRosaServer
import org.odk.collect.android.support.pages.FirstLaunchPage
import org.odk.collect.android.support.pages.MainMenuPage
Expand Down Expand Up @@ -80,14 +78,4 @@ class CollectTestRule @JvmOverloads constructor(
actions.accept(destination)
return scenario.result
}

private fun getLaunchIntent(): Intent {
return ApplicationProvider
.getApplicationContext<Context>()
.packageManager
.getLaunchIntentForPackage(APPLICATION_ID)!!
.apply {
this.addCategory(Intent.CATEGORY_LAUNCHER)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<size android:width="@dimen/margin_standard" />
<size android:height="@dimen/margin_standard" />
</shape>
</item>
</layer-list>
30 changes: 11 additions & 19 deletions collect_app/src/main/res/layout/form_entry_end.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,46 +77,38 @@ the specific language governing permissions and limitations under the License.
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
app:layout_constraintWidth_max="640dp"
android:divider="@drawable/margin_standard_list_divider"
android:showDividers="middle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/form_edits_warning">
app:layout_constraintTop_toBottomOf="@+id/form_edits_warning"
app:layout_constraintWidth_max="@dimen/max_content_width">

<com.google.android.material.button.MaterialButton
android:id="@+id/save_as_draft"
style="?materialButtonOutlinedIconStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/save_as_draft"
android:layout_marginEnd="@dimen/margin_extra_small"
app:layout_goneMarginEnd="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/finalize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:icon="@drawable/ic_save_menu_24"
app:iconGravity="textStart" />

<com.google.android.material.button.MaterialButton
android:id="@+id/finalize"
style="?materialButtonIconStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/finalize"
android:layout_marginStart="@dimen/margin_extra_small"
app:layout_goneMarginStart="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/save_as_draft"
app:layout_constraintTop_toTopOf="parent"
app:icon="@drawable/ic_send_24"
app:iconGravity="textStart" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>