From 402fc3e87c1143d94a066257d49c6df29ff1d353 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Thu, 31 May 2018 13:30:38 +0530 Subject: [PATCH] - google maven reference fix --- Example/android/build.gradle | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- README.md | 4 +- android/build.gradle | 4 +- .../main/java/ui/apptour/RNAppTourModule.java | 27 +-- ios/RNAppTour.m | 195 +++++++++--------- ios/RNAppTour.xcodeproj/project.pbxproj | 16 -- package.json | 2 +- 8 files changed, 117 insertions(+), 140 deletions(-) diff --git a/Example/android/build.gradle b/Example/android/build.gradle index ac0250d..845e47b 100644 --- a/Example/android/build.gradle +++ b/Example/android/build.gradle @@ -3,11 +3,11 @@ buildscript { repositories { jcenter() - google() + maven { url "https://maven.google.com" } maven { url "https://jitpack.io" } } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -18,7 +18,7 @@ allprojects { repositories { mavenLocal() jcenter() - google() + maven { url "https://maven.google.com" } maven { url "https://jitpack.io" } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm diff --git a/Example/android/gradle/wrapper/gradle-wrapper.properties b/Example/android/gradle/wrapper/gradle-wrapper.properties index bf1b63c..47ad315 100644 --- a/Example/android/gradle/wrapper/gradle-wrapper.properties +++ b/Example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed May 30 18:27:15 IST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/README.md b/README.md index 089318a..78d46a3 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This library is a React Native bridge around native app tour libraries. It allow buildscript { repositories { jcenter() - google() + maven { url "https://maven.google.com" } maven { url "https://jitpack.io" } ... } @@ -40,7 +40,7 @@ allprojects { repositories { mavenLocal() jcenter() - google() + maven { url "https://maven.google.com" } maven { url "https://jitpack.io" } ... } diff --git a/android/build.gradle b/android/build.gradle index 007260a..b6e2bee 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ buildscript { repositories { jcenter() - google() + maven { url "https://maven.google.com" } } dependencies { @@ -29,7 +29,7 @@ android { repositories { mavenCentral() - google() + maven { url "https://maven.google.com" } } diff --git a/android/src/main/java/ui/apptour/RNAppTourModule.java b/android/src/main/java/ui/apptour/RNAppTourModule.java index c86ac11..87f8f95 100644 --- a/android/src/main/java/ui/apptour/RNAppTourModule.java +++ b/android/src/main/java/ui/apptour/RNAppTourModule.java @@ -119,7 +119,7 @@ public void onSequenceCanceled(TapTarget lastTarget) { @ReactMethod public void ShowFor(final int view, final ReadableMap props, final Promise promise) { - final Activity activity = this.getCurrentActivity(); + final Activity activity = getCurrentActivity(); final Dialog dialog = new AlertDialog.Builder(activity).create(); activity.runOnUiThread(new Runnable() { @@ -218,15 +218,6 @@ private TapTarget generateTapTarget(final View view, final ReadableMap props) { } catch (Exception e) { } - float finalOuterCircleAlpha = outerCircleAlpha; - int finalTitleTextSize = titleTextSize; - int finalDescriptionTextSize = descriptionTextSize; - boolean finalDrawShadow = drawShadow; - boolean finalCancelable = cancelable; - boolean finalTintTarget = tintTarget; - boolean finalTransparentTarget = transparentTarget; - int finalTargetRadius = targetRadius; - //Populate Props TapTarget targetView = TapTarget.forView(view, title, description); @@ -245,14 +236,14 @@ private TapTarget generateTapTarget(final View view, final ReadableMap props) { targetView.dimColorInt(Color.parseColor(dimColor)); - targetView.outerCircleAlpha(finalOuterCircleAlpha); - targetView.titleTextSize(finalTitleTextSize); - targetView.descriptionTextSize(finalDescriptionTextSize); - targetView.drawShadow(finalDrawShadow); - targetView.cancelable(finalCancelable); - targetView.tintTarget(finalTintTarget); - targetView.transparentTarget(finalTransparentTarget); - targetView.targetRadius(finalTargetRadius); + targetView.outerCircleAlpha(outerCircleAlpha); + targetView.titleTextSize(titleTextSize); + targetView.descriptionTextSize(descriptionTextSize); + targetView.drawShadow(drawShadow); + targetView.cancelable(cancelable); + targetView.tintTarget(tintTarget); + targetView.transparentTarget(transparentTarget); + targetView.targetRadius(targetRadius); return targetView; } diff --git a/ios/RNAppTour.m b/ios/RNAppTour.m index b7e4d00..cf5c7c1 100644 --- a/ios/RNAppTour.m +++ b/ios/RNAppTour.m @@ -68,73 +68,10 @@ - (id)init { return self; } - - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); } - -- (NSTextAlignment*) getTextAlignmentByString: (NSString*) strAlignment { - if (strAlignment == nil) { - return NSTextAlignmentLeft; // default is left - } - - NSString *lowCaseString = [strAlignment lowercaseString]; - if ([lowCaseString isEqualToString:@"left"]) { - return NSTextAlignmentLeft; - } if ([lowCaseString isEqualToString:@"right"]) { - return NSTextAlignmentRight; - } if ([lowCaseString isEqualToString:@"center"]) { - return NSTextAlignmentCenter; - } if ([lowCaseString isEqualToString:@"justify"]) { - return NSTextAlignmentJustified; - } - - return NSTextAlignmentLeft; -} - -- (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length { - NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; - NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; - unsigned hexComponent; - [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; - return hexComponent / 255.0; -} - -- (UIColor *) colorWithHexString: (NSString *) hexString { - NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; - CGFloat alpha, red, blue, green; - switch ([colorString length]) { - case 3: // #RGB - alpha = 1.0f; - red = [self colorComponentFrom: colorString start: 0 length: 1]; - green = [self colorComponentFrom: colorString start: 1 length: 1]; - blue = [self colorComponentFrom: colorString start: 2 length: 1]; - break; - case 4: // #ARGB - alpha = [self colorComponentFrom: colorString start: 0 length: 1]; - red = [self colorComponentFrom: colorString start: 1 length: 1]; - green = [self colorComponentFrom: colorString start: 2 length: 1]; - blue = [self colorComponentFrom: colorString start: 3 length: 1]; - break; - case 6: // #RRGGBB - alpha = 1.0f; - red = [self colorComponentFrom: colorString start: 0 length: 2]; - green = [self colorComponentFrom: colorString start: 2 length: 2]; - blue = [self colorComponentFrom: colorString start: 4 length: 2]; - break; - case 8: // #AARRGGBB - alpha = [self colorComponentFrom: colorString start: 0 length: 2]; - red = [self colorComponentFrom: colorString start: 2 length: 2]; - green = [self colorComponentFrom: colorString start: 4 length: 2]; - blue = [self colorComponentFrom: colorString start: 6 length: 2]; - break; - default: - return nil; - } - return [UIColor colorWithRed: red green: green blue: blue alpha: alpha]; -} - RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(ShowSequence:(NSArray *)views props:(NSDictionary *)props) @@ -148,40 +85,6 @@ - (UIColor *) colorWithHexString: (NSString *) hexString { [self ShowFor:[NSNumber numberWithLongLong:[showTargetKey longLongValue]] props:[targets objectForKey:showTargetKey] ]; } -- (void)showCaseWillDismissWithShowcase:(MaterialShowcase *)materialShowcase { - NSLog(@""); -} -- (void)showCaseDidDismissWithShowcase:(MaterialShowcase *)materialShowcase { - NSLog(@""); - - NSArray *targetKeys = [targets allKeys]; - if (targetKeys.count <= 0) { - return; - } - - NSString *removeTargetKey = [targetKeys objectAtIndex: 0]; - [targets removeObjectForKey: removeTargetKey]; - - NSMutableArray *viewIds = [[NSMutableArray alloc] init]; - NSMutableDictionary *props = [[NSMutableDictionary alloc] init]; - - if (targetKeys.count <= 1) { - [self.bridge.eventDispatcher sendDeviceEventWithName:onFinishShowStepEvent body:@{@"finish": @YES}]; - } - else { - [self.bridge.eventDispatcher sendDeviceEventWithName:onShowSequenceStepEvent body:@{@"next_step": @YES}]; - } - - for (NSString *view in [targets allKeys]) { - [viewIds addObject: [NSNumber numberWithLongLong:[view longLongValue]]]; - [props setObject:(NSDictionary *)[targets objectForKey: view] forKey:view]; - } - - if ([viewIds count] > 0) { - [self ShowSequence:viewIds props:props]; - } -} - RCT_EXPORT_METHOD(ShowFor:(nonnull NSNumber *)view props:(NSDictionary *)props) { MaterialShowcase *materialShowcase = [self generateMaterialShowcase:view props:props]; @@ -327,4 +230,102 @@ - (MaterialShowcase *)generateMaterialShowcase:(NSNumber *)view props:(NSDiction return materialShowcase; } + +- (void)showCaseWillDismissWithShowcase:(MaterialShowcase *)materialShowcase { + NSLog(@""); +} +- (void)showCaseDidDismissWithShowcase:(MaterialShowcase *)materialShowcase { + NSLog(@""); + + NSArray *targetKeys = [targets allKeys]; + if (targetKeys.count <= 0) { + return; + } + + NSString *removeTargetKey = [targetKeys objectAtIndex: 0]; + [targets removeObjectForKey: removeTargetKey]; + + NSMutableArray *viewIds = [[NSMutableArray alloc] init]; + NSMutableDictionary *props = [[NSMutableDictionary alloc] init]; + + if (targetKeys.count <= 1) { + [self.bridge.eventDispatcher sendDeviceEventWithName:onFinishShowStepEvent body:@{@"finish": @YES}]; + } + else { + [self.bridge.eventDispatcher sendDeviceEventWithName:onShowSequenceStepEvent body:@{@"next_step": @YES}]; + } + + for (NSString *view in [targets allKeys]) { + [viewIds addObject: [NSNumber numberWithLongLong:[view longLongValue]]]; + [props setObject:(NSDictionary *)[targets objectForKey: view] forKey:view]; + } + + if ([viewIds count] > 0) { + [self ShowSequence:viewIds props:props]; + } +} + + +- (NSTextAlignment*) getTextAlignmentByString: (NSString*) strAlignment { + if (strAlignment == nil) { + return NSTextAlignmentLeft; // default is left + } + + NSString *lowCaseString = [strAlignment lowercaseString]; + if ([lowCaseString isEqualToString:@"left"]) { + return NSTextAlignmentLeft; + } if ([lowCaseString isEqualToString:@"right"]) { + return NSTextAlignmentRight; + } if ([lowCaseString isEqualToString:@"center"]) { + return NSTextAlignmentCenter; + } if ([lowCaseString isEqualToString:@"justify"]) { + return NSTextAlignmentJustified; + } + + return NSTextAlignmentLeft; +} + +- (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length { + NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; + NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; + unsigned hexComponent; + [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; + return hexComponent / 255.0; +} + +- (UIColor *) colorWithHexString: (NSString *) hexString { + NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; + CGFloat alpha, red, blue, green; + switch ([colorString length]) { + case 3: // #RGB + alpha = 1.0f; + red = [self colorComponentFrom: colorString start: 0 length: 1]; + green = [self colorComponentFrom: colorString start: 1 length: 1]; + blue = [self colorComponentFrom: colorString start: 2 length: 1]; + break; + case 4: // #ARGB + alpha = [self colorComponentFrom: colorString start: 0 length: 1]; + red = [self colorComponentFrom: colorString start: 1 length: 1]; + green = [self colorComponentFrom: colorString start: 2 length: 1]; + blue = [self colorComponentFrom: colorString start: 3 length: 1]; + break; + case 6: // #RRGGBB + alpha = 1.0f; + red = [self colorComponentFrom: colorString start: 0 length: 2]; + green = [self colorComponentFrom: colorString start: 2 length: 2]; + blue = [self colorComponentFrom: colorString start: 4 length: 2]; + break; + case 8: // #AARRGGBB + alpha = [self colorComponentFrom: colorString start: 0 length: 2]; + red = [self colorComponentFrom: colorString start: 2 length: 2]; + green = [self colorComponentFrom: colorString start: 4 length: 2]; + blue = [self colorComponentFrom: colorString start: 6 length: 2]; + break; + default: + return nil; + } + return [UIColor colorWithRed: red green: green blue: blue alpha: alpha]; +} + + @end diff --git a/ios/RNAppTour.xcodeproj/project.pbxproj b/ios/RNAppTour.xcodeproj/project.pbxproj index f2e9e69..34a1ec1 100644 --- a/ios/RNAppTour.xcodeproj/project.pbxproj +++ b/ios/RNAppTour.xcodeproj/project.pbxproj @@ -121,7 +121,6 @@ 58B511D71A9E6C8500147676 /* Sources */, 58B511D81A9E6C8500147676 /* Frameworks */, 58B511D91A9E6C8500147676 /* CopyFiles */, - 14C24E4574DDBAEA75B69BED /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -187,21 +186,6 @@ /* End PBXReferenceProxy section */ /* Begin PBXShellScriptBuildPhase section */ - 14C24E4574DDBAEA75B69BED /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RNAppTour/Pods-RNAppTour-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 59BECF4019998478B6B4E997 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/package.json b/package.json index 62d7fd2..f4b16f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-app-tour", - "version": "0.0.7", + "version": "0.0.8", "description": "React Native: Native App Tour Library", "repository": { "type": "git",