[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161819364
 
 

 ##
 File path: src/android/SplashScreen.java
 ##
 @@ -410,4 +428,60 @@ public void run() {
 }
 });
 }
+
+private String getAppVersion() {
+
+  String appVersion = null;
+
+  try {
+
+String packageName = cordova.getActivity().getPackageName();
+PackageManager packageManager = 
cordova.getActivity().getApplicationContext().getPackageManager();
+PackageInfo pi = packageManager.getPackageInfo(packageName, 0);
+
+appVersion = "v" + pi.versionName;
 
 Review comment:
   Will everyone be OK with prefixing `v`? I could see some apps wanting to use 
"Version", a localized string, or even nothing at all. Feels like a preference 
(format string, perhaps?)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org



[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161818781
 
 

 ##
 File path: README.md
 ##
 @@ -376,6 +376,23 @@ To disable the splashscreen add the following preference 
to `config.xml`:
 
 ```
 
+ Display app version (Android, iOS)
+
+To display your app version on splashscreen add the following preference to 
`config.xml`:
+```xml
+
+```
+
+To customise the version color, size and position add the following preference 
to `config.xml`:
+```xml
+
+
+
+```
+**Note**: those values are defaults.
+For the horizontal gravity, you may choose between `left`, `center` and 
`right`.
+For the vertical gravity, you don't have choice, text is placed at the bottom 
of the splashscreen.
 
 Review comment:
   This is just begging for a preference, because _someone_ out there is 
inevitably going to need to position the version separately...


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org



[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161820219
 
 

 ##
 File path: src/ios/CDVSplashScreen.m
 ##
 @@ -60,6 +60,63 @@ - (void)observeValueForKeyPath:(NSString*)keyPath 
ofObject:(id)object change:(NS
 [self updateImage];
 }
 
+- (UIColor *)colorFromHexString:(NSString *)hexString {
+unsigned rgbValue = 0;
+NSScanner *scanner = [NSScanner scannerWithString:hexString];
+[scanner setScanLocation:1]; // bypass '#' character
+[scanner scanHexInt:];
+return [UIColor colorWithRed:((rgbValue & 0xFF) >> 16)/255.0 
green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
+}
+
+-(UIImage*) drawText:(NSString*) text inImage:(UIImage*) image 
gravity:(NSString*) gravity fontSize:(CGFloat) fontSize fontColor:(NSString*) 
fontColor
+{
+
+UIFont *font = [UIFont boldSystemFontOfSize:fontSize];
+UIGraphicsBeginImageContext(image.size);
+[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
+
+UIScreen* mainScreen = [UIScreen mainScreen];
+CGFloat mainScreenHeight = mainScreen.bounds.size.height;
+CGFloat mainScreenWidth = mainScreen.bounds.size.width;
+
+CGSize textSize = [text sizeWithFont:font];
+CGFloat padding = 15.0;
+CGFloat position = mainScreenWidth - (textSize.width + padding);
+
+if([gravity isEqualToString:@"left"]) {
+position = padding;
+} else if ([gravity isEqualToString:@"center"]) {
+position = (mainScreenWidth / 2) - padding;
+}
+
+CGRect rect = CGRectMake(position, mainScreenHeight - 30.0, 
textSize.width, textSize.height);
+UIColor *color = [self colorFromHexString:fontColor];
+[color set];
+[text drawInRect:CGRectIntegral(rect) withFont:font];
+UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
+UIGraphicsEndImageContext();
+
+return newImage;
+}
+
+
+-(NSString*) getAppVersion
+{
+NSString* version = [[[NSBundle mainBundle] infoDictionary] 
objectForKey:@"CFBundleShortVersionString"];
+
+if (version == nil) {
+  NSLog(@"CFBundleShortVersionString was nil, attempting CFBundleVersion");
+  version = [[[NSBundle mainBundle] infoDictionary] 
objectForKey:@"CFBundleVersion"];
+}
+
+
+if(version != nil) {
+version = [NSString stringWithFormat:@"v%@", version];
 
 Review comment:
   Will everyone be OK with prefixing `v`? I could see some apps wanting to use 
"Version", a localized string, or even nothing at all. Feels like a preference 
(format string, perhaps?)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org



[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161819016
 
 

 ##
 File path: README.md
 ##
 @@ -376,6 +376,23 @@ To disable the splashscreen add the following preference 
to `config.xml`:
 
 ```
 
+ Display app version (Android, iOS)
+
+To display your app version on splashscreen add the following preference to 
`config.xml`:
+```xml
+
+```
+
+To customise the version color, size and position add the following preference 
to `config.xml`:
+```xml
+
+
+
+```
+**Note**: those values are defaults.
+For the horizontal gravity, you may choose between `left`, `center` and 
`right`.
+For the vertical gravity, you don't have choice, text is placed at the bottom 
of the splashscreen.
 
 Review comment:
   Note: not saying this needs to _be_ a preference -- just that if there's a 
good reason for it not being a preference that it should be called out -- 
otherwise someone is definitely going to ask for it as a feature.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org



[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161825874
 
 

 ##
 File path: src/ios/CDVSplashScreen.m
 ##
 @@ -60,6 +60,63 @@ - (void)observeValueForKeyPath:(NSString*)keyPath 
ofObject:(id)object change:(NS
 [self updateImage];
 }
 
+- (UIColor *)colorFromHexString:(NSString *)hexString {
 
 Review comment:
   Does Cordova not export any methods to handle color parsing in preferences? 
(I don't know -- have't looked). If it does, I'd suggest using those, rather 
than building your own. If not, a few thoughts:
   
   1. Would it make sense to support the case where the user forgets "#"?
   2. Would it make sense to support the backgroundColor pref case where it 
uses "0x" instead?
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org



[GitHub] kerrishotts commented on a change in pull request #148: CB-13392(Android & iOS): Display app version on splashscreen

2018-01-16 Thread GitBox
kerrishotts commented on a change in pull request #148: CB-13392(Android & 
iOS): Display app version on splashscreen
URL: 
https://github.com/apache/cordova-plugin-splashscreen/pull/148#discussion_r161820527
 
 

 ##
 File path: src/ios/CDVSplashScreen.m
 ##
 @@ -60,6 +60,63 @@ - (void)observeValueForKeyPath:(NSString*)keyPath 
ofObject:(id)object change:(NS
 [self updateImage];
 }
 
+- (UIColor *)colorFromHexString:(NSString *)hexString {
+unsigned rgbValue = 0;
+NSScanner *scanner = [NSScanner scannerWithString:hexString];
+[scanner setScanLocation:1]; // bypass '#' character
+[scanner scanHexInt:];
+return [UIColor colorWithRed:((rgbValue & 0xFF) >> 16)/255.0 
green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
+}
+
+-(UIImage*) drawText:(NSString*) text inImage:(UIImage*) image 
gravity:(NSString*) gravity fontSize:(CGFloat) fontSize fontColor:(NSString*) 
fontColor
+{
+
+UIFont *font = [UIFont boldSystemFontOfSize:fontSize];
+UIGraphicsBeginImageContext(image.size);
+[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
+
+UIScreen* mainScreen = [UIScreen mainScreen];
+CGFloat mainScreenHeight = mainScreen.bounds.size.height;
+CGFloat mainScreenWidth = mainScreen.bounds.size.width;
+
+CGSize textSize = [text sizeWithFont:font];
+CGFloat padding = 15.0;
+CGFloat position = mainScreenWidth - (textSize.width + padding);
+
+if([gravity isEqualToString:@"left"]) {
+position = padding;
+} else if ([gravity isEqualToString:@"center"]) {
+position = (mainScreenWidth / 2) - padding;
+}
+
+CGRect rect = CGRectMake(position, mainScreenHeight - 30.0, 
textSize.width, textSize.height);
 
 Review comment:
   Curious -- what's this look like on an iPhone X? Does this clear the home 
screen indicator?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org