Merge "Get rid of LinearLayoutCompatUtils"
commit
0e7bd388d2
|
@ -22,16 +22,9 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
|
||||||
>
|
>
|
||||||
<!-- Placer for debug information -->
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/suggestions_placer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
>
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/suggestions_strip"
|
android:id="@+id/suggestions_strip"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
</RelativeLayout>
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
<dimen name="more_suggestions_key_horizontal_padding">12dip</dimen>
|
<dimen name="more_suggestions_key_horizontal_padding">12dip</dimen>
|
||||||
<dimen name="more_suggestions_row_height">40dip</dimen>
|
<dimen name="more_suggestions_row_height">40dip</dimen>
|
||||||
<dimen name="more_suggestions_slide_allowance">0.2in</dimen>
|
<dimen name="more_suggestions_slide_allowance">0.2in</dimen>
|
||||||
<fraction name="more_suggestions_info_ratio">12%</fraction>
|
<fraction name="more_suggestions_info_ratio">18%</fraction>
|
||||||
<dimen name="key_preview_backing_height">40dip</dimen>
|
<dimen name="key_preview_backing_height">40dip</dimen>
|
||||||
<dimen name="suggestions_strip_padding">0dip</dimen>
|
<dimen name="suggestions_strip_padding">0dip</dimen>
|
||||||
<dimen name="suggestion_min_width">44dip</dimen>
|
<dimen name="suggestion_min_width">44dip</dimen>
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2011 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class LinearLayoutCompatUtils {
|
|
||||||
private static final String TAG = LinearLayoutCompatUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final Class<?> CLASS_R_STYLEABLE = CompatUtils.getClass(
|
|
||||||
"com.android.internal.R$styleable");
|
|
||||||
private static final Field STYLEABLE_VIEW = CompatUtils.getField(
|
|
||||||
CLASS_R_STYLEABLE, "View");
|
|
||||||
private static final Field STYLEABLE_VIEW_BACKGROUND = CompatUtils.getField(
|
|
||||||
CLASS_R_STYLEABLE, "View_background");
|
|
||||||
private static final Object VALUE_STYLEABLE_VIEW = CompatUtils.getFieldValue(
|
|
||||||
null, null, STYLEABLE_VIEW);
|
|
||||||
private static final Integer VALUE_STYLEABLE_VIEW_BACKGROUND =
|
|
||||||
(Integer)CompatUtils.getFieldValue(null, null, STYLEABLE_VIEW_BACKGROUND);
|
|
||||||
|
|
||||||
public static Drawable getBackgroundDrawable(Context context, AttributeSet attrs,
|
|
||||||
int defStyleAttr, int defStyleRes) {
|
|
||||||
if (!(VALUE_STYLEABLE_VIEW instanceof int[]) || VALUE_STYLEABLE_VIEW_BACKGROUND == null) {
|
|
||||||
Log.w(TAG, "Can't get View background attribute using reflection");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int[] styleableView = (int[])VALUE_STYLEABLE_VIEW;
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
|
||||||
attrs, styleableView, defStyleAttr, defStyleRes);
|
|
||||||
final Drawable background = a.getDrawable(VALUE_STYLEABLE_VIEW_BACKGROUND);
|
|
||||||
a.recycle();
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,10 +45,10 @@ import android.view.View.OnLongClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
|
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
|
||||||
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||||
|
@ -58,7 +58,8 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SuggestionsView extends LinearLayout implements OnClickListener, OnLongClickListener {
|
public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
||||||
|
OnLongClickListener {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public boolean addWordToDictionary(String word);
|
public boolean addWordToDictionary(String word);
|
||||||
public void pickSuggestionManually(int index, CharSequence word);
|
public void pickSuggestionManually(int index, CharSequence word);
|
||||||
|
@ -69,7 +70,6 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
|
|
||||||
private static final boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
private final ViewGroup mSuggestionsPlacer;
|
|
||||||
private final ViewGroup mSuggestionsStrip;
|
private final ViewGroup mSuggestionsStrip;
|
||||||
private KeyboardView mKeyboardView;
|
private KeyboardView mKeyboardView;
|
||||||
|
|
||||||
|
@ -451,18 +451,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuggestionsView(Context context, AttributeSet attrs, int defStyle) {
|
public SuggestionsView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
// Note: Up to version 10 (Gingerbread) of the API, LinearLayout doesn't have 3-argument
|
super(context, attrs, defStyle);
|
||||||
// constructor.
|
|
||||||
// TODO: Call 3-argument constructor, super(context, attrs, defStyle), when we abandon
|
|
||||||
// backward compatibility with the version 10 or earlier of the API.
|
|
||||||
super(context, attrs);
|
|
||||||
if (defStyle != R.attr.suggestionsViewStyle) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"can't accept defStyle other than R.attr.suggestionsViewStyle: defStyle="
|
|
||||||
+ defStyle);
|
|
||||||
}
|
|
||||||
setBackgroundDrawable(LinearLayoutCompatUtils.getBackgroundDrawable(
|
|
||||||
context, attrs, defStyle, R.style.SuggestionsViewStyle));
|
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
inflater.inflate(R.layout.suggestions_strip, this);
|
inflater.inflate(R.layout.suggestions_strip, this);
|
||||||
|
@ -474,7 +463,6 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
mPreviewPopup.setContentView(mPreviewText);
|
mPreviewPopup.setContentView(mPreviewText);
|
||||||
mPreviewPopup.setBackgroundDrawable(null);
|
mPreviewPopup.setBackgroundDrawable(null);
|
||||||
|
|
||||||
mSuggestionsPlacer = (ViewGroup)findViewById(R.id.suggestions_placer);
|
|
||||||
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
||||||
for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
|
for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
|
||||||
final TextView word = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
final TextView word = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
||||||
|
@ -527,7 +515,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
if (mSuggestions.size() == 0)
|
if (mSuggestions.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mParams.layout(mSuggestions, mSuggestionsStrip, mSuggestionsPlacer, getWidth());
|
mParams.layout(mSuggestions, mSuggestionsStrip, this, getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
||||||
|
@ -648,9 +636,9 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mShowingAutoCorrectionInverted = false;
|
mShowingAutoCorrectionInverted = false;
|
||||||
mSuggestionsPlacer.removeAllViews();
|
|
||||||
mSuggestionsPlacer.addView(mSuggestionsStrip);
|
|
||||||
mSuggestionsStrip.removeAllViews();
|
mSuggestionsStrip.removeAllViews();
|
||||||
|
removeAllViews();
|
||||||
|
addView(mSuggestionsStrip);
|
||||||
dismissMoreSuggestions();
|
dismissMoreSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue