Skip to content

Commit

Permalink
Added invisible element (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrebane authored Sep 22, 2023
1 parent a55b43d commit 015b0b2
Show file tree
Hide file tree
Showing 25 changed files with 340 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ee.ria.DigiDoc.android.crypto.create;

import static android.view.View.GONE;
import static android.view.accessibility.AccessibilityEvent.TYPE_ANNOUNCEMENT;
import static com.jakewharton.rxbinding4.view.RxView.clicks;
import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
Expand Down Expand Up @@ -43,6 +44,7 @@
import ee.ria.DigiDoc.android.utils.files.EmptyFileException;
import ee.ria.DigiDoc.android.utils.mvi.MviView;
import ee.ria.DigiDoc.android.utils.mvi.State;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Screen;
import ee.ria.DigiDoc.android.utils.widget.ConfirmationDialog;
import ee.ria.DigiDoc.android.utils.widget.ErrorDialog;
Expand All @@ -55,7 +57,7 @@
import io.reactivex.rxjava3.subjects.PublishSubject;
import io.reactivex.rxjava3.subjects.Subject;

public final class CryptoCreateScreen extends Controller implements Screen,
public final class CryptoCreateScreen extends Controller implements Screen, ContentView,
MviView<Intent, ViewState> {

private static final String KEY_CONTAINER_FILE = "containerFile";
Expand Down Expand Up @@ -377,8 +379,8 @@ private void showSuccessNotification() {
}

private void setActivity(boolean activity) {
activityOverlayView.setVisibility(activity ? View.VISIBLE : View.GONE);
activityIndicatorView.setVisibility(activity ? View.VISIBLE : View.GONE);
activityOverlayView.setVisibility(activity ? View.VISIBLE : GONE);
activityIndicatorView.setVisibility(activity ? View.VISIBLE : GONE);
encryptButton.setEnabled(!activity);
decryptButton.setEnabled(!activity);
signButton.setEnabled(!activity);
Expand Down Expand Up @@ -440,6 +442,12 @@ protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup
disposables.add(viewModel.viewStates().subscribe(this::render));
viewModel.process(intents());

ContentView.addInvisibleElement(getApplicationContext(), view);

View lastElementView = view.findViewById(R.id.lastInvisibleElement);

ContentView.addInvisibleElementScrollListener(listView, lastElementView);

return view;
}

Expand All @@ -448,6 +456,7 @@ protected void onDestroyView(@NonNull View view) {
decryptDialog.dismiss();
errorDialog.dismiss();
sivaConfirmationDialog.dismiss();
ContentView.removeInvisibleElementScrollListener(listView);
disposables.detach();
super.onDestroyView(view);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static ee.ria.DigiDoc.android.Constants.MAXIMUM_PERSONAL_CODE_LENGTH;
import static ee.ria.DigiDoc.android.Constants.VOID;
import static ee.ria.DigiDoc.android.utils.ViewUtil.moveView;

import android.content.Context;
import android.graphics.Color;
Expand Down Expand Up @@ -48,6 +49,7 @@
import ee.ria.DigiDoc.android.utils.display.DisplayUtil;
import ee.ria.DigiDoc.android.utils.mvi.MviView;
import ee.ria.DigiDoc.android.utils.mvi.State;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Screen;
import ee.ria.DigiDoc.android.utils.validator.PersonalCodeValidator;
Expand All @@ -57,7 +59,7 @@
import io.reactivex.rxjava3.subjects.PublishSubject;
import io.reactivex.rxjava3.subjects.Subject;

public final class CryptoRecipientsScreen extends Controller implements Screen,
public final class CryptoRecipientsScreen extends Controller implements Screen, ContentView,
MviView<Intent, ViewState>, Navigator.BackButtonClickListener {

private static final String KEY_CRYPTO_CREATE_SCREEN_ID = "cryptoCreateScreenId";
Expand All @@ -79,6 +81,7 @@ public static CryptoRecipientsScreen create(String cryptoCreateScreenId) {
private Toolbar toolbarView;
private SearchView searchView;
private EditText searchViewInnerText;
private RecyclerView listView;
private CryptoCreateAdapter adapter;
private View doneButton;
private View activityOverlayView;
Expand Down Expand Up @@ -333,13 +336,20 @@ public void afterTextChanged(Editable s) {

searchView.setSubmitButtonEnabled(true);
searchView.setEnabled(true);
RecyclerView listView = view.findViewById(R.id.cryptoRecipientsList);
listView = view.findViewById(R.id.cryptoRecipientsList);
listView.setLayoutManager(new LinearLayoutManager(container.getContext()));
listView.setAdapter(adapter = new CryptoCreateAdapter());
listView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
doneButton = view.findViewById(R.id.cryptoRecipientsDoneButton);
activityOverlayView = view.findViewById(R.id.activityOverlay);
activityIndicatorView = view.findViewById(R.id.activityIndicator);

ContentView.addInvisibleElement(getApplicationContext(), view);

View lastElementView = view.findViewById(R.id.lastInvisibleElement);

ContentView.addInvisibleElementScrollListener(listView, lastElementView);

return view;
}

Expand Down Expand Up @@ -372,6 +382,7 @@ protected void onDetach(@NonNull View view) {
disposables.detach();
navigator.removeBackButtonClickListener(this);
searchView.setOnCloseListener(null);
ContentView.removeInvisibleElementScrollListener(listView);
ee.ria.DigiDoc.android.utils.TextUtil.removeTextWatcher(searchViewInnerText,searchViewTextWatcher);
super.onDetach(view);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
import ee.ria.DigiDoc.android.eid.CodeUpdateError.CodeSameAsCurrentError;
import ee.ria.DigiDoc.android.eid.CodeUpdateError.CodeTooEasyError;
import ee.ria.DigiDoc.android.utils.mvi.State;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import io.reactivex.rxjava3.core.Observable;

import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static com.jakewharton.rxbinding4.view.RxView.clicks;
import static ee.ria.DigiDoc.android.utils.ErrorMessageUtil.setTextViewError;
import static ee.ria.DigiDoc.android.utils.InputMethodUtils.hideSoftKeyboard;

public final class CodeUpdateView extends CoordinatorLayout {
public final class CodeUpdateView extends CoordinatorLayout implements ContentView {

private final Toolbar toolbarView;
private final TextView successMessageView;
Expand Down Expand Up @@ -88,6 +89,8 @@ public CodeUpdateView(Context context, @Nullable AttributeSet attrs, int defStyl
activityOverlayView = findViewById(R.id.activityOverlay);
activityIndicatorView = findViewById(R.id.activityIndicator);
scrollView = findViewById(R.id.eidHomeCodeUpdateScroll);

ContentView.addInvisibleElement(context, this);
}

public void render(@State String state, CodeUpdateAction action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

import ee.ria.DigiDoc.BuildConfig;
import ee.ria.DigiDoc.R;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.common.TextUtil;

final class AboutAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final class AboutAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements ContentView {

private final ImmutableList<Component> components = ImmutableList.<Component>builder()
.add(Component.create(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package ee.ria.DigiDoc.android.main.about;

import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static ee.ria.DigiDoc.android.utils.navigator.ContentView.addInvisibleElement;
import static ee.ria.DigiDoc.android.utils.navigator.ContentView.addInvisibleElementScrollListener;
import static ee.ria.DigiDoc.android.utils.navigator.ContentView.removeInvisibleElementScrollListener;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -20,14 +25,14 @@
import ee.ria.DigiDoc.android.utils.navigator.Screen;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;

import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;

public final class AboutScreen extends Controller implements Screen {

public static AboutScreen create() {
return new AboutScreen();
}

private RecyclerView listView;

private final ViewDisposables disposables = new ViewDisposables();

@SuppressWarnings("WeakerAccess")
Expand All @@ -45,10 +50,14 @@ protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup
toolbarView.setTitle(R.string.main_about_title);
toolbarView.setNavigationIcon(androidx.appcompat.R.drawable.abc_ic_ab_back_material);
toolbarView.setNavigationContentDescription(R.string.back);
RecyclerView listView = view.findViewById(R.id.mainAboutList);
listView = view.findViewById(R.id.mainAboutList);
listView.setLayoutManager(new LinearLayoutManager(container.getContext()));
listView.setAdapter(new AboutAdapter());

addInvisibleElement(getApplicationContext(), view);
View lastElementView = view.findViewById(R.id.lastInvisibleElement);
addInvisibleElementScrollListener(listView, lastElementView);

disposables.attach();
disposables.add(navigationClicks(toolbarView).subscribe(ignored ->
ApplicationApp.component(container.getContext()).navigator().execute(Transaction.pop())));
Expand All @@ -59,6 +68,7 @@ protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup
@Override
protected void onDestroyView(@NonNull View view) {
disposables.detach();
removeInvisibleElementScrollListener(listView);
super.onDestroyView(view);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package ee.ria.DigiDoc.android.main.accessibility;

import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static ee.ria.DigiDoc.android.utils.TextUtil.getInvisibleElementTextView;
import static ee.ria.DigiDoc.android.utils.ViewUtil.findLastElement;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toolbar;

import androidx.coordinatorlayout.widget.CoordinatorLayout;

import ee.ria.DigiDoc.R;
import ee.ria.DigiDoc.android.ApplicationApp;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;

public class AccessibilityView extends CoordinatorLayout {
public class AccessibilityView extends CoordinatorLayout implements ContentView {

private final Toolbar toolbarView;

Expand All @@ -40,6 +45,8 @@ public AccessibilityView(Context context, AttributeSet attrs, int defStyleAttr)
toolbarView.setTitle(R.string.main_accessibility_title);
toolbarView.setNavigationIcon(androidx.appcompat.R.drawable.abc_ic_ab_back_material);
toolbarView.setNavigationContentDescription(R.string.back);

ContentView.addInvisibleElement(getContext(), this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static ee.ria.DigiDoc.android.main.diagnostics.DiagnosticsScreen.diagnosticsFileSaveClicksSubject;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -52,6 +53,8 @@
import ee.ria.DigiDoc.android.utils.TSLException;
import ee.ria.DigiDoc.android.utils.TSLUtil;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.ViewUtil;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;
import ee.ria.DigiDoc.android.utils.widget.ConfirmationDialog;
Expand All @@ -69,7 +72,7 @@
import okhttp3.Response;
import timber.log.Timber;

public final class DiagnosticsView extends CoordinatorLayout {
public final class DiagnosticsView extends CoordinatorLayout implements ContentView {

private final Navigator navigator;
private final SimpleDateFormat dateFormat;
Expand All @@ -94,6 +97,8 @@ public DiagnosticsView(Context context) {
View saveDiagnosticsButton = findViewById(R.id.configurationSaveButton);
navigator = ApplicationApp.component(context).navigator();

ContentView.addInvisibleElement(getContext(), this);

diagnosticsRestartConfirmationDialog = new ConfirmationDialog(navigator.activity(),
R.string.main_diagnostics_restart_message, R.id.mainDiagnosticsRestartConfirmationDialog);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@

import ee.ria.DigiDoc.R;
import ee.ria.DigiDoc.android.utils.display.DisplayUtil;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.common.TextUtil;
import io.reactivex.rxjava3.core.Observable;

import static com.jakewharton.rxbinding4.view.RxView.clicks;
import static com.jakewharton.rxbinding4.widget.RxRadioGroup.checkedChanges;
import static ee.ria.DigiDoc.android.utils.TintUtils.tintCompoundDrawables;

public final class HomeMenuView extends NestedScrollView {
public final class HomeMenuView extends NestedScrollView implements ContentView {

private final View closeButton;

Expand Down Expand Up @@ -139,6 +140,8 @@ public HomeMenuView(@NonNull Context context, @Nullable AttributeSet attrs, int
}, 2000);

setFontSize();

ContentView.addInvisibleElement(getContext(), this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
import ee.ria.DigiDoc.android.utils.TextUtil;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.mvi.MviView;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.subjects.PublishSubject;
import io.reactivex.rxjava3.subjects.Subject;

import static com.jakewharton.rxbinding4.material.RxBottomNavigationView.itemSelections;
import static ee.ria.DigiDoc.android.utils.Predicates.duplicates;
import static ee.ria.DigiDoc.android.utils.ViewUtil.moveView;
import static ee.ria.DigiDoc.android.utils.rxbinding.app.RxDialog.cancels;

@SuppressLint("ViewConstructor")
public final class HomeView extends LinearLayout implements MviView<Intent, ViewState> {
public final class HomeView extends LinearLayout implements ContentView, MviView<Intent, ViewState> {

public interface HomeViewChild {

Expand Down Expand Up @@ -93,6 +95,11 @@ public HomeView(Context context, android.content.Intent intent, String screenId)
viewModel = ApplicationApp.component(context).navigator().viewModel(screenId,
HomeViewModel.class);
viewModel.eidScreenId(eidScreenId);

ContentView.addInvisibleElement(getContext(), navigationContainerView);

View lastElementView = findViewById(R.id.lastInvisibleElement);
moveView(lastElementView);
}

private void setCustomAccessibilityFeedback(BottomNavigationItemView bottomNavigationItemView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import ee.ria.DigiDoc.android.ApplicationApp;
import ee.ria.DigiDoc.android.main.settings.access.SettingsAccessScreen;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;

public final class SettingsView extends CoordinatorLayout {
public final class SettingsView extends CoordinatorLayout implements ContentView {

private final Toolbar toolbarView;
private final Button accessCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import ee.ria.DigiDoc.android.ApplicationApp;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.mvi.MviView;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import io.reactivex.rxjava3.core.Observable;

@SuppressLint("ViewConstructor")
public final class SignatureCreateView extends FrameLayout implements MviView<Intent, ViewState> {
public final class SignatureCreateView extends FrameLayout implements ContentView, MviView<Intent, ViewState> {

@Nullable private final android.content.Intent intent;

Expand All @@ -27,6 +28,8 @@ public SignatureCreateView(@NonNull Context context, String screenId,
viewModel = ApplicationApp.component(context).navigator()
.viewModel(screenId, SignatureCreateViewModel.class);
inflate(context, R.layout.signature_create, this);

ContentView.addInvisibleElement(getContext(), this);
}

private Observable<Intent.InitialIntent> initialIntent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
import ee.ria.DigiDoc.android.utils.TextUtil;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.ViewSavedState;
import ee.ria.DigiDoc.android.utils.navigator.ContentView;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;
import timber.log.Timber;

@SuppressLint("ViewConstructor")
public final class CertificateDetailView extends CoordinatorLayout {
public final class CertificateDetailView extends CoordinatorLayout implements ContentView {

private final Navigator navigator;
private final Toolbar toolbarView;
Expand All @@ -76,6 +77,8 @@ public CertificateDetailView(Context context, X509Certificate certificate) {
toolbarView.setNavigationContentDescription(R.string.back);

setData(certificate);

ContentView.addInvisibleElement(context, this);
}


Expand Down
Loading

0 comments on commit 015b0b2

Please sign in to comment.