Skip to content

Commit e1dfdef

Browse files
committed
android complete, ready for release, ios admob banner adjust, bug fix
1 parent 5caaf0a commit e1dfdef

File tree

597 files changed

+70444
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

597 files changed

+70444
-489
lines changed

Data/ui.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{"from":"first_unit","to":"","type_from":"height","type_to":"height","multiplier":1,"offset":21},
1717
{"from":"first_unit","to":"self","type_from":"top","type_to":"top","multiplier":1,"offset":20},
1818
{"from":"first_unit","to":"line1","type_from":"leading","type_to":"leading","multiplier":1,"offset":0},
19-
{"from":"first_unit","to":"self","type_from":"width","type_to":"width","multiplier":0.5,"offset":-55}
19+
{"from":"first_unit","to":"self","type_from":"width","type_to":"width","multiplier":0.5,"offset":-58}
2020
],
2121
"first_us_unit":[
2222
{"from":"first_us_unit","to":"first_unit","type_from":"width","type_to":"width","multiplier":1,"offset":0},
@@ -58,7 +58,7 @@
5858
"views":[
5959
{"id":"input_view","type":"base",
6060
"views":[
61-
{"id":"input_text","type":"input","frame":[0,0,0,30],"text_boarder":3,"keyboardtype":"DecimalPad","numericText":true},
61+
{"id":"input_text","type":"input","frame":[0,0,0,30],"text_boarder":3,"keyboardtype":"DecimalPad","numericText":true,"maxlength":20},
6262
{"id":"time_label","type":"label","frame":[0,0,150,12],"fontsize":11,"textalign":2}
6363
],
6464
"constraints":[

GypAndroid.mk

-19
This file was deleted.

IOS/USNIT/AdmobBanner.swift

+42-18
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,66 @@ import GoogleMobileAds
1212

1313

1414
class AdmobBanner: NSObject, GADBannerViewDelegate{
15-
var bannerView: GADBannerView!
16-
var rootController: UIViewController!
15+
var m_bannerView: GADBannerView!
16+
var m_rootController: UIViewController!
1717

1818
init(root: UIViewController) {
1919

20-
rootController = root
21-
bannerView = GADBannerView()
22-
bannerView.rootViewController = rootController
20+
m_rootController = root
21+
m_bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
22+
m_bannerView.rootViewController = m_rootController
23+
m_rootController.view.addSubview(m_bannerView)
24+
}
25+
26+
init(bannerView: GADBannerView,root: UIViewController) {
27+
m_rootController = root
28+
m_bannerView = bannerView
29+
m_bannerView.rootViewController = m_rootController
2330
}
2431

2532
func didLoad(adid: String){
26-
bannerView.translatesAutoresizingMaskIntoConstraints = false
27-
bannerView.delegate = self
28-
bannerView.adUnitID = adid
33+
m_bannerView.translatesAutoresizingMaskIntoConstraints = false
34+
m_bannerView.delegate = self
35+
m_bannerView.adUnitID = adid
2936

30-
rootController.view.addSubview(bannerView)
31-
32-
//let offsety:CGFloat = (rootController.tabBarController?.tabBar.frame.height)!
33-
rootController.view.addConstraint(NSLayoutConstraint(item: bannerView, attribute: .Bottom,
34-
relatedBy: .Equal, toItem: rootController.bottomLayoutGuide , attribute: .Top, multiplier: 1, constant: 0))
35-
rootController.view.addConstraint(NSLayoutConstraint(item: bannerView, attribute: .CenterX,
36-
relatedBy: .Equal, toItem: rootController.view, attribute: .CenterX, multiplier: 1, constant: 0))
37+
if nil != m_rootController{
38+
bannerAboveTab(m_rootController!)
39+
}
3740

3841
if UIDevice.currentDevice().orientation == .Portrait {
39-
bannerView.adSize = kGADAdSizeSmartBannerPortrait
42+
m_bannerView.adSize = kGADAdSizeSmartBannerPortrait
4043
} else {
41-
bannerView.adSize = kGADAdSizeSmartBannerLandscape
44+
m_bannerView.adSize = kGADAdSizeSmartBannerLandscape
4245
}
4346

44-
bannerView.loadRequest(GADRequest())
47+
m_bannerView.loadRequest(GADRequest())
4548

4649
}
4750

51+
func bannerUnderTab(root: UIViewController){
52+
53+
// don't work
54+
var content_frame = root.view.frame
55+
let banner_fram = m_bannerView.sizeThatFits(content_frame.size)
56+
57+
content_frame.size.height -= banner_fram.height;
58+
m_bannerView.frame.origin.y = content_frame.size.height
59+
60+
root.tabBarController?.tabBar.frame.origin.y -= banner_fram.height
61+
}
62+
63+
func bannerAboveTab(root: UIViewController){
64+
//let offsety:CGFloat = (rootController.tabBarController?.tabBar.frame.height)!
65+
root.view.addConstraint(NSLayoutConstraint(item: m_bannerView, attribute: .Bottom,
66+
relatedBy: .Equal, toItem: root.bottomLayoutGuide , attribute: .Top, multiplier: 1, constant: 0))
67+
root.view.addConstraint(NSLayoutConstraint(item: m_bannerView, attribute: .CenterX,
68+
relatedBy: .Equal, toItem: root.view, attribute: .CenterX, multiplier: 1, constant: 0))
69+
}
70+
4871
// Called when an ad request loaded an ad.
4972
func adViewDidReceiveAd(bannerView: GADBannerView!) {
5073
//print(#function)
74+
5175
}
5276

5377
// Called when an ad request failed.

IOS/USNIT/Base.lproj/Main.storyboard

+16-4
Original file line numberDiff line numberDiff line change
@@ -615,18 +615,26 @@
615615
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
616616
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
617617
<subviews>
618+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="k0r-gh-j17" userLabel="ad_banner" customClass="GADBannerView">
619+
<rect key="frame" x="140" y="501" width="320" height="50"/>
620+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
621+
<constraints>
622+
<constraint firstAttribute="width" constant="320" id="Qnb-lX-jKR"/>
623+
<constraint firstAttribute="height" constant="50" id="Sz1-Lx-f4h"/>
624+
</constraints>
625+
</view>
618626
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="khK-HE-Mhb" userLabel="view_input">
619627
<rect key="frame" x="0.0" y="0.0" width="600" height="71"/>
620628
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
621629
<constraints>
622630
<constraint firstAttribute="height" constant="71" id="4ts-Vt-8Uo"/>
623631
</constraints>
624632
</view>
625-
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lpC-Nb-gUV" userLabel="sc_view">
626-
<rect key="frame" x="0.0" y="70" width="600" height="481"/>
633+
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lpC-Nb-gUV" userLabel="sc_view">
634+
<rect key="frame" x="0.0" y="70" width="600" height="431"/>
627635
<subviews>
628-
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Ge-5W-mdR" userLabel="view_unit">
629-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
636+
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Ge-5W-mdR" userLabel="view_unit">
637+
<rect key="frame" x="0.0" y="0.0" width="600" height="0.0"/>
630638
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
631639
</view>
632640
</subviews>
@@ -641,8 +649,11 @@
641649
<constraints>
642650
<constraint firstItem="lpC-Nb-gUV" firstAttribute="width" secondItem="TIe-r9-M19" secondAttribute="width" identifier="vsc=vroot" id="06J-UV-4gA"/>
643651
<constraint firstItem="khK-HE-Mhb" firstAttribute="top" secondItem="TIe-r9-M19" secondAttribute="topMargin" id="3CX-vM-0wS"/>
652+
<constraint firstItem="k0r-gh-j17" firstAttribute="centerX" secondItem="TIe-r9-M19" secondAttribute="centerX" id="7xH-3L-yLE"/>
644653
<constraint firstItem="khK-HE-Mhb" firstAttribute="centerX" secondItem="TIe-r9-M19" secondAttribute="centerX" id="I7K-pp-eeK"/>
645654
<constraint firstItem="khK-HE-Mhb" firstAttribute="width" secondItem="TIe-r9-M19" secondAttribute="width" identifier="vinput=vsc" id="dDy-2o-CkC"/>
655+
<constraint firstItem="k0r-gh-j17" firstAttribute="top" secondItem="lpC-Nb-gUV" secondAttribute="bottom" id="k4w-B3-zWJ"/>
656+
<constraint firstItem="1da-YU-ttH" firstAttribute="top" secondItem="k0r-gh-j17" secondAttribute="bottom" id="pOH-IK-9hz"/>
646657
<constraint firstItem="3Ge-5W-mdR" firstAttribute="width" secondItem="TIe-r9-M19" secondAttribute="width" id="qBV-oJ-IEw"/>
647658
<constraint firstItem="lpC-Nb-gUV" firstAttribute="top" secondItem="khK-HE-Mhb" secondAttribute="bottom" constant="-1" id="rES-IS-tl3"/>
648659
<constraint firstItem="lpC-Nb-gUV" firstAttribute="centerX" secondItem="TIe-r9-M19" secondAttribute="centerX" id="yVg-Ox-Xkq"/>
@@ -652,6 +663,7 @@
652663
<offsetWrapper key="titlePositionAdjustment" horizontal="0.0" vertical="-10"/>
653664
</tabBarItem>
654665
<connections>
666+
<outlet property="viewBanner" destination="k0r-gh-j17" id="oEI-Uw-vSM"/>
655667
<outlet property="viewInput" destination="khK-HE-Mhb" id="I2C-gp-qvd"/>
656668
<outlet property="viewSC" destination="lpC-Nb-gUV" id="mQ3-9g-JR6"/>
657669
<outlet property="viewUnit" destination="3Ge-5W-mdR" id="1bt-3h-f8V"/>

IOS/USNIT/SFUsnitLogic.swift

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SFUsnitLogic {
4141

4242
let uilogic_path = NSBundle.mainBundle().pathForResource("uilogic", ofType: "json")
4343
USNUilogicGen.instance()?.initialize(uilogic_path!)
44+
USNUilogicGen.instance()?.buildUi()
4445
//USNUsnitGen.instance()!.initialize(uilogic_path, lang: 0, callback: nil)
4546
}
4647

IOS/USNIT/SecondViewController.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class SecondViewController: UIViewController {
2727
}
2828

2929
m_ad = AdmobBanner(root: self)
30-
m_ad.didLoad("ca-app-pub-4953725946697554/8856468622")
31-
30+
m_ad.didLoad("ca-app-pub-4953725946697554/8856468622")
3231
}
3332

3433
override func didReceiveMemoryWarning() {

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ djinni:gearsbox/gearsbox.djinni gearsbox/ui.djinni usnit.djinni
33
cd gearsbox/ && make djinni
44
sh ./run_djinni.sh
55

6+
67
ios_proj: djinni usnit.gyp ./gearsbox/deps/djinni/support-lib/support_lib.gyp
78
./gearsbox/deps/gyp/gyp --depth=. -f xcode -DOS=ios --generator-output ./ios/build_ios -Igearsbox/deps/djinni/common.gypi ./usnit.gyp --root-target=usnit_objc
89

@@ -12,7 +13,7 @@ ios: ios_proj
1213
-configuration 'Debug' \
1314
-sdk iphonesimulator
1415

15-
android_proj: usnit.gyp ./gearsbox/deps/djinni/support-lib/support_lib.gyp usnit.djinni
16+
android_proj: djinni usnit.gyp ./gearsbox/deps/djinni/support-lib/support_lib.gyp usnit.djinni
1617
sh ./run_djinni.sh
1718
ANDROID_BUILD_TOP=$(shell dirname `which ndk-build`) ./gearsbox/deps/gyp/gyp --depth=. -f android -DOS=android -Igearsbox/deps/djinni/common.gypi ./usnit.gyp --root-target=usnit_jni
1819

@@ -21,6 +22,9 @@ android: android_proj
2122
@echo "Apks produced at:"
2223
@python ./gearsbox/deps/djinni/example/glob.py ./ '*.apk'
2324

25+
ndk_build: GypAndroid.mk android/jni/Android.mk android/jni/Application.mk
26+
sh ./ndk_build.sh
27+
2428

2529
clean_ios:
2630
-rm -rf build

android/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

android/jni/Android.mk

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# always force this build to re-run its dependencies
2+
FORCE_GYP := $(shell make -C ../../GypAndroid.mk)
3+
include ../../GypAndroid.mk

android/jni/Application.mk

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Android makefile for helloworld shared lib, jni wrapper around libhelloworld C API
2+
3+
APP_ABI := armeabi-v7a
4+
APP_OPTIM := release
5+
APP_PLATFORM := android-19
6+
# GCC 4.9 Toolchain
7+
NDK_TOOLCHAIN_VERSION = 4.9
8+
# GNU libc++ is the only Android STL which supports C++11 features
9+
APP_STL := gnustl_shared
10+
#APP_BUILD_SCRIPT := ./Android.mk
11+
APP_MODULES := gearsbox_jni

android/usnit--/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

android/usnit--/.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/.idea/misc.xml

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/usnit--/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)