From ddb61ea461b920d87be4ad78c8a36eec1013b965 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Mon, 6 Jun 2011 17:23:18 +0900 Subject: [PATCH] Separate candidate divider from candidate view This change is one of the preparations for suggestion strip redesign. Bug: 4175031 Change-Id: Ia0dc487c11c3005ef19b87ec0efcc18e48411f76 --- java/res/layout/candidate.xml | 11 ------- java/res/layout/candidate_divider.xml | 31 +++++++++++++++++++ .../inputmethod/latin/CandidateView.java | 15 +++++---- 3 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 java/res/layout/candidate_divider.xml diff --git a/java/res/layout/candidate.xml b/java/res/layout/candidate.xml index aea34acf11..aa2845fb4b 100644 --- a/java/res/layout/candidate.xml +++ b/java/res/layout/candidate.xml @@ -24,17 +24,6 @@ android:layout_height="match_parent" 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 android:id="@+id/candidate_word" android:layout_width="wrap_content" diff --git a/java/res/layout/candidate_divider.xml b/java/res/layout/candidate_divider.xml new file mode 100644 index 0000000000..dc6738a4a6 --- /dev/null +++ b/java/res/layout/candidate_divider.xml @@ -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" /> diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index abdf30e6bc..6c6eb72bb3 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -16,8 +16,6 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; - import android.content.Context; import android.content.res.Resources; import android.graphics.Color; @@ -40,11 +38,12 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.TextView; +import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; + import java.util.ArrayList; import java.util.List; @@ -57,6 +56,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo private static final boolean DBG = LatinImeLogger.sDBG; private final ArrayList<View> mWords = new ArrayList<View>(); + private final ArrayList<View> mDividers = new ArrayList<View>(); private final boolean mConfigCandidateHighlightFontColorEnabled; private final CharacterStyle mInvertedForegroundColorSpan; private final CharacterStyle mInvertedBackgroundColorSpan; @@ -148,10 +148,11 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo tv.setOnClickListener(this); if (i == 0) 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); + if (i > 0) { + View divider = inflater.inflate(R.layout.candidate_divider, null); + mDividers.add(divider); + } } scrollTo(0, getScrollY()); @@ -237,6 +238,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo } else { dv.setVisibility(GONE); } + if (i > 0) + addView(mDividers.get(i - 1)); addView(v); } -- GitLab