2013-09-10 08:55:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
package com.android.inputmethod.keyboard.internal;
|
2013-09-10 08:55:44 +00:00
|
|
|
|
|
|
|
import com.android.inputmethod.latin.R;
|
|
|
|
import com.android.inputmethod.latin.utils.ResourceUtils;
|
|
|
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
|
|
|
public class EmojiLayoutParams {
|
|
|
|
private static final int DEFAULT_KEYBOARD_ROWS = 4;
|
|
|
|
|
2013-09-13 12:49:53 +00:00
|
|
|
public final int mEmojiPagerHeight;
|
|
|
|
private final int mEmojiPagerBottomMargin;
|
2013-09-10 08:55:44 +00:00
|
|
|
public final int mEmojiKeyboardHeight;
|
2013-09-18 08:02:37 +00:00
|
|
|
private final int mEmojiCategoryPageIdViewHeight;
|
2013-09-10 08:55:44 +00:00
|
|
|
public final int mEmojiActionBarHeight;
|
|
|
|
public final int mKeyVerticalGap;
|
|
|
|
private final int mKeyHorizontalGap;
|
|
|
|
private final int mBottomPadding;
|
|
|
|
private final int mTopPadding;
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public EmojiLayoutParams(final Resources res) {
|
2013-09-10 08:55:44 +00:00
|
|
|
final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
|
|
|
final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
2013-12-13 08:09:16 +00:00
|
|
|
mKeyVerticalGap = (int) res.getFraction(R.fraction.config_key_vertical_gap_holo,
|
|
|
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
|
|
|
mBottomPadding = (int) res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
|
|
|
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
|
|
|
mTopPadding = (int) res.getFraction(R.fraction.config_keyboard_top_padding_holo,
|
|
|
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
|
|
|
mKeyHorizontalGap = (int) (res.getFraction(R.fraction.config_key_horizontal_gap_holo,
|
2013-09-10 08:55:44 +00:00
|
|
|
defaultKeyboardWidth, defaultKeyboardWidth));
|
2013-09-18 08:02:37 +00:00
|
|
|
mEmojiCategoryPageIdViewHeight =
|
2013-12-13 08:09:16 +00:00
|
|
|
(int) (res.getDimension(R.dimen.config_emoji_category_page_id_height));
|
2013-09-10 08:55:44 +00:00
|
|
|
final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding
|
|
|
|
+ mKeyVerticalGap;
|
2013-12-13 08:09:16 +00:00
|
|
|
mEmojiActionBarHeight = baseheight / DEFAULT_KEYBOARD_ROWS
|
2013-09-10 08:55:44 +00:00
|
|
|
- (mKeyVerticalGap - mBottomPadding) / 2;
|
2013-09-18 08:02:37 +00:00
|
|
|
mEmojiPagerHeight = defaultKeyboardHeight - mEmojiActionBarHeight
|
|
|
|
- mEmojiCategoryPageIdViewHeight;
|
2013-10-04 11:00:05 +00:00
|
|
|
mEmojiPagerBottomMargin = 0;
|
2013-09-13 12:49:53 +00:00
|
|
|
mEmojiKeyboardHeight = mEmojiPagerHeight - mEmojiPagerBottomMargin - 1;
|
2013-09-10 08:55:44 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public void setPagerProperties(final ViewPager vp) {
|
2013-09-10 08:55:44 +00:00
|
|
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
|
2013-09-18 08:02:37 +00:00
|
|
|
lp.height = mEmojiKeyboardHeight;
|
2013-09-13 12:49:53 +00:00
|
|
|
lp.bottomMargin = mEmojiPagerBottomMargin;
|
2013-09-10 08:55:44 +00:00
|
|
|
vp.setLayoutParams(lp);
|
|
|
|
}
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public void setCategoryPageIdViewProperties(final LinearLayout ll) {
|
2013-09-18 08:02:37 +00:00
|
|
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
|
|
|
lp.height = mEmojiCategoryPageIdViewHeight;
|
|
|
|
ll.setLayoutParams(lp);
|
|
|
|
}
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public void setActionBarProperties(final LinearLayout ll) {
|
2013-09-10 08:55:44 +00:00
|
|
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
2013-10-01 13:20:56 +00:00
|
|
|
lp.height = mEmojiActionBarHeight - mBottomPadding;
|
2013-09-10 08:55:44 +00:00
|
|
|
ll.setLayoutParams(lp);
|
|
|
|
}
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public void setKeyProperties(final ImageView ib) {
|
2013-09-10 08:55:44 +00:00
|
|
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams();
|
|
|
|
lp.leftMargin = mKeyHorizontalGap / 2;
|
|
|
|
lp.rightMargin = mKeyHorizontalGap / 2;
|
|
|
|
ib.setLayoutParams(lp);
|
|
|
|
}
|
|
|
|
}
|