mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
ec1b40bf83
--HG-- rename : mobile/android/base/GeckoEditText.java.in => mobile/android/base/widget/GeckoEditText.java.in rename : mobile/android/base/GeckoImageButton.java.in => mobile/android/base/widget/GeckoImageButton.java.in rename : mobile/android/base/GeckoImageView.java.in => mobile/android/base/widget/GeckoImageView.java.in rename : mobile/android/base/GeckoLinearLayout.java.in => mobile/android/base/widget/GeckoLinearLayout.java.in rename : mobile/android/base/GeckoRelativeLayout.java.in => mobile/android/base/widget/GeckoRelativeLayout.java.in rename : mobile/android/base/GeckoTextSwitcher.java.in => mobile/android/base/widget/GeckoTextSwitcher.java.in rename : mobile/android/base/GeckoTextView.java.in => mobile/android/base/widget/GeckoTextView.java.in rename : mobile/android/base/GeckoView.java.frag => mobile/android/base/widget/GeckoView.java.frag
81 lines
2.7 KiB
Java
81 lines
2.7 KiB
Java
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
import org.mozilla.gecko.widget.GeckoEditText;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
|
|
public class CustomEditText extends GeckoEditText {
|
|
private OnKeyPreImeListener mOnKeyPreImeListener;
|
|
private OnSelectionChangedListener mOnSelectionChangedListener;
|
|
private OnWindowFocusChangeListener mOnWindowFocusChangeListener;
|
|
|
|
public CustomEditText(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
mOnKeyPreImeListener = null;
|
|
}
|
|
|
|
public interface OnKeyPreImeListener {
|
|
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event);
|
|
}
|
|
|
|
public void setOnKeyPreImeListener(OnKeyPreImeListener listener) {
|
|
mOnKeyPreImeListener = listener;
|
|
}
|
|
|
|
@Override
|
|
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
|
|
if (mOnKeyPreImeListener != null)
|
|
return mOnKeyPreImeListener.onKeyPreIme(this, keyCode, event);
|
|
|
|
return false;
|
|
}
|
|
|
|
public interface OnSelectionChangedListener {
|
|
public void onSelectionChanged(int selStart, int selEnd);
|
|
}
|
|
|
|
public void setOnSelectionChangedListener(OnSelectionChangedListener listener) {
|
|
mOnSelectionChangedListener = listener;
|
|
}
|
|
|
|
@Override
|
|
protected void onSelectionChanged(int selStart, int selEnd) {
|
|
if (mOnSelectionChangedListener != null)
|
|
mOnSelectionChangedListener.onSelectionChanged(selStart, selEnd);
|
|
|
|
super.onSelectionChanged(selStart, selEnd);
|
|
}
|
|
|
|
public interface OnWindowFocusChangeListener {
|
|
public void onWindowFocusChanged(boolean hasFocus);
|
|
}
|
|
|
|
public void setOnWindowFocusChangeListener(OnWindowFocusChangeListener listener) {
|
|
mOnWindowFocusChangeListener = listener;
|
|
}
|
|
|
|
@Override
|
|
public void onWindowFocusChanged(boolean hasFocus) {
|
|
super.onWindowFocusChanged(hasFocus);
|
|
if (mOnWindowFocusChangeListener != null)
|
|
mOnWindowFocusChangeListener.onWindowFocusChanged(hasFocus);
|
|
}
|
|
|
|
@Override
|
|
public void setPrivateMode(boolean isPrivate) {
|
|
super.setPrivateMode(isPrivate);
|
|
|
|
// android:textColorHighlight cannot support a ColorStateList.
|
|
int colorId = isPrivate ? R.color.url_bar_text_highlight_pb : R.color.url_bar_text_highlight;
|
|
setHighlightColor(getContext().getResources().getColor(colorId));
|
|
}
|
|
}
|