From c8461d1ae26d43a09c0f835d833f3d49fbe8d2f3 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 2 Apr 2012 22:55:12 +0900 Subject: [PATCH] Cleanup FrameLayoutCompatUtils to ViewLayoutUtils Bug: 6129704 Change-Id: I52f2e236c7dae3ac2cba64392165f955a53d3f42 --- .../inputmethod/keyboard/KeyboardView.java | 5 ++--- .../ViewLayoutUtils.java} | 19 ++++--------------- .../latin/suggestions/SuggestionsView.java | 4 ++-- 3 files changed, 8 insertions(+), 20 deletions(-) rename java/src/com/android/inputmethod/{compat/FrameLayoutCompatUtils.java => keyboard/ViewLayoutUtils.java} (73%) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index c1d11a086..b51dbb906 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -37,7 +37,6 @@ import android.view.ViewGroup; import android.widget.RelativeLayout; import android.widget.TextView; -import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; @@ -853,7 +852,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { windowContentView.addView(mPreviewPlacer); } mPreviewPlacer.addView( - keyPreview, FrameLayoutCompatUtils.newLayoutParam(mPreviewPlacer, 0, 0)); + keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacer, 0, 0)); } private void showKey(PointerTracker tracker) { @@ -919,7 +918,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { previewText.getBackground().setState( key.mMoreKeys != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET); previewText.setTextColor(params.mPreviewTextColor); - FrameLayoutCompatUtils.placeViewAt( + ViewLayoutUtils.placeViewAt( previewText, previewX, previewY, previewWidth, previewHeight); previewText.setVisibility(VISIBLE); } diff --git a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java b/java/src/com/android/inputmethod/keyboard/ViewLayoutUtils.java similarity index 73% rename from java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java rename to java/src/com/android/inputmethod/keyboard/ViewLayoutUtils.java index 523bf7d0e..ee5047083 100644 --- a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java +++ b/java/src/com/android/inputmethod/keyboard/ViewLayoutUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.inputmethod.compat; +package com.android.inputmethod.keyboard; import android.view.View; import android.view.ViewGroup; @@ -22,20 +22,9 @@ import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; import android.widget.RelativeLayout; -public class FrameLayoutCompatUtils { - private static final boolean NEEDS_FRAME_LAYOUT_HACK = ( - android.os.Build.VERSION.SDK_INT < 11 /* Honeycomb */); - - public static ViewGroup getPlacer(ViewGroup container) { - if (NEEDS_FRAME_LAYOUT_HACK) { - // Insert RelativeLayout to be able to setMargin because pre-Honeycomb FrameLayout - // could not handle setMargin properly. - final ViewGroup placer = new RelativeLayout(container.getContext()); - container.addView(placer); - return placer; - } else { - return container; - } +public class ViewLayoutUtils { + private ViewLayoutUtils() { + // This utility class is not publicly instantiable. } public static MarginLayoutParams newLayoutParam(ViewGroup placer, int width, int height) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index ca253543e..1ad37b933 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -52,11 +52,11 @@ import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; -import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.MoreKeysPanel; import com.android.inputmethod.keyboard.PointerTracker; +import com.android.inputmethod.keyboard.ViewLayoutUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; @@ -416,7 +416,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, ViewGroup.LayoutParams.WRAP_CONTENT); final int infoWidth = info.getMeasuredWidth(); final int y = info.getMeasuredHeight(); - FrameLayoutCompatUtils.placeViewAt( + ViewLayoutUtils.placeViewAt( info, x - infoWidth, y, infoWidth, info.getMeasuredHeight()); } }