Example usage for android.graphics Typeface DEFAULT

List of usage examples for android.graphics Typeface DEFAULT

Introduction

In this page you can find the example usage for android.graphics Typeface DEFAULT.

Prototype

Typeface DEFAULT

To view the source code for android.graphics Typeface DEFAULT.

Click Source Link

Document

The default NORMAL typeface object

Usage

From source file:it.sephiroth.android.library.bottomnavigation.BottomNavigation.java

private void initialize(final Context context, final AttributeSet attrs, final int defStyleAttr,
        final int defStyleRes) {
    typeface = new SoftReference<>(Typeface.DEFAULT);

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigation, defStyleAttr,
            defStyleRes);/*from ww w  . ja v  a  2  s . c  o  m*/
    final int menuResId = array.getResourceId(R.styleable.BottomNavigation_bbn_entries, 0);
    pendingMenu = MenuParser.inflateMenu(context, menuResId);
    badgeProvider = parseBadgeProvider(this, context,
            array.getString(R.styleable.BottomNavigation_bbn_badgeProvider));
    array.recycle();

    backgroundColorAnimation = getResources().getInteger(R.integer.bbn_background_animation_duration);
    defaultSelectedIndex = 0;

    defaultHeight = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_height);
    defaultWidth = getResources().getDimensionPixelSize(R.dimen.bbn_bottom_navigation_width);
    shadowHeight = getResources().getDimensionPixelOffset(R.dimen.bbn_top_shadow_height);

    // check if the bottom navigation is translucent
    if (!isInEditMode()) {
        final Activity activity = MiscUtils.getActivity(context);
        if (null != activity) {
            final SystemBarTintManager systembarTint = new SystemBarTintManager(activity);
            if (MiscUtils.hasTranslucentNavigation(activity) && systembarTint.getConfig().isNavigationAtBottom()
                    && systembarTint.getConfig().hasNavigtionBar()) {
                bottomInset = systembarTint.getConfig().getNavigationBarHeight();
            } else {
                bottomInset = 0;
            }
            topInset = systembarTint.getConfig().getStatusBarHeight();
        }
    }

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    backgroundOverlay = new View(getContext());
    backgroundOverlay.setLayoutParams(params);
    addView(backgroundOverlay);
}

From source file:com.bryan.example.widget.slidingtablayout.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab
 * view is not set via {@link #setCustomTabView(int, int)}.
 *//*w w  w . j a v  a  2  s  .co m*/
@SuppressLint("NewApi")
protected TextView createDefaultTabView(Context context) {
    /**
     * ?Holo??
     */
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    // textView.setTypeface(Typeface.DEFAULT_BOLD);//
    textView.setTypeface(Typeface.DEFAULT);

    // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
    // {
    // // If we're running on Honeycomb or newer, then we can use the
    // // Theme's
    // // selectableItemBackground to ensure that the View has a pressed
    // // state
    // TypedValue outValue = new TypedValue();
    // getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
    // outValue, true);
    // textView.setBackgroundResource(outValue.resourceId);
    // }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the
        // Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private void initAnnotateImageView(Bitmap bitmap, String originalImagePath) {
    annotateImageView = new AnnotateImageView(this);
    // Set the bitmap to draw on
    annotateImageView.drawBitmap(bitmap);
    // Add the file of the original image
    annotateImageView.addCroppedImage(new File(originalImagePath));
    // Set the background color of the canvas (used for the eraser)
    annotateImageView.setBaseColor(Color.WHITE);
    // Set the mode
    annotateImageView.setMode(AnnotateImageView.Mode.DRAW);
    // Set the drawer
    annotateImageView.setDrawer(AnnotateImageView.Drawer.PEN);
    // Set the paint attributes
    annotateImageView.setPaintStyle(Paint.Style.STROKE);
    annotateImageView.setPaintStrokeColor(Color.RED);
    annotateImageView.setLineCap(Paint.Cap.ROUND);
    annotateImageView.setLineJoin(Paint.Join.ROUND);
    float strokeWidth = getResources().getDisplayMetrics().density < 1.6F ? 6F : 12F;
    annotateImageView.setPaintStrokeWidth(strokeWidth);
    annotateImageView.setPaintFillColor(Color.RED);
    annotateImageView.setOpacity(255);/*from   ww  w . j av  a  2 s. c om*/
    annotateImageView.setBlur(0F);
    // Set the text attributes
    annotateImageView.setText("Default text");
    annotateImageView.setFontFamily(Typeface.DEFAULT);
    annotateImageView.setFontSize(32F);
    annotateImageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    RelativeLayout relativeLayout = (RelativeLayout) findViewById(
            R.id.supersede_feedbacklibrary_annotate_image_layout);
    if (relativeLayout != null) {
        relativeLayout.addView(annotateImageView);
    }
}

From source file:com.auth0.android.lock.views.ValidatedInputView.java

private void setupInputValidation() {
    String hint = "";
    String error = "";
    input.setTransformationMethod(null);
    Log.v(TAG, "Setting up validation for field of type " + dataType);
    switch (dataType) {
    case EMAIL://from   w w w.j av  a2 s . c  o m
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_email;
        hint = getResources().getString(R.string.com_auth0_lock_hint_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_email);
        break;
    case PASSWORD:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        input.setTypeface(Typeface.DEFAULT);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_password);
        error = getResources().getString(R.string.com_auth0_lock_input_error_password);
        break;
    case USERNAME_OR_EMAIL:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username_or_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_email);
        break;
    case TEXT_NAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case NON_EMPTY_USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_empty);
        break;
    case USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = String.format(getResources().getString(R.string.com_auth0_lock_input_error_username),
                MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH);
        break;
    case NUMBER:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case MFA_CODE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_code);
        break;
    case MOBILE_PHONE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_mobile;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    case PHONE_NUMBER:
        input.setInputType(InputType.TYPE_CLASS_PHONE);
        inputIcon = R.drawable.com_auth0_lock_ic_phone;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    }
    input.setHint(hint);
    errorDescription.setText(error);
    icon.setImageResource(inputIcon);
}

From source file:com.jjoe64.graphview_demos.fragments.Home.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
        if (resultCode == getActivity().RESULT_OK) {
            try {
                String strWord = data.getStringExtra("word");
                //etWrite.setText(strWord);
                // Set a cursor position last
                //etWrite.setSelection(etWrite.getText().length());
            } catch (Exception e) {
                Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
            }//from  w  w w . j a  v a2  s.c  o m
        }
    } else if (requestCode == REQUEST_PREFERENCE) {

        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());

        String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
        mDisplayType = Integer.valueOf(res);

        res = pref.getString("fontsize_list", Integer.toString(12));
        mTextFontSize = Integer.valueOf(res);
        mTvSerial.setTextSize(mTextFontSize);

        res = pref.getString("typeface_list", Integer.toString(3));
        switch (Integer.valueOf(res)) {
        case 0:
            mTextTypeface = Typeface.DEFAULT;
            break;
        case 1:
            mTextTypeface = Typeface.SANS_SERIF;
            break;
        case 2:
            mTextTypeface = Typeface.SERIF;
            break;
        case 3:
            mTextTypeface = Typeface.MONOSPACE;
            break;
        }
        mTvSerial.setTypeface(mTextTypeface);
        //etWrite.setTypeface(mTextTypeface);

        res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mReadLinefeedCode = Integer.valueOf(res);

        res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mWriteLinefeedCode = Integer.valueOf(res);

        res = pref.getString("email_edittext", "@gmail.com");
        mEmailAddress = res;

        int intRes;

        res = pref.getString("baudrate_list", Integer.toString(57600));
        intRes = Integer.valueOf(res);
        if (mBaudrate != intRes) {

            mBaudrate = intRes;
            mSerial.setBaudrate(mBaudrate);
        }

        res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
        intRes = Integer.valueOf(res);
        if (mDataBits != intRes) {
            mDataBits = Integer.valueOf(res);
            mSerial.setDataBits(mDataBits);
        }

        res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
        intRes = Integer.valueOf(res);
        if (mParity != intRes) {
            mParity = intRes;
            mSerial.setParity(mParity);
        }

        res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
        intRes = Integer.valueOf(res);
        if (mStopBits != intRes) {
            mStopBits = intRes;
            mSerial.setStopBits(mStopBits);
        }

        res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
        intRes = Integer.valueOf(res);
        if (mFlowControl != intRes) {
            mFlowControl = intRes;
            if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                mSerial.setDtrRts(true, true);
            } else {
                mSerial.setDtrRts(false, false);
            }
        }

        /*
        res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
        intRes = Integer.valueOf(res) << 14;
        if (mBreak != intRes) {
        mBreak = intRes;
        mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
        mSerial.setSerialPropertyToChip(FTDriver.CH_A);
        }
        */
    }
}

From source file:com.orange.ocara.ui.view.PagerSlidingTabStrip.java

private void updateTabStates(int selectedPosition) {
    for (int i = 0; i < tabCount; i++) {
        boolean isSelected = (i == selectedPosition);

        View v = tabsContainer.getChildAt(i);
        TextView tab = (TextView) v;//from  ww w.j a v a2 s . c o  m
        if (isSelected == true) {
            tab.setTypeface(Typeface.DEFAULT_BOLD);
        } else {
            tab.setTypeface(Typeface.DEFAULT);
        }
    }
}

From source file:im.ene.ribbon.BottomNavigationView.java

private void initialize(final Context context, final AttributeSet attrs, final int defStyleAttr,
        final int defStyleRes) {
    typeface = new SoftReference<>(Typeface.DEFAULT);

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigationView, defStyleAttr,
            defStyleRes);/*from  ww w  . j  a  v  a 2  s. c  o m*/
    final int menuResId = array.getResourceId(R.styleable.BottomNavigationView_ribbon_menu, 0);
    if (menuResId == 0) {
        throw new IllegalArgumentException("A valid menu must be set in xml");
    }

    pendingMenu = MenuParser.inflateMenu(context, menuResId);
    badgeProvider = parseBadgeProvider(this, context,
            array.getString(R.styleable.BottomNavigationView_ribbon_badgeProvider));
    array.recycle();

    backgroundColorAnimation = getResources().getInteger(R.integer.ribbon_background_animation_duration);

    defaultSelectedIndex = 0;

    defaultHeight = getResources().getDimensionPixelSize(R.dimen.ribbon_bottom_navigation_height);
    defaultWidth = getResources().getDimensionPixelSize(R.dimen.ribbon_bottom_navigation_width);
    shadowHeight = getResources().getDimensionPixelOffset(R.dimen.ribbon_top_shadow_height);

    // check if the bottom navigation is translucent
    if (!isInEditMode()) {
        final Activity activity = MiscUtils.getActivity(context);
        if (activity != null) {
            final SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity);
            if (MiscUtils.hasTranslucentNavigationBar(activity) && //
                    systemBarTintManager.getConfig().isNavigationAtBottom() && //
                    systemBarTintManager.getConfig().hasNavigtionBar()) {
                bottomInset = systemBarTintManager.getConfig().getNavigationBarHeight();
            } else {
                bottomInset = 0;
            }
            topInset = systemBarTintManager.getConfig().getStatusBarHeight();
        }
    }

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    params.topMargin = shadowHeight;
    backgroundOverlay = new View(getContext());
    backgroundOverlay.setLayoutParams(params);
    addView(backgroundOverlay);
}

From source file:com.facebook.react.views.textinput.ReactTextInputManager.java

/**
/* This code was taken from the method setFontWeight of the class ReactTextShadowNode
/* TODO: Factor into a common place they can both use
*///from w w  w. j a  v a  2s .c  om
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(ReactEditText view, @Nullable String fontWeightString) {
    int fontWeightNumeric = fontWeightString != null ? parseNumericFontWeight(fontWeightString) : -1;
    int fontWeight = UNSET;
    if (fontWeightNumeric >= 500 || "bold".equals(fontWeightString)) {
        fontWeight = Typeface.BOLD;
    } else if ("normal".equals(fontWeightString) || (fontWeightNumeric != -1 && fontWeightNumeric < 500)) {
        fontWeight = Typeface.NORMAL;
    }
    Typeface currentTypeface = view.getTypeface();
    if (currentTypeface == null) {
        currentTypeface = Typeface.DEFAULT;
    }
    if (fontWeight != currentTypeface.getStyle()) {
        view.setTypeface(currentTypeface, fontWeight);
    }
}

From source file:com.axolotl.yanews.customize.SlidingTabLayout.java

/**
 * tabview. tab view/*from w  w  w . j a v a 2 s. c om*/
 * {@link #setCustomTabView(int, int)}.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context, null, 0);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTab_text_size_sp);
    if (mBold) {
        textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    } else {
        textView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
    }
    if (mChangeTextColor) {
        textView.setTextColor(mNormalColor);
    }
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (mBackgroundResource != 0) {
        textView.setBackgroundResource(mBackgroundResource);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // If we're running on Honeycomb or newer, then we can use the Theme's
            // selectableItemBackground to ensure that the View has a pressed state
            TypedValue outValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
            textView.setBackgroundResource(outValue.resourceId);
        }
    }

    //wtf
    //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    //            // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
    //            textView.setAllCaps(true);
    //        }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, 0, padding, 0);
    return textView;
}

From source file:com.b44t.ui.PasscodeActivity.java

@Override
public View createView(Context context) {
    actionBar/*w  ww.  j  a  v a 2s . c om*/
            .setBackButtonImage(screen == SCREEN0_SETTINGS ? R.drawable.ic_ab_back : R.drawable.ic_close_white);
    actionBar.setAllowOverlayTitle(false);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (passcodeSetStep == 0) {
                    processNext();
                } else if (passcodeSetStep == 1) {
                    processDone();
                }
            } else if (id == pin_item) {
                currentPasswordType = 0;
                updateDropDownTextView();
            } else if (id == password_item) {
                currentPasswordType = 1;
                updateDropDownTextView();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    if (screen != SCREEN0_SETTINGS) {
        ActionBarMenu menu = actionBar.createMenu();
        menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

        titleTextView = new TextView(context);
        titleTextView.setTextColor(0xff757575);
        if (screen == SCREEN1_ENTER_CODE1) {
            if (UserConfig.passcodeHash.length() != 0) {
                titleTextView
                        .setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode));
            } else {
                titleTextView.setText(
                        LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode));
            }
        } else {
            titleTextView
                    .setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode));
        }
        titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
        frameLayout.addView(titleTextView);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams();
        layoutParams.width = LayoutHelper.WRAP_CONTENT;
        layoutParams.height = LayoutHelper.WRAP_CONTENT;
        layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
        layoutParams.topMargin = AndroidUtilities.dp(38);
        titleTextView.setLayoutParams(layoutParams);

        passwordEditText = new EditText(context);
        passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
        passwordEditText.setTextColor(0xff000000);
        passwordEditText.setMaxLines(1);
        passwordEditText.setLines(1);
        passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
        passwordEditText.setSingleLine(true);
        if (screen == SCREEN1_ENTER_CODE1) {
            passcodeSetStep = 0;
            passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        } else {
            passcodeSetStep = 1;
            passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        }
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        passwordEditText.setTypeface(Typeface.DEFAULT);
        AndroidUtilities.clearCursorDrawable(passwordEditText);
        frameLayout.addView(passwordEditText);
        layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
        layoutParams.topMargin = AndroidUtilities.dp(90);
        layoutParams.height = AndroidUtilities.dp(36);
        layoutParams.leftMargin = AndroidUtilities.dp(40);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        layoutParams.rightMargin = AndroidUtilities.dp(40);
        layoutParams.width = LayoutHelper.MATCH_PARENT;
        passwordEditText.setLayoutParams(layoutParams);
        passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                if (passcodeSetStep == 0) {
                    processNext();
                    return true;
                } else if (passcodeSetStep == 1) {
                    processDone();
                    return true;
                }
                return false;
            }
        });
        passwordEditText.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) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (passwordEditText.length() == 4) {
                    if (screen == SCREEN2_ENTER_CODE2 && UserConfig.passcodeType == 0) {
                        processDone();
                    } else if (screen == SCREEN1_ENTER_CODE1 && currentPasswordType == 0) {
                        if (passcodeSetStep == 0) {
                            processNext();
                        } else if (passcodeSetStep == 1) {
                            processDone();
                        }
                    }
                }
            }
        });

        passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });

        if (screen == SCREEN1_ENTER_CODE1) {
            dropDownContainer = new ActionBarMenuItem(context, menu, 0);
            dropDownContainer.setSubMenuOpenSide(1);
            dropDownContainer.addSubItem(pin_item,
                    LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0);
            dropDownContainer.addSubItem(password_item,
                    LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0);
            actionBar.addView(dropDownContainer);
            layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
            layoutParams.height = LayoutHelper.MATCH_PARENT;
            layoutParams.width = LayoutHelper.WRAP_CONTENT;
            layoutParams.rightMargin = AndroidUtilities.dp(40);
            layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64)
                    : AndroidUtilities.dp(56);
            layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
            dropDownContainer.setLayoutParams(layoutParams);
            dropDownContainer.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dropDownContainer.toggleSubMenu();
                }
            });

            dropDown = new TextView(context);
            dropDown.setGravity(Gravity.LEFT);
            dropDown.setSingleLine(true);
            dropDown.setLines(1);
            dropDown.setMaxLines(1);
            dropDown.setEllipsize(TextUtils.TruncateAt.END);
            dropDown.setTextColor(0xffffffff);
            dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
            dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
            dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
            dropDownContainer.addView(dropDown);
            layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
            layoutParams.width = LayoutHelper.WRAP_CONTENT;
            layoutParams.height = LayoutHelper.WRAP_CONTENT;
            layoutParams.leftMargin = AndroidUtilities.dp(16);
            layoutParams.gravity = Gravity.CENTER_VERTICAL;
            layoutParams.bottomMargin = AndroidUtilities.dp(1);
            dropDown.setLayoutParams(layoutParams);
        } else {
            actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
        }

        updateDropDownTextView();
    } else {
        actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
        frameLayout.setBackgroundColor(0xfff0f0f0);
        listView = new ListView(context);
        listView.setDivider(null);
        listView.setDividerHeight(0);
        listView.setVerticalScrollBarEnabled(false);
        listView.setDrawSelectorOnTop(true);
        frameLayout.addView(listView);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        layoutParams.width = LayoutHelper.MATCH_PARENT;
        layoutParams.height = LayoutHelper.MATCH_PARENT;
        layoutParams.gravity = Gravity.TOP;
        listView.setLayoutParams(layoutParams);
        listView.setAdapter(listAdapter = new ListAdapter(context));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
                if (i == changePasscodeRow) {
                    presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1));
                } else if (i == passcodeOnOffRow) {
                    TextCheckCell cell = (TextCheckCell) view;
                    if (UserConfig.passcodeHash.length() != 0) {
                        UserConfig.passcodeHash = "";
                        UserConfig.appLocked = false;
                        UserConfig.saveConfig(false);
                        int count = listView.getChildCount();
                        for (int a = 0; a < count; a++) {
                            View child = listView.getChildAt(a);
                            if (child instanceof TextSettingsCell) {
                                TextSettingsCell textCell = (TextSettingsCell) child;
                                textCell.setTextColor(0xffc6c6c6);
                                break;
                            }
                        }
                        cell.setChecked(UserConfig.passcodeHash.length() != 0);
                        NotificationCenter.getInstance()
                                .postNotificationName(NotificationCenter.didSetPasscode);
                    } else {
                        presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1));
                    }
                } else if (i == autoLockRow) {
                    if (getParentActivity() == null) {
                        return;
                    }
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
                    final NumberPicker numberPicker = new NumberPicker(getParentActivity());
                    numberPicker.setMinValue(0);
                    numberPicker.setMaxValue(4);
                    if (UserConfig.autoLockIn == 0) {
                        numberPicker.setValue(0);
                    } else if (UserConfig.autoLockIn == 60) {
                        numberPicker.setValue(1);
                    } else if (UserConfig.autoLockIn == 60 * 5) {
                        numberPicker.setValue(2);
                    } else if (UserConfig.autoLockIn == 60 * 60) {
                        numberPicker.setValue(3);
                    } else if (UserConfig.autoLockIn == 60 * 60 * 5) {
                        numberPicker.setValue(4);
                    }
                    numberPicker.setFormatter(new NumberPicker.Formatter() {
                        @Override
                        public String format(int value) {
                            if (value == 0) {
                                return LocaleController.getString("Disabled", R.string.Disabled);
                            } else if (value == 1) {
                                return ApplicationLoader.applicationContext.getResources()
                                        .getQuantityString(R.plurals.Minutes, 1, 1);
                            } else if (value == 2) {
                                return ApplicationLoader.applicationContext.getResources()
                                        .getQuantityString(R.plurals.Minutes, 5, 5);
                            } else if (value == 3) {
                                return ApplicationLoader.applicationContext.getResources()
                                        .getQuantityString(R.plurals.Hours, 1, 1);
                            } else if (value == 4) {
                                return ApplicationLoader.applicationContext.getResources()
                                        .getQuantityString(R.plurals.Hours, 5, 5);
                            }
                            return "";
                        }
                    });
                    numberPicker.setWrapSelectorWheel(false);
                    builder.setView(numberPicker);
                    builder.setNegativeButton(LocaleController.getString("Done", R.string.Done),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    which = numberPicker.getValue();
                                    if (which == 0) {
                                        UserConfig.autoLockIn = 0;
                                    } else if (which == 1) {
                                        UserConfig.autoLockIn = 60;
                                    } else if (which == 2) {
                                        UserConfig.autoLockIn = 60 * 5;
                                    } else if (which == 3) {
                                        UserConfig.autoLockIn = 60 * 60;
                                    } else if (which == 4) {
                                        UserConfig.autoLockIn = 60 * 60 * 5;
                                    }
                                    listView.invalidateViews();
                                    UserConfig.saveConfig(false);
                                }
                            });
                    showDialog(builder.create());
                } else if (i == fingerprintRow) {
                    UserConfig.useFingerprint = !UserConfig.useFingerprint;
                    UserConfig.saveConfig(false);
                    ((TextCheckCell) view).setChecked(UserConfig.useFingerprint);
                }
            }
        });
    }

    return fragmentView;
}