cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13392) Display app version on splashscreen
Date Tue, 16 Jan 2018 17:18:01 GMT

    [ https://issues.apache.org/jira/browse/CB-13392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16327413#comment-16327413
] 

ASF GitHub Bot commented on CB-13392:
-------------------------------------

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:&rgbValue];
+    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 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:
users@infra.apache.org


> Display app version on splashscreen
> -----------------------------------
>
>                 Key: CB-13392
>                 URL: https://issues.apache.org/jira/browse/CB-13392
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-plugin-splashscreen
>    Affects Versions: Master
>         Environment: Available on Android and iOS.
>            Reporter: Jonathan Corral
>            Priority: Minor
>              Labels: beginner, features
>   Original Estimate: 14h
>  Remaining Estimate: 14h
>
> This feature allows you to display the app version number at splashscreen's bottom.
> You could configure the color, size and position (left, center, right) with preferences
into config.xml.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message