aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/CandidateView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-06-21 00:11:17 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-06-22 20:16:21 +0900
commita7eed902f1b0d6871d416412b3c6f91163fa2578 (patch)
treeb5c1af841b24bde7efc146f76729b0eae1b3d097 /java/src/com/android/inputmethod/latin/CandidateView.java
parentb947c73dccd2035b786dbfd0e86cc746be3e1718 (diff)
downloadlatinime-a7eed902f1b0d6871d416412b3c6f91163fa2578.tar.gz
latinime-a7eed902f1b0d6871d416412b3c6f91163fa2578.tar.xz
latinime-a7eed902f1b0d6871d416412b3c6f91163fa2578.zip
Make CandidateView backward compatible
Up to version 10 (Gingerbread) of the API, FrameLayout doesn't handle margin properly. This change inserts RelativeLayout to FrameLayout as placer to set margin and place children views absolutely. Change-Id: Iee785bc2da77677738caf456bcd2bbf57b89f007
Diffstat (limited to 'java/src/com/android/inputmethod/latin/CandidateView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index fa27ca5ad..09b356d65 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -44,6 +44,7 @@ import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
+import com.android.inputmethod.compat.FrameLayoutCompatUtils;
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -244,7 +245,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
public void setListener(Listener listener, View inputView) {
mListener = listener;
mKeyboardView = inputView.findViewById(R.id.keyboard_view);
- mCandidatesPane = (ViewGroup)inputView.findViewById(R.id.candidates_pane);
+ mCandidatesPane = FrameLayoutCompatUtils.getPlacer(
+ (ViewGroup)inputView.findViewById(R.id.candidates_pane));
mCandidatesPane.setOnClickListener(this);
mCandidatesPaneContainer = (ViewGroup)inputView.findViewById(
R.id.candidates_pane_container);
@@ -346,12 +348,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
if (x != 0) {
final View divider = mDividers.get(i - NUM_CANDIDATES_IN_STRIP);
- mCandidatesPane.addView(divider);
- placeCandidateAt(divider, x, y);
+ addCandidateAt(divider, x, y);
x += dividerWidth;
}
- mCandidatesPane.addView(tv);
- placeCandidateAt(tv, x, y);
+ addCandidateAt(tv, x, y);
x += width;
}
@@ -372,14 +372,13 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
- private void placeCandidateAt(View v, int x, int y) {
- ViewGroup.LayoutParams lp = v.getLayoutParams();
- if (lp instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
- mlp.width = v.getMeasuredWidth();
- mlp.height = v.getMeasuredHeight();
- mlp.setMargins(x, y + (mCandidateStripHeight - mlp.height) / 2, 0, 0);
- }
+ private void addCandidateAt(View v, int x, int y) {
+ final int width = v.getMeasuredWidth();
+ final int height = v.getMeasuredHeight();
+ final MarginLayoutParams marginLayoutParams = FrameLayoutCompatUtils.newLayoutParam(
+ mCandidatesPane, width, height);
+ marginLayoutParams.setMargins(x, y + (mCandidateStripHeight - height) / 2, 0, 0);
+ mCandidatesPane.addView(v, marginLayoutParams);
}
private void centeringCandidates(int from, int to, int width, int paneWidth) {