Search in sources :

Example 6 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class ValidateCodeFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    authType = getArguments().getString("authType");
    isSign = getArguments().getBoolean(AUTH_TYPE_SIGN);
    keyboardHelper = new KeyboardHelper(getActivity());
    View v = inflater.inflate(R.layout.fragment_validate_code, container, false);
    v.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    TextView buttonConfirm = (TextView) v.findViewById(R.id.button_confirm_sms_code_text);
    buttonConfirm.setTypeface(Fonts.medium());
    buttonConfirm.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
    StateListDrawable states = SelectorFactory.get(ActorSDK.sharedActor().style.getMainColor(), getActivity());
    buttonConfirm.setBackgroundDrawable(states);
    ((TextView) v.findViewById(R.id.button_edit_phone)).setTypeface(Fonts.medium());
    ((TextView) v.findViewById(R.id.button_edit_phone)).setTextColor(ActorSDK.sharedActor().style.getMainColor());
    TextView sendHint = (TextView) v.findViewById(R.id.sendHint);
    sendHint.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    String authId = getArguments().getString("authId", "");
    if (authType.equals(AUTH_TYPE_PHONE)) {
        String phoneNumber = "+" + authId;
        try {
            Phonenumber.PhoneNumber number = PhoneNumberUtil.getInstance().parse(phoneNumber, null);
            phoneNumber = PhoneNumberUtil.getInstance().format(number, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL);
        } catch (NumberParseException e) {
            e.printStackTrace();
        }
        sendHint.setText(Html.fromHtml(getString(R.string.auth_code_phone_hint).replace("{0}", "<b>" + phoneNumber + "</b>")));
    } else if (authType.equals(AUTH_TYPE_EMAIL)) {
        sendHint.setText(Html.fromHtml(getString(R.string.auth_code_email_hint).replace("{0}", "<b>" + authId + "</b>")));
    }
    codeEnterEditText = (EditText) v.findViewById(R.id.et_sms_code_enter);
    codeEnterEditText.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    codeEnterEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        //                if (s.length() == 6) {
        //                    sendCode();
        //                }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    codeEnterEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                sendCode();
                return true;
            }
            return false;
        }
    });
    codeEnterEditText.setText(((AuthActivity) getActivity()).getCurrentCode());
    onClick(v, R.id.button_confirm_sms_code, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            sendCode();
        }
    });
    Button editAuth = (Button) v.findViewById(R.id.button_edit_phone);
    if (authType.equals(AUTH_TYPE_EMAIL)) {
        editAuth.setText(getString(R.string.auth_code_wrong_email));
    }
    onClick(v, R.id.button_edit_phone, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(getActivity()).setMessage(authType.equals(AUTH_TYPE_EMAIL) ? R.string.auth_code_email_change : R.string.auth_code_phone_change).setPositiveButton(R.string.auth_code_change_yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (isSign) {
                        startSignIn();
                    } else {
                        if (authType.equals(AUTH_TYPE_EMAIL)) {
                            switchToEmail();
                        } else if (authType.equals(AUTH_TYPE_PHONE)) {
                            switchToPhone();
                        }
                    }
                }
            }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).show().setCanceledOnTouchOutside(true);
        }
    });
    v.findViewById(R.id.divider).setBackgroundColor(style.getDividerColor());
    return v;
}
Also used : DialogInterface(android.content.DialogInterface) StateListDrawable(android.graphics.drawable.StateListDrawable) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) NumberParseException(com.google.i18n.phonenumbers.NumberParseException) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) Phonenumber(com.google.i18n.phonenumbers.Phonenumber)

Example 7 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class GroupNameFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    helper = new KeyboardHelper(getActivity());
    View res = inflater.inflate(R.layout.fragment_create_group_name, container, false);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    TextView hintTextView = (TextView) res.findViewById(R.id.create_group_hint);
    hintTextView.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    if (isChannel) {
        hintTextView.setText(R.string.create_channel_hint);
    } else {
        hintTextView.setText(R.string.create_group_hint);
    }
    groupName = (EditText) res.findViewById(R.id.groupTitle);
    groupName.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_NEXT) {
            next();
            return true;
        }
        return false;
    });
    if (isChannel) {
        groupName.setHint(R.string.create_channel_name_hint);
    } else {
        groupName.setHint(R.string.create_group_name_hint);
    }
    groupName.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    groupName.setHintTextColor(ActorSDK.sharedActor().style.getTextHintColor());
    avatarView = (AvatarView) res.findViewById(R.id.avatar);
    avatarView.init(Screen.dp(96), 24);
    avatarView.getHierarchy().setPlaceholderImage(R.drawable.circle_placeholder);
    // avatarView.getHierarchy().setControllerOverlay(getResources().getDrawable(R.drawable.circle_selector));
    avatarView.setImageURI(null);
    res.findViewById(R.id.pickAvatar).setOnClickListener(view -> {
        startActivityForResult(Intents.pickAvatar(avatarPath != null, getActivity()), REQUEST_AVATAR);
    });
    return res;
}
Also used : TextView(android.widget.TextView) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) TextView(android.widget.TextView) AvatarView(im.actor.sdk.view.avatar.AvatarView) View(android.view.View)

Example 8 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class GroupUsersFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    isChannel = getArguments().getBoolean("isChannel", false);
    setTitle(isChannel ? R.string.channel_add_members : R.string.create_group_title);
    gid = getArguments().getInt("gid");
    title = getArguments().getString("title");
    avatarPath = getArguments().getString("avatarPath");
    View res = onCreateContactsView(R.layout.fragment_create_group_participants, inflater, container, savedInstanceState);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    searchField = (EditText) res.findViewById(R.id.searchField);
    searchField.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    searchField.setHintTextColor(ActorSDK.sharedActor().style.getTextHintColor());
    textWatcher = new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            checkForDeletions(s);
            String filter = s.toString().trim();
            while (filter.length() > 0 && filter.charAt(0) == '!') {
                filter = filter.substring(1);
            }
            filter(filter);
        }
    };
    KeyboardHelper helper = new KeyboardHelper(getActivity());
    helper.setImeVisibility(searchField, false);
    return res;
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) SpannableString(android.text.SpannableString) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) View(android.view.View)

Example 9 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class SignInFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_sign_in, container, false);
    TextView buttonCotinueText = (TextView) v.findViewById(R.id.button_continue_text);
    StateListDrawable states = SelectorFactory.get(ActorSDK.sharedActor().style.getMainColor(), getActivity());
    buttonCotinueText.setBackgroundDrawable(states);
    buttonCotinueText.setTypeface(Fonts.medium());
    buttonCotinueText.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
    keyboardHelper = new KeyboardHelper(getActivity());
    v.findViewById(R.id.divider).setBackgroundColor(style.getDividerColor());
    initView(v);
    return v;
}
Also used : TextView(android.widget.TextView) StateListDrawable(android.graphics.drawable.StateListDrawable) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) TextView(android.widget.TextView) View(android.view.View)

Example 10 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class SignPhoneFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_sign_phone, container, false);
    v.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    TextView buttonContinue = (TextView) v.findViewById(R.id.button_continue_text);
    StateListDrawable states = SelectorFactory.get(ActorSDK.sharedActor().style.getMainColor(), getActivity());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        buttonContinue.setBackground(states);
    } else {
        buttonContinue.setBackgroundDrawable(states);
    }
    buttonContinue.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
    buttonContinue.setTypeface(Fonts.medium());
    ((TextView) v.findViewById(R.id.button_why)).setTypeface(Fonts.medium());
    ((TextView) v.findViewById(R.id.button_why)).setTextColor(ActorSDK.sharedActor().style.getMainColor());
    keyboardHelper = new KeyboardHelper(getActivity());
    initView(v);
    countryDb = Countries.getInstance();
    String deviceCountry = Devices.getDeviceCountry();
    if (!TextUtils.isEmpty(deviceCountry)) {
        Country country = countryDb.getCountryByShortName(deviceCountry);
        setCountryName(country);
        if (country != null) {
            countryCodeEditText.setText(country.phoneCode);
            focusPhone();
        } else {
            focusCode();
        }
    } else {
        setCountryName(null);
        countryCodeEditText.setText("");
        focusCode();
    }
    v.findViewById(R.id.divider).setBackgroundColor(style.getDividerColor());
    setTosAndPrivacy((TextView) v.findViewById(R.id.disclaimer));
    return v;
}
Also used : Country(im.actor.sdk.util.country.Country) TextView(android.widget.TextView) StateListDrawable(android.graphics.drawable.StateListDrawable) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) View(android.view.View) TextView(android.widget.TextView)

Aggregations

KeyboardHelper (im.actor.sdk.util.KeyboardHelper)11 View (android.view.View)10 TextView (android.widget.TextView)9 StateListDrawable (android.graphics.drawable.StateListDrawable)5 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 CommandCallback (im.actor.core.viewmodel.CommandCallback)3 UserVM (im.actor.core.viewmodel.UserVM)3 DialogInterface (android.content.DialogInterface)2 GroupVM (im.actor.core.viewmodel.GroupVM)2 AlertDialog (android.app.AlertDialog)1 Intent (android.content.Intent)1 SpannableString (android.text.SpannableString)1 KeyEvent (android.view.KeyEvent)1 Button (android.widget.Button)1 NumberParseException (com.google.i18n.phonenumbers.NumberParseException)1 Phonenumber (com.google.i18n.phonenumbers.Phonenumber)1 Void (im.actor.runtime.actors.messages.Void)1 Country (im.actor.sdk.util.country.Country)1 AvatarView (im.actor.sdk.view.avatar.AvatarView)1