Search in sources :

Example 36 with AppCompatTextView

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

the class VerifyEmailFragment 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.resetAndDeleteTeam(v.getContext());
        getActivity().finish();
    });
    ProgressBar progressBar = rootView.findViewById(R.id.progressBar);
    progressBar.setAlpha(0);
    Button submitButton = rootView.findViewById(R.id.submitButton);
    Button changeButton = rootView.findViewById(R.id.changeButton);
    Button resendButton = rootView.findViewById(R.id.resendButton);
    AppCompatTextView checkYourEmailText = rootView.findViewById(R.id.checkYourEmailText);
    AppCompatTextView checkYourEmailSubtext = rootView.findViewById(R.id.checkYourEmailSubtext);
    AppCompatEditText emailEditText = rootView.findViewById(R.id.profileEmail);
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    Runnable onSubmitUI = () -> {
        emailEditText.setEnabled(false);
        emailEditText.clearFocus();
        if (imm != null) {
            imm.hideSoftInputFromWindow(emailEditText.getWindowToken(), 0);
        }
        progressBar.animate().alpha(1).setDuration(1000).start();
        submitButton.setEnabled(false);
        submitButton.animate().alpha(0).setDuration(500).start();
        checkYourEmailSubtext.animate().alpha(0).setDuration(500).start();
        checkYourEmailText.animate().alpha(0).setDuration(500).start();
    };
    Runnable onEditUI = () -> {
        emailEditText.setEnabled(true);
        submitButton.animate().alpha(1).setDuration(500).start();
        changeButton.animate().alpha(0).setDuration(500).start();
        resendButton.animate().alpha(0).setDuration(500).start();
        submitButton.setEnabled(true);
        changeButton.setEnabled(false);
        resendButton.setEnabled(false);
        checkYourEmailSubtext.animate().alpha(0).setDuration(500).start();
        checkYourEmailText.animate().alpha(0).setDuration(500).start();
        progressBar.animate().alpha(0).setDuration(500).start();
    };
    Runnable onSuccessUI = () -> {
        progressBar.animate().alpha(0).setDuration(500).start();
        changeButton.animate().alpha(1).setDuration(1000).start();
        resendButton.animate().alpha(1).setDuration(1000).start();
        submitButton.animate().alpha(0).setDuration(500).start();
        changeButton.setEnabled(true);
        resendButton.setEnabled(true);
        checkYourEmailSubtext.animate().alpha(1).setDuration(500).start();
        checkYourEmailText.animate().alpha(1).setDuration(500).start();
    };
    Runnable focusEmail = () -> {
        onEditUI.run();
        emailEditText.requestFocus();
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
    };
    Runnable onErrorUI = () -> {
        focusEmail.run();
        Toast.makeText(getContext(), "Error sending email verification.", Toast.LENGTH_SHORT).show();
    };
    submitButton.setAlpha(1);
    changeButton.setAlpha(0);
    resendButton.setAlpha(0);
    checkYourEmailSubtext.setAlpha(0);
    checkYourEmailText.setAlpha(0);
    changeButton.setEnabled(false);
    resendButton.setEnabled(false);
    AppCompatTextView teamName = rootView.findViewById(R.id.teamName);
    teamName.setText(progress.getTeamOnboardingData().decryptInviteOutput.teamName);
    String initialEmail = Silo.shared(getContext().getApplicationContext()).meStorage().load().email;
    emailEditText.setText(initialEmail);
    final Sigchain.IndirectInvitationRestriction restriction = progress.getTeamOnboardingData().decryptInviteOutput.indirectInvitationSecret.restriction;
    Runnable requestEmailChallenge = () -> {
        final String email = emailEditText.getEditableText().toString();
        if (!Email.verifyEmailPattern.matcher(email).matches()) {
            Toast.makeText(getContext(), "Please enter a valid email.", Toast.LENGTH_SHORT).show();
            return;
        }
        if (!restriction.isSatisfiedByEmail(email)) {
            if (restriction.domain != null) {
                Toast.makeText(getContext(), "Email must end with @" + restriction.domain, Toast.LENGTH_SHORT).show();
            } else if (restriction.emails != null) {
                Toast.makeText(getContext(), "Invite link not valid for this email address.", Toast.LENGTH_SHORT).show();
            }
            return;
        }
        onSubmitUI.run();
        new Thread(() -> {
            MeStorage meStorage = Silo.shared(getContext()).meStorage();
            try {
                meStorage.setEmail(email);
            } catch (CryptoException e) {
                co.krypt.krypton.uiutils.Error.shortToast(getContext(), "Failed to set email: " + e.getMessage());
                e.printStackTrace();
                return;
            }
            Profile me = meStorage.load();
            progress.updateTeamData((s, d) -> {
                if (s.equals(JoinStage.VERIFY_EMAIL)) {
                    d.profile = 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");
                                onSuccessUI.run();
                            } else {
                                Log.i(TAG, "request email challenge failure");
                                onErrorUI.run();
                            }
                        });
                        if (result.success != null) {
                            return JoinStage.CHALLENGE_EMAIL_SENT;
                        } else {
                            return s;
                        }
                    } catch (Native.NotLinked notLinked) {
                        notLinked.printStackTrace();
                    }
                }
                return s;
            });
        }).start();
    };
    final Runnable setSelectionBeforeDomain = () -> {
        String currentEmail = emailEditText.getText().toString();
        if (restriction.domain != null) {
            String domainSuffix = "@" + restriction.domain;
            if (currentEmail.length() >= domainSuffix.length()) {
                if (emailEditText.getSelectionStart() == emailEditText.getSelectionEnd()) {
                    if (emailEditText.getSelectionStart() > currentEmail.length() - domainSuffix.length()) {
                        emailEditText.setSelection(currentEmail.length() - domainSuffix.length());
                    }
                }
            }
        }
    };
    emailEditText.setOnEditorActionListener((v, i, ev) -> {
        requestEmailChallenge.run();
        return false;
    });
    // focus before adding listener
    focusEmail.run();
    setSelectionBeforeDomain.run();
    emailEditText.setOnFocusChangeListener((view, b) -> {
        if (view.isEnabled()) {
            if (b) {
                setSelectionBeforeDomain.run();
            }
        }
    });
    emailEditText.setOnClickListener(v -> setSelectionBeforeDomain.run());
    final AtomicReference<String> lastEmail = new AtomicReference<>(new String(emailEditText.getText().toString()));
    if (!restriction.isSatisfiedByEmail(lastEmail.get())) {
        if (restriction.domain != null) {
            lastEmail.set("@" + restriction.domain);
        } else if (restriction.emails != null && restriction.emails.length == 1) {
            lastEmail.set(restriction.emails[0]);
        } else {
            lastEmail.set("");
        }
        emailEditText.setText(lastEmail.get());
    }
    final Runnable updateTextColor = () -> {
        if (Email.verifyEmailPattern.matcher(emailEditText.getText()).matches()) {
            emailEditText.setTextColor(getContext().getColor(R.color.appGreen));
        } else {
            emailEditText.setTextColor(getContext().getColor(R.color.appGray));
        }
    };
    updateTextColor.run();
    final TextWatcher domainCheck = new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            lastEmail.set(s.toString());
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateTextColor.run();
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (restriction.domain != null) {
                if (!s.toString().endsWith("@" + restriction.domain)) {
                    emailEditText.removeTextChangedListener(this);
                    s.clear();
                    s.append(lastEmail.get());
                    setSelectionBeforeDomain.run();
                    emailEditText.addTextChangedListener(this);
                    Toast.makeText(getContext(), "Email must end with @" + restriction.domain, Toast.LENGTH_SHORT).show();
                }
            }
        }
    };
    emailEditText.addTextChangedListener(domainCheck);
    resendButton.setOnClickListener(v -> {
        requestEmailChallenge.run();
    });
    changeButton.setOnClickListener(v -> {
        focusEmail.run();
    });
    submitButton.setOnClickListener(v -> requestEmailChallenge.run());
    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) AtomicReference(java.util.concurrent.atomic.AtomicReference) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) Profile(co.krypt.krypton.protocol.Profile) Native(co.krypt.krypton.team.Native) AppCompatEditText(android.support.v7.widget.AppCompatEditText) Button(android.widget.Button) MeStorage(co.krypt.krypton.me.MeStorage) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) CryptoException(co.krypt.krypton.exception.CryptoException) ProgressBar(android.widget.ProgressBar)

Example 37 with AppCompatTextView

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

the class OnboardingLoadTeamFragment 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);
    final CreateTeamProgress progress = new CreateTeamProgress(getContext());
    Button cancelButton = rootView.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(v -> {
        progress.reset();
        getActivity().finish();
    });
    progressBar = rootView.findViewById(R.id.progressBar);
    errorText = rootView.findViewById(R.id.errorText);
    errorText.setAlpha(0);
    AppCompatTextView progressText = rootView.findViewById(R.id.progressText);
    progressText.setText("CREATING TEAM");
    return rootView;
}
Also used : Button(android.widget.Button) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) View(android.view.View)

Example 38 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project EssayJoke by qiyei2015.

the class SkinAppCompatViewInflater method createView.

public final View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs, boolean inheritContext, boolean readAndroidTheme, boolean readAppTheme) {
    final Context originalContext = context;
    // by using the parent's context
    if (inheritContext && parent != null) {
        context = parent.getContext();
    }
    if (readAndroidTheme || readAppTheme) {
        // We then apply the theme on the context, if specified
        context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
    }
    View view = null;
    // We need to 'inject' our tint aware Views in place of the standard framework versions
    switch(name) {
        case "TextView":
            view = new AppCompatTextView(context, attrs);
            break;
        case "ImageView":
            view = new AppCompatImageView(context, attrs);
            break;
        case "Button":
            view = new AppCompatButton(context, attrs);
            break;
        case "EditText":
            view = new AppCompatEditText(context, attrs);
            break;
        case "Spinner":
            view = new AppCompatSpinner(context, attrs);
            break;
        case "ImageButton":
            view = new AppCompatImageButton(context, attrs);
            break;
        case "CheckBox":
            view = new AppCompatCheckBox(context, attrs);
            break;
        case "RadioButton":
            view = new AppCompatRadioButton(context, attrs);
            break;
        case "CheckedTextView":
            view = new AppCompatCheckedTextView(context, attrs);
            break;
        case "AutoCompleteTextView":
            view = new AppCompatAutoCompleteTextView(context, attrs);
            break;
        case "MultiAutoCompleteTextView":
            view = new AppCompatMultiAutoCompleteTextView(context, attrs);
            break;
        case "RatingBar":
            view = new AppCompatRatingBar(context, attrs);
            break;
        case "SeekBar":
            view = new AppCompatSeekBar(context, attrs);
            break;
    }
    if (view == null) {
        // If the original context does not equal our themed context, then we need to manually
        // inflate it using the name so that android:theme takes effect.
        view = createViewFromTag(context, name, attrs);
    }
    if (view != null) {
        // If we have created a view, check it's android:onClick
        checkOnClickListener(view, attrs);
    }
    return view;
}
Also used : Context(android.content.Context) AppCompatSeekBar(android.support.v7.widget.AppCompatSeekBar) AppCompatRadioButton(android.support.v7.widget.AppCompatRadioButton) AppCompatRatingBar(android.support.v7.widget.AppCompatRatingBar) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView) View(android.view.View) AppCompatImageView(android.support.v7.widget.AppCompatImageView) AppCompatMultiAutoCompleteTextView(android.support.v7.widget.AppCompatMultiAutoCompleteTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) AppCompatMultiAutoCompleteTextView(android.support.v7.widget.AppCompatMultiAutoCompleteTextView) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView)

Example 39 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project ps-advisor-app by wpi-poverty-stoplight.

the class ResumeSnapshotPopupWindow method createContentView.

@Override
protected View createContentView(ViewGroup parent) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.view_resumesnapshotpopup, parent, false);
    ((AdvisorApplication) getContext().getApplicationContext()).getApplicationComponent().inject(this);
    mViewModel = ViewModelProviders.of((FragmentActivity) getContext(), mViewModelFactory).get(ResumeSnapshotPopupViewModel.class);
    AppCompatButton continueButton = view.findViewById(R.id.btn_resumesnapshotpopup_continue);
    continueButton.setOnClickListener((event) -> {
        if (mOnContinueCallback != null) {
            mOnContinueCallback.onContinue(this, mViewModel.getSnapshot(), mViewModel.getSurvey(), mViewModel.getFamily());
        }
    });
    AppCompatButton dismissButton = view.findViewById(R.id.btn_resumesnapshotpopup_dismiss);
    dismissButton.setOnClickListener((event) -> {
        if (mOnDismissCallback != null) {
            mOnDismissCallback.onDismiss(this, mViewModel.getSnapshot(), mViewModel.getSurvey(), mViewModel.getFamily());
        }
    });
    AppCompatTextView title = view.findViewById(R.id.tv_resumesnapshotpopup_snapshottitle);
    mViewModel.family().observe((FragmentActivity) getContext(), (family) -> {
        String familyString;
        if (family != null) {
            familyString = family.getMember().getLastName();
        } else {
            // this snapshot is for a new family
            familyString = getContext().getString(R.string.all_new);
        }
        title.setText(getContext().getString(R.string.resumesnapshotpopup_snapshottitle, familyString));
    });
    AppCompatTextView surveyName = view.findViewById(R.id.tv_resumesnapshotpopup_snapshotsurveyname);
    mViewModel.survey().observe((FragmentActivity) getContext(), (survey) -> {
        String surveyString;
        if (survey != null) {
            surveyString = survey.getTitle();
        } else {
            surveyString = "";
        }
        surveyName.setText(surveyString);
    });
    AppCompatTextView timeAgo = view.findViewById(R.id.tv_resumesnapshotpopup_snapshottimeago);
    mViewModel.snapshot().observe((FragmentActivity) getContext(), (snapshot) -> {
        String dateString;
        if (snapshot != null) {
            Date dateCreated = snapshot.getCreatedAt();
            dateString = new PrettyTime().format(dateCreated);
        } else {
            dateString = "";
        }
        timeAgo.setText(dateString);
    });
    ViewCompat.setBackgroundTintList(view.findViewById(R.id.layout_resumesnapshot_surveyinfo), ContextCompat.getColorStateList(getContext(), R.color.lightPrimary));
    return view;
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView) PrettyTime(org.ocpsoft.prettytime.PrettyTime) AppCompatTextView(android.support.v7.widget.AppCompatTextView) View(android.view.View) Date(java.util.Date) AppCompatButton(android.support.v7.widget.AppCompatButton)

Example 40 with AppCompatTextView

use of android.support.v7.widget.AppCompatTextView in project AmazeFileManager by TeamAmaze.

the class InvalidablePreferenceCategory method onBindView.

@Override
protected void onBindView(View view) {
    super.onBindView(view);
    AppCompatTextView title = view.findViewById(android.R.id.title);
    title.setTextColor(titleColor);
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView)

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