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

feat(bank-sdk): Onobarding landscape mode for phones #647

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:clickable="true"
android:orientation="vertical"
tools:context="net.gini.android.bank.sdk.capture.digitalinvoice.onboarding.DigitalInvoiceOnboardingFragment">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:fillViewport="true"
android:layout_marginVertical="@dimen/gc_large_24"
app:layout_constraintBottom_toTopOf="@+id/done_button"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/onboarding_text_1"
style="@style/GiniCaptureTheme.Typography.Headline6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="@dimen/gc_large_64"
android:layout_marginEnd="@dimen/gc_large_64"
android:gravity="center"
android:text="@string/gbs_digital_invoice_onboarding_text_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/digital_invoice_image_container"
app:layout_constraintTop_toTopOf="@+id/digital_invoice_image_container" />

<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/digital_invoice_image_container"
android:layout_width="250dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/gc_medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/onboarding_text_2"
style="@style/GiniCaptureTheme.Typography.Body1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="@dimen/gc_large_64"
android:layout_marginTop="16dp"
android:layout_marginEnd="@dimen/gc_large_64"
android:gravity="center"
android:lineSpacingExtra="5sp"
android:text="@string/gbs_digital_invoice_onboarding_text_2"
android:textColor="@color/gc_dark_06"
android:translationY="-2.62sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@id/digital_invoice_image_container"
app:layout_constraintTop_toBottomOf="@+id/onboarding_text_1" />


</androidx.constraintlayout.widget.ConstraintLayout>


<com.google.android.material.button.MaterialButton
android:id="@+id/done_button"
style="@style/GiniCaptureTheme.Widget.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/gc_large_32"
android:layout_marginStart="250dp"
android:text="@string/gbs_digital_invoice_onboarding_done_button_title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gbs_injected_navigation_bar_container_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import net.gini.android.capture.tracking.useranalytics.UserAnalytics
import net.gini.android.capture.tracking.useranalytics.properties.UserAnalyticsEventSuperProperty
import net.gini.android.capture.tracking.useranalytics.properties.UserAnalyticsUserProperty
import net.gini.android.capture.tracking.useranalytics.tracker.AmplitudeUserAnalyticsEventTracker
import net.gini.android.capture.util.safeNavigate
import java.util.UUID


Expand Down Expand Up @@ -154,7 +155,7 @@ class GiniCaptureFragment(
))
) {
oncePerInstallEventStore.saveEvent(OncePerInstallEvent.SHOW_ONBOARDING)
navController.navigate(CameraFragmentDirections.toOnboardingFragment())
safeNavigate(navController, CameraFragmentDirections.toOnboardingFragment())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ public void onCreate(final Bundle savedInstanceState) {
if (activity == null) {
return;
}
forcePortraitOrientationOnPhones(activity);
initFlashState();
if (savedInstanceState != null) {
restoreSavedState(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public void onCreate(final Bundle savedInstanceState) {
if (activity == null) {
throw new IllegalStateException("Missing activity for fragment.");
}
forcePortraitOrientationOnPhones(activity);

initPresenter(activity, getCustomOnboardingPages());
}

Expand Down Expand Up @@ -122,8 +120,10 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe

@Override
public void hideButtons() {
groupNextAndSkipButtons.setVisibility(View.GONE);
buttonGetStarted.setVisibility(View.GONE);
if (injectedNavigationBarBottomContainer != null) {
groupNextAndSkipButtons.setVisibility(View.GONE);
buttonGetStarted.setVisibility(View.GONE);
}
}

@Override
Expand All @@ -139,7 +139,6 @@ private void bindViews(final View view) {
buttonSkip = view.findViewById(R.id.gc_skip);
buttonGetStarted = view.findViewById(R.id.gc_get_started);
groupNextAndSkipButtons = view.findViewById(R.id.gc_next_skip_group);

handleSkipButtonMultipleLines();
}

Expand Down Expand Up @@ -202,10 +201,12 @@ public void showGetStartedButton() {
@Override
public void showGetStartedButtonInNavigationBarBottom() {
navigationBarBottomButtons = new OnboardingNavigationBarBottomButton[]{GET_STARTED};
injectedNavigationBarBottomContainer.modifyAdapterIfOwned(adapter -> {
adapter.showButtons(navigationBarBottomButtons);
return Unit.INSTANCE;
});
if (injectedNavigationBarBottomContainer != null) {
injectedNavigationBarBottomContainer.modifyAdapterIfOwned(adapter -> {
adapter.showButtons(navigationBarBottomButtons);
return Unit.INSTANCE;
});
}
}

@Override
Expand All @@ -217,20 +218,24 @@ public void showSkipAndNextButtons() {
@Override
public void showSkipAndNextButtonsInNavigationBarBottom() {
navigationBarBottomButtons = new OnboardingNavigationBarBottomButton[]{SKIP, NEXT};
injectedNavigationBarBottomContainer.modifyAdapterIfOwned(adapter -> {
adapter.showButtons(navigationBarBottomButtons);
return Unit.INSTANCE;
});
if (injectedNavigationBarBottomContainer != null) {
injectedNavigationBarBottomContainer.modifyAdapterIfOwned(adapter -> {
adapter.showButtons(navigationBarBottomButtons);
return Unit.INSTANCE;
});
}
}

@Override
public void setNavigationBarBottomAdapterInstance(@NonNull InjectedViewAdapterInstance<OnboardingNavigationBarBottomAdapter> adapterInstance) {
injectedNavigationBarBottomContainer.setInjectedViewAdapterHolder(new InjectedViewAdapterHolder<>(adapterInstance, injectedViewAdapter -> {
injectedViewAdapter.setOnNextButtonClickListener(new IntervalClickListener(v -> mPresenter.showNextPage()));
injectedViewAdapter.setOnSkipButtonClickListener(new IntervalClickListener(v -> mPresenter.skip()));
injectedViewAdapter.setOnGetStartedButtonClickListener(new IntervalClickListener(v -> mPresenter.showNextPage()));
injectedViewAdapter.showButtons(navigationBarBottomButtons);
}));
if (injectedNavigationBarBottomContainer != null) {
injectedNavigationBarBottomContainer.setInjectedViewAdapterHolder(new InjectedViewAdapterHolder<>(adapterInstance, injectedViewAdapter -> {
injectedViewAdapter.setOnNextButtonClickListener(new IntervalClickListener(v -> mPresenter.showNextPage()));
injectedViewAdapter.setOnSkipButtonClickListener(new IntervalClickListener(v -> mPresenter.skip()));
injectedViewAdapter.setOnGetStartedButtonClickListener(new IntervalClickListener(v -> mPresenter.showNextPage()));
injectedViewAdapter.showButtons(navigationBarBottomButtons);
}));
}
}

static class PageIndicators {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.gini.android.capture.util

import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.NavDirections
import org.slf4j.LoggerFactory

fun Fragment.safeNavigate(
navController: NavController,
navDirections: NavDirections,
) {
try {
navController.navigate(navDirections)
} catch (exception: java.lang.Exception) {
val logger = LoggerFactory.getLogger(this::class.java)
logger.error("Navigation exception " + exception.message)
}
}
124 changes: 124 additions & 0 deletions capture-sdk/sdk/src/main/res/layout-land/gc_fragment_onboarding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:orientation="vertical"
>

<androidx.viewpager.widget.ViewPager
android:id="@+id/gc_onboarding_viewpager"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/gc_medium"
android:layout_marginVertical="@dimen/gc_large_24"
android:layout_marginStart="@dimen/gc_medium"
android:contentDescription="@string/gc_onboarding_viewpager_content_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">

</androidx.viewpager.widget.ViewPager>


<LinearLayout
android:id="@+id/gc_layout_page_indicators"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gc_large_80"
android:layout_marginBottom="60dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/gc_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_guideline_image_start"/>

<androidx.constraintlayout.widget.Guideline
android:id="@+id/gc_guideline_image_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="270dp"/>

<TextView
android:id="@+id/gc_title"
style="@style/GiniCaptureTheme.Typography.Headline6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_medium"
android:layout_marginEnd="@dimen/gc_medium"
android:layout_marginTop="@dimen/gc_large_24"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_onboarding_viewpager"
app:layout_constraintTop_toTopOf="parent"
tools:text="Within the frame" />

<TextView
android:id="@+id/gc_message"
style="@style/GiniCaptureTheme.Typography.Body1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_large_64"
android:layout_marginTop="@dimen/gc_large"
android:layout_marginEnd="@dimen/gc_large_64"
android:gravity="center"
android:textColor="@color/gc_dark_06"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_onboarding_viewpager"
app:layout_constraintTop_toBottomOf="@+id/gc_title"
tools:text="Ensure that the document is flat, and positioned within the frame" />


<Button
android:id="@+id/gc_skip"
style="@style/GiniCaptureTheme.Widget.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_large_64"
android:layout_marginEnd="@dimen/gc_medium"
android:text="@string/gc_skip"
app:layout_constraintBottom_toBottomOf="@id/gc_onboarding_viewpager"
app:layout_constraintEnd_toStartOf="@id/gc_next"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/gc_guideline_image_start"
app:layout_constraintWidth_max="160dp"
app:layout_constraintWidth_min="120dp" />

<Button
android:id="@+id/gc_next"
style="@style/GiniCaptureTheme.Widget.Button.UnelevatedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/gc_large_64"
android:text="@string/gc_next"
app:layout_constraintBottom_toBottomOf="@id/gc_skip"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_skip"
app:layout_constraintTop_toTopOf="@id/gc_skip"
app:layout_constraintWidth_max="160dp"
app:layout_constraintWidth_min="120dp" />

<androidx.constraintlayout.widget.Group
android:id="@+id/gc_next_skip_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:constraint_referenced_ids="gc_skip,gc_next" />

<Button
android:id="@+id/gc_get_started"
style="@style/GiniCaptureTheme.Widget.Button.UnelevatedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="invisible"
android:text="@string/gc_get_started"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/gc_skip"
app:layout_constraintWidth_max="160dp"
app:layout_constraintWidth_min="120dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundColor">

<net.gini.android.capture.view.InjectedViewContainer
android:id="@+id/gc_injected_icon_container"
android:layout_width="240dp"
android:layout_height="260dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/gc_title"
style="@style/GiniCaptureTheme.Typography.Headline6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_medium"
android:layout_marginEnd="@dimen/gc_medium"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_injected_icon_container"
app:layout_constraintTop_toTopOf="@id/gc_injected_icon_container"
tools:text="Within the frame" />

<TextView
android:id="@+id/gc_message"
style="@style/GiniCaptureTheme.Typography.Body1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gc_large_64"
android:layout_marginTop="@dimen/gc_large"
android:layout_marginEnd="@dimen/gc_large_64"
android:gravity="center"
android:textColor="@color/gc_dark_06"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gc_injected_icon_container"
app:layout_constraintTop_toBottomOf="@+id/gc_title"
tools:text="Ensure that the document is flat, and positioned within the frame" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading