diff --git a/.gitignore b/.gitignore
index c5935ba..2195139 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-*.DS_Store
+.DS_Store
+xcuserdata/
+build/
iRime/LibAndResource
diff --git a/LibAndResource.png b/LibAndResource.png
new file mode 100755
index 0000000..8cd6154
Binary files /dev/null and b/LibAndResource.png differ
diff --git a/README.md b/README.md
index 42a69fb..5f0bd5d 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@
## 鳴謝/Credits
-- [Rime]: [佛振](https://github.com/lotem)
+- \[Rime\]: [佛振](https://github.com/lotem)
- 圖文教程:[xiaoqun2016](https://github.com/xiaoqun2016)
- 在[Issues](https://github.com/jimmy54/iRime/issues)、[貼吧](http://tieba.baidu.com/f?kw=rime)、QQ羣中反饋意見的網友
- 依賴的第三方庫等開源項目
@@ -53,11 +53,46 @@
The GNU General Public License v3.0 (GPL v3)
>Copyright (C) 2014 Stackia
->
+>
>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
->
+>
>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
->
+>
>You should have received a copy of the GNU General Public License along with this program. If not, see .
+
+---
+
+## 克隆本仓库, 并下载所依赖的第三方库(`LibAndResource`)
+
+`LibAndResource` 下载地址:
+链接: http://pan.baidu.com/s/1mi0wt88 密码: ey9v
+下载之后将解压出来的文件夹 `LibAndResource` 放置在 `iRime` 目录下, 具体位置可参考下图:
+
+
+
+
+## 如果你有MAC电脑的话, 可以跳到本步骤.
+
+#### 在 `Windows` 上使用 `VMWare Player` 安装 `macOS Sierra(10.12)`
+教程如下(网页中有相关工具下载地址):
+https://techsviewer.com/install-macos-sierra-vmware-windows/
+
+> `VMWare` 的虚拟机文件, 百度盘下载地址:
+链接:http://pan.baidu.com/s/1eR9L1KY 密码:qcm9
+
+> `VMware Player` 请从 [VMWare官网](https://www.vmware.com/products/player/playerpro-evaluation.html) 直接下载(免费).
+
+
+### 下载 `XCode 8.3.3` 并安装至MAC系统中
+
+[XCode 8.3.3下载地址](https://developer.apple.com/download/)
+
+
+完成上面的操作之后, 用 `XCode` 打开 `iRime` 目录下的 `iRime.xcworkspace` 文件,
+更新 项目中 所关联的 Apple Id 为您自己的账号及对应的group.
+然后将手机连接至电脑上, 将目标选择为自己的手机,
+然后按 `Command+R` 就可以编译代码并将编译后的程序安装到您的手机上了.
+
+## PS: 该仓库中原有代码版权归原作者所有, 请在使用时遵守相关的 LICENSE.
diff --git a/iRime/.DS_Store b/iRime/.DS_Store
deleted file mode 100644
index 953f1c4..0000000
Binary files a/iRime/.DS_Store and /dev/null differ
diff --git a/iRime/Header.h b/iRime/Header.h
index 0d7249b..f333a6d 100644
--- a/iRime/Header.h
+++ b/iRime/Header.h
@@ -16,9 +16,8 @@
#import "AGEmojiPageView.h"
#import "SVProgressHUD.h"
#import "FileManger.h"
-#import "NSString+path.h"
+#import "NSString+Path.h"
#import "common.h"
-#import "PlaySound.h"
#import "OpenCCService.h"
#import
#import
diff --git a/iRime/Keyboard/.DS_Store b/iRime/Keyboard/.DS_Store
deleted file mode 100644
index 500f2fa..0000000
Binary files a/iRime/Keyboard/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/Keyboard.entitlements b/iRime/Keyboard/Keyboard.entitlements
index e746164..10730bd 100644
--- a/iRime/Keyboard/Keyboard.entitlements
+++ b/iRime/Keyboard/Keyboard.entitlements
@@ -4,7 +4,7 @@
com.apple.security.application-groups
- group.Rime
+ group.xqin.net
diff --git a/iRime/Keyboard/RimeWrapeper/.DS_Store b/iRime/Keyboard/RimeWrapeper/.DS_Store
deleted file mode 100644
index 96931c6..0000000
Binary files a/iRime/Keyboard/RimeWrapeper/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/RimeWrapeper/Source/RimeWrapper.m b/iRime/Keyboard/RimeWrapeper/Source/RimeWrapper.m
index 3d45cb9..e7dbcf2 100644
--- a/iRime/Keyboard/RimeWrapeper/Source/RimeWrapper.m
+++ b/iRime/Keyboard/RimeWrapeper/Source/RimeWrapper.m
@@ -92,13 +92,13 @@ typedef NS_OPTIONS(NSUInteger, NSEventModifierFlags) {
static id notificationDelegate_ = nil;
void notificationHandler(void* context_object, RimeSessionId session_id, const char* message_type, const char* message_value) {
-
+
if (notificationDelegate_ == nil) {
return;
}
-
+
if (!strcmp(message_type, "deploy")) { // Deployment state change
-
+
if (!strcmp(message_value, "start")) {
if ([notificationDelegate_ respondsToSelector:@selector(onDeploymentStarted)]) {
[notificationDelegate_ onDeploymentStarted];
@@ -114,20 +114,20 @@ void notificationHandler(void* context_object, RimeSessionId session_id, const c
[notificationDelegate_ onDeploymentFailed];
}
}
-
+
} else if (!strcmp(message_type, "schema") && [notificationDelegate_ respondsToSelector:@selector(onSchemaChangedWithNewSchema:)]) { // Schema change
-
+
const char* schema_name = strchr(message_value, '/');
if (schema_name) {
++schema_name;
[notificationDelegate_ onSchemaChangedWithNewSchema:[NSString stringWithFormat:@"%@", [NSString stringWithUTF8String:schema_name]]];
}
-
+
} else if (!strcmp(message_type, "option") && [notificationDelegate_ respondsToSelector:@selector(onOptionChangedWithOption:value:)]) { // Option change
-
+
XRimeOption option = XRimeOptionUndefined;
BOOL value = (message_value[0] != '!');;
-
+
if (!strcmp(message_value, "ascii_mode") || !strcmp(message_value, "!ascii_mode")) {
option = XRimeOptionASCIIMode;
}
@@ -143,9 +143,9 @@ void notificationHandler(void* context_object, RimeSessionId session_id, const c
else if (!strcmp(message_value, "extended_charset") || !strcmp(message_value, "!extended_charset")) {
option = XRimeOptionExtendedCharset;
}
-
+
[notificationDelegate_ onOptionChangedWithOption:option value:value];
-
+
}
}
@@ -156,16 +156,16 @@ + (void)setNotificationDelegate:(id)delegate {
}
+ (BOOL)startService {
-
+
NSString *rimePath = nil;
NSString *shareSupportPath = nil;
NSString *userPath = nil;
-
+
shareSupportPath = [NSString appendingHostAppBundlePath:@"SharedSupport"];
rimePath = [NSString rimeResource];
userPath = [NSString userPath];
-
-
+
+
NSError *err = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:rimePath]) {
@@ -174,13 +174,13 @@ + (BOOL)startService {
return NO;
}
}
-
+
if (![fileManager fileExistsAtPath:userPath]) {
if (![fileManager createDirectoryAtPath:userPath withIntermediateDirectories:YES attributes:nil error:&err]) {
NSLog(@"Failed to create user data directory. err :%@", err);
}
}
-
+
RIME_STRUCT(RimeTraits, vXIMETraits);
vXIMETraits.shared_data_dir = [shareSupportPath UTF8String];
vXIMETraits.user_data_dir = [rimePath UTF8String];
@@ -191,10 +191,10 @@ + (BOOL)startService {
NSString *dir = [NSString stringWithFormat:@"%@/%@", rimePath, @"testDir"];
NSFileManager * f = [NSFileManager defaultManager];
NSURL * url = [f containerURLForSecurityApplicationGroupIdentifier:GROUP_ID];
-
+
res = [f createDirectoryAtPath:[url absoluteString] withIntermediateDirectories:YES attributes:NULL error:&err];
-
-
+
+
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"test", @"test----", nil];
dir = [NSString stringWithFormat:@"%@/%@", rimePath, @"test.txt"];
res = [dic writeToFile:dir atomically:YES];
@@ -206,19 +206,19 @@ + (BOOL)startService {
vXIMETraits.distribution_code_name = "iRime";
vXIMETraits.distribution_version = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] UTF8String];
vXIMETraits.app_name = "iRime";
-
+
// Set Rime notification handler
RimeSetNotificationHandler(notificationHandler, (__bridge void *)self);
-
+
// Setup deployer and logging
RimeSetup(&vXIMETraits);
-
+
// Load modules and start service
RimeInitialize(NULL);
-
+
// Fast deploy
[self deployWithFastMode:YES];
-
+
return YES;
}
@@ -241,7 +241,7 @@ + (void)redeployWithFastMode:(BOOL)fastMode {
// Restart service
RimeFinalize();
RimeInitialize(NULL);
-
+
// Deploy
[self deployWithFastMode:fastMode];
}
@@ -391,12 +391,12 @@ + (XRimeContext *)contextForSession:(RimeSessionId)sessiodId {
if (ctx.commit_text_preview) {
[xCtx setCommitTextPreview:[NSString stringWithUTF8String:ctx.commit_text_preview]];
}
-
+
XRimeMenu *xMenu = [[XRimeMenu alloc] init];
XRimeComposition * xComp = [[XRimeComposition alloc] init];
[xCtx setMenu:xMenu];
[xCtx setComposition:xComp];
-
+
[xMenu setPageSize:ctx.menu.page_size];
[xMenu setPageNumber:ctx.menu.page_no];
[xMenu setIsLastPage:ctx.menu.is_last_page == True];
@@ -440,18 +440,18 @@ + (NSArray *)getCandidateListForSession:(RimeSessionId)sessionId
//candidate
RimeCandidateListIterator ite;
NSMutableArray *candidates = [NSMutableArray new];
-
+
@autoreleasepool {
-
-
+
+
bool res = RimeCandidateListBegin(sessionId, &ite);
if (res == false) {
return nil;
}
-
+
NSString *s = nil;
while (RimeCandidateListNext(&ite)) {
-
+
if (ite.index > kMaxCandidateListCount) {
break;
}
@@ -459,7 +459,7 @@ + (NSArray *)getCandidateListForSession:(RimeSessionId)sessionId
// NSLog(@"%@", s);
[candidates addObject:s];
}
-
+
RimeCandidateListEnd(&ite);
}
return candidates;
@@ -471,37 +471,38 @@ +(NSArray*)getCandidateListForSession:(RimeSessionId)sessionId andIndex:(NSInteg
if (index > kMaxCandidateListCount) {
return candidates;
}
-
+
//candidate
RimeCandidateListIterator ite;
-
- @autoreleasepool {
-
- bool res = RimeCandidateListBeginWithIndex((int)index, sessionId, &ite);
- if (res == false) {
- return nil;
+ bool res = RimeCandidateListBegin(sessionId, &ite);
+ if (res == false) {
+ return nil;
+ }
+
+
+ NSString *s = nil;
+ NSInteger candidateMax = index + count;
+
+ if (candidateMax > kMaxCandidateListCount) {
+ candidateMax = kMaxCandidateListCount;
+ }
+
+ while (RimeCandidateListNext(&ite)) {
+ if (ite.index <= index) {
+ continue;
}
- NSInteger candidateMax = index + count;
-
-
- //NSInteger i = index;
- NSString *s = nil;
- while (RimeCandidateListNext(&ite)) {
-
- if (ite.index > candidateMax) {
- break;
- }
- s = [NSString stringWithUTF8String:ite.candidate.text];
- //NSLog(@"%d:%@", i, s);
-// i++;
- [candidates addObject:s];
+
+ if (ite.index > candidateMax) {
+ break;
}
-
- RimeCandidateListEnd(&ite);
+
+ s = [NSString stringWithUTF8String:ite.candidate.text];
+ [candidates addObject:s];
}
-
+
+ RimeCandidateListEnd(&ite);
+
return candidates;
-
}
@@ -519,34 +520,34 @@ + (BOOL)selectCandidateForSession:(RimeSessionId)seesionId inIndex:(size_t)index
+(NSArray*)getSchemaList
{
-
+
RimeSchemaList schemaList;
-
+
Bool r = rime_get_api()->get_schema_list(&schemaList);
if (r == NO) {
NSLog(@"get schema list fail");
return nil;
}
-
-
+
+
NSMutableArray *res = [NSMutableArray new];
RimeSchemaListItem *item = nil;
-
+
for (int i = 0; i < schemaList.size; i++) {
-
+
item = &schemaList.list[i];
-
+
}
-
-
+
+
return res;
-
-
+
+
}
+(void)selectSchemaInRimeSeesiong:(RimeSessionId) seesionId useSchemaId:(const char*) schemaId
{
-
+
}
diff --git a/iRime/Keyboard/ZipArchive/.DS_Store b/iRime/Keyboard/ZipArchive/.DS_Store
deleted file mode 100644
index d951000..0000000
Binary files a/iRime/Keyboard/ZipArchive/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/.DS_Store b/iRime/Keyboard/tasty-imitation-keyboard/.DS_Store
deleted file mode 100644
index 30285fa..0000000
Binary files a/iRime/Keyboard/tasty-imitation-keyboard/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Controller/KeyboardViewController.swift b/iRime/Keyboard/tasty-imitation-keyboard/Controller/KeyboardViewController.swift
index 7b27f7e..33c047f 100644
--- a/iRime/Keyboard/tasty-imitation-keyboard/Controller/KeyboardViewController.swift
+++ b/iRime/Keyboard/tasty-imitation-keyboard/Controller/KeyboardViewController.swift
@@ -542,7 +542,7 @@ class KeyboardViewController: UIInputViewController {
self.setCapsIfNeeded()
// trigger for subsequent deletes
- self.backspaceDelayTimer = Timer.scheduledTimer(timeInterval: backspaceDelay - backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceDelayCallback), userInfo: nil, repeats: false)
+ self.backspaceDelayTimer = Timer.scheduledTimer(timeInterval: backspaceDelay - backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceDelayCallback), userInfo: sender, repeats: false)
}
func backspaceUp(_ sender: KeyboardKey) {
@@ -551,15 +551,15 @@ class KeyboardViewController: UIInputViewController {
self.keyPressedHelper(sender)
}
- func backspaceDelayCallback() {
+ func backspaceDelayCallback(timer: Timer) {
self.backspaceDelayTimer = nil
- self.backspaceRepeatTimer = Timer.scheduledTimer(timeInterval: backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceRepeatCallback), userInfo: nil, repeats: true)
+ self.backspaceRepeatTimer = Timer.scheduledTimer(timeInterval: backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceRepeatCallback), userInfo: timer.userInfo, repeats: true)
}
- func backspaceRepeatCallback() {
+ func backspaceRepeatCallback(timer: Timer) {
self.playKeySound()
- self.textDocumentProxy.deleteBackward()
+ self.keyPressedHelper(timer.userInfo as! KeyboardKey)
self.setCapsIfNeeded()
}
@@ -870,11 +870,8 @@ class KeyboardViewController: UIInputViewController {
// this only works if full access is enabled
func playKeySound() {
- if !UserDefaults.standard.bool(forKey: kKeyboardClicks) {
- return
- }
-
- DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async(execute: {
+
+ DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async(execute: {
AudioServicesPlaySystemSound(1104)
})
}
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/.DS_Store b/iRime/Keyboard/tasty-imitation-keyboard/Demo/.DS_Store
deleted file mode 100644
index 17202d3..0000000
Binary files a/iRime/Keyboard/tasty-imitation-keyboard/Demo/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/Catboard.swift b/iRime/Keyboard/tasty-imitation-keyboard/Demo/Catboard.swift
index 9f3982e..d755c4f 100644
--- a/iRime/Keyboard/tasty-imitation-keyboard/Demo/Catboard.swift
+++ b/iRime/Keyboard/tasty-imitation-keyboard/Demo/Catboard.swift
@@ -7,6 +7,7 @@
//
import UIKit
+import AudioToolbox
// FIXME: comparison operators with optionals were removed from the Swift Standard Libary.
// Consider refactoring the code to use the non-optional operators.
fileprivate func < (lhs: T?, rhs: T?) -> Bool {
@@ -87,17 +88,8 @@ let indexPathFirst = IndexPath(row: 1, section: 0)
var startTime: Date?
-//// //////////
-
-
-
-
-
-
-let kCatTypeEnabled = "kCatTypeEnabled"
-
class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UITableViewDelegate, UITableViewDataSource, AGEmojiKeyboardViewDataSource, AGEmojiKeyboardViewDelegate,iRNumberBoardFatherViewProtocol{
-
+
lazy var viewNumberBoardView:iRNumberBoardFatherView = {
let viewNumberBoard = iRNumberBoardFatherView.init(frame: CGRect.null)
self.view.addSubview(viewNumberBoard)
@@ -105,7 +97,7 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
viewNumberBoard.delegateAction = self
//--约束布局
viewNumberBoard.mas_makeConstraints { (make:MASConstraintMaker!) in
-
+
make.left.equalTo()(self.view)
make.right.equalTo()(self.view)
make.bottom.equalTo()(self.view)
@@ -114,202 +106,210 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
return viewNumberBoard
}()
-
+
var rimeSessionId_ : RimeSessionId = 0
- var isChineseInput: Bool = true
+ var isChineseInput: Bool = true {
+ didSet {
+ if isChineseInput && shiftState != .disabled {
+ shiftState = .disabled
+ }
+ }
+ }
var switchInputView:KeyboardKey?
var candidatesBanner: CandidatesBanner?
-
+
let fm :FileManger = FileManger()
-
+
var openCCServer: OpenCCService?
-
+
var isShowEmojiView: Bool = false
-
+
var candidateIndex : NSInteger = -1;
var candidateCount : NSInteger = 50;
var candidateList:[CandidateModel]! = Array(){
-
-
-
+
+
+
willSet{
-
+
}
-
+
didSet{
-
+
}
-
+
}
-
+
var modelQueue: [Int] = Array()
-
-
-
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- UserDefaults.standard.register(defaults: [kCatTypeEnabled: true])
-
-
-
-
- super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
+
+ override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
+ super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
-
+
override func viewDidLoad() {
print("----------------------------viewDidLoad--------------------");
super.viewDidLoad()
print("input viewDidLoad");
fm.startBlock = {
()->() in
-
+
self.view.isUserInteractionEnabled = false
-
+
}
-
-
+
+
fm.endBlock = {
()->()in
-
+
self.view.isUserInteractionEnabled = true
-
+
}
-
+
fm.initSettingFile()
-
-
+
+
self.modePush(self.currentMode)
-
-
+
+
print("----------------------------viewDidLoad--------------------");
-
+
}
-
+
func presentTextFromNumberPad(_ text:String) -> Void
{
self.textDocumentProxy.insertText(text);
}
-
+
func deleteBackwardOfiRNumberBoardFatherView() -> Void
{
self.textDocumentProxy.deleteBackward()
}
-
-
+
+
func getReturnKeyTitle() -> String {
return self.getReturnKeyTitleString()
}
-
-
+
+
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
print("------------------viewDidAppear---------------------")
+
+ //keyboard 没有权限,需要跳到iRime去创建目录
+ let fm = FileManager.default.fileExists(atPath: NSString.rimeResource())
+ if !fm {
+ let iRimeURL = "iRime://create.iRime.dir";
+ self.openURL(iRimeURL)
+ return;
+ }
+
RimeWrapper .setNotificationDelegate(self)
if RimeWrapper.startService() {
-
+
print("start service success");
-
-
+
+
//
let curSchema = NSString.userDefaultsInGroup().string(forKey: CURRENT_SCHEMA_NAME)
// print(curSchema);
if curSchema == nil {
print("当前默认输入法为空")
NSString.userDefaultsInGroup().set(DEFAULT_SCHEMA_NAME, forKey:CURRENT_SCHEMA_NAME)
-
+
}
-
+
//
-
-
+
+
openCCServer = nil
let ud = NSString.userDefaultsInGroup()
let CC = ud?.integer(forKey: CURRENT_CC)
if CC != 0 {
let unsignCC = UInt(CC!)
-
+
let f = OpenCCServiceConverterType(rawValue: unsignCC)
openCCServer = OpenCCService(converterType: f!)
-
+
}
-
-
+
+
//中文输入
if !RimeWrapper.isSessionAlive(rimeSessionId_) {
rimeSessionId_ = RimeWrapper.createSession()
}
-
-
+
+
}else{
-
+
print("start service error");
-
+
}
print("------------------viewDidAppear---------------------")
-
+
}
-
+
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
print("------------------viewDidDidAppear---------------------")
-
-
+
+
openCCServer = nil
RimeWrapper.stopService()
print("------------------viewDidDidAppear---------------------")
}
-
+
deinit{
-
+
print("-------------------------deinit---------------------------")
-
+
}
-
-
+
+
func modePush(_ model : Int) {
self.modelQueue.append(model)
self.currentMode = model
-
+
if self.currentMode == 0 {
self.isChineseInput = true
}else{
self.isChineseInput = false
}
-
+
print(self.modelQueue)
}
-
+
func modelPop() {
self.modelQueue.removeLast()
let first = self.modelQueue.last
self.currentMode = first!
-
+
if self.currentMode == 0 {
self.isChineseInput = true
}else{
self.isChineseInput = false
}
-
+
print(self.modelQueue)
}
-
+
func modelPopToModel(_ model : Int) {
-
+
}
-
+
override func modeChangeTapped(_ sender: KeyboardKey){
-
+
let toMode = self.layout?.viewToModel[sender]?.toMode
-
-
+
+
if toMode == -1 {
self.modelPop()
}
@@ -322,39 +322,35 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
else{
self.modePush(toMode!)
}
-
+
RimeWrapper.clearComposition(forSession: rimeSessionId_)
-
+
self.removeAllCandidateList();
self.candidatesBanner?.reloadData()
-
+
}
-
+
override func keyPressed(_ key: Key) {
-
- //play key sound
- PlaySound.playDefaultSound()
-
+ // 由 在空格上左右移动之后触发的 keyPressed 事件 只重置状态,不插入任何内容
+ if key.type == .space && self.spaceDragIsMoving {
+ self.spaceDragIsMoving = false
+ return
+ }
+
let textDocumentProxy = self.textDocumentProxy
-
+
if self.isChineseInput == false {
if key.type == .backspace {
textDocumentProxy.deleteBackward()
return;
}
-
- if key.type == .space && self.spaceDragIsMoving == false {
- textDocumentProxy.insertText(" ")
- self.spaceDragIsMoving = false
- return;
- }
-
+
if key.type == .modeChange{
return;
}
-
+
super.keyPressed(key)
-
+
if key.type == .specialCharacter {
if let m = key.toMode {
if m == -1 {
@@ -365,12 +361,12 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
}
return
}
-
-
+
+
//返回键
if key.type == .return {
-
+
if RimeWrapper.isSessionAlive(self.rimeSessionId_) == false {
print("按键-->session 不存在")
return;
@@ -378,71 +374,60 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
let c: XRimeContext = RimeWrapper.context(forSession: rimeSessionId_)
var preedite:String? = c.composition.preeditedText
if preedite?.characters.count > 0{
-
+
preedite = preedite!.replacingOccurrences(of: " ", with: "")//去掉所有空格
-
+
// textDocumentProxy.insertText(preedite!)
self.insertText(preedite!)
RimeWrapper.clearComposition(forSession: self.rimeSessionId_)
-
-
+
+
self.removeAllCandidateList();
self.candidatesBanner?.reloadData()
-
+
return;
}
-
+
textDocumentProxy.insertText("\n")
return
}
-
-
- //数字,符号等
- //--------------------------------------------------
- let keyOutput = key.outputForCase(self.shiftState.uppercase())
-
- if !UserDefaults.standard.bool(forKey: kCatTypeEnabled) {
- textDocumentProxy.insertText(keyOutput)
- return
- }
-
- //----------------------------------------------
- let ko = key.outputForCase(self.shiftState.uppercase())
- let nsstrTest:NSString = ko as NSString
- let result = nsstrTest.utf8String?[0] //result = 99
-
- //删除按钮
- var r = Int32(result!)
- if key.type == .backspace {
- r = Int32(XK_BackSpace)
- }
-
+
if key.type == .space {
-
-
if self.candidateList.count <= 0 {
if RimeWrapper.commitComposition(forSession: rimeSessionId_) {
RimeWrapper.clearComposition(forSession: rimeSessionId_)
self.candidatesBanner?.reloadData()
}
- if self.spaceDragIsMoving == false {
- textDocumentProxy.insertText(" ")
- }
- self.spaceDragIsMoving = false
+ super.keyPressed(key)
return
}
-
+
+ let context: XRimeContext = RimeWrapper.context(forSession: rimeSessionId_)
+
+
+ if let preeditedText = context.commitTextPreview {
+ self.insertText(preeditedText)
+ }
+
RimeWrapper.clearComposition(forSession: rimeSessionId_)
- var t = self.candidateList.first!.text
- t = t! + " "
- self.insertText(t!)
self.removeAllCandidateList();
self.candidatesBanner?.reloadData()
-
+ return
+ }
+
+ //--------------------------------------------------
+ let keyOutput = key.outputForCase(self.shiftState.uppercase())
+ let nsstrTest:NSString = keyOutput as NSString
+ let result = nsstrTest.utf8String?[0] //result = 99
+
+ //删除按钮
+ var r = Int32(result!)
+ if key.type == .backspace {
+ r = Int32(XK_BackSpace)
}
-
+
let h = RimeWrapper.inputKey(forSession: rimeSessionId_, rimeKeyCode: r, rimeModifier: 0)
if h == false {
@@ -451,143 +436,146 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
self.candidatesBanner?.reloadData()
return;
}
-
-
- self.removeAllCandidateList();
+
+ let comitText = RimeWrapper.consumeComposedText(forSession: rimeSessionId_)
+ if comitText != nil {
+ self.insertText(comitText!)
+ self.removeAllCandidateList()
+ self.candidatesBanner?.reloadData()
+ return
+ }
+
+
let cl = RimeWrapper.getCandidateList(forSession: rimeSessionId_, andIndex: -1, andCount: 50) as? [String]
-
- if (cl == nil) {
- self.removeAllCandidateList();
- }else{
-
+ self.removeAllCandidateList();
+
+ if (cl != nil) {
self.addCandidates(cl!)
-
}
-
+
self.candidatesBanner?.reloadData()
-
-
+
+
return;
-
+
}
-
+
func addCandidates(_ strings:[String]) {
-
+
for s in strings {
let candidate = CandidateModel()
candidate.text = self.openCC(s)
self.candidateList.append(candidate)
}
-
+
}
-
+
func removeAllCandidateList() {
self.candidateList.removeAll()
self.candidateIndex = -1;
self.candidateCount = 50;
}
-
+
func openCC(_ text: String) ->String {
-
+
var ret = text
-
+
if self.openCCServer != nil {
ret = (self.openCCServer?.convert(text))!
}
return ret;
}
-
+
func insertText(_ text:String) {
-
+
//
var s = text;
if self.openCCServer != nil {
s = self.openCCServer!.convert(text)
}
-
+
self.textDocumentProxy.insertText(s)
}
-
-
+
+
override func setupKeys() {
super.setupKeys()
-
-
+
+
for page in keyboard.pages {
for rowKeys in page.rows {
for key in rowKeys {
if let keyView = self.layout?.viewForKey(key){
-
-
+
+
//
if key.type == .space {
var s = UIPanGestureRecognizer(target: self, action: #selector(Catboard.spaceSwipLeft(_:)))
keyView.addGestureRecognizer(s)
-
-
+
+
s = UIPanGestureRecognizer(target: self, action: #selector(Catboard.spaceSwipRigth(_:)))
keyView.addGestureRecognizer(s)
-
-
-
+
+
+
break;
}
-
-
-
-
-
-
+
+
+
+
+
+
}
}
}
}
-
+
}
-
-
+
+
func spaceSwipLeft(_ gesture: UISwipeGestureRecognizer) {
-
+
print("swip left ...")
}
-
+
func spaceSwipRigth(_ gesture: UISwipeGestureRecognizer) {
-
+
print("swip rigth...")
}
-
-
-
+
+
+
// a settings view that replaces the keyboard when the settings button is pressed
// override func createSettings() -> ExtraView? {
-//
+//
// settingsView = EmojiView(globalColors: self.dynamicType.globalColors, darkMode: false, solidColorMode: self.solidColorMode())
-//
+//
// return settingsView
// }
-
-
-
-
-
-
+
+
+
+
+
+
override func createBanner() -> ExtraView? {
-
+
candidatesBanner = CandidatesBanner(globalColors: type(of: self).globalColors, darkMode: false, solidColorMode: self.solidColorMode())
candidatesBanner!.delegate = self
-
+
candidatesBanner?.toolsView.tapToolsItem = {
(btn:UIButton, index:Int) in
-
+
if index == 1 {
- //open iRime
- //let iRimeURL = "iRime://";
- //self.openURL(iRimeURL)
+ let iRimeURL = "iRime://";
+ self.openURL(iRimeURL)
}else if index == 2{
if self.isShowEmojiView {
self.exitEmojiView()
@@ -600,12 +588,12 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
}
}
-
+
}
return candidatesBanner
}
-
-
+
+
func openURL(_ url: String) {
var responder: UIResponder = self
while responder.next != nil {
@@ -616,7 +604,7 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
}
}
}
-
+
// KeyboardViewController
override func updateAppearances(_ appearanceIsDark: Bool) {
return
@@ -625,41 +613,41 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
super.updateAppearances(candidatesBannerAppearanceIsDark)
candidatesBanner?.updateAppearance()
}
-
-
+
+
var currentOrientation: UIInterfaceOrientation? = nil
override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
super.willRotate(to: toInterfaceOrientation, duration: duration)
currentOrientation = toInterfaceOrientation
self.candidatesBanner?.willRotateToInterfaceOrientation(toInterfaceOrientation, duration: duration)
}
-
-
+
+
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated
print("-------------------------------didReceiveMemoryWarning------------------------------------------")
-
+
}
-
+
//collocetionView
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
-
+
self.selectText(indexPath.row)
self.exitCandidatesTableIfNecessary()
-
+
}
-
-
+
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-
+
let count = self.candidateList?.count
//print(count)
return count!
}
-
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-
+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CandidateCell
cell.updateAppearance()
if (indexPath == indexPathZero) {
@@ -672,20 +660,20 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
// cell.textLabel.sizeToFit()
return cell
}
-
+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
-
+
let candidate = self.candidateList[indexPath.row]
-
+
if candidate.textSize == nil{
candidate.textSize = getCellSizeAtIndex(indexPath, andText: candidate.text, andSetLayout: collectionViewLayout as! UICollectionViewFlowLayout)
}
-
+
return candidate.textSize!
-
+
}
-
-
+
+
//
func getCellSizeAtIndex(_ indexPath: IndexPath, andText text: String, andSetLayout layout: UICollectionViewFlowLayout) -> CGSize {
let size = CandidateCell.getCellSizeByText(text, needAccuracy: indexPath == indexPathZero ? true : false)
@@ -694,18 +682,18 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
}
return size
}
-
-
+
+
var isShowingCandidatesTable = false
@IBAction func toggleCandidatesTableOrDismissKeyboard() {
-
+
if self.candidateList?.count <= 0 {
Logger.sharedInstance.writeLogLine(filledString: "[DOWN] <> DISMISS")
self.dismissKeyboard()
return
}
-
-
+
+
if isShowingCandidatesTable == false {
Logger.sharedInstance.writeLogLine(filledString: "[DOWN] <>")
isShowingCandidatesTable = true
@@ -716,7 +704,7 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
exitCandidatesTable()
}
}
-
+
var candidatesTable: UICollectionView!
func showCandidatesTable() {
isShowingCandidatesTable = true
@@ -729,27 +717,27 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
candidatesTable.register(CandidateCell.self, forCellWithReuseIdentifier: "Cell")
candidatesTable.delegate = self
candidatesTable.dataSource = self
-
+
//add mjrefresh
// self.candidatesTable.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
//Call this Block When enter the refresh status automatically
// }];
-
+
weak var weakSelf = self
let footer = MJRefreshAutoNormalFooter.init(refreshingBlock: {
-
+
weakSelf?.loadMoreCandidate(scrollView: (weakSelf?.candidatesTable)!)
-
+
});
(footer!).stateLabel.isHidden = true
self.candidatesTable.mj_footer = footer
-
-
-
-
+
+
+
+
self.view.addSubview(candidatesTable)
}
-
+
func exitCandidatesTable() {
isShowingCandidatesTable = false
candidatesBanner!.scrollToFirstCandidate()
@@ -757,31 +745,28 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
candidatesBanner!.changeArrowDown()
candidatesTable.removeFromSuperview()
}
-
+
func loadMoreCandidate(scrollView: UIScrollView) {
-// let cl = RimeWrapper.getCandidateList(forSession: rimeSessionId_) as? [String]
- //print("index:%d", self.candidateIndex)
- //print("count:%d", self.candidateCount)
self.candidateIndex += self.candidateCount
let cl = RimeWrapper.getCandidateList(forSession: rimeSessionId_, andIndex: self.candidateIndex, andCount: self.candidateCount) as? [String]
-
- if (cl != nil) {
+
+ if (cl != nil && cl?.count > 0) {
self.addCandidates(cl!)
}else{
scrollView.mj_footer.endRefreshingWithNoMoreData()
return;
}
-
+
self.candidatesTable.reloadData()
-
-
+
+
scrollView.mj_footer.endRefreshing();
}
-
-
+
+
//------------emoji view
var emojiView : AGEmojiKeyboardView!
-
+
func showEmojiView() {
let r = CGRect(x: view.frame.origin.x, y: view.frame.origin.y + getBannerHeight(), width: view.frame.width, height: view.frame.height - getBannerHeight())
@@ -793,178 +778,178 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
emojiView.pageControl.currentPageIndicatorTintColor = UIColor.darkGray
self.view.addSubview(emojiView)
self.isShowEmojiView = true
-
-
-
+
+
+
}
-
+
func exitEmojiView() {
-
+
self.isShowEmojiView = false
emojiView.removeFromSuperview()
-
+
}
-
-
+
+
func emojiKeyBoardView(_ emojiKeyBoardView: AGEmojiKeyboardView!, didUseEmoji emoji: String!) {
-
+
self.textDocumentProxy.insertText(emoji)
-
+
}
-
+
func emojiKeyBoardViewDidPressBackSpace(_ emojiKeyBoardView: AGEmojiKeyboardView!) {
-
+
self.textDocumentProxy.deleteBackward()
-
+
}
-
-
+
+
func emojiKeyboardView(_ emojiKeyboardView: AGEmojiKeyboardView!, imageForSelectedCategory category: AGEmojiKeyboardViewCategoryImage) -> UIImage! {
-
+
var imgName: String = ""
-
+
if category == .recent {
-
+
imgName = "emoji_tab0Press"
-
+
}else if category == .face{
-
+
imgName = "emoji_tab1Press"
-
+
}else if category == .bell{
-
+
imgName = "emoji_tab2Press"
-
+
}else if category == .flower{
-
+
imgName = "emoji_tab3Press"
-
+
}else if category == .car {
-
+
imgName = "emoji_tab4Press"
-
+
}else if category == .characters{
-
+
imgName = "emoji_tab5Press"
-
+
}
-
+
return UIImage(named: imgName)
-
+
}
-
+
func emojiKeyboardView(_ emojiKeyboardView: AGEmojiKeyboardView!, imageForNonSelectedCategory category: AGEmojiKeyboardViewCategoryImage) -> UIImage! {
var imgName: String = ""
-
+
if category == .recent {
-
+
imgName = "emoji_tab0"
-
+
}else if category == .face{
-
+
imgName = "emoji_tab1"
-
+
}else if category == .bell{
-
+
imgName = "emoji_tab2"
-
+
}else if category == .flower{
-
+
imgName = "emoji_tab3"
-
+
}else if category == .car {
-
+
imgName = "emoji_tab4"
-
+
}else if category == .characters{
-
+
imgName = "emoji_tab5"
-
+
}
-
- return UIImage(named: imgName)
+
+ return UIImage(named: imgName)
}
-
+
func backSpaceButtonImage(for emojiKeyboardView: AGEmojiKeyboardView!) -> UIImage! {
-
+
return UIImage(named: "expression_delete")
}
-
-
+
+
//-----------------------
-
+
func exitCandidatesTableIfNecessary() {
if isShowingCandidatesTable == false {
return
}
exitCandidatesTable()
}
-
+
//tableView
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return (self.candidateList?.count)!
}
-
-
+
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
-
-
+
+
var cell = tableView.dequeueReusableCell(withIdentifier: "textCell")
if cell == nil {
cell = CandidateTableCellTableViewCell(style: .default, reuseIdentifier: "textCell")
}
-
+
let c: CandidateTableCellTableViewCell = cell as! CandidateTableCellTableViewCell
let candidate = self.candidateList[indexPath.row]
c.txtLabel?.text = candidate.text
-
+
if indexPath.row == 0 {
c.txtLabel?.textColor = UIColor.init(red: 0, green: 128.0 / 255.0, blue: 248.0 / 255, alpha: 1.0);
}else{
c.txtLabel?.textColor = UIColor.black
}
-
+
return cell!
-
-
-
-
+
+
+
+
}
-
-
+
+
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{
-
+
let s = self.candidateList![indexPath.row]
-
+
if s.textSize == nil {
s.textSize = CandidateCell.getCellSizeByText(s.text, needAccuracy: indexPath == indexPathZero ? true : false)
}
return s.textSize!.width
-
-
-
+
+
+
}
-
-
-
+
+
+
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
-
+
self.selectText(indexPath.row)
self.candidatesBanner?.scrollToFirstCandidate()
-
+
}
-
-
+
+
func selectText(_ index: NSInteger) -> String? {
let res = RimeWrapper.selectCandidate(forSession: self.rimeSessionId_, in: index)
if res == false {
print("选中没有文字了")
return nil;
}
-
-
+
+
let comitText = RimeWrapper.consumeComposedText(forSession: self.rimeSessionId_)
if (comitText != nil) {
// self.textDocumentProxy.insertText(comitText)
@@ -973,151 +958,151 @@ class Catboard: KeyboardViewController,RimeNotificationDelegate, UICollectionVie
self.candidatesBanner?.reloadData()
return comitText;
}
-
+
// let cl = RimeWrapper.getCandidateList(forSession: self.rimeSessionId_) as? [String]
let cl = RimeWrapper.getCandidateList(forSession: self.rimeSessionId_, andIndex: -1, andCount: 50) as? [String]
+ self.removeAllCandidateList();
if (cl != nil) {
self.addCandidates(cl!)
}
- self.removeAllCandidateList();
self.candidatesBanner?.reloadData()
return nil;
}
-
-
-
+
+
+
func getPreeditedText() -> String {
-
+
if RimeWrapper.isSessionAlive(rimeSessionId_) == false {
return "";
}
-
+
let context: XRimeContext = RimeWrapper.context(forSession: rimeSessionId_)
return context.composition.preeditedText
}
-
-
-
+
+
+
func switchInputTouchDown(){
}
-
+
func switchInputTouchUp(){
-
+
self.clearInput()
self.isChineseInput = !self.isChineseInput
-
+
self.shiftState = .locked
self.changeSwitchInputButtonText()
-
+
}
-
+
func changeSwitchInputButtonText() {
-
+
if self.isChineseInput {
self.switchInputView?.label.text = "ABC"
}else{
self.switchInputView?.label.text = "返回"
}
-
+
}
-
+
func clearInput() {
-
+
if RimeWrapper.isSessionAlive(self.rimeSessionId_) == false {
print("按键-->session 不存在")
return;
}
RimeWrapper.clearComposition(forSession: self.rimeSessionId_)
-
+
}
-
-
+
+
//-----------------------------
-
+
func onDeploymentStarted() {
print("deploy start....")
-// DispatchQueue.main.async {
+// DispatchQueue.main.async {
// self.showDeployView()
// };
}
-
-
+
+
func onDeploymentSuccessful() {
-
+
print("deploy successful....")
-
-
- DispatchQueue.main.async {
+
+
+ DispatchQueue.main.async {
// let uf = NSString.userDefaultsInGroup()
// uf.setObject(NOT_NEED_DEPOLY, forKey: IS_NEED_DEPOLY)
// self.exitDeployView()
-
+
//中文输入
if !RimeWrapper.isSessionAlive(self.rimeSessionId_) {
self.rimeSessionId_ = RimeWrapper.createSession()
}
};
-
-
-
+
+
+
}
-
+
func onDeploymentFailed() {
-
+
print("deploy fail....")
-// DispatchQueue.main.async {
+// DispatchQueue.main.async {
// self.exitDeployView()
// }
}
-
+
func onSchemaChanged(withNewSchema schema: String!) {
-
+
print("deploy change new schema....")
}
-
+
func onOptionChanged(with option: XRimeOption, value: Bool) {
-
+
print("deploy chand option....")
}
-
-
+
+
//--------------------
-
-
+
+
func needDeploy() {
-
+
// if RimeWrapper.isSessionAlive(rimeSessionId_) == false {
// return;
// }
-
+
let uf = NSString .userDefaultsInGroup()
-
+
let isNeed = uf?.string(forKey: NEED_DEPOLY)
-
+
if isNeed == IS_NEED_DEPOLY || isNeed == nil {
-
-
+
+
RimeWrapper.redeploy(withFastMode: false)
}
-
-
+
+
}
-
+
var deployView: DeployView?
func showDeployView() {
-
+
let r = CGRect(x: view.frame.origin.x, y: view.frame.origin.y + getBannerHeight(), width: view.frame.width, height: view.frame.height - getBannerHeight())
deployView = DeployView(frame: r)
self.view.addSubview(deployView!)
-
+
}
-
-
+
+
func exitDeployView() {
-
+
deployView?.removeFromSuperview()
-
+
}
}
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardLeftKeysView.swift b/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardLeftKeysView.swift
index c010fd8..963a054 100644
--- a/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardLeftKeysView.swift
+++ b/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardLeftKeysView.swift
@@ -15,10 +15,6 @@ protocol iRNumberBoardLeftKeysViewProtocol:NSObjectProtocol {
}
class iRNumberBoardLeftKeysBtn: UIButton {
-
- var viewBottomLine:UIView?
-
-
override init(frame: CGRect) {
super.init(frame: frame)
let backColor = UIColor.init(red: 204.0/255.0, green: 210.0/255.0, blue: 217.0/255.0, alpha: 1.0)
@@ -28,114 +24,63 @@ class iRNumberBoardLeftKeysBtn: UIButton {
self.setBackgroundImage(UIImage.imageWithColor(UIColor.lightGray), for: .highlighted)
self.createSubVeiws()
}
-
+
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
+
func createSubVeiws() -> Void {
//1.下部分割线
- viewBottomLine = UIView.init(frame: CGRect.null)
- self .addSubview(viewBottomLine!)
- //--属性设置
- viewBottomLine?.backgroundColor = UIColor.init(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0)
- //--约束布局
- viewBottomLine?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.bottom.equalTo()(self)
- maker.right.equalTo()(self);
- maker.height.mas_equalTo()(0.5)
- })
+ let viewBottomLine:UIView = UIView.init(frame: CGRect.null)
+
+ self.addSubview(viewBottomLine)
+ //--属性设置
+ viewBottomLine.backgroundColor = UIColor.init(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0)
+ //--约束布局
+ viewBottomLine.mas_makeConstraints({ (maker:MASConstraintMaker!) in
+ maker.left.equalTo()(self)
+ maker.bottom.equalTo()(self)
+ maker.right.equalTo()(self);
+ maker.height.mas_equalTo()(0.5)
+ })
}
}
class iRNumberBoardLeftKeysView: UIView {
-
- var btnOne:iRNumberBoardLeftKeysBtn? = nil
- var btnTwo:iRNumberBoardLeftKeysBtn? = nil
- var btnThree:iRNumberBoardLeftKeysBtn? = nil
- var btnFour:iRNumberBoardLeftKeysBtn? = nil
- var btnFive:iRNumberBoardLeftKeysBtn? = nil
weak var delegateToCallBack:iRNumberBoardLeftKeysViewProtocol? = nil
-
+
override init(frame: CGRect) {
super.init(frame: frame)
self.createSubVeiws()
}
-
+
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
+
func createSubVeiws() -> Void {
- //想了半天,还是傻瓜式创建吧,这个也不会有太大的变动
- //1.第一个btn item
- btnOne = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnOne!)
- //--属性设置
- btnOne?.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
- btnOne?.setTitle("+", for: UIControlState())
- //--约束布局
- btnOne?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
- })
- //2.第二个btn item 减号
- btnTwo = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnTwo!)
- //--属性设置
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
- btnTwo?.setTitle("-", for: UIControlState())
- //--约束布局
- btnTwo?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnOne!.mas_bottom)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
- })
- //3.第三个btn item 除号
- btnThree = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnThree!)
- //--属性设置
- btnThree?.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
- btnThree?.setTitle("/", for: UIControlState())
- //--约束布局
- btnThree?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnTwo!.mas_bottom)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
- })
- //4.第四个btn item 乘号
- btnFour = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnFour!)
- //--属性设置
- btnFour?.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
- btnFour?.setTitle("*", for: UIControlState())
- //--约束布局
- btnFour?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnThree!.mas_bottom)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
- })
- //5.第五个btn item 冒号
- btnFive = iRNumberBoardLeftKeysBtn.init(frame:CGRect.null)
- self.addSubview(btnFive!)
- //--属性设置
- btnFive?.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
- btnFive?.setTitle(":", for: UIControlState())
- //--约束布局
- btnFive?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.right.equalTo()(self)
- maker.top.equalTo()(self.btnFour!.mas_bottom)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
+ var last:MASViewAttribute? = nil
+
+ for key in ["+", "-", "*" , "/", ":"] {
+ let iBtn:iRNumberBoardLeftKeysBtn = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
+ self.addSubview(iBtn)
+
+ iBtn.addTarget(self, action:#selector(iRNumberBoardLeftKeysView.btnAction(_:)) , for: .touchUpInside)
+ iBtn.setTitle(key, for: UIControlState())
+
+ iBtn.mas_makeConstraints({ (maker:MASConstraintMaker!) in
+ maker.left.equalTo()(self)
+ maker.top.equalTo()(last == nil ? self : last!)
+ maker.right.equalTo()(self)
+ maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/5.0)
})
+
+ last = iBtn.mas_bottom
+ }
}
-
-
+
+
func btnAction(_ btn:iRNumberBoardLeftKeysBtn) -> Void {
if (self.delegateToCallBack != nil) {
self.delegateToCallBack?.iRNumberBoardLeftKeysViewPassText((btn.titleLabel?.text)!)
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardRightKeysView.swift b/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardRightKeysView.swift
index 110ec95..dc10aa9 100644
--- a/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardRightKeysView.swift
+++ b/iRime/Keyboard/tasty-imitation-keyboard/Demo/iRNumberBoard/View/iRNumberBoardRightKeysView.swift
@@ -16,10 +16,10 @@ protocol iRNumberBoardRightKeysViewProtocol:NSObjectProtocol {
}
class iRNumberBoardRightKeysBtn: UIButton {
-
+
var viewBottomLine:UIView?
-
-
+
+
override init(frame: CGRect) {
super.init(frame: frame)
let backColor = UIColor.init(red: 204.0/255.0, green: 210.0/255.0, blue: 217.0/255.0, alpha: 1.0)
@@ -29,7 +29,7 @@ class iRNumberBoardRightKeysBtn: UIButton {
self.setBackgroundImage(UIImage.imageWithColor(UIColor.lightGray), for: .highlighted)
self.createSubVeiws()
}
-
+
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@@ -63,82 +63,53 @@ class iRNumberBoardRightKeysView: UIView {
super.init(frame: frame)
self.createSubVeiws()
}
-
+
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
-
+
func createSubVeiws() -> Void {
- //想了半天,还是傻瓜式创建吧,这个也不会有太大的变动
- //1.第一个btn item
- btnOne = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnOne!)
- //--属性设置
- btnOne?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnOneStartAction(_:)), for: .touchDown)
- btnOne?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchUpInside)
- btnOne?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchCancel)
-
- btnOne?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragExit)
- btnOne?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragEnter)
-
-// btnOne?.setTitle("退格", forState: .Normal)
- //expression_delete_pressed filter_delete
- btnOne?.setImage(UIImage.init(named: "expression_delete"), for: UIControlState())
- btnOne?.setImage(UIImage.init(named: "filter_delete"), for: .highlighted)
- //--约束布局
- btnOne?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/4.0)
- })
- //2.第二个btn item 空格
- btnTwo = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnTwo!)
- //--属性设置
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnTwoStartAction(_:)), for: .touchDown)
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchUpInside)
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchCancel)
-
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragExit)
- btnTwo?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragEnter)
-
- btnTwo?.setTitle("空格", for: UIControlState())
- //--约束布局
- btnTwo?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnOne!.mas_bottom)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/4.0)
- })
- //3.第三个btn item @
- btnThree = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnThree!)
- //--属性设置
- btnThree?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnThreeAction(_:)) , for: .touchUpInside)
- btnThree?.setTitle("@", for: UIControlState())
- //--约束布局
- btnThree?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
- maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnTwo!.mas_bottom)
- maker.right.equalTo()(self)
- maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/4.0)
- })
- //4.第四个btn item 换行
- btnFour = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
- self.addSubview(btnFour!)
- //--属性设置
- btnFour?.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnFourAction(_:)) , for: .touchUpInside)
- btnFour?.setTitle("换行", for: UIControlState())
+ var last:MASViewAttribute? = nil
+ let layout:[NSDictionary] = [
+ ["title": "BackSpace", "action": #selector(iRNumberBoardRightKeysView.btnOneStartAction(_:))],
+ ["title": "空格", "action": #selector(iRNumberBoardRightKeysView.btnTwoStartAction(_:))],
+ ["title": "@", "action": #selector(iRNumberBoardRightKeysView.btnThreeAction(_:))],
+ ["title": "换行", "action": #selector(iRNumberBoardRightKeysView.btnFourAction(_:))]
+ ]
+
+ for key in layout {
+ let iBtn:iRNumberBoardLeftKeysBtn = iRNumberBoardLeftKeysBtn.init(frame: CGRect.null)
+
+ self.addSubview(iBtn)
+
+ iBtn.addTarget(self, action:key["action"] as! Selector, for: .touchDown)
+
+ iBtn.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchUpInside)
+ iBtn.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchCancel)
+ iBtn.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragExit)
+ iBtn.addTarget(self, action:#selector(iRNumberBoardRightKeysView.btnEndAction(_:)) , for: .touchDragEnter)
+
+ if let title = key["title"] as? String {
+ if title == "BackSpace" {
+ iBtn.setImage(UIImage.init(named: "expression_delete"), for: UIControlState())
+ iBtn.setImage(UIImage.init(named: "filter_delete"), for: .highlighted)
+ } else {
+ iBtn.setTitle(title, for: UIControlState())
+ }
+ }
+
//--约束布局
- btnFour?.mas_makeConstraints({ (maker:MASConstraintMaker!) in
+ iBtn.mas_makeConstraints({ (maker:MASConstraintMaker!) in
maker.left.equalTo()(self)
- maker.top.equalTo()(self.btnThree!.mas_bottom)
+ maker.top.equalTo()(last == nil ? self : last)
maker.right.equalTo()(self)
maker.height.equalTo()(self.mas_height)?.multipliedBy()(1.0/4.0)
})
+
+ last = iBtn.mas_bottom
+ }
}
-
+
func btnOneStartAction(_ btn:iRNumberBoardRightKeysBtn) -> Void {
self.timer = Timer.scheduledTimer(timeInterval: timeRepeat, target: self, selector: #selector(iRNumberBoardRightKeysView.repeatBtnOneAction), userInfo: nil, repeats: true)
self.timer?.fire()
@@ -148,22 +119,22 @@ class iRNumberBoardRightKeysView: UIView {
self.timer = nil
}
func repeatBtnOneAction() -> Void {
-
+
if self.delegateAction != nil {
self.delegateAction?.deleteOneOfIRNumberBoardRightKeysView()
}
-
+
}
func btnTwoStartAction(_ btn:iRNumberBoardRightKeysBtn) -> Void {
self.timer = Timer.scheduledTimer(timeInterval: timeRepeat, target: self, selector: #selector(iRNumberBoardRightKeysView.repeatBtnTwoAction), userInfo: nil, repeats: true)
self.timer?.fire()
}
func repeatBtnTwoAction() -> Void {
-
+
if self.delegateAction != nil {
self.delegateAction?.passTextOfIRNumberBoardRightKeysView(" ")
}
-
+
}
// func btnTwoAction(btn:iRNumberBoardRightKeysBtn) -> Void {
// if self.delegateAction != nil {
@@ -181,5 +152,5 @@ class iRNumberBoardRightKeysView: UIView {
}
}
-
+
}
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/.DS_Store b/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/.DS_Store
deleted file mode 100644
index 649c27e..0000000
Binary files a/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/res/.DS_Store b/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/res/.DS_Store
deleted file mode 100644
index 5008ddf..0000000
Binary files a/iRime/Keyboard/tasty-imitation-keyboard/Demo/spi/res/.DS_Store and /dev/null differ
diff --git a/iRime/Keyboard/tasty-imitation-keyboard/Views/Shapes.swift b/iRime/Keyboard/tasty-imitation-keyboard/Views/Shapes.swift
index d5cff35..be1e68f 100644
--- a/iRime/Keyboard/tasty-imitation-keyboard/Views/Shapes.swift
+++ b/iRime/Keyboard/tasty-imitation-keyboard/Views/Shapes.swift
@@ -271,7 +271,7 @@ func drawGlobe(_ bounds: CGRect, color: UIColor) {
let factors = getFactors(CGSize(width: 41, height: 40), toRect: bounds)
let xScalingFactor = factors.xScalingFactor
let yScalingFactor = factors.yScalingFactor
- let lineWidthScalingFactor = factors.lineWidthScalingFactor
+ let lineWidthScalingFactor = factors.lineWidthScalingFactor * 2
centerShape(CGSize(width: 41 * xScalingFactor, height: 40 * yScalingFactor), toRect: bounds)
diff --git a/iRime/NSString+Path.m b/iRime/NSString+Path.m
index 052d594..2eaa5aa 100644
--- a/iRime/NSString+Path.m
+++ b/iRime/NSString+Path.m
@@ -13,7 +13,7 @@
#define ZIP_FILE @"iRime"
#define USER_PATH @"user"
-#define GROUP_ID @"group.Rime"
+#define GROUP_ID @"group.xqin.net"
@implementation NSString (Path)
diff --git a/iRime/Pods/.DS_Store b/iRime/Pods/.DS_Store
deleted file mode 100644
index d106ba7..0000000
Binary files a/iRime/Pods/.DS_Store and /dev/null differ
diff --git a/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/index.css b/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/index.css
index 53b0247..6b33d65 100644
--- a/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/index.css
+++ b/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/index.css
@@ -128,3 +128,13 @@
.uploading {
display: none;
}
+
+#listing tr:hover td {
+ color: #3879d9;
+ font-weight: bold;
+ background-color: #f6fbff;
+}
+
+#listing p.edit {
+ display: inline-block;
+}
diff --git a/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/index.html b/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/index.html
index 8be6a18..09f6658 100644
--- a/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/index.html
+++ b/iRime/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/index.html
@@ -1,7 +1,7 @@