Search in sources :

Example 26 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project twicalico by moko256.

the class ShowTweetActivity method updateView.

private void updateView(Status item) {
    TextView tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
    long replyTweetId = item.getInReplyToStatusId();
    if (replyTweetId != -1) {
        tweetIsReply.setVisibility(VISIBLE);
        tweetIsReply.setOnClickListener(v -> startActivity(getIntent(this, replyTweetId)));
    } else {
        tweetIsReply.setVisibility(GONE);
    }
    StatusView statusView = new StatusView(this);
    statusView.setStatus(item);
    ViewGroup cview = (ViewGroup) statusView.getChildAt(0);
    ViewGroup sview = (ViewGroup) cview.getChildAt(0);
    cview.removeView(sview);
    FrameLayout statusViewFrame = findViewById(R.id.tweet_show_tweet);
    statusViewFrame.removeAllViews();
    statusViewFrame.addView(sview);
    ((TextView) findViewById(R.id.tweet_show_timestamp)).setText(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(item.getCreatedAt()));
    TextView viaText = findViewById(R.id.tweet_show_via);
    viaText.setText(TwitterStringUtils.convertUrlSpanToCustomTabs(Html.fromHtml("via:" + item.getSource()), this));
    viaText.setMovementMethod(new LinkMovementMethod());
    AppCompatEditText replyText = findViewById(R.id.tweet_show_tweet_reply_text);
    AppCompatButton replyButton = findViewById(R.id.tweet_show_tweet_reply_button);
    UserMentionEntity[] users = item.getUserMentionEntities();
    replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
    replyButton.setOnClickListener(v -> {
        replyButton.setEnabled(false);
        PostTweetModel model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
        model.setTweetText(replyText.getText().toString());
        model.setInReplyToStatusId(item.getId());
        subscriptions.add(model.postTweet().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
            replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
            replyButton.setEnabled(true);
            Toast.makeText(ShowTweetActivity.this, R.string.succeeded, Toast.LENGTH_SHORT).show();
        }, e -> {
            e.printStackTrace();
            Toast.makeText(ShowTweetActivity.this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
            replyButton.setEnabled(true);
        }));
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) FrameLayout(android.widget.FrameLayout) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) UserMentionEntity(twitter4j.UserMentionEntity) MenuItem(android.view.MenuItem) AppCompatButton(android.support.v7.widget.AppCompatButton) Single(rx.Single) AppCustomTabsKt(com.github.moko256.twicalico.intent.AppCustomTabsKt) Toast(android.widget.Toast) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) TwitterException(twitter4j.TwitterException) VISIBLE(android.view.View.VISIBLE) ActionBar(android.support.v7.app.ActionBar) DateFormat(java.text.DateFormat) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) StatusCacheMap(com.github.moko256.twicalico.cacheMap.StatusCacheMap) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) CompositeSubscription(rx.subscriptions.CompositeSubscription) TextView(android.widget.TextView) GONE(android.view.View.GONE) Html(android.text.Html) Status(twitter4j.Status) PostTweetModelCreator(com.github.moko256.twicalico.model.impl.PostTweetModelCreator) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatEditText(android.support.v7.widget.AppCompatEditText) UserMentionEntity(twitter4j.UserMentionEntity) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) AppCompatButton(android.support.v7.widget.AppCompatButton)

Example 27 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project vlc-android by videolan.

the class FileBrowserFragment method showAddDirectoryDialog.

public void showAddDirectoryDialog() {
    final Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final AppCompatEditText input = new AppCompatEditText(context);
    if (!AndroidUtil.isHoneycombOrLater) {
        input.setTextColor(getResources().getColor(R.color.grey50));
    }
    input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    builder.setTitle(R.string.add_custom_path);
    builder.setMessage(R.string.add_custom_path_description);
    builder.setView(input);
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int which) {
        }
    });
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String path = input.getText().toString().trim();
            File f = new File(path);
            if (!f.exists() || !f.isDirectory()) {
                UiTools.snacker(getView(), getString(R.string.directorynotfound, path));
                return;
            }
            try {
                CustomDirectories.addCustomDirectory(f.getCanonicalPath());
                ((AudioPlayerContainerActivity) getActivity()).updateLib();
            } catch (IOException ignored) {
            }
        }
    });
    mAlertDialog = builder.show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) AppCompatEditText(android.support.v7.widget.AppCompatEditText) DialogInterface(android.content.DialogInterface) IOException(java.io.IOException) File(java.io.File)

Example 28 with AppCompatEditText

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

the class GeneralDialogCreation method showEncryptAuthenticateDialog.

public static void showEncryptAuthenticateDialog(final Context c, final Intent intent, final MainActivity main, AppTheme appTheme, final EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterface) {
    int accentColor = main.getColorPreference().getColor(ColorUsage.ACCENT);
    MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
    builder.title(main.getResources().getString(R.string.crypt_encrypt));
    View rootView = View.inflate(c, R.layout.dialog_encrypt_authenticate, null);
    final AppCompatEditText passwordEditText = rootView.findViewById(R.id.edit_text_dialog_encrypt_password);
    final AppCompatEditText passwordConfirmEditText = rootView.findViewById(R.id.edit_text_dialog_encrypt_password_confirm);
    passwordEditText.post(() -> {
        InputMethodManager imm = (InputMethodManager) main.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(passwordEditText, InputMethodManager.SHOW_IMPLICIT);
    });
    TextInputLayout textInputLayoutPassword = rootView.findViewById(R.id.til_encrypt_password);
    TextInputLayout textInputLayoutPasswordConfirm = rootView.findViewById(R.id.til_encrypt_password_confirm);
    passwordEditText.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            super.afterTextChanged(s);
            if (!TextUtils.isEmpty(s.toString())) {
                textInputLayoutPassword.setError("");
            }
        }
    });
    passwordConfirmEditText.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            super.afterTextChanged(s);
            if (s.toString().equals(passwordEditText.getText().toString())) {
                textInputLayoutPasswordConfirm.setError("");
            }
        }
    });
    passwordConfirmEditText.setOnFocusChangeListener((v, hasFocus) -> {
        if (TextUtils.isEmpty(passwordEditText.getText().toString())) {
            textInputLayoutPassword.setError(c.getResources().getString(R.string.error) + ": " + String.format(c.getResources().getString(R.string.cantbeempty), c.getResources().getString(R.string.password)));
        } else {
            textInputLayoutPassword.setError("");
        }
    });
    passwordEditText.setOnFocusChangeListener((v, hasFocus) -> {
        boolean isPasswordSame = passwordConfirmEditText.getText().toString().equals(passwordEditText.getText().toString());
        if (!isPasswordSame && !TextUtils.isEmpty(passwordConfirmEditText.getText().toString())) {
            textInputLayoutPasswordConfirm.setError(c.getResources().getString(R.string.error) + ": " + c.getResources().getString(R.string.password_no_match));
        }
    });
    builder.customView(rootView, true);
    builder.positiveText(c.getString(R.string.ok));
    builder.negativeText(c.getString(R.string.cancel));
    builder.theme(appTheme.getMaterialDialogTheme());
    builder.positiveColor(accentColor);
    builder.negativeColor(accentColor);
    builder.onNegative((dialog, which) -> dialog.cancel());
    builder.autoDismiss(false);
    builder.onPositive((dialog, which) -> {
        if (TextUtils.isEmpty(passwordEditText.getText().toString())) {
            textInputLayoutPassword.setError(c.getResources().getString(R.string.error) + ": " + String.format(c.getResources().getString(R.string.cantbeempty), c.getResources().getString(R.string.password)));
        } else if (!passwordConfirmEditText.getText().toString().equals(passwordEditText.getText().toString())) {
            textInputLayoutPasswordConfirm.setError(c.getResources().getString(R.string.error) + ": " + c.getResources().getString(R.string.password_no_match));
        } else {
            try {
                encryptButtonCallbackInterface.onButtonPressed(intent, passwordEditText.getText().toString());
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(c, c.getString(R.string.crypt_encryption_fail), Toast.LENGTH_LONG).show();
            } finally {
                dialog.dismiss();
            }
        }
    });
    builder.show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) TextView(android.widget.TextView) ShellNotRunningException(com.amaze.filemanager.exceptions.ShellNotRunningException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Editable(android.text.Editable) TextInputLayout(android.support.design.widget.TextInputLayout)

Example 29 with AppCompatEditText

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

the class RenameBookmark method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context c = getActivity();
    if (getActivity() instanceof BookmarkCallback)
        bookmarkCallback = (BookmarkCallback) getActivity();
    title = getArguments().getString("title");
    path = getArguments().getString("path");
    int accentColor = getArguments().getInt("accentColor");
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
    studiomode = sp.getInt("studio", 0);
    if (dataUtils.containsBooks(new String[] { title, path }) != -1) {
        final MaterialDialog materialDialog;
        String pa = path;
        MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
        builder.title(R.string.renamebookmark);
        builder.positiveColor(accentColor);
        builder.negativeColor(accentColor);
        builder.neutralColor(accentColor);
        builder.positiveText(R.string.save);
        builder.neutralText(R.string.cancel);
        builder.negativeText(R.string.delete);
        builder.theme(((BasicActivity) getActivity()).getAppTheme().getMaterialDialogTheme());
        builder.autoDismiss(false);
        View v2 = getActivity().getLayoutInflater().inflate(R.layout.rename, null);
        builder.customView(v2, true);
        final TextInputLayout t1 = v2.findViewById(R.id.t1);
        final TextInputLayout t2 = v2.findViewById(R.id.t2);
        final AppCompatEditText conName = v2.findViewById(R.id.editText4);
        conName.setText(title);
        final String s1 = String.format(getString(R.string.cantbeempty), c.getResources().getString(R.string.name));
        final String s2 = String.format(getString(R.string.cantbeempty), c.getResources().getString(R.string.path));
        conName.addTextChangedListener(new SimpleTextWatcher() {

            @Override
            public void afterTextChanged(Editable s) {
                if (conName.getText().toString().length() == 0)
                    t1.setError(s2);
                else
                    t1.setError("");
            }
        });
        final AppCompatEditText ip = v2.findViewById(R.id.editText);
        if (studiomode != 0) {
            if (path.startsWith("smb:/")) {
                try {
                    jcifs.Config.registerSmbURLHandler();
                    URL a = new URL(path);
                    String userinfo = a.getUserInfo();
                    if (userinfo != null) {
                        String inf = URLDecoder.decode(userinfo, "UTF-8");
                        user = inf.substring(0, inf.indexOf(":"));
                        pass = inf.substring(inf.indexOf(":") + 1, inf.length());
                        String ipp = a.getHost();
                        pa = "smb://" + ipp + a.getPath();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            ip.addTextChangedListener(new SimpleTextWatcher() {

                @Override
                public void afterTextChanged(Editable s) {
                    if (ip.getText().toString().length() == 0)
                        t2.setError(s1);
                    else
                        t2.setError("");
                }
            });
        } else
            t2.setVisibility(View.GONE);
        ip.setText(pa);
        builder.onNeutral((dialog, which) -> dialog.dismiss());
        materialDialog = builder.build();
        materialDialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(v -> {
            String t = ip.getText().toString();
            String name = conName.getText().toString();
            if (studiomode != 0 && t.startsWith("smb://")) {
                try {
                    URL a = new URL(t);
                    String userinfo = a.getUserInfo();
                    if (userinfo == null && user.length() > 0) {
                        t = "smb://" + ((URLEncoder.encode(user, "UTF-8") + ":" + URLEncoder.encode(pass, "UTF-8") + "@")) + a.getHost() + a.getPath();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            int i = -1;
            if ((i = dataUtils.containsBooks(new String[] { title, path })) != -1) {
                if (!t.equals(title) && t.length() >= 1) {
                    dataUtils.removeBook(i);
                    dataUtils.addBook(new String[] { name, t });
                    dataUtils.sortBook();
                    if (bookmarkCallback != null) {
                        bookmarkCallback.modify(path, title, t, name);
                    }
                }
            }
            materialDialog.dismiss();
        });
        materialDialog.getActionButton(DialogAction.NEGATIVE).setOnClickListener(v -> {
            int i;
            if ((i = dataUtils.containsBooks(new String[] { title, path })) != -1) {
                dataUtils.removeBook(i);
                if (bookmarkCallback != null) {
                    bookmarkCallback.delete(title, path);
                }
            }
            materialDialog.dismiss();
        });
        return materialDialog;
    }
    return null;
}
Also used : Context(android.content.Context) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SharedPreferences(android.content.SharedPreferences) BasicActivity(com.amaze.filemanager.activities.superclasses.BasicActivity) View(android.view.View) URL(java.net.URL) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Editable(android.text.Editable) TextInputLayout(android.support.design.widget.TextInputLayout)

Example 30 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText 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)

Aggregations

AppCompatEditText (android.support.v7.widget.AppCompatEditText)37 View (android.view.View)20 DialogInterface (android.content.DialogInterface)16 AlertDialog (android.support.v7.app.AlertDialog)13 TextView (android.widget.TextView)11 Editable (android.text.Editable)10 AppCompatButton (android.support.v7.widget.AppCompatButton)8 TextWatcher (android.text.TextWatcher)7 LinearLayout (android.widget.LinearLayout)7 File (java.io.File)7 Context (android.content.Context)6 TextInputLayout (android.support.design.widget.TextInputLayout)6 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)6 AppCompatTextView (android.support.v7.widget.AppCompatTextView)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 AdapterView (android.widget.AdapterView)5 SuppressLint (android.annotation.SuppressLint)4 AppCompatDialog (android.support.v7.app.AppCompatDialog)4 RelativeLayout (android.widget.RelativeLayout)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4