aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-11-26 18:34:35 +0900
committerTadashi G. Takaoka <takaoka@google.com>2013-11-27 11:51:05 +0900
commit6bd28dfa996e814fe667b077082c78be05472104 (patch)
tree2f8da1234d26e36ad2f6b6879fdc959cda0eb903 /java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
parent091865a26606606691a95ffba617fc3bfaf9764a (diff)
downloadlatinime-6bd28dfa996e814fe667b077082c78be05472104.tar.gz
latinime-6bd28dfa996e814fe667b077082c78be05472104.tar.xz
latinime-6bd28dfa996e814fe667b077082c78be05472104.zip
Remove compiler warnings from emoji related code
Change-Id: I88ed0d25bee87c4dabcbc425589215b901345908
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
new file mode 100644
index 000000000..0796f8ea1
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+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;
+
+ public final int mEmojiPagerHeight;
+ private final int mEmojiPagerBottomMargin;
+ public final int mEmojiKeyboardHeight;
+ private final int mEmojiCategoryPageIdViewHeight;
+ public final int mEmojiActionBarHeight;
+ public final int mKeyVerticalGap;
+ private final int mKeyHorizontalGap;
+ private final int mBottomPadding;
+ private final int mTopPadding;
+
+ public EmojiLayoutParams(final Resources res) {
+ final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
+ final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
+ mKeyVerticalGap = (int) res.getFraction(R.fraction.key_bottom_gap_holo,
+ defaultKeyboardHeight, defaultKeyboardHeight);
+ mBottomPadding = (int) res.getFraction(R.fraction.keyboard_bottom_padding_holo,
+ defaultKeyboardHeight, defaultKeyboardHeight);
+ mTopPadding = (int) res.getFraction(R.fraction.keyboard_top_padding_holo,
+ defaultKeyboardHeight, defaultKeyboardHeight);
+ mKeyHorizontalGap = (int) (res.getFraction(R.fraction.key_horizontal_gap_holo,
+ defaultKeyboardWidth, defaultKeyboardWidth));
+ mEmojiCategoryPageIdViewHeight =
+ (int) (res.getDimension(R.dimen.emoji_category_page_id_height));
+ final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding
+ + mKeyVerticalGap;
+ mEmojiActionBarHeight = baseheight / DEFAULT_KEYBOARD_ROWS
+ - (mKeyVerticalGap - mBottomPadding) / 2;
+ mEmojiPagerHeight = defaultKeyboardHeight - mEmojiActionBarHeight
+ - mEmojiCategoryPageIdViewHeight;
+ mEmojiPagerBottomMargin = 0;
+ mEmojiKeyboardHeight = mEmojiPagerHeight - mEmojiPagerBottomMargin - 1;
+ }
+
+ public void setPagerProperties(final ViewPager vp) {
+ final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
+ lp.height = mEmojiKeyboardHeight;
+ lp.bottomMargin = mEmojiPagerBottomMargin;
+ vp.setLayoutParams(lp);
+ }
+
+ public void setCategoryPageIdViewProperties(final LinearLayout ll) {
+ final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
+ lp.height = mEmojiCategoryPageIdViewHeight;
+ ll.setLayoutParams(lp);
+ }
+
+ public void setActionBarProperties(final LinearLayout ll) {
+ final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
+ lp.height = mEmojiActionBarHeight - mBottomPadding;
+ ll.setLayoutParams(lp);
+ }
+
+ public void setKeyProperties(final ImageView ib) {
+ final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams();
+ lp.leftMargin = mKeyHorizontalGap / 2;
+ lp.rightMargin = mKeyHorizontalGap / 2;
+ ib.setLayoutParams(lp);
+ }
+}