Search in sources :

Example 31 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project krypton-android by kryptco.

the class MemberScan method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.fragment_teams_invite_inperson_scan, container, false);
    lastScannedPayload.set(null);
    barcodeView = v.findViewById(R.id.camera_preview_in_person_scan);
    barcodeView.decodeContinuous(new BarcodeCallback() {

        @Override
        public void barcodeResult(BarcodeResult result) {
            if (result.getText() != null) {
                try {
                    Sigchain.AdminQRPayload qr = JSON.fromJson(result.getText(), Sigchain.QRPayload.class).adminQRPayload;
                    if (qr == null) {
                        Error.shortToast(getContext(), "Make sure you are scanning an admin that is already on a team.");
                        return;
                    }
                    if (lastScannedPayload.compareAndSet(null, qr)) {
                        Transitions.beginSlide(MemberScan.this).addToBackStack(null).replace(R.id.fragmentOverlay, new MemberEnterEmail()).commitAllowingStateLoss();
                    } else {
                        Log.i(TAG, "not first scan");
                    }
                } catch (JsonParseException e) {
                    Log.e(TAG, "could not parse QR code", e);
                    Error.shortToast(getContext(), "Invalid QR code");
                }
            }
        }

        @Override
        public void possibleResultPoints(List<ResultPoint> resultPoints) {
        }
    });
    AppCompatTextView detailText = v.findViewById(R.id.inPersonScanDetail);
    detailText.setText("Scan your team admin's QR code to join their team.");
    return v;
}
Also used : BarcodeResult(com.journeyapps.barcodescanner.BarcodeResult) BarcodeCallback(com.journeyapps.barcodescanner.BarcodeCallback) ResultPoint(com.google.zxing.ResultPoint) Sigchain(co.krypt.krypton.team.Sigchain) AppCompatTextView(android.support.v7.widget.AppCompatTextView) JsonParseException(com.google.gson.JsonParseException) AppCompatTextView(android.support.v7.widget.AppCompatTextView) BarcodeView(com.journeyapps.barcodescanner.BarcodeView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 32 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project krypton-android by kryptco.

the class LoaderOverlay method start.

public static void start(Activity a, String text) {
    if (a == null) {
        return;
    }
    new Handler(Looper.getMainLooper()).post(() -> {
        ConstraintLayout globalContainer = a.findViewById(R.id.team_loader_overlay_container);
        if (globalContainer == null) {
            return;
        }
        View container = globalContainer.findViewById(R.id.teams_loader);
        AppCompatTextView loaderText = container.findViewById(R.id.text);
        ProgressBar progressBar = container.findViewById(R.id.progressBar);
        progressBar.setAlpha(1f);
        AppCompatImageView check = container.findViewById(R.id.check);
        check.setAlpha(0f);
        AppCompatImageView problem = container.findViewById(R.id.problem);
        problem.setAlpha(0f);
        loaderText.setTextColor(a.getColor(R.color.appBlack));
        loaderText.setText(text);
        container.setAlpha(0f);
        container.animate().setDuration(500).alpha(1).start();
    });
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView) Handler(android.os.Handler) AppCompatImageView(android.support.v7.widget.AppCompatImageView) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ProgressBar(android.widget.ProgressBar) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ConstraintLayout(android.support.constraint.ConstraintLayout)

Example 33 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project krypton-android by kryptco.

the class LoaderOverlay method success.

public static void success(Activity a, String text) {
    if (a == null) {
        return;
    }
    new Handler(Looper.getMainLooper()).post(() -> {
        ConstraintLayout globalContainer = a.findViewById(R.id.team_loader_overlay_container);
        if (globalContainer == null) {
            return;
        }
        ConstraintLayout container = globalContainer.findViewById(R.id.teams_loader);
        container.setAlpha(1f);
        AppCompatTextView loaderText = container.findViewById(R.id.text);
        ProgressBar progressBar = container.findViewById(R.id.progressBar);
        AppCompatImageView check = container.findViewById(R.id.check);
        AppCompatImageView problem = container.findViewById(R.id.problem);
        progressBar.animate().setDuration(500).alpha(0f).start();
        check.animate().setDuration(500).alpha(1f).start();
        problem.setAlpha(0f);
        loaderText.setTextColor(a.getColor(R.color.appBlack));
        loaderText.setText(text);
        progressBar.setAlpha(1);
        progressBar.animate().setDuration(500).alpha(0);
        container.animate().setStartDelay(1000).setDuration(500).alpha(0);
    });
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView) Handler(android.os.Handler) ProgressBar(android.widget.ProgressBar) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ConstraintLayout(android.support.constraint.ConstraintLayout)

Example 34 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project krypton-android by kryptco.

the class OnboardingVerifyEmailFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_teams_onboarding_verify_email, container, false);
    Button cancelButton = rootView.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(v -> {
        progress.reset();
        getActivity().finish();
    });
    ProgressBar progressBar = rootView.findViewById(R.id.progressBar);
    progressBar.setAlpha(0);
    Button changeButton = rootView.findViewById(R.id.changeButton);
    changeButton.setEnabled(false);
    Button resendButton = rootView.findViewById(R.id.resendButton);
    resendButton.setEnabled(false);
    ConstraintLayout checkYourEmailContainer = rootView.findViewById(R.id.checkYourEmailContainer);
    checkYourEmailContainer.setAlpha(0);
    AppCompatTextView teamName = rootView.findViewById(R.id.teamName);
    teamName.setText(progress.getTeamOnboardingData().name);
    emailEditText = rootView.findViewById(R.id.profileEmail);
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    Runnable focusEmail = () -> {
        emailEditText.setEnabled(true);
        emailEditText.requestFocus();
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
        progressBar.animate().alpha(0).setDuration(500).start();
    };
    focusEmail.run();
    Runnable requestEmailChallenge = () -> {
        emailEditText.setEnabled(false);
        emailEditText.clearFocus();
        if (imm != null) {
            imm.hideSoftInputFromWindow(emailEditText.getWindowToken(), 0);
        }
        progressBar.animate().alpha(1).setDuration(1000).start();
        final String email = emailEditText.getEditableText().toString();
        new Thread(() -> {
            MeStorage meStorage = Silo.shared(getContext()).meStorage();
            try {
                meStorage.setEmail(email);
            } catch (CryptoException e) {
                Error.shortToast(getContext(), "Failed to set email: " + e.getMessage());
                e.printStackTrace();
                return;
            }
            Profile me = meStorage.load();
            progress.updateTeamData((s, d) -> {
                if (s.equals(CreateStage.VERIFY_EMAIL) || s.equals(CreateStage.EMAIL_CHALLENGE_SENT)) {
                    d.creatorProfile = me;
                    Log.i(TAG, "requesting email challenge...");
                    try {
                        final Sigchain.NativeResult<JsonObject> result = TeamDataProvider.requestEmailChallenge(getContext(), email);
                        emailEditText.post(() -> {
                            if (result.success != null) {
                                Log.i(TAG, "request email challenge success");
                                progressBar.animate().alpha(0).setDuration(500).start();
                                checkYourEmailContainer.animate().alpha(1).setDuration(1000).start();
                                changeButton.setEnabled(true);
                                resendButton.setEnabled(true);
                            } else {
                                Log.i(TAG, "request email challenge failure: " + result.error);
                                Error.shortToast(getContext(), "Error sending email: " + result.error);
                                focusEmail.run();
                            }
                        });
                        if (result.success != null) {
                            return CreateStage.EMAIL_CHALLENGE_SENT;
                        } else {
                            return s;
                        }
                    } catch (Native.NotLinked notLinked) {
                        notLinked.printStackTrace();
                    }
                }
                return s;
            });
        }).start();
    };
    emailEditText.setOnEditorActionListener((v, i, ev) -> {
        requestEmailChallenge.run();
        return false;
    });
    emailEditText.setOnFocusChangeListener((view, b) -> {
        if (view.isEnabled() && !b) {
            requestEmailChallenge.run();
        }
    });
    resendButton.setOnClickListener(v -> {
        requestEmailChallenge.run();
    });
    changeButton.setOnClickListener(v -> {
        focusEmail.run();
    });
    Button submitButton = rootView.findViewById(R.id.submitButton);
    submitButton.setEnabled(false);
    submitButton.setAlpha(0);
    submitButton.setOnClickListener(v -> {
        FragmentManager fragmentManager = getFragmentManager();
        if (fragmentManager != null) {
            fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.fragment_teams, new OnboardingLoadTeamFragment()).commitNowAllowingStateLoss();
        }
    });
    EventBus.getDefault().register(this);
    EventBus.getDefault().post(new IdentityService.GetProfile(getContext()));
    return rootView;
}
Also used : Sigchain(co.krypt.krypton.team.Sigchain) AppCompatTextView(android.support.v7.widget.AppCompatTextView) JsonObject(com.google.gson.JsonObject) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) Profile(co.krypt.krypton.protocol.Profile) ConstraintLayout(android.support.constraint.ConstraintLayout) Native(co.krypt.krypton.team.Native) FragmentManager(android.support.v4.app.FragmentManager) IdentityService(co.krypt.krypton.silo.IdentityService) Button(android.widget.Button) MeStorage(co.krypt.krypton.me.MeStorage) CryptoException(co.krypt.krypton.exception.CryptoException) ProgressBar(android.widget.ProgressBar)

Example 35 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project krypton-android by kryptco.

the class OnboardingLoadInviteLinkFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_teams_onboarding_load_team, container, false);
    Button cancelButton = rootView.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(v -> {
        progress.resetAndDeleteTeam(v.getContext());
        getActivity().finish();
    });
    ProgressBar progressBar = rootView.findViewById(R.id.progressBar);
    errorText = rootView.findViewById(R.id.errorText);
    errorText.setAlpha(0);
    AppCompatTextView progressText = rootView.findViewById(R.id.progressText);
    progressText.setText("LOADING TEAM INVITE");
    return rootView;
}
Also used : Button(android.widget.Button) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) View(android.view.View) ProgressBar(android.widget.ProgressBar)

Aggregations

AppCompatTextView (android.support.v7.widget.AppCompatTextView)45 View (android.view.View)26 AppCompatButton (android.support.v7.widget.AppCompatButton)9 AppCompatImageView (android.support.v7.widget.AppCompatImageView)7 ProgressBar (android.widget.ProgressBar)7 Sigchain (co.krypt.krypton.team.Sigchain)7 AlertDialog (android.support.v7.app.AlertDialog)6 Button (android.widget.Button)6 DialogInterface (android.content.DialogInterface)4 ConstraintLayout (android.support.constraint.ConstraintLayout)4 ViewGroup (android.view.ViewGroup)4 TextView (android.widget.TextView)4 Context (android.content.Context)3 Handler (android.os.Handler)3 Nullable (android.support.annotation.Nullable)3 Espresso.onView (android.support.test.espresso.Espresso.onView)3 MediumTest (android.support.test.filters.MediumTest)3 AppCompatEditText (android.support.v7.widget.AppCompatEditText)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2