Example usage for android.content.res Resources getDimension

List of usage examples for android.content.res Resources getDimension

Introduction

In this page you can find the example usage for android.content.res Resources getDimension.

Prototype

public float getDimension(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID.

Usage

From source file:carbon.recycler.ItemTouchHelper.java

/**
 * Attaches the ItemTouchHelper to the provided RecyclerView. If TouchHelper is already
 * attached to a RecyclerView, it will first detach from the previous one. You can call this
 * method with {@code null} to detach it from the current RecyclerView.
 *
 * @param recyclerView The RecyclerView instance to which you want to add this helper or
 *                     {@code null} if you want to remove ItemTouchHelper from the current
 *                     RecyclerView./*from  www  .ja  v  a 2  s . co m*/
 */
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
    if (mRecyclerView == recyclerView) {
        return; // nothing to do
    }
    if (mRecyclerView != null) {
        destroyCallbacks();
    }
    mRecyclerView = recyclerView;
    if (mRecyclerView != null) {
        final Resources resources = recyclerView.getResources();
        mSwipeEscapeVelocity = resources.getDimension(R.dimen.carbon_item_touch_helper_swipe_escape_velocity);
        mMaxSwipeVelocity = resources.getDimension(R.dimen.carbon_item_touch_helper_swipe_escape_max_velocity);
        setupCallbacks();
    }
}

From source file:cn.ismartv.tvrecyclerview.widget.helper.ItemTouchHelper.java

/**
 * Attaches the ItemTouchHelper to the provided RecyclerView. If TouchHelper is already
 * attached to a RecyclerView, it will first detach from the previous one. You can call this
 * method with {@code null} to detach it from the current RecyclerView.
 *
 * @param recyclerView The RecyclerView instance to which you want to add this helper or
 *                     {@code null} if you want to remove ItemTouchHelper from the current
 *                     RecyclerView./*ww  w  .j  a  va2 s. co m*/
 */
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
    if (mRecyclerView == recyclerView) {
        return; // nothing to do
    }
    if (mRecyclerView != null) {
        destroyCallbacks();
    }
    mRecyclerView = recyclerView;
    if (mRecyclerView != null) {
        final Resources resources = recyclerView.getResources();
        mSwipeEscapeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_velocity);
        mMaxSwipeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_max_velocity);
        setupCallbacks();
    }
}

From source file:com.android.launcher3.ItemTouchHelper.java

/**
 * Attaches the ItemTouchHelper to the provided RecyclerView. If TouchHelper is already
 * attached to a RecyclerView, it will first detach from the previous one. You can call this
 * method with {@code null} to detach it from the current RecyclerView.
 *
 * @param recyclerView The RecyclerView instance to which you want to add this helper or
 *                     {@code null} if you want to remove ItemTouchHelper from the current
 *                     RecyclerView./*from   www  .  j a  v  a2s.co  m*/
 */
public void attachToRecyclerView(@Nullable android.support.v7.widget.RecyclerView recyclerView) {
    if (mRecyclerView == recyclerView) {
        return; // nothing to do
    }
    if (mRecyclerView != null) {
        destroyCallbacks();
    }
    mRecyclerView = recyclerView;
    if (mRecyclerView != null) {
        final Resources resources = recyclerView.getResources();
        mSwipeEscapeVelocity = resources
                .getDimension(android.support.v7.recyclerview.R.dimen.item_touch_helper_swipe_escape_velocity);
        mMaxSwipeVelocity = resources.getDimension(
                android.support.v7.recyclerview.R.dimen.item_touch_helper_swipe_escape_max_velocity);
        setupCallbacks();
    }
}

From source file:com.android.calendar.EventInfoFragment.java

private void setDialogSize(Resources r) {
    mDialogWidth = (int) r.getDimension(R.dimen.event_info_dialog_width);
    mDialogHeight = (int) r.getDimension(R.dimen.event_info_dialog_height);
}

From source file:com.tct.mail.ui.ConversationListFragment.java

private void updateLocalSearchResultHeader(int count) {
    if (mActivity == null || mSearchHeaderView == null) {
        return;//from  ww w  .  j  a  va 2  s.co m
    }
    // Only show the header if the context is for a search result
    final Resources res = getResources();
    final boolean showHeader = ConversationListContext.isSearchResult(mViewContext);
    LogUtils.d(LOG_TAG, "ConversationListFragment.updateSearchResultHeader(%d)", count);
    if (showHeader) {
        if (!ActionBarController.SERVICE_SEARCH_MODE) {
            mListAdapter.setQueryInfo(mViewContext.searchQuery, localSearchField);
            mlocalSearchHeader.setVisibility(View.VISIBLE);
            //mSearchStatusView.setVisibility(View.GONE);
            int marginTop = true
                    ? (int) (res.getDimension(R.dimen.notification_view_height)
                            + res.getDimension(R.dimen.local_search_header_height))
                    : 0;
            MarginLayoutParams layoutParams = (MarginLayoutParams) mListView.getLayoutParams();
            layoutParams.topMargin = marginTop;
            mListView.setLayoutParams(layoutParams);
            mLocalSearchHeaderText.setText(res.getString(R.string.search_results_header));
            mLocalSearchHeaderCount.setText(res.getString(R.string.search_results_loaded, count));
        }
    }
}

From source file:com.github.omadahealth.slidepager.lib.views.ProgressView.java

/**
 * Loads the styles and attributes defined in the xml tag of this class
 *
 * @param attributes The attributes to read from, do not pass {@link AttributeSet} as inflation needs the context of the {@link android.support.v4.view.PagerAdapter}
 *//*  ww  w.j a  v a2s . c o  m*/
public ProgressView loadStyledAttributes(TypedArray attributes, ProgressAttr progress) {
    mAttributes = attributes;
    mProgressAttr = progress;

    mIsSpecial = progress != null && progress.isSpecial();
    mIsFuture = progress != null && progress.isFuture();
    mCompletedDrawable = progress == null ? null : progress.getCompletedDrawable();

    Resources res = getContext().getResources();
    if (attributes != null) {
        mShowStreaks = attributes.getBoolean(R.styleable.SlidePager_slide_show_streaks, true);
        mShowProgressText = attributes.getBoolean(R.styleable.SlidePager_slide_show_progress_text, true);
        mShowProgressPlusMark = attributes.getBoolean(R.styleable.SlidePager_slide_show_progress_plusmark,
                true);
        mHasToReanimate = mAttributes.getBoolean(R.styleable.SlidePager_slide_pager_reanimate_slide_view, true);

        mCompletedColor = progress != null && progress.getCompletedColor() != null
                ? progress.getCompletedColor()
                : attributes.getColor(R.styleable.SlidePager_slide_progress_completed_reach_color,
                        res.getColor(R.color.default_progress_completed_reach_color));

        mCompletedFillColor = progress != null && progress.getCompletedFillColor() != null
                ? progress.getCompletedFillColor()
                : attributes.getColor(R.styleable.SlidePager_slide_progress_completed_fill_color,
                        res.getColor(R.color.default_progress_completed_fill_color));

        mNotCompletedReachColor = progress != null && progress.getReachedColor() != null
                ? progress.getReachedColor()
                : attributes.getColor(R.styleable.SlidePager_slide_progress_not_completed_reach_color,
                        res.getColor(R.color.default_progress_not_completed_reach_color));

        mNotCompletedOutlineColor = attributes.getColor(
                R.styleable.SlidePager_slide_progress_not_completed_outline_color,
                res.getColor(R.color.default_progress_not_completed_outline_color));
        mNotCompletedOutlineSize = attributes.getDimension(
                R.styleable.SlidePager_slide_progress_not_completed_outline_size,
                res.getDimension(R.dimen.circular_bar_default_outline_width));
        mNotCompletedFutureOutlineSize = attributes.getDimension(
                R.styleable.SlidePager_slide_progress_not_completed_future_outline_size,
                res.getDimension(R.dimen.circular_bar_default_future_outline_width));
        mNotCompletedFillColor = attributes.getColor(
                R.styleable.SlidePager_slide_progress_not_completed_fill_color,
                res.getColor(R.color.default_progress_not_completed_fill_color));

        mSpecialReachColor = attributes.getColor(R.styleable.SlidePager_slide_progress_special_reach_color,
                res.getColor(R.color.default_progress_special_reach_color));
        mSpecialOutlineColor = attributes.getColor(R.styleable.SlidePager_slide_progress_special_outline_color,
                res.getColor(R.color.default_progress_special_outline_color));
        mSpecialFillColor = attributes.getColor(R.styleable.SlidePager_slide_progress_special_fill_color,
                res.getColor(R.color.default_progress_special_fill_color));

        mProgressTextColor = attributes.getColor(R.styleable.SlidePager_slide_progress_text_color,
                res.getColor(R.color.default_progress_text_color));

        mReachedWidth = attributes.getDimension(R.styleable.SlidePager_slide_progress_reached_width,
                res.getDimension(R.dimen.default_progress_reached_width));
        //Do not recycle attributes, we need them for the future views
    } else {
        mShowStreaks = true;
        mShowProgressText = true;
        mShowProgressPlusMark = true;
        mHasToReanimate = true;

        mCompletedColor = progress != null && progress.getCompletedColor() != null
                ? progress.getCompletedColor()
                : res.getColor(R.color.default_progress_completed_reach_color);
        mCompletedFillColor = res.getColor(R.color.default_progress_completed_fill_color);

        mNotCompletedReachColor = res.getColor(R.color.default_progress_not_completed_reach_color);
        mNotCompletedOutlineColor = res.getColor(R.color.default_progress_not_completed_outline_color);
        mNotCompletedOutlineSize = res.getDimension(R.dimen.circular_bar_default_outline_width);
        mNotCompletedFutureOutlineSize = res.getDimension(R.dimen.circular_bar_default_future_outline_width);
        mNotCompletedFillColor = res.getColor(R.color.default_progress_not_completed_fill_color);

        mSpecialReachColor = res.getColor(R.color.default_progress_special_reach_color);
        mSpecialOutlineColor = res.getColor(R.color.default_progress_special_outline_color);
        mSpecialFillColor = res.getColor(R.color.default_progress_special_fill_color);

        mProgressTextColor = res.getColor(R.color.default_progress_text_color);

        mReachedWidth = res.getDimension(R.dimen.default_progress_reached_width);
    }
    loadProgressTextLabels(res);

    setCircleColorsAndSize();

    initAnimations();

    return this;
}

From source file:com.ruesga.timelinechart.TimelineChartView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mUiHandler = new Handler(Looper.getMainLooper(), mMessenger);
    if (!isInEditMode()) {
        mAudioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    }//w w  w.j  a  va2 s  .c o m

    final Resources res = getResources();
    final Resources.Theme theme = ctx.getTheme();

    mTickFormats = getResources().getStringArray(R.array.tlcDefTickLabelFormats);
    mTickLabels = getResources().getStringArray(R.array.tlcDefTickLabelValues);

    final DisplayMetrics dp = getResources().getDisplayMetrics();
    mSize8 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8, dp);
    mSize12 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dp);
    mSize20 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, dp);

    final ViewConfiguration vc = ViewConfiguration.get(ctx);
    mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
    mTouchSlop = vc.getScaledTouchSlop() / 2;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(ctx);

    int graphBgColor = ContextCompat.getColor(ctx, R.color.tlcDefGraphBackgroundColor);
    int footerBgColor = ContextCompat.getColor(ctx, R.color.tlcDefFooterBackgroundColor);

    mDefFooterBarHeight = mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight);
    mShowFooter = res.getBoolean(R.bool.tlcDefShowFooter);
    mGraphMode = res.getInteger(R.integer.tlcDefGraphMode);
    mPlaySelectionSoundEffect = res.getBoolean(R.bool.tlcDefPlaySelectionSoundEffect);
    mSelectionSoundEffectSource = res.getInteger(R.integer.tlcDefSelectionSoundEffectSource);
    mAnimateCursorTransition = res.getBoolean(R.bool.tlcDefAnimateCursorTransition);
    mFollowCursorPosition = res.getBoolean(R.bool.tlcDefFollowCursorPosition);
    mAlwaysEnsureSelection = res.getBoolean(R.bool.tlcDefAlwaysEnsureSelection);

    mGraphAreaBgPaint = new Paint();
    mGraphAreaBgPaint.setColor(graphBgColor);
    mFooterAreaBgPaint = new Paint();
    mFooterAreaBgPaint.setColor(footerBgColor);
    mTickLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mTickLabelFgPaint.setFakeBoldText(true);
    mTickLabelFgPaint.setColor(MaterialPaletteHelper.isDarkColor(footerBgColor) ? Color.LTGRAY : Color.DKGRAY);

    mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth);
    mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace);

    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.tlcTimelineChartView, defStyleAttr,
            defStyleRes);
    try {
        int n = a.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = a.getIndex(i);
            if (attr == R.styleable.tlcTimelineChartView_tlcGraphBackground) {
                graphBgColor = a.getColor(attr, graphBgColor);
                mGraphAreaBgPaint.setColor(graphBgColor);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcShowFooter) {
                mShowFooter = a.getBoolean(attr, mShowFooter);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBackground) {
                footerBgColor = a.getColor(attr, footerBgColor);
                mFooterAreaBgPaint.setColor(footerBgColor);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBarHeight) {
                mFooterBarHeight = a.getDimension(attr, mFooterBarHeight);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcGraphMode) {
                mGraphMode = a.getInt(attr, mGraphMode);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcAnimateCursorTransition) {
                mAnimateCursorTransition = a.getBoolean(attr, mAnimateCursorTransition);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFollowCursorPosition) {
                mFollowCursorPosition = a.getBoolean(attr, mFollowCursorPosition);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcAlwaysEnsureSelection) {
                mAlwaysEnsureSelection = a.getBoolean(attr, mAlwaysEnsureSelection);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemWidth) {
                mBarItemWidth = a.getDimension(attr, mBarItemWidth);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemSpace) {
                mBarItemSpace = a.getDimension(attr, mBarItemSpace);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcPlaySelectionSoundEffect) {
                mPlaySelectionSoundEffect = a.getBoolean(attr, mPlaySelectionSoundEffect);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcSelectionSoundEffectSource) {
                mSelectionSoundEffectSource = a.getInt(attr, mSelectionSoundEffectSource);
            }
        }
    } finally {
        a.recycle();
    }

    // SurfaceView requires a background
    if (getBackground() == null) {
        setBackgroundColor(ContextCompat.getColor(ctx, android.R.color.transparent));
    }

    // Minimize the impact of create dynamic layouts by assume that in most case
    // we will have a day formatter
    mTickHasDayFormat = true;

    // Initialize stuff
    setupBackgroundHandler();
    setupTickLabels();
    if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) {
        setupEdgeEffects();
    }
    setupAnimators();
    setupSoundEffects();

    // Initialize the drawing refs (this will be update when we have
    // the real size of the canvas)
    computeBoundAreas();

    // Create a fake data for the edit mode
    if (isInEditMode()) {
        setupViewInEditMode();
    }
}

From source file:com.android.ex.chips.RecipientEditTextView.java

private void setChipDimensions(final Context context, final AttributeSet attrs) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecipientEditTextView, 0, 0);
    final Resources r = getContext().getResources();
    mChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_chipBackground);
    if (mChipBackground == null)
        mChipBackground = ContextCompat.getDrawable(context, R.drawable.circle_background_chips);
    mChipBackgroundPressed = a.getDrawable(R.styleable.RecipientEditTextView_chipBackgroundPressed);
    if (mChipBackgroundPressed == null)
        mChipBackgroundPressed = ContextCompat.getDrawable(context, R.drawable.chip_background_selected);
    mChipDelete = a.getDrawable(R.styleable.RecipientEditTextView_chipDelete);
    if (mChipDelete == null)
        mChipDelete = ContextCompat.getDrawable(context, R.drawable.chip_delete);
    mChipPadding = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipPadding, -1);
    if (mChipPadding == -1)
        mChipPadding = (int) r.getDimension(R.dimen.chip_padding);
    mAlternatesLayout = a.getResourceId(R.styleable.RecipientEditTextView_chipAlternatesLayout, -1);
    if (mAlternatesLayout == -1)
        mAlternatesLayout = R.layout.chips_alternate_item;
    mDefaultContactPhoto = BitmapFactory.decodeResource(r, R.drawable.ic_contact_picture);
    mMoreItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.more_item, null);
    mChipHeight = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipHeight, -1);
    if (mChipHeight == -1)
        mChipHeight = r.getDimension(R.dimen.chip_height);
    mChipFontSize = a.getDimensionPixelSize(R.styleable.RecipientEditTextView_chipFontSize, -1);
    if (mChipFontSize == -1)
        mChipFontSize = r.getDimension(R.dimen.chip_text_size);
    mInvalidChipBackground = a.getDrawable(R.styleable.RecipientEditTextView_invalidChipBackground);
    if (mInvalidChipBackground == null)
        mInvalidChipBackground = ContextCompat.getDrawable(context, R.drawable.chip_background_invalid);
    mLineSpacingExtra = r.getDimension(R.dimen.line_spacing_extra);
    mMaxLines = r.getInteger(R.integer.chips_max_lines);
    final TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    a.recycle();//from   w ww . j  a  va  2s  . co m
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

public AnyKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    //creating the KeyDrawableStateProvider, as it suppose to be backward compatible
    int keyTypeFunctionAttrId = R.attr.key_type_function;
    int keyActionAttrId = R.attr.key_type_action;
    int keyActionTypeDoneAttrId = R.attr.action_done;
    int keyActionTypeSearchAttrId = R.attr.action_search;
    int keyActionTypeGoAttrId = R.attr.action_go;

    LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // int previewLayout = 0;
    mPreviewKeyTextSize = -1;//  w w  w  . j  a va  2s . co  m
    mPreviewLabelTextSize = -1;
    mPreviewKeyBackground = null;
    mPreviewKeyTextColor = 0xFFF;
    final int[] padding = new int[] { 0, 0, 0, 0 };

    KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(context.getApplicationContext());
    final int keyboardThemeStyleResId = getKeyboardStyleResId(theme);
    Log.d(TAG, "Will use keyboard theme " + theme.getName() + " id " + theme.getId() + " res "
            + keyboardThemeStyleResId);

    //creating a mapping from the remote Attribute IDs to my local attribute ID.
    //this is required in order to backward support any build-system (which may cause the attribute IDs to change)
    final SparseIntArray attributeIdMap = new SparseIntArray(R.styleable.AnyKeyboardViewTheme.length
            + R.styleable.AnyKeyboardViewIconsTheme.length + ACTION_KEY_TYPES.length + KEY_TYPES.length);

    final int[] remoteKeyboardThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable(
            R.styleable.AnyKeyboardViewTheme, context, theme.getPackageContext(), attributeIdMap);
    final int[] remoteKeyboardIconsThemeStyleable = KeyboardSupport.createBackwardCompatibleStyleable(
            R.styleable.AnyKeyboardViewIconsTheme, context, theme.getPackageContext(), attributeIdMap);

    HashSet<Integer> doneLocalAttributeIds = new HashSet<Integer>();
    TypedArray a = theme.getPackageContext().obtainStyledAttributes(keyboardThemeStyleResId,
            remoteKeyboardThemeStyleable);
    final int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        final int remoteIndex = a.getIndex(i);
        final int localAttrId = attributeIdMap.get(remoteKeyboardThemeStyleable[remoteIndex]);
        if (setValueFromTheme(a, padding, localAttrId, remoteIndex)) {
            doneLocalAttributeIds.add(localAttrId);
            if (localAttrId == R.attr.keyBackground) {
                //keyTypeFunctionAttrId and keyActionAttrId are remote
                final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable(KEY_TYPES,
                        context, theme.getPackageContext(), attributeIdMap);
                keyTypeFunctionAttrId = keyStateAttributes[0];
                keyActionAttrId = keyStateAttributes[1];
            }
        }
    }
    a.recycle();
    // taking icons
    int iconSetStyleRes = theme.getIconsThemeResId();
    Log.d(TAG, "Will use keyboard icons theme " + theme.getName() + " id " + theme.getId() + " res "
            + iconSetStyleRes);
    if (iconSetStyleRes != 0) {
        a = theme.getPackageContext().obtainStyledAttributes(iconSetStyleRes,
                remoteKeyboardIconsThemeStyleable);
        final int iconsCount = a.getIndexCount();
        for (int i = 0; i < iconsCount; i++) {
            final int remoteIndex = a.getIndex(i);
            final int localAttrId = attributeIdMap.get(remoteKeyboardIconsThemeStyleable[remoteIndex]);
            if (setKeyIconValueFromTheme(theme, a, localAttrId, remoteIndex)) {
                doneLocalAttributeIds.add(localAttrId);
                if (localAttrId == R.attr.iconKeyAction) {
                    //keyActionTypeDoneAttrId and keyActionTypeSearchAttrId and keyActionTypeGoAttrId are remote
                    final int[] keyStateAttributes = KeyboardSupport.createBackwardCompatibleStyleable(
                            ACTION_KEY_TYPES, context, theme.getPackageContext(), attributeIdMap);
                    keyActionTypeDoneAttrId = keyStateAttributes[0];
                    keyActionTypeSearchAttrId = keyStateAttributes[1];
                    keyActionTypeGoAttrId = keyStateAttributes[2];
                }
            }
        }
        a.recycle();
    }
    // filling what's missing
    KeyboardTheme fallbackTheme = KeyboardThemeFactory.getFallbackTheme(context.getApplicationContext());
    final int keyboardFallbackThemeStyleResId = getKeyboardStyleResId(fallbackTheme);
    Log.d(TAG, "Will use keyboard fallback theme " + fallbackTheme.getName() + " id " + fallbackTheme.getId()
            + " res " + keyboardFallbackThemeStyleResId);
    a = fallbackTheme.getPackageContext().obtainStyledAttributes(keyboardFallbackThemeStyleResId,
            R.styleable.AnyKeyboardViewTheme);

    final int fallbackCount = a.getIndexCount();
    for (int i = 0; i < fallbackCount; i++) {
        final int index = a.getIndex(i);
        final int attrId = R.styleable.AnyKeyboardViewTheme[index];
        if (doneLocalAttributeIds.contains(attrId))
            continue;
        Log.d(TAG, "Falling back theme res ID " + index);
        setValueFromTheme(a, padding, attrId, index);
    }
    a.recycle();
    // taking missing icons
    int fallbackIconSetStyleId = fallbackTheme.getIconsThemeResId();
    Log.d(TAG, "Will use keyboard fallback icons theme " + fallbackTheme.getName() + " id "
            + fallbackTheme.getId() + " res " + fallbackIconSetStyleId);
    a = fallbackTheme.getPackageContext().obtainStyledAttributes(fallbackIconSetStyleId,
            R.styleable.AnyKeyboardViewIconsTheme);

    final int fallbackIconsCount = a.getIndexCount();
    for (int i = 0; i < fallbackIconsCount; i++) {
        final int index = a.getIndex(i);
        final int attrId = R.styleable.AnyKeyboardViewIconsTheme[index];
        if (doneLocalAttributeIds.contains(attrId))
            continue;
        Log.d(TAG, "Falling back icon res ID " + index);
        setKeyIconValueFromTheme(fallbackTheme, a, attrId, index);
    }
    a.recycle();
    //creating the key-drawable state provider, as we suppose to have the entire data now
    mDrawableStatesProvider = new KeyDrawableStateProvider(keyTypeFunctionAttrId, keyActionAttrId,
            keyActionTypeDoneAttrId, keyActionTypeSearchAttrId, keyActionTypeGoAttrId);

    // settings.
    // don't forget that there are TWO paddings, the theme's and the
    // background image's padding!
    Drawable keyboardBabground = super.getBackground();
    if (keyboardBabground != null) {
        Rect backgroundPadding = new Rect();
        keyboardBabground.getPadding(backgroundPadding);
        padding[0] += backgroundPadding.left;
        padding[1] += backgroundPadding.top;
        padding[2] += backgroundPadding.right;
        padding[3] += backgroundPadding.bottom;
    }
    super.setPadding(padding[0], padding[1], padding[2], padding[3]);

    final Resources res = getResources();
    mKeyboardDimens.setKeyboardMaxWidth(res.getDisplayMetrics().widthPixels - padding[0] - padding[2]);
    mPreviewPopup = new PopupWindow(context);
    if (mPreviewKeyTextSize > 0) {
        if (mPreviewLabelTextSize <= 0)
            mPreviewLabelTextSize = mPreviewKeyTextSize;
        mPreviewLayut = inflatePreviewWindowLayout(inflate);
        mPreviewText = (TextView) mPreviewLayut.findViewById(R.id.key_preview_text);
        mPreviewText.setTextColor(mPreviewKeyTextColor);
        mPreviewText.setTypeface(mKeyTextStyle);
        mPreviewIcon = (ImageView) mPreviewLayut.findViewById(R.id.key_preview_icon);
        mPreviewPopup.setBackgroundDrawable(mPreviewKeyBackground);
        mPreviewPopup.setContentView(mPreviewLayut);
        mShowPreview = mPreviewLayut != null;
    } else {
        mPreviewLayut = null;
        mPreviewText = null;
        mShowPreview = false;
    }
    mPreviewPopup.setTouchable(false);
    mPreviewPopup
            .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.KeyPreviewAnimation);
    mDelayBeforePreview = 0;
    mDelayAfterPreview = 10;

    mMiniKeyboardParent = this;
    mMiniKeyboardPopup = new PopupWindow(context.getApplicationContext());
    mMiniKeyboardPopup.setBackgroundDrawable(null);

    mMiniKeyboardPopup
            .setAnimationStyle((mAnimationLevel == AnimationsLevel.None) ? 0 : R.style.MiniKeyboardAnimation);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(mKeyTextSize);
    mPaint.setTextAlign(Align.CENTER);
    mPaint.setAlpha(255);

    mKeyBackgroundPadding = new Rect(0, 0, 0, 0);
    mKeyBackground.getPadding(mKeyBackgroundPadding);

    reloadSwipeThresholdsSettings(res);

    mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance);

    AskOnGestureListener listener = new AskGestureEventsListener(this);

    mGestureDetector = AnyApplication.getDeviceSpecific().createGestureDetector(getContext(), listener);
    mGestureDetector.setIsLongpressEnabled(false);

    MultiTouchSupportLevel multiTouchSupportLevel = AnyApplication.getDeviceSpecific()
            .getMultiTouchSupportLevel(getContext());

    mHasDistinctMultitouch = multiTouchSupportLevel == MultiTouchSupportLevel.Distinct;

    mKeyRepeatInterval = 50;

    AnyApplication.getConfig().addChangedListener(this);
}