This action will force synchronization from 艾润物联/vehicle-keyboard-android, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
VehicleKeyboard
是停车王品牌的各端产品线的基础组件,专为提高中国车牌号码输入速度而定制开发的专用键盘组件。
为停车行业的用户输入车牌号码,提供非常便捷有效的输入方式。
包括以下三个项目:
Android
Android项目,为Android客户端定制包括输入组件、键盘组件及相关控制逻辑实现;iOS
iOS客户端项目,为iOS客户端定制包括输入组件、键盘组件及相关控制逻辑实现;JavaScript(Vue.js)
JavaScript(Vue.js)项目,为H5页面定制,包括Web、微信、支付宝等,同样包括输入组件、键盘组件及相关控制逻辑实现注意: 当前版本v0.5,已修改为Java原生实现键盘逻辑,不再使用Javascript。项目包结构已发生重大修改,不再向0.4及以下版本兼容。
支持中华人民共和国现行绝大部分车牌号码类型:
增加仓库地址:
repositories {
jcenter()
}
添加库依赖:
implementation 'com.parkingwang:keyboard:0.6.1'
// OR
compile 'com.parkingwang:keyboard:0.6.1'
InputView是用于手动输入车牌的组件,提供7-8个用户可选择修改的输入框,如上图所示。
在XML中放置输入组件:
<com.parkingwang.keyboard.view.InputView
android:id="@+id/input_view"
app:pwkInputTextSize="22sp"
android:layout_width="match_parent"
android:layout_height="60dp"/>
KeyboardView是车牌输入键盘组件,提供按车牌类型显示一定规则的键盘布局供用户点击,如上图所示。
在XML中放置键盘组件:
<com.parkingwang.keyboard.view.InputView
android:id="@+id/input_view"
android:layout_margin="6dp"
app:pwkInputTextSize="22sp"
android:layout_width="match_parent"
android:layout_height="60dp"/>
在代码中绑定输入组件与键盘的关联:
使用弹出键盘
// Init Views
// 创建弹出键盘
mPopupKeyboard = new PopupKeyboard(this);
// 弹出键盘内部包含一个KeyboardView,在此绑定输入两者关联。
mPopupKeyboard.attach(mInputView, this);
// KeyboardInputController提供一个默认实现的新能源车牌锁定按钮
mPopupKeyboard.getController()
.setDebugEnabled(true)
.bindLockTypeProxy(new KeyboardInputController.ButtonProxyImpl(lockTypeButton) {
@Override
public void onNumberTypeChanged(boolean isNewEnergyType) {
super.onNumberTypeChanged(isNewEnergyType);
if (isNewEnergyType) {
lockTypeButton.setTextColor(getResources().getColor(android.R.color.holo_green_light));
} else {
lockTypeButton.setTextColor(getResources().getColor(android.R.color.black));
}
}
});
不弹出键盘,直接显示
// 使用 KeyboardInputController 来关联
mController = KeyboardInputController
.with(mKeyboardView, inputView);
mController.useDefaultMessageHandler();
根据需要,你可以通过调用KeyboardEngine的setHideOKKey(boolean)
来设置是否隐藏“确定”键。
mPopupKeyboard.getKeyboardEngine().setHideOKKey(mHideOKKey);
根据需要,在不同地区的用户,输入车牌号码时,可以根据当地地理位置,显示周边省份的简称。 获取地理位置需要的定位功能,需要你外部调用定位API,获取到对应的省份名称后,设置到KeyboardEngine中。 使用如下代码:
mPopupKeyboard.getKeyboardEngine().setLocalProvinceName("广东省");
由于顶层按键的气泡会显示到键盘之外,因此需要键盘所在的父布局增加以下属性(如果气泡范围超出父布局,则需往上递归设置):
android:clipChildren="false"
mKeyboardView.setShowBubble(false);
在Java代码中添加以下设置:
mKeyboardView.setCNTextSize(float); //设置中文字体大小
mKeyboardView.setENTextSize(float); //设置英文字母或数字字体大小
在colors.xml中覆盖以下颜色值以修改键盘主题色
<color name="pwk_primary_color">#418AF9</color>
<!--确定按键按下时的颜色-->
<color name="pwk_primary_dark_color">#3A7CE0</color>
<com.parkingwang.keyboard.view.InputView
app:pwkInputTextSize="22sp"
..../>
默认提供两种输入组件样式:
<!--输入框按键样式,最左最右键样式设置-->
<style name="PWKInputItemStyleKey" parent="PWKInputItemStyle_BORDER_KEY"/>
<!--输入框外部样式-->
<style name="PWKInputViewStyle" parent="PWKInputViewStyle_MIXED"/>
<!--输入框按键样式,最左最右键样式设置-->
<style name="PWKInputItemStyleKey" parent="PWKInputItemStyle_FILLED_KEY"/>
<!--输入框外部样式-->
<style name="PWKInputViewStyle" parent="PWKInputViewStyle_DIVIDED"/>
在项目的styles.xml
中覆盖设置以上两种样式配置,可以切换显示不同的样式。可参考 App 的配置代码。
覆盖PWKInputItemStyleKey / PWKInputItemStyleLeft / PWKInputItemStyleRight
和PWKInputViewStyle
来实现。
PWKInputItemStyleKey
控制输入组件内每个输入框的按键Button样式,样式作用于每个Button;PWKInputViewStyle
控制输入组件的整体样式,作用于LinearLayout;注意
最新版本需要配置 InputView
的 style
。配置方法有以下两种:
在布局文件中为 InputView
添加以下属性:
style="@style/PWKInputViewStyle"
或者是在 Application
或 Activity
所配置的 theme
的 style
中添加配置(参考 demo 项目):
<item name="pwkInputStyle">@style/PWKInputViewStyle</item>
常规配置
通过覆盖以下样式配置,可以修改默认样式
<!--输入框外边框宽度-->
<dimen name="pwk_input_view_border_width">0.7pt</dimen>
<!--背景缩进,必须与pwk_input_view_border_width保持一致,并且为负值-->
<dimen name="pwk_input_view_border_width_inset">-0.7pt</dimen>
<!--输入框分割线的宽度,在混合组件中使用-->
<dimen name="pwk_input_view_divider_split_line">@dimen/pwk_input_view_border_width</dimen>
<!--输入框分割空间的距离,在分离组件样式中使用-->
<dimen name="pwk_input_view_divider_split_space">5dp</dimen>
<!--输入框选中状态的边框宽度,在混合组件中使用-->
<dimen name="pwk_input_item_highlight_border_width">1.2pt</dimen>
<!--输入框圆角-->
<dimen name="pwk_input_item_radius">4dp</dimen>
<!--输入框字体大小-->
<dimen name="pwk_input_item_text_size">24sp</dimen>
SelectedDrawable
并重写 public void draw(@NonNull Canvas canvas)
方法自己绘制选中效果。InputView
的 app:pwkSelectedDrawable
属性或其 style
中,如下所示: <item name="pwkSelectedDrawable">com.parkingwang.keyboard.view.SelectedDrawable</item>
停车王车牌键盘布局切换逻辑的思维导图,说明了当前版本的键盘布局的切换,以及“更多”、“返回”按钮的切换逻辑。
说明:在此版本中,发生架构和项目结构的重大修改,不向下兼容,请按照当前版本的使用说明来修改;
说明:在此版本中,如果使用
com.parkingwang.keyboard.support.KeyboardInputController
包的相关类, 会报告Deprecated,使用com.parkingwang.keyboard.KeyboardInputController
包的类即可。
pwk_keyboard_primary_color
修改为pwk_primary_color
,并作为整个键盘的主题色。PWKInputItemStyleKey / PWKInputItemStyleLeft / PWKInputItemStyleRight
。VehicleKeyboard-Android 由西安艾润物联网技术服务有限公司第一事业部深圳研发中心开发和维护,旨在为停车行业同行进行技术交流和分享。
目前在两位开发者在开发维护,如您有相关问题,可以通过PullRequest和Issues来提交,也可以通过邮件与我们联系。
如果你在使用此键盘时,出现一些问题,或者有相关疑问。可以添加以下微信技术群做讨论。
如果群二维码过期,可以通过以下微信加好友,注明“车牌键盘”,我会拉到专门技术群做讨论。
Sign in for post a comment
Comments ( 0 )