diff --git a/styledlabel/mobile/android/.classpath b/styledlabel/mobile/android/.classpath index 4050475c..914dee38 100644 --- a/styledlabel/mobile/android/.classpath +++ b/styledlabel/mobile/android/.classpath @@ -3,12 +3,10 @@ + + + + - - - - - - diff --git a/styledlabel/mobile/android/build.properties.example b/styledlabel/mobile/android/build.properties.example deleted file mode 100644 index 11e8723f..00000000 --- a/styledlabel/mobile/android/build.properties.example +++ /dev/null @@ -1,8 +0,0 @@ -titanium.sdk=/Library/Application\ Support/Titanium/ -titanium.os=osx -titanium.version=2.1.3.GA -android.sdk=/usr/android-sdk - -titanium.platform=${titanium.sdk}/mobilesdk/${titanium.os}/${titanium.version}/android -android.platform=${android.sdk}/platforms/android-8 -google.apis=${android.sdk}/add-ons/addon_google_apis_google_inc_8 \ No newline at end of file diff --git a/styledlabel/mobile/android/build.xml b/styledlabel/mobile/android/build.xml index b4999561..166c562d 100644 --- a/styledlabel/mobile/android/build.xml +++ b/styledlabel/mobile/android/build.xml @@ -6,5 +6,5 @@ - + diff --git a/styledlabel/mobile/android/dist/ti.styledlabel-android-2.0.1.zip b/styledlabel/mobile/android/dist/ti.styledlabel-android-2.0.1.zip deleted file mode 100644 index 1f70f7d7..00000000 Binary files a/styledlabel/mobile/android/dist/ti.styledlabel-android-2.0.1.zip and /dev/null differ diff --git a/styledlabel/mobile/android/manifest b/styledlabel/mobile/android/manifest index cf8cc8c8..aef7c4c9 100644 --- a/styledlabel/mobile/android/manifest +++ b/styledlabel/mobile/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 2.0.1 +version: 3.3 apiversion: 2 description: Gives you the power of HTML and CSS without the weight of a WebView. author: Dawson Toth @@ -15,4 +15,4 @@ name: styledlabel moduleid: ti.styledlabel guid: e0405808-ee07-4d00-8207-19b211dadceb platform: android -minsdk: 2.1.3.GA +minsdk: 3.2.3.GA diff --git a/styledlabel/mobile/android/src/ti/styledlabel/Label.java b/styledlabel/mobile/android/src/ti/styledlabel/Label.java index 7f43417f..c6d17ddd 100644 --- a/styledlabel/mobile/android/src/ti/styledlabel/Label.java +++ b/styledlabel/mobile/android/src/ti/styledlabel/Label.java @@ -6,11 +6,14 @@ package ti.styledlabel; +import java.util.HashMap; + import org.appcelerator.titanium.TiApplication; import org.appcelerator.kroll.KrollDict; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; import org.ccil.cowan.tagsoup.Parser; +import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiMessenger; import org.appcelerator.kroll.common.AsyncResult; @@ -22,6 +25,8 @@ import android.graphics.Color; import android.text.InputType; import android.view.Gravity; +import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.TextView; import android.os.Handler; import android.os.Message; @@ -32,18 +37,37 @@ public class Label extends TiUIView { private String _html; private String[] _filteredTags; private int _filterTagsMode = -1; + private TiViewProxy pr; public Label(TiViewProxy proxy) { super(proxy); - TextView textView = new TextView(TiApplication.getAppCurrentActivity()); - textView.setMovementMethod(new CustomLinkMovementMethod(proxy)); - textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); - textView.setPadding(0, 0, 0, 0); - textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE); - textView.setKeyListener(null); - textView.setTextColor(Color.BLACK); - textView.setFocusable(false); - setNativeView(textView); + + WebView webview = new WebView(TiApplication.getAppCurrentActivity().getApplicationContext()); + webview.getSettings().setJavaScriptEnabled(true); + webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webview.getSettings().setAllowContentAccess(true); + webview.setDrawingCacheEnabled(false); + webview.setBackgroundColor(0x00000000); + pr = proxy; + webview.setWebViewClient(new WebViewClient(){ + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url){ + if(url.startsWith("blankify://")) { + HashMap hashMap= new HashMap(); + hashMap.put("data", url.replaceAll("blankify://", "")); + pr.fireEvent("blankify.answer.updated", hashMap); + return true; + } + else if(url.startsWith("selected://")) { + HashMap hashMap= new HashMap(); + hashMap.put("data", url.replaceAll("selected://", "")); + pr.fireEvent("blankify.answer.selected", hashMap); + return true; + } + return false; + } + }); + setNativeView(webview); } @Override @@ -62,14 +86,14 @@ public void processProperties(KrollDict props) { private static final int MSG_UPDATE_TEXT = 50000; - private final Handler handler = new Handler(TiMessenger.getMainMessenger().getLooper(), new Handler.Callback () + private final Handler handler = new Handler(TiMessenger.getMainMessenger().getLooper(), new Handler.Callback () { public boolean handleMessage(Message msg) { switch (msg.what) { case MSG_UPDATE_TEXT: { AsyncResult result = (AsyncResult) msg.obj; - handleUpdateText((Spanned) result.getArg()); + handleUpdateText((String) result.getArg()); result.setResult(null); return true; } @@ -78,21 +102,21 @@ public boolean handleMessage(Message msg) } }); - private void updateText(final Spanned text) - { - if (!TiApplication.isUIThread()) { - TiMessenger.sendBlockingMainMessage(handler.obtainMessage(MSG_UPDATE_TEXT), text); - } else { - handleUpdateText(text); - } - } + private void updateText(final String html) + {handleUpdateText(html); +// if (!TiApplication.isUIThread()) { +// TiMessenger.sendBlockingMainMessage(handler.obtainMessage(MSG_UPDATE_TEXT), html); +// } else { +// handleUpdateText(html); +// } + } - private void handleUpdateText(final Spanned text) - { - TextView textView = (TextView) getNativeView(); - textView.setText(text); - textView.invalidate(); - } + + private void handleUpdateText(final String html){ + WebView webview = (WebView) getNativeView(); + webview.loadDataWithBaseURL(null, html, "text/html", "utf-8", null); + + } public void setHtml(String html) { _html = html; @@ -107,11 +131,8 @@ public void setHtml(String html) { throw new RuntimeException(e); } - HtmlToSpannedConverter converter = new HtmlToSpannedConverter(html, new CustomImageGetter(proxy), parser); - converter.setFilteredTags(_filteredTags); - converter.setFilteredTagsMode(_filterTagsMode); - updateText(converter.convert()); + updateText(_html); } public void setFilteredTags(String[] tags) { diff --git a/styledlabel/mobile/android/src/ti/styledlabel/LabelProxy.java b/styledlabel/mobile/android/src/ti/styledlabel/LabelProxy.java index 94635a0f..6c202de9 100644 --- a/styledlabel/mobile/android/src/ti/styledlabel/LabelProxy.java +++ b/styledlabel/mobile/android/src/ti/styledlabel/LabelProxy.java @@ -7,6 +7,7 @@ package ti.styledlabel; import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.kroll.common.Log; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.view.TiUIView; @@ -29,9 +30,12 @@ public TiUIView createView(Activity activity) { @Override public boolean fireEvent(String event, Object args) { // Suppress click events that didn't come from us (no "url" property). + Log.e("TL SL", "touch event fired"); if (event.equals("click") && (args instanceof HashMap) && !((HashMap)args).containsKey("url")) { + + Log.e("TL SL", "returning false"); return false; } return super.fireEvent(event, args); diff --git a/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.h b/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.h index 3c1ee88d..a147afc6 100755 --- a/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.h +++ b/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.h @@ -6,10 +6,12 @@ #import "TiUIView.h" -@interface TiStyledlabelLabel : TiUIView { +@interface TiStyledlabelLabel : TiUIView { UIWebView* _web; NSString* _html; float _contentHeight; +// UIGestureRecognizer *singleTap; +// CGFloat og; } -(void)setHtml_:(NSString *)html; diff --git a/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.m b/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.m index 6f2d9596..8e1d7e01 100755 --- a/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.m +++ b/styledlabel/mobile/ios/Classes/TiStyledlabelLabel.m @@ -12,6 +12,9 @@ @interface TiStyledlabelLabel (Private) -(void)updateTextViewsHtml; +-(void)keyboardWillShow:(NSNotification*)notification; +-(void)keyboardWillHide:(NSNotification*)notification; + @end @@ -22,6 +25,9 @@ @implementation TiStyledlabelLabel - (id)init { if ((self = [super init])) { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; + [nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; } return self; } @@ -30,6 +36,9 @@ -(void)dealloc { RELEASE_TO_NIL(_html); RELEASE_TO_NIL(_web); + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil]; + [nc removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [super dealloc]; } @@ -40,13 +49,25 @@ -(UIWebView*)web { if (!_web) { _web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)]; UIView *v = [[_web subviews] lastObject]; + [v setBackgroundColor:[UIColor clearColor]]; + [v setOpaque:NO]; + [_web setBackgroundColor:[UIColor clearColor]]; + [_web setOpaque:NO]; + [self setBackgroundColor:[UIColor clearColor]]; + [self setOpaque:NO]; if([v isKindOfClass:[UIScrollView class]]) { [v setScrollEnabled:NO]; } _web.delegate = self; + _web.scrollView.delegate = self; + [_web.scrollView setScrollEnabled:NO]; + [self addSubview:_web]; + } + [_web setBackgroundColor:[UIColor clearColor]]; + [_web setOpaque:NO]; return _web; } @@ -60,7 +81,7 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds { [TiUtils setView:[self web] positionRect:bounds]; if (_html != nil) { - [[self web] loadHTMLString:_html baseURL:nil]; + [[self web] loadHTMLString:_html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]]; } [super frameSizeChanged:frame bounds:bounds]; } @@ -87,17 +108,21 @@ -(float)currentContentHeight -(void)setHtml_:(NSString *)html { NSString* head = - @""; + @""; NSString* onload = - @"
"; RELEASE_TO_NIL(_html); _html = [[NSString stringWithFormat:@"%@%@%@", head, html, onload] retain]; + + [[self web] loadHTMLString:_html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]]; + + [self web].scrollView.scrollEnabled = NO; + [self web].scrollView.delegate = self; - [[self web] loadHTMLString:_html baseURL:nil]; } #pragma mark - @@ -106,21 +131,25 @@ -(void)setHtml_:(NSString *)html - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSURL *url = [request URL]; + NSLog(@"load request with navtype: %d and scheme: %@", navigationType, [url scheme]); if (navigationType == UIWebViewNavigationTypeOther) { if ([[url scheme] isEqualToString:@"ready"]) { _contentHeight = [[url host] floatValue]; [((TiViewProxy*)[self proxy]) willEnqueue]; [[((TiViewProxy*)[self proxy]) parent] willChangeSize]; return NO; - } else if ([[url scheme] isEqualToString:@"about"]) { - return YES; + } else if ([[url scheme] isEqualToString:@"about"]) { + return YES; + } else if ([[url scheme] isEqualToString:@"blankify"]) { + [[self proxy] fireEvent:@"blankify.answer.updated" withObject:[[NSDictionary alloc] initWithObjectsAndKeys:[url host], @"data", nil]]; + return NO; + } else if ([[url scheme] isEqualToString:@"selected"]) { + [[self proxy] fireEvent:@"blankify.answer.selected" withObject:[[NSDictionary alloc] initWithObjectsAndKeys:[url host], @"data", nil]]; + return NO; } } - [self.proxy fireEvent:@"click" withObject:[[NSDictionary alloc] initWithObjectsAndKeys: - [url absoluteString], @"url", - nil]]; - return NO; + return YES; } - (void)webViewDidStartLoad:(UIWebView *)webView @@ -135,4 +164,73 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { } +- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { + +} + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { + + [scrollView setContentOffset:CGPointMake(0, 0) animated:NO]; + scrollView.bounds = [self web].bounds; +} + +- (void)singleTapGestureCaptured:(UIGestureRecognizer *)gesture +{ + +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ + +} + +- (void)keyboardWillShow:(NSNotification *)notification +{ + NSDictionary *userInfo = notification.userInfo; + + NSValue *beginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey]; + CGRect keyboardBeginFrame = [self.web convertRect:beginFrameValue.CGRectValue fromView:nil]; + + NSValue *endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey]; + CGRect keyboardEndFrame = [self.web convertRect:endFrameValue.CGRectValue fromView:nil]; + + NSNumber *durationValue = userInfo[UIKeyboardAnimationDurationUserInfoKey]; + NSNumber *curveValue = userInfo[UIKeyboardAnimationCurveUserInfoKey]; + NSTimeInterval animationDuration = durationValue.doubleValue; + UIViewAnimationCurve animationCurve = curveValue.intValue; + + [[self proxy] fireEvent:@"ti.styledlabel.keyboard.will.show" withObject:[[NSDictionary alloc] + initWithObjectsAndKeys:curveValue, @"curveValue", + durationValue, @"durationValue", + [NSNumber numberWithFloat:beginFrameValue.CGRectValue.origin.y], @"beginFrameValue_origin_y", + [NSNumber numberWithFloat:endFrameValue.CGRectValue.origin.y], @"endFrameValue_origin_y", + [NSNumber numberWithFloat:keyboardBeginFrame.origin.y], @"keyboardBeginFrame_origin_y", + [NSNumber numberWithFloat:keyboardEndFrame.origin.y], @"keyboardEndFrame_origin_y", nil]]; +} + +- (void)keyboardWillHide:(NSNotification *)notification +{ + NSDictionary *userInfo = notification.userInfo; + + NSValue *beginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey]; + CGRect keyboardBeginFrame = [self.web convertRect:beginFrameValue.CGRectValue fromView:nil]; + + NSValue *endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey]; + CGRect keyboardEndFrame = [self.web convertRect:endFrameValue.CGRectValue fromView:nil]; + + NSNumber *durationValue = userInfo[UIKeyboardAnimationDurationUserInfoKey]; + NSNumber *curveValue = userInfo[UIKeyboardAnimationCurveUserInfoKey]; + NSTimeInterval animationDuration = durationValue.doubleValue; + UIViewAnimationCurve animationCurve = curveValue.intValue; + + [[self proxy] fireEvent:@"ti.styledlabel.keyboard.will.hide" withObject:[[NSDictionary alloc] + initWithObjectsAndKeys:curveValue, @"curveValue", + durationValue, @"durationValue", + [NSNumber numberWithFloat:beginFrameValue.CGRectValue.origin.y], @"beginFrameValue_origin_y", + [NSNumber numberWithFloat:endFrameValue.CGRectValue.origin.y], @"endFrameValue_origin_y", + [NSNumber numberWithFloat:keyboardBeginFrame.origin.y], @"keyboardBeginFrame_origin_y", + [NSNumber numberWithFloat:keyboardEndFrame.origin.y], @"keyboardEndFrame_origin_y", + nil]]; +} + + @end diff --git a/styledlabel/mobile/ios/Classes/TiStyledlabelLabelProxy.m b/styledlabel/mobile/ios/Classes/TiStyledlabelLabelProxy.m index 0ea2d3d8..85304715 100755 --- a/styledlabel/mobile/ios/Classes/TiStyledlabelLabelProxy.m +++ b/styledlabel/mobile/ios/Classes/TiStyledlabelLabelProxy.m @@ -12,6 +12,8 @@ @implementation TiStyledlabelLabelProxy -(void)viewDidAttach { [(TiStyledlabelLabel*)[self view] createView]; + [(TiStyledlabelLabel*)[self view] setBackgroundColor:[UIColor clearColor]]; + [(TiStyledlabelLabel*)[self view] setOpaque:NO]; } // The following is to support the new layout in TiSDK diff --git a/styledlabel/mobile/ios/manifest b/styledlabel/mobile/ios/manifest index ad876e48..b5da135a 100644 --- a/styledlabel/mobile/ios/manifest +++ b/styledlabel/mobile/ios/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.5.4 +version: 3.2 description: Gives you the power of HTML and CSS without the full weight of a WebView. author: Dawson Toth license: Appcelerator Commercial License diff --git a/styledlabel/mobile/ios/styledlabel.xcodeproj/project.pbxproj b/styledlabel/mobile/ios/styledlabel.xcodeproj/project.pbxproj index 6fd71e56..5e3a6274 100755 --- a/styledlabel/mobile/ios/styledlabel.xcodeproj/project.pbxproj +++ b/styledlabel/mobile/ios/styledlabel.xcodeproj/project.pbxproj @@ -166,6 +166,8 @@ /* Begin PBXProject section */ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + }; buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "styledlabel" */; compatibilityVersion = "Xcode 3.1"; developmentRegion = English; @@ -230,15 +232,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; buildSettings = { - ARCHS = ( - armv6, - armv7, - ); - "ARCHS[sdk=iphoneos*]" = ( - armv6, - armv7, - ); - "ARCHS[sdk=iphonesimulator*]" = i386; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DSTROOT = /tmp/TiStyledlabel.dst; @@ -268,6 +264,8 @@ "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; RUN_CLANG_STATIC_ANALYZER = NO; SDKROOT = iphoneos; + TITANIUM_SDK = "/Users/mshields/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)"; + TITANIUM_SDK_VERSION = 3.2.0.GA; USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; @@ -277,15 +275,9 @@ baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = ( - armv6, - armv7, - ); - "ARCHS[sdk=iphoneos*]" = ( - armv6, - armv7, - ); - "ARCHS[sdk=iphonesimulator*]" = i386; + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; + "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; DSTROOT = /tmp/TiStyledlabel.dst; GCC_C_LANGUAGE_STANDARD = c99; GCC_MODEL_TUNING = G5; @@ -303,12 +295,14 @@ GCC_WARN_UNUSED_VALUE = NO; GCC_WARN_UNUSED_VARIABLE = NO; INSTALL_PATH = /usr/local/lib; - IPHONEOS_DEPLOYMENT_TARGET = 4.0; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; OTHER_CFLAGS = "-DTI_POST_1_2"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = TiStyledlabel; RUN_CLANG_STATIC_ANALYZER = NO; SDKROOT = iphoneos; + TITANIUM_SDK = "/Users/mshields/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)"; + TITANIUM_SDK_VERSION = 3.2.0.GA; USER_HEADER_SEARCH_PATHS = ""; }; name = Release; diff --git a/styledlabel/mobile/ios/ti.styledlabel-iphone-1.5.4.zip b/styledlabel/mobile/ios/ti.styledlabel-iphone-1.5.4.zip index b41f7898..9542ba40 100644 Binary files a/styledlabel/mobile/ios/ti.styledlabel-iphone-1.5.4.zip and b/styledlabel/mobile/ios/ti.styledlabel-iphone-1.5.4.zip differ diff --git a/styledlabel/mobile/ios/titanium.xcconfig b/styledlabel/mobile/ios/titanium.xcconfig index 788d685e..08432b1c 100755 --- a/styledlabel/mobile/ios/titanium.xcconfig +++ b/styledlabel/mobile/ios/titanium.xcconfig @@ -4,13 +4,13 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 2.1.3.GA +TITANIUM_SDK_VERSION = 3.2.0.GA // // THESE SHOULD BE OK GENERALLY AS-IS // -TITANIUM_SDK = /Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) +TITANIUM_SDK = /Users/ehouriga/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2)