Separate candidate divider from candidate view

This change is one of the preparations for suggestion strip redesign.

Bug: 4175031
Change-Id: Ia0dc487c11c3005ef19b87ec0efcc18e48411f76
main
Tadashi G. Takaoka 2011-06-06 17:23:18 +09:00
parent 7d494b67a1
commit ddb61ea461
3 changed files with 40 additions and 17 deletions

View File

@ -24,17 +24,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
> >
<ImageView
android:id="@+id/candidate_divider"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/keyboard_suggest_strip_divider"
android:paddingRight="@dimen/candidate_padding"
android:paddingLeft="@dimen/candidate_padding"
android:visibility="invisible"
android:focusable="false"
android:clickable="false"
android:gravity="center_vertical|center_horizontal" />
<Button <Button
android:id="@+id/candidate_word" android:id="@+id/candidate_word"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, 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.
*/
-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/candidate_divider"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/keyboard_suggest_strip_divider"
android:paddingRight="@dimen/candidate_padding"
android:paddingLeft="@dimen/candidate_padding"
android:focusable="false"
android:clickable="false"
android:gravity="center_vertical|center_horizontal" />

View File

@ -16,8 +16,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
@ -40,11 +38,12 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import android.widget.TextView; import android.widget.TextView;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -57,6 +56,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean DBG = LatinImeLogger.sDBG;
private final ArrayList<View> mWords = new ArrayList<View>(); private final ArrayList<View> mWords = new ArrayList<View>();
private final ArrayList<View> mDividers = new ArrayList<View>();
private final boolean mConfigCandidateHighlightFontColorEnabled; private final boolean mConfigCandidateHighlightFontColorEnabled;
private final CharacterStyle mInvertedForegroundColorSpan; private final CharacterStyle mInvertedForegroundColorSpan;
private final CharacterStyle mInvertedBackgroundColorSpan; private final CharacterStyle mInvertedBackgroundColorSpan;
@ -148,10 +148,11 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
tv.setOnClickListener(this); tv.setOnClickListener(this);
if (i == 0) if (i == 0)
tv.setOnLongClickListener(this); tv.setOnLongClickListener(this);
ImageView divider = (ImageView)v.findViewById(R.id.candidate_divider);
// Do not display divider of first candidate.
divider.setVisibility(i == 0 ? INVISIBLE : VISIBLE);
mWords.add(v); mWords.add(v);
if (i > 0) {
View divider = inflater.inflate(R.layout.candidate_divider, null);
mDividers.add(divider);
}
} }
scrollTo(0, getScrollY()); scrollTo(0, getScrollY());
@ -237,6 +238,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
} else { } else {
dv.setVisibility(GONE); dv.setVisibility(GONE);
} }
if (i > 0)
addView(mDividers.get(i - 1));
addView(v); addView(v);
} }