2011-08-24 05:44:46 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-12-16 02:26:14 +00:00
|
|
|
package com.android.inputmethod.latin.suggestions;
|
2011-08-24 05:44:46 +00:00
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
2012-12-03 02:47:52 +00:00
|
|
|
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
|
2011-12-16 02:26:14 +00:00
|
|
|
import com.android.inputmethod.latin.R;
|
2011-08-24 05:44:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A view that renders a virtual {@link MoreSuggestions}. It handles rendering of keys and detecting
|
|
|
|
* key presses and touch movements.
|
|
|
|
*/
|
2012-12-03 02:47:52 +00:00
|
|
|
public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
2012-10-03 05:46:47 +00:00
|
|
|
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
|
2011-09-05 07:46:15 +00:00
|
|
|
this(context, attrs, R.attr.moreSuggestionsViewStyle);
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 05:46:47 +00:00
|
|
|
public MoreSuggestionsView(final Context context, final AttributeSet attrs,
|
|
|
|
final int defStyle) {
|
2011-08-24 05:44:46 +00:00
|
|
|
super(context, attrs, defStyle);
|
2012-12-03 02:47:52 +00:00
|
|
|
}
|
2011-08-24 05:44:46 +00:00
|
|
|
|
2012-12-03 02:47:52 +00:00
|
|
|
@Override
|
|
|
|
protected int getDefaultCoordX() {
|
|
|
|
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
|
|
|
|
return pane.mOccupiedWidth / 2;
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|
|
|
|
|
2012-10-16 20:26:45 +00:00
|
|
|
public void updateKeyboardGeometry(final int keyHeight) {
|
2013-04-11 03:08:36 +00:00
|
|
|
updateKeyDrawParams(keyHeight);
|
2012-10-16 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 05:44:46 +00:00
|
|
|
@Override
|
2013-01-22 05:32:47 +00:00
|
|
|
public void onCodeInput(final int code, final int x, final int y) {
|
|
|
|
final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
|
2012-12-03 02:47:52 +00:00
|
|
|
if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
|
|
|
|
mListener.onCustomRequest(index);
|
2011-09-06 02:37:51 +00:00
|
|
|
}
|
2012-12-03 06:49:10 +00:00
|
|
|
}
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|