am f3b92fb9: Merge "Fix IllegalStateException of ViewGroup"

* commit 'f3b92fb952cac605118bac22e21a1fccb843183f':
  Fix IllegalStateException of ViewGroup
main
Tadashi G. Takaoka 2013-12-16 00:39:27 -08:00 committed by Android Git Automerger
commit ad23710f1d
3 changed files with 29 additions and 10 deletions

View File

@ -932,11 +932,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
locatePreviewPlacerView();
// TODO: Remove this check
if (panel.isShowingInParent()) {
panel.dismissMoreKeysPanel();
}
mPreviewPlacerView.addView(panel.getContainerView());
panel.showInParent(mPreviewPlacerView);
mMoreKeysPanel = panel;
dimEntireKeyboard(true /* dimmed */);
}
@ -954,7 +950,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
dimEntireKeyboard(false /* dimmed */);
if (isShowingMoreKeysPanel()) {
mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
mMoreKeysPanel.removeFromParent();
mMoreKeysPanel = null;
}
}

View File

@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
@ -216,11 +217,25 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
return true;
}
@Override
public View getContainerView() {
private View getContainerView() {
return (View)getParent();
}
@Override
public void showInParent(final ViewGroup parentView) {
removeFromParent();
parentView.addView(getContainerView());
}
@Override
public void removeFromParent() {
final View containerView = getContainerView();
final ViewGroup currentParent = (ViewGroup)containerView.getParent();
if (currentParent != null) {
currentParent.removeView(containerView);
}
}
@Override
public boolean isShowingInParent() {
return (getContainerView().getParent() != null);

View File

@ -17,6 +17,7 @@
package com.android.inputmethod.keyboard;
import android.view.View;
import android.view.ViewGroup;
public interface MoreKeysPanel {
public interface Controller {
@ -119,9 +120,16 @@ public interface MoreKeysPanel {
public int translateY(int y);
/**
* Return the view containing the more keys panel.
* Show this {@link MoreKeysPanel} in the parent view.
*
* @param parentView the {@link ViewGroup} that hosts this {@link MoreKeysPanel}.
*/
public View getContainerView();
public void showInParent(ViewGroup parentView);
/**
* Remove this {@link MoreKeysPanel} from the parent view.
*/
public void removeFromParent();
/**
* Return whether the panel is currently being shown.