mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-17 21:27:40 +00:00
[iOS] FV Remove ObjC files, fixup banner -- until we have suggestions
This commit is contained in:
parent
b0429ed1aa
commit
c6ee7eaef1
15 changed files with 53 additions and 1056 deletions
|
|
@ -1,24 +0,0 @@
|
|||
//
|
||||
// FVShared.h
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 19/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString *const FVGroupID;
|
||||
|
||||
extern NSString *const kFVKeyboardList;
|
||||
|
||||
extern NSString *const kFVKeyboardNameKey;
|
||||
extern NSString *const kFVKeyboardLanguageCodeKey;
|
||||
extern NSString *const kFVKeyboardFilenameKey;
|
||||
extern NSString *const kFVKeyboardCheckStateKey;
|
||||
|
||||
@interface FVShared : NSObject
|
||||
|
||||
+ (NSUserDefaults *)userDefaults;
|
||||
|
||||
@end
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
//
|
||||
// FVShared.m
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 19/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FVShared.h"
|
||||
|
||||
NSString *const FVGroupID = @"group.FVKeyboards";
|
||||
|
||||
NSString *const kFVKeyboardList = @"FVKeyboardList";
|
||||
|
||||
NSString *const kFVKeyboardNameKey = @"FVKeyboardName";
|
||||
NSString *const kFVKeyboardLanguageCodeKey = @"FVKeyboardLanguageCode";
|
||||
NSString *const kFVKeyboardFilenameKey = @"FVKeyboardFilename";
|
||||
NSString *const kFVKeyboardCheckStateKey = @"FVKeyboardCheckState";
|
||||
|
||||
@implementation FVShared
|
||||
|
||||
+ (NSUserDefaults *)userDefaults {
|
||||
NSUserDefaults *_userDefaults = nil;
|
||||
if ([[NSUserDefaults standardUserDefaults] respondsToSelector:@selector(initWithSuiteName:)])
|
||||
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:FVGroupID];
|
||||
|
||||
if (_userDefaults == nil)
|
||||
_userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
return _userDefaults;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -675,7 +675,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "FirstVoices/FirstVoices-Bridging-Header.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
|
@ -700,7 +700,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "FirstVoices/FirstVoices-Bridging-Header.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
|
|
@ -726,7 +726,7 @@
|
|||
PROVISIONING_PROFILE = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SWKeyboard/SWKeyboard-Bridging-Header.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
|
@ -753,7 +753,7 @@
|
|||
PROVISIONING_PROFILE = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SWKeyboard/SWKeyboard-Bridging-Header.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// AppDelegate.h
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
// AppDelegate.m
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
File: Checkbox.h
|
||||
Abstract: A UIControl subclass that implements a checkbox.
|
||||
|
||||
Version: 1.4
|
||||
|
||||
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
||||
Inc. ("Apple") in consideration of your agreement to the following
|
||||
terms, and your use, installation, modification or redistribution of
|
||||
this Apple software constitutes acceptance of these terms. If you do
|
||||
not agree with these terms, please do not use, install, modify or
|
||||
redistribute this Apple software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, Apple grants you a personal, non-exclusive
|
||||
license, under Apple's copyrights in this original Apple software (the
|
||||
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
||||
Software, with or without modifications, in source and/or binary forms;
|
||||
provided that if you redistribute the Apple Software in its entirety and
|
||||
without modifications, you must retain this notice and the following
|
||||
text and disclaimers in all such redistributions of the Apple Software.
|
||||
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
||||
be used to endorse or promote products derived from the Apple Software
|
||||
without specific prior written permission from Apple. Except as
|
||||
expressly stated in this notice, no other rights or licenses, express or
|
||||
implied, are granted by Apple herein, including but not limited to any
|
||||
patent rights that may be infringed by your derivative works or by other
|
||||
works in which the Apple Software may be incorporated.
|
||||
|
||||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
||||
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
||||
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
||||
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
||||
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
||||
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
||||
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Copyright (C) 2014 Apple Inc. All Rights Reserved.
|
||||
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Checkbox : UIControl
|
||||
|
||||
//! The control state.
|
||||
@property (nonatomic, readwrite, getter = isChecked) BOOL checked;
|
||||
|
||||
//! The color of the box surrounding the tappable area of the Checkbox control.
|
||||
//!
|
||||
//! In iOS 7, all views have a tintColor property. We redeclare that property
|
||||
//! here to accommodate tint color customization for iOS 6 devices.
|
||||
@property (nonatomic, strong) UIColor *tintColor;
|
||||
|
||||
@end
|
||||
|
|
@ -1,308 +0,0 @@
|
|||
/*
|
||||
File: Checkbox.m
|
||||
Abstract: A UIControl subclass that implements a checkbox.
|
||||
|
||||
Version: 1.4
|
||||
|
||||
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
|
||||
Inc. ("Apple") in consideration of your agreement to the following
|
||||
terms, and your use, installation, modification or redistribution of
|
||||
this Apple software constitutes acceptance of these terms. If you do
|
||||
not agree with these terms, please do not use, install, modify or
|
||||
redistribute this Apple software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, Apple grants you a personal, non-exclusive
|
||||
license, under Apple's copyrights in this original Apple software (the
|
||||
"Apple Software"), to use, reproduce, modify and redistribute the Apple
|
||||
Software, with or without modifications, in source and/or binary forms;
|
||||
provided that if you redistribute the Apple Software in its entirety and
|
||||
without modifications, you must retain this notice and the following
|
||||
text and disclaimers in all such redistributions of the Apple Software.
|
||||
Neither the name, trademarks, service marks or logos of Apple Inc. may
|
||||
be used to endorse or promote products derived from the Apple Software
|
||||
without specific prior written permission from Apple. Except as
|
||||
expressly stated in this notice, no other rights or licenses, express or
|
||||
implied, are granted by Apple herein, including but not limited to any
|
||||
patent rights that may be infringed by your derivative works or by other
|
||||
works in which the Apple Software may be incorporated.
|
||||
|
||||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
|
||||
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
|
||||
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
|
||||
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
|
||||
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
|
||||
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
|
||||
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Copyright (C) 2014 Apple Inc. All Rights Reserved.
|
||||
|
||||
*/
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#import "Checkbox.h"
|
||||
|
||||
@implementation Checkbox
|
||||
{
|
||||
// This variable is only used on iOS 6. On iOS 7, calls to read/write the
|
||||
// tintColor property are forwarded to the super (UIView).
|
||||
//
|
||||
// We must manually define it because we've manually implemented both the
|
||||
// getter and setter for the 'tintColor' property.
|
||||
UIColor *_tintColor;
|
||||
}
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
- (void)tintColorDidChange
|
||||
{
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
//! Manual implementation of the getter for the 'tintColor' property.
|
||||
//
|
||||
// The getter for this property is implemented to forward invcations to the
|
||||
// super if the device is running iOS 7.
|
||||
//
|
||||
- (UIColor*)tintColor
|
||||
{
|
||||
// On iOS 7, forward to the super (UIView).
|
||||
if ([[super superclass] instancesRespondToSelector:@selector(tintColor)])
|
||||
return [super tintColor];
|
||||
else
|
||||
return _tintColor;
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
//! Manual implementation of the setter for the 'tintColor' property.
|
||||
//
|
||||
// The setter for this property is implemented to forward invcations to the
|
||||
// super if the device is running iOS 7.
|
||||
//
|
||||
- (void)setTintColor:(UIColor *)tintColor
|
||||
{
|
||||
// On iOS 7, forward to the super (UIView).
|
||||
if ([[super superclass] instancesRespondToSelector:@selector(setTintColor:)])
|
||||
return [super setTintColor:tintColor];
|
||||
else
|
||||
_tintColor = tintColor;
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// This method is overridden to draw the control using Quartz2D.
|
||||
//
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
const CGFloat size = MIN(self.bounds.size.width, self.bounds.size.height);
|
||||
CGAffineTransform transform = CGAffineTransformIdentity;
|
||||
|
||||
// Account for non-square frames.
|
||||
if (self.bounds.size.width < self.bounds.size.height) {
|
||||
// Vertical Center
|
||||
transform = CGAffineTransformMakeTranslation(0, (self.bounds.size.height - size)/2);
|
||||
} else if (self.bounds.size.width > self.bounds.size.height) {
|
||||
// Horizontal Center
|
||||
transform = CGAffineTransformMakeTranslation((self.bounds.size.width - size)/2, 0);
|
||||
}
|
||||
|
||||
// Draw the checkbox
|
||||
{
|
||||
const CGFloat strokeWidth = 0.068359375f * size;
|
||||
const CGFloat checkBoxInset = 0.171875f * size;
|
||||
|
||||
CGRect checkboxRect = CGRectMake(checkBoxInset, checkBoxInset, size - checkBoxInset*2, size - checkBoxInset*2);
|
||||
UIBezierPath *checkboxPath = [UIBezierPath bezierPathWithRect:checkboxRect];
|
||||
|
||||
[checkboxPath applyTransform:transform];
|
||||
|
||||
if (!self.tintColor)
|
||||
self.tintColor = [UIColor colorWithWhite:0.5f alpha:1.0f];
|
||||
[self.tintColor setStroke];
|
||||
|
||||
checkboxPath.lineWidth = strokeWidth;
|
||||
|
||||
[checkboxPath stroke];
|
||||
}
|
||||
|
||||
// Draw the checkmark if self.checked==YES
|
||||
if (self.checked)
|
||||
{
|
||||
// The checkmark is drawn as a bezier path using Quartz2D.
|
||||
// The control points for this path are stored (hardcoded) as normalized
|
||||
// values so that the path can be accurately reconstructed at any size.
|
||||
|
||||
// A small macro to scale the normalized control points for the
|
||||
// checkmark bezier path to the size of the control.
|
||||
#define P(POINT) (POINT * size)
|
||||
|
||||
CGContextSetGrayFillColor(context, 0.0f, 1.0f);
|
||||
CGContextConcatCTM(context, transform);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context,
|
||||
P(0.304f), P(0.425f));
|
||||
CGContextAddLineToPoint(context, P(0.396f), P(0.361f));
|
||||
CGContextAddCurveToPoint(context,
|
||||
P(0.396f), P(0.361f),
|
||||
P(0.453f), P(0.392f),
|
||||
P(0.5f), P(0.511f));
|
||||
CGContextAddCurveToPoint(context,
|
||||
P(0.703f), P(0.181f),
|
||||
P(0.988f), P(0.015f),
|
||||
P(0.988f), P(0.015f));
|
||||
CGContextAddLineToPoint(context, P(0.998f), P(0.044f));
|
||||
CGContextAddCurveToPoint(context,
|
||||
P(0.998f), P(0.044f),
|
||||
P(0.769f), P(0.212f),
|
||||
P(0.558f), P(0.605f));
|
||||
CGContextAddLineToPoint(context, P(0.458f), P(0.681f));
|
||||
CGContextAddCurveToPoint(context,
|
||||
P(0.365f), P(0.451f),
|
||||
P(0.304f), P(0.425f),
|
||||
P(0.302f), P(0.425f));
|
||||
CGContextClosePath(context);
|
||||
|
||||
CGContextFillPath(context);
|
||||
|
||||
#undef P
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
//! Custom implementation of the setter for the 'checked' property.
|
||||
//
|
||||
- (void)setChecked:(BOOL)checked
|
||||
{
|
||||
if (checked != _checked) {
|
||||
_checked = checked;
|
||||
|
||||
// Flag ourself as needing to be redrawn.
|
||||
[self setNeedsDisplay];
|
||||
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
//! Sends action messages for the given control events along with the UIEvent
|
||||
//! which triggered them.
|
||||
//
|
||||
// UIControl provides the -sendActionsForControlEvents: method to send action
|
||||
// messages associated with controlEvents. A limitation of
|
||||
// -sendActionsForControlEvents is that it does not include the UIEvent that
|
||||
// triggered the controlEvents with the action messages.
|
||||
//
|
||||
// AccessoryViewController and CustomAccessoryViewController rely on receiving
|
||||
// the underlying UIEvent when their associated IBActions are invoked.
|
||||
// This method functions identically to -sendActionsForControlEvents:
|
||||
// but accepts a UIEvent that is sent with the action messages.
|
||||
//
|
||||
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents withEvent:(UIEvent*)event
|
||||
{
|
||||
NSSet *allTargets = [self allTargets];
|
||||
|
||||
for (id target in allTargets) {
|
||||
|
||||
NSArray *actionsForTarget = [self actionsForTarget:target forControlEvent:controlEvents];
|
||||
|
||||
// Actions are returned as NSString objects, where each string is the
|
||||
// selector for the action.
|
||||
for (NSString *action in actionsForTarget) {
|
||||
SEL selector = NSSelectorFromString(action);
|
||||
[self sendAction:selector to:target forEvent:event];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// If you override one of the touch event callbacks, you should override all of
|
||||
// them.
|
||||
//
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{ }
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// If you override one of the touch event callbacks, you should override all of
|
||||
// them.
|
||||
//
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{ }
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// This is the touch callback we are interested in. If there is a touch inside
|
||||
// our bounds, toggle our checked state and notify our target of the change.
|
||||
//
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
if ([[touches anyObject] tapCount] == 1) {
|
||||
// Toggle our state.
|
||||
self.checked = !self.checked;
|
||||
|
||||
// Notify our target (if we have one) of the change.
|
||||
[self sendActionsForControlEvents:UIControlEventValueChanged withEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// If you override one of the touch event callbacks, you should override all of
|
||||
// them.
|
||||
//
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{ }
|
||||
|
||||
#pragma mark -
|
||||
// If you implement a custom control, you should put in the extra work to
|
||||
// make it accessible. Your users will appreciate it.
|
||||
#pragma mark Accessibility
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
// Declare that this control is accessible element to assistive applications.
|
||||
//
|
||||
- (BOOL)isAccessibilityElement
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Note: accessibilityHint and accessibilityLabel should be configured
|
||||
// elsewhere because this control does not know its purpose
|
||||
// as it relates to the program as a whole.
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
- (UIAccessibilityTraits)accessibilityTraits
|
||||
{
|
||||
// Always combine our accessibilityTraits with the super's
|
||||
// accessibilityTraits
|
||||
return super.accessibilityTraits | UIAccessibilityTraitButton;
|
||||
}
|
||||
|
||||
|
||||
//| ----------------------------------------------------------------------------
|
||||
- (NSString*)accessibilityValue
|
||||
{
|
||||
return self.checked ? @"Enabled" : @"Disabled";
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// KeyboardsViewController.h
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface KeyboardsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
|
||||
@end
|
||||
|
|
@ -1,318 +0,0 @@
|
|||
//
|
||||
// KeyboardsViewController.m
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KeyboardsViewController.h"
|
||||
#import "Keyman.h"
|
||||
#import "FVShared.h"
|
||||
#import "Checkbox.h"
|
||||
|
||||
NSString *const helpLink = @"http://help.keyman.com/keyboard/";
|
||||
NSString *const kKeyboardsFileLastModDateKey = @"KeyboardsFileLastModDate";
|
||||
NSInteger const tHelpButtonTag = 1000;
|
||||
NSInteger const tCheckBoxTag = 2000;
|
||||
|
||||
@interface KeyboardsViewController ()
|
||||
@property (nonatomic, weak) IBOutlet UITableView *tableView;
|
||||
@property (nonatomic, strong) NSMutableArray *keyboardList;
|
||||
@end
|
||||
|
||||
@implementation KeyboardsViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:NO];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return [self.keyboardList count]/2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
NSInteger index = (section*2)+1;
|
||||
NSArray *kbArray = [self.keyboardList objectAtIndex:index];
|
||||
return [kbArray count];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
static NSString *cellIdentifier = @"Cell";
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
||||
if (!cell) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
|
||||
UIView *selectionColor = [[UIView alloc] init];
|
||||
[selectionColor setBackgroundColor:[UIColor colorWithRed:204.0/255.0 green:136.0/255.0 blue:34.0/255.0 alpha:1.0]];
|
||||
[cell setSelectedBackgroundView:selectionColor];
|
||||
[cell.textLabel setFont:[UIFont systemFontOfSize:14.0]];
|
||||
}
|
||||
|
||||
if (cell.accessoryView == nil) {
|
||||
CGFloat cellH = CGRectGetHeight(cell.frame);
|
||||
CGFloat margin = 0.0;
|
||||
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[helpButton setTag:tHelpButtonTag];
|
||||
[helpButton addTarget:self action:@selector(helpButtonTapped:forEvent:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[helpButton setImage:[UIImage imageNamed:@"739-question"] forState:UIControlStateNormal];
|
||||
[helpButton setImage:[UIImage imageNamed:@"739-question-selected"] forState:UIControlStateHighlighted];
|
||||
CGFloat w1 = cellH;
|
||||
CGFloat h1 = cellH;
|
||||
[helpButton setFrame:CGRectMake(margin, 0, w1, h1)];
|
||||
|
||||
CGFloat w2 = cellH-10;
|
||||
CGFloat h2 = cellH;
|
||||
Checkbox *checkBox = [[Checkbox alloc] initWithFrame:CGRectMake(margin+w1, 0, w2, h2)];
|
||||
[checkBox setTag:tCheckBoxTag];
|
||||
[checkBox addTarget:self action:@selector(checkBoxTapped:forEvent:) forControlEvents:UIControlEventValueChanged];
|
||||
checkBox.opaque = NO;
|
||||
checkBox.tintColor = [UIColor lightGrayColor];
|
||||
|
||||
cell.accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, margin+w1+w2+margin, cellH)];
|
||||
[cell.accessoryView addSubview:helpButton];
|
||||
[cell.accessoryView addSubview:checkBox];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
return [self.keyboardList objectAtIndex:section*2];
|
||||
}
|
||||
|
||||
#pragma mark - Table view delegate
|
||||
|
||||
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
[cell setAccessoryType:UITableViewCellAccessoryNone];
|
||||
|
||||
NSInteger index = (indexPath.section*2)+1;
|
||||
NSArray *kbArray = [self.keyboardList objectAtIndex:index];
|
||||
NSDictionary *kbDict = [kbArray objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = [kbDict objectForKey:kFVKeyboardNameKey];
|
||||
|
||||
NSString *checkState = [kbDict objectForKey:kFVKeyboardCheckStateKey];
|
||||
Checkbox *checkbox = (Checkbox *)[cell.accessoryView viewWithTag:tCheckBoxTag];
|
||||
[checkbox setChecked:[checkState isEqualToString:@"YES"]];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
//
|
||||
}
|
||||
|
||||
- (NSArray *)keyboardList {
|
||||
if (_keyboardList == nil) {
|
||||
NSUserDefaults *sharedData = [FVShared userDefaults];
|
||||
_keyboardList = [[sharedData arrayForKey:kFVKeyboardList] mutableCopy];
|
||||
NSArray *oldKeyboardList = nil;
|
||||
if (_keyboardList == nil || [self shouldLoadFromKeyboardsFile]) {
|
||||
@try {
|
||||
if (_keyboardList != nil) {
|
||||
oldKeyboardList = [_keyboardList copy];
|
||||
_keyboardList = nil;
|
||||
}
|
||||
NSString *keyboardsFile = [[NSBundle mainBundle] pathForResource:@"keyboards" ofType:@"csv"];
|
||||
NSString *fileContents = [[NSString stringWithContentsOfFile:keyboardsFile encoding:NSUTF8StringEncoding error:NULL] stringByReplacingOccurrencesOfString:@"\r" withString:@""];
|
||||
NSArray *lines = [fileContents componentsSeparatedByString:@"\n"];
|
||||
for (int i = 1; i < lines.count; i++) {
|
||||
NSString *line = [lines objectAtIndex:i];
|
||||
if (!line.length)
|
||||
continue;
|
||||
|
||||
NSArray *values = [line componentsSeparatedByString:@","];
|
||||
if (values.count) {
|
||||
if (_keyboardList == nil)
|
||||
_keyboardList = [NSMutableArray arrayWithCapacity:0];
|
||||
|
||||
NSString *kbName = values[0];
|
||||
NSString *region = values[3];
|
||||
NSString *langCode = values[9];
|
||||
NSMutableString *kbFilename = [[values[7] stringByReplacingOccurrencesOfString:@".kmn" withString:@"-9.0.js"] mutableCopy];
|
||||
|
||||
if (![_keyboardList containsObject:region]) {
|
||||
[_keyboardList addObject:region];
|
||||
NSMutableDictionary *kbDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:kbName, kFVKeyboardNameKey,
|
||||
langCode, kFVKeyboardLanguageCodeKey,
|
||||
kbFilename, kFVKeyboardFilenameKey,
|
||||
@"NO", kFVKeyboardCheckStateKey, nil];
|
||||
[_keyboardList addObject:[NSMutableArray arrayWithObject:kbDict]];
|
||||
}
|
||||
else {
|
||||
NSUInteger index = [_keyboardList indexOfObject:region];
|
||||
index++;
|
||||
NSMutableArray *kbArray = [_keyboardList objectAtIndex:index];
|
||||
NSMutableDictionary *kbDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:kbName, kFVKeyboardNameKey,
|
||||
langCode, kFVKeyboardLanguageCodeKey,
|
||||
kbFilename, kFVKeyboardFilenameKey,
|
||||
@"NO", kFVKeyboardCheckStateKey, nil];
|
||||
[kbArray addObject:kbDict];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSUserDefaults *sharedData = [FVShared userDefaults];
|
||||
[sharedData setObject:_keyboardList forKey:kFVKeyboardList];
|
||||
[sharedData setObject:[NSArray arrayWithObject:[self keyboardsFileModDate]] forKey:kKeyboardsFileLastModDateKey];
|
||||
[sharedData synchronize];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
NSLog(@"Error = %@", e.description);
|
||||
_keyboardList = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldKeyboardList != nil)
|
||||
[self restoreActiveKeyboardsFromArray:oldKeyboardList];
|
||||
}
|
||||
|
||||
return _keyboardList;
|
||||
}
|
||||
|
||||
- (BOOL)shouldLoadFromKeyboardsFile {
|
||||
NSUserDefaults *sharedData = [FVShared userDefaults];
|
||||
NSDate *lastModDate = [[sharedData objectForKey:kKeyboardsFileLastModDateKey] objectAtIndex:0];
|
||||
if (lastModDate == nil)
|
||||
return YES;
|
||||
|
||||
NSDate *fileModDate = [self keyboardsFileModDate];
|
||||
if (fileModDate == nil)
|
||||
return YES;
|
||||
|
||||
if ([fileModDate timeIntervalSinceDate:lastModDate] > 0)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSDate *)keyboardsFileModDate {
|
||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"keyboards" ofType:@"csv"];
|
||||
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
|
||||
return [attrs objectForKey:NSFileModificationDate];
|
||||
}
|
||||
|
||||
- (void)helpButtonTapped:(id)sender forEvent:(UIEvent*)event {
|
||||
NSSet *touches = [event allTouches];
|
||||
UITouch *touch = [touches anyObject];
|
||||
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
|
||||
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
|
||||
if (indexPath != nil) {
|
||||
NSInteger index = (indexPath.section*2)+1;
|
||||
NSArray *kbArray = [self.keyboardList objectAtIndex:index];
|
||||
NSDictionary *kbDict = [kbArray objectAtIndex:indexPath.row];
|
||||
NSString *kbFilename = [kbDict objectForKey:kFVKeyboardFilenameKey];
|
||||
NSString *kbID = [kbFilename substringToIndex:[kbFilename rangeOfString:@"-"].location];
|
||||
NSURL *helpUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", helpLink, kbID]];
|
||||
[[UIApplication sharedApplication] openURL:helpUrl];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkBoxTapped:(id)sender forEvent:(UIEvent*)event {
|
||||
NSSet *touches = [event allTouches];
|
||||
UITouch *touch = [touches anyObject];
|
||||
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
|
||||
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
|
||||
if (indexPath != nil) {
|
||||
// Update the checkState with the new checked state
|
||||
NSInteger index = (indexPath.section*2)+1;
|
||||
NSMutableArray *kbArray = [[self.keyboardList objectAtIndex:index] mutableCopy];
|
||||
NSMutableDictionary *kbDict = [[kbArray objectAtIndex:indexPath.row] mutableCopy];
|
||||
|
||||
[kbDict setObject:[(Checkbox *)sender isChecked]?@"YES":@"NO" forKey:kFVKeyboardCheckStateKey];
|
||||
[kbArray replaceObjectAtIndex:indexPath.row withObject:kbDict];
|
||||
[_keyboardList replaceObjectAtIndex:index withObject:kbArray];
|
||||
|
||||
NSUserDefaults *sharedData = [FVShared userDefaults];
|
||||
[sharedData setObject:_keyboardList forKey:kFVKeyboardList];
|
||||
[sharedData synchronize];
|
||||
|
||||
[self updateActiveKeyboardsList];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateActiveKeyboardsList {
|
||||
NSUserDefaults *sharedData = [FVShared userDefaults];
|
||||
[sharedData removeObjectForKey:kKeymanUserKeyboardsListKey];
|
||||
NSArray *kbList = self.keyboardList;
|
||||
for (int i = 0; i < kbList.count; i+=2) {
|
||||
NSArray *kbArray = [kbList objectAtIndex:i+1];
|
||||
for (NSDictionary *kbDict in kbArray) {
|
||||
if ([[kbDict objectForKey:kFVKeyboardCheckStateKey] isEqualToString:@"YES"]) {
|
||||
NSString *kbFilename = [kbDict objectForKey:kFVKeyboardFilenameKey];
|
||||
NSString *kbID = [kbFilename substringToIndex:[kbFilename rangeOfString:@"-"].location];
|
||||
NSString *langCode = [kbDict objectForKey:kFVKeyboardLanguageCodeKey];
|
||||
NSString *langID = [[langCode substringToIndex:(langCode.length<3?langCode.length:3)] lowercaseString];
|
||||
NSString *kbName = [kbDict objectForKey:kFVKeyboardNameKey];
|
||||
NSString *langName = kbName;
|
||||
[[KMManager sharedInstance] addKeyboardWithID:kbID
|
||||
languageID:langID
|
||||
keyboardName:kbName
|
||||
languageName:langName
|
||||
isRTL:NO
|
||||
isCustom:YES
|
||||
font:nil
|
||||
oskFont:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (![sharedData objectForKey:kKeymanUserKeyboardsListKey]) {
|
||||
[[KMManager sharedInstance] addKeyboardWithID:kKeymanDefaultKeyboardID
|
||||
languageID:kKeymanDefaultLanguageID
|
||||
keyboardName:kKeymanDefaultKeyboardName
|
||||
languageName:kKeymanDefaultLanguageName
|
||||
isRTL:[kKeymanDefaultKeyboardRTL isEqualToString:@"Y"]?YES:NO
|
||||
isCustom:NO
|
||||
font:kKeymanDefaultKeyboardFont
|
||||
oskFont:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)restoreActiveKeyboardsFromArray:(NSArray *)oldKeyboardList {
|
||||
NSMutableArray *oldActiveKeyboards = [NSMutableArray arrayWithCapacity:0];
|
||||
for (int i = 0; i < oldKeyboardList.count; i+=2) {
|
||||
NSArray *kbArray = [oldKeyboardList objectAtIndex:i+1];
|
||||
for (NSDictionary *kbDict in kbArray) {
|
||||
if ([[kbDict objectForKey:kFVKeyboardCheckStateKey] isEqualToString:@"YES"]) {
|
||||
NSString *kbFilename = [kbDict objectForKey:kFVKeyboardFilenameKey];
|
||||
NSString *kbID = [kbFilename substringToIndex:[kbFilename rangeOfString:@"-"].location];
|
||||
[oldActiveKeyboards addObject:kbID];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < self.keyboardList.count; i+=2) {
|
||||
NSArray *kbArray = [self.keyboardList objectAtIndex:i+1];
|
||||
int x = 0;
|
||||
for (NSDictionary *kbDict in kbArray) {
|
||||
NSString *kbFilename = [kbDict objectForKey:kFVKeyboardFilenameKey];
|
||||
NSString *kbID = [kbFilename substringToIndex:[kbFilename rangeOfString:@"-"].location];
|
||||
if ([oldActiveKeyboards containsObject:kbID]) {
|
||||
NSMutableArray *nArray = [kbArray mutableCopy];
|
||||
NSMutableDictionary *nDict = [kbDict mutableCopy];
|
||||
[nDict setObject:@"YES" forKey:kFVKeyboardCheckStateKey];
|
||||
[nArray replaceObjectAtIndex:x withObject:nDict];
|
||||
[_keyboardList replaceObjectAtIndex:i+1 withObject:nArray];
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
[self updateActiveKeyboardsList];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
//
|
||||
// ViewController.h
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController <UIWebViewDelegate>
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
//
|
||||
// ViewController.m
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "KeymanEngine/KeymanEngine.h"
|
||||
#import "FVShared.h"
|
||||
|
||||
@interface ViewController ()
|
||||
@property (nonatomic, weak) IBOutlet UIWebView *webView;
|
||||
@property (nonatomic, weak) IBOutlet UIView *statusBarBackground;
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
[KMManager setApplicationGroupIdentifier: FVGroupID];
|
||||
|
||||
#ifdef DEBUG
|
||||
[[KMManager sharedInstance] setDebugPrintingOn:YES];
|
||||
#endif
|
||||
|
||||
NSArray *kbPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"js" inDirectory:nil];
|
||||
for (NSString *kbPath in kbPaths)
|
||||
[[KMManager sharedInstance] preloadLanguageFileAtPath:kbPath shouldOverwrite:YES];
|
||||
|
||||
self.webView.delegate = self;
|
||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"setup" ofType:@"html" inDirectory:nil];
|
||||
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:YES];
|
||||
[self setStatusBarBackgroundWithOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
[self setStatusBarBackgroundWithOrientation:toInterfaceOrientation];
|
||||
}
|
||||
|
||||
- (void)setStatusBarBackgroundWithOrientation:(UIInterfaceOrientation)orientation {
|
||||
if (UIInterfaceOrientationIsPortrait(orientation))
|
||||
[self.statusBarBackground setHidden:NO];
|
||||
else
|
||||
[self.statusBarBackground setHidden:([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)];
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
|
||||
//NSLog([NSString stringWithFormat:@"Error : %@", error]);
|
||||
}
|
||||
|
||||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
||||
NSString *fragment = [[request URL] fragment];
|
||||
if (fragment != nil && [fragment rangeOfString:@"showKeyboards"].location != NSNotFound) {
|
||||
[self performSegueWithIdentifier:@"Keyboards" sender:nil];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
|
||||
[[UIApplication sharedApplication] openURL:[request URL]];
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// main.m
|
||||
// FirstVoices
|
||||
//
|
||||
// Created by Serkan Kurt on 17/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// FVInputViewController.h
|
||||
// SWKeyboard
|
||||
//
|
||||
// Created by Serkan Kurt on 18/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "KeymanEngine.h"
|
||||
|
||||
@interface FVInputViewController : KMInputViewController
|
||||
|
||||
@end
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
//
|
||||
// FVInputViewController.m
|
||||
// SWKeyboard
|
||||
//
|
||||
// Created by Serkan Kurt on 18/11/2015.
|
||||
// Copyright © 2015 FirstVoices. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FVInputViewController.h"
|
||||
#import "FVShared.h"
|
||||
|
||||
@interface FVInputViewController ()
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@end
|
||||
|
||||
@implementation FVInputViewController
|
||||
|
||||
- (void)updateViewConstraints {
|
||||
[super updateViewConstraints];
|
||||
|
||||
// Add custom view sizing constraints here
|
||||
if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0)
|
||||
return;
|
||||
|
||||
[self setupTopBarImage:[KMInputViewController isPortrait]];
|
||||
[self resizeTitleLabel];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[KMManager setKeymanLicense:@"FirstVoices" key:@"a016449b6b29ebb661d31179b279fef4"];
|
||||
[KMManager setApplicationGroupIdentifier:FVGroupID];
|
||||
|
||||
#ifdef DEBUG
|
||||
[[KMManager sharedInstance] setDebugPrintingOn:YES];
|
||||
#endif
|
||||
|
||||
[super viewDidLoad];
|
||||
|
||||
[self setGlobeKeyTapBehaviour:GKTapSwitchToNextKeyboard];
|
||||
[self setMenuBehaviour:MenuShowAlways];
|
||||
[self setMenuCloseButtonTitle:@"Switch to other keyboard"];
|
||||
|
||||
[self setupTopBarImage:[KMInputViewController isPortrait]];
|
||||
|
||||
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
[_titleLabel setTextColor:[UIColor colorWithRed:170.0/255.0 green:18.0/255.0 blue:37.0/255.0 alpha:1.0]];
|
||||
[_titleLabel setText:@"FirstVoices"];
|
||||
|
||||
[self resizeTitleLabel];
|
||||
[self.topBarImageView addSubview:_titleLabel];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated
|
||||
}
|
||||
|
||||
- (void)textWillChange:(id<UITextInput>)textInput {
|
||||
// The app is about to change the document's contents. Perform any preparation here.
|
||||
}
|
||||
|
||||
- (void)textDidChange:(id<UITextInput>)textInput {
|
||||
// The app has just changed the document's contents, the document context has been updated.
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
||||
[self setupTopBarImage:UIInterfaceOrientationIsPortrait(toInterfaceOrientation)];
|
||||
}
|
||||
|
||||
- (void)setupTopBarImage:(BOOL)isPortrait {
|
||||
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
||||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
||||
CGFloat size = screenRect.size.height > screenRect.size.width?screenRect.size.height:screenRect.size.width;
|
||||
if (size >= 568.0) {
|
||||
// TopBarImage for iPhone and iPod Touch with 4"+ Display
|
||||
if (isPortrait)
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Portrait.png"]];
|
||||
else
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Landscape-568h.png"]];
|
||||
}
|
||||
else if (size < 568.0) {
|
||||
// TopBarImage for iPhone and iPod Touch with 3.5" Display
|
||||
if (isPortrait)
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Portrait.png"]];
|
||||
else
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Landscape.png"]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TopBarImage for iPad
|
||||
if (isPortrait)
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Portrait.png"]];
|
||||
else
|
||||
[self.topBarImageView setImage:[UIImage imageNamed:@"banner-Landscape.png"]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resizeTitleLabel {
|
||||
[_titleLabel sizeToFit];
|
||||
CGRect frame = _titleLabel.frame;
|
||||
frame.origin.x = 10;
|
||||
frame.size.height = self.topBarImageView.frame.size.height;
|
||||
[_titleLabel setFrame:frame];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -32,5 +32,54 @@ class FVInputViewController: InputViewController {
|
|||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func updateViewConstraints() {
|
||||
super.updateViewConstraints()
|
||||
|
||||
if view.frame.size.width == 0 || self.view.frame.size.height == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
setupTopBarImage(isPortrait: InputViewController.isPortrait)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setupTopBarImage(isPortrait: InputViewController.isPortrait)
|
||||
}
|
||||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
setupTopBarImage(isPortrait: UIDevice.current.orientation.isPortrait)
|
||||
}
|
||||
|
||||
func getTopBarImage(isPortrait: Bool) -> String? {
|
||||
if isPortrait {
|
||||
return Bundle.main.path(forResource: "banner-Portrait@2x", ofType: "png")
|
||||
}
|
||||
|
||||
// iPad
|
||||
if UIDevice.current.userInterfaceIdiom != UIUserInterfaceIdiom.phone {
|
||||
return Bundle.main.path(forResource: "banner-Landscape@2x", ofType: "png")
|
||||
}
|
||||
|
||||
// iPhone
|
||||
let screenRect = UIScreen.main.bounds
|
||||
if CGFloat.maximum(screenRect.height, screenRect.width) >= 568.0 {
|
||||
return Bundle.main.path(forResource: "banner-Landscape-568h@2x", ofType: "png")
|
||||
} else {
|
||||
return Bundle.main.path(forResource: "banner-Landscape@2x", ofType: "png")
|
||||
}
|
||||
}
|
||||
|
||||
func setupTopBarImage(isPortrait: Bool) {
|
||||
let imgPath = getTopBarImage(isPortrait: isPortrait)
|
||||
guard let path = imgPath else {
|
||||
log.error("No image specified for the image banner!")
|
||||
return
|
||||
}
|
||||
|
||||
self.setBannerImage(to: path)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue