cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: CB-7826 - Add CDVPlugin support for getting items from plugin resource bundles
Date Tue, 17 Mar 2015 00:57:56 GMT
Repository: cordova-ios
Updated Branches:
  refs/heads/4.0.x 1e500ce9f -> f55cfb41e


CB-7826 - Add CDVPlugin support for getting items from plugin resource bundles


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f55cfb41
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f55cfb41
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f55cfb41

Branch: refs/heads/4.0.x
Commit: f55cfb41e5302bfd378eb04e5d2fc491b2ac3fbc
Parents: 1e500ce
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Mar 16 17:57:55 2015 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Mar 16 17:57:55 2015 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVPlugin+Resources.h        | 39 ++++++++++++++++++++
 CordovaLib/Classes/CDVPlugin+Resources.m        | 38 +++++++++++++++++++
 CordovaLib/Classes/CDVPlugin.m                  |  1 +
 CordovaLib/CordovaLib.xcodeproj/project.pbxproj |  8 ++++
 4 files changed, 86 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f55cfb41/CordovaLib/Classes/CDVPlugin+Resources.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin+Resources.h b/CordovaLib/Classes/CDVPlugin+Resources.h
new file mode 100644
index 0000000..cc43b16
--- /dev/null
+++ b/CordovaLib/Classes/CDVPlugin+Resources.h
@@ -0,0 +1,39 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <UIKit/UIKit.h>
+#import "CDVPlugin.h"
+
+@interface CDVPlugin (CDVPluginResources)
+
+/*
+ This will return the localized string for a key in a .bundle that is named the same as your
class
+ For example, if your plugin class was called Foo, and you have a Spanish localized strings
file, it will
+ try to load the desired key from Foo.bundle/es.lproj/Localizable.strings
+ */
+- (NSString*)pluginLocalizedString:(NSString*)key;
+
+/*
+ This will return the image for a name in a .bundle that is named the same as your class
+ For example, if your plugin class was called Foo, and you have an image called "bar",
+ it will try to load the image from Foo.bundle/bar.png (and appropriately named retina versions)
+ */
+- (UIImage*)pluginImageResource:(NSString*)name;
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f55cfb41/CordovaLib/Classes/CDVPlugin+Resources.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin+Resources.m b/CordovaLib/Classes/CDVPlugin+Resources.m
new file mode 100644
index 0000000..5690738
--- /dev/null
+++ b/CordovaLib/Classes/CDVPlugin+Resources.m
@@ -0,0 +1,38 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CDVPlugin+Resources.h"
+
+@implementation CDVPlugin (CDVPluginResources)
+
+- (NSString*)pluginLocalizedString:(NSString*)key
+{
+    NSBundle* bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:NSStringFromClass([self
class]) ofType:@"bundle"]];
+
+    return [bundle localizedStringForKey:(key) value:nil table:nil];
+}
+
+- (UIImage*)pluginImageResource:(NSString*)name
+{
+    NSString* resourceIdentifier = [NSString stringWithFormat:@"%@.bundle/%@", NSStringFromClass([self
class]), name];
+
+    return [UIImage imageNamed:resourceIdentifier];
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f55cfb41/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
index 121e54c..ac3a8ee 100644
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.m
@@ -19,6 +19,7 @@
 
 #import "CDVPlugin.h"
 #import "CDVPlugin+Private.h"
+#import "CDVPlugin+Resources.h"
 #import "CDVViewController.h"
 #include <objc/message.h>
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f55cfb41/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 2dbf054..2957580 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -13,6 +13,8 @@
 		3034979C1513D56A0090E688 /* CDVLocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef
= 3034979A1513D56A0090E688 /* CDVLocalStorage.h */; settings = {ATTRIBUTES = (Public, ); };
};
 		3034979E1513D56A0090E688 /* CDVLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef
= 3034979B1513D56A0090E688 /* CDVLocalStorage.m */; };
 		30392E4E14F4FCAB00B9E0B8 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef
= 30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */; settings = {ATTRIBUTES = (Public, ); };
};
+		306A45021AB7B073003D6925 /* CDVPlugin+Resources.h in Headers */ = {isa = PBXBuildFile;
fileRef = 306A45001AB7B073003D6925 /* CDVPlugin+Resources.h */; settings = {ATTRIBUTES = (Public,
); }; };
+		306A45031AB7B073003D6925 /* CDVPlugin+Resources.m in Sources */ = {isa = PBXBuildFile;
fileRef = 306A45011AB7B073003D6925 /* CDVPlugin+Resources.m */; };
 		306ADADD1AAA739800CAC885 /* CDVHandleOpenURL.h in Headers */ = {isa = PBXBuildFile; fileRef
= 306ADADC1AAA739800CAC885 /* CDVHandleOpenURL.h */; };
 		306ADAE01AAA73BA00CAC885 /* CDVHandleOpenURL.m in Sources */ = {isa = PBXBuildFile; fileRef
= 306ADADE1AAA73A800CAC885 /* CDVHandleOpenURL.m */; };
 		306ADAE51AAA73E100CAC885 /* CDVUIWebViewEngine.m in Sources */ = {isa = PBXBuildFile; fileRef
= 306ADAE11AAA73E100CAC885 /* CDVUIWebViewEngine.m */; };
@@ -63,6 +65,8 @@
 		3034979A1513D56A0090E688 /* CDVLocalStorage.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = CDVLocalStorage.h; path = Classes/CDVLocalStorage.h;
sourceTree = "<group>"; };
 		3034979B1513D56A0090E688 /* CDVLocalStorage.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = CDVLocalStorage.m; path = Classes/CDVLocalStorage.m;
sourceTree = "<group>"; };
 		30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = CDVAvailability.h; path = Classes/CDVAvailability.h;
sourceTree = "<group>"; };
+		306A45001AB7B073003D6925 /* CDVPlugin+Resources.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = "CDVPlugin+Resources.h"; path = "Classes/CDVPlugin+Resources.h";
sourceTree = "<group>"; };
+		306A45011AB7B073003D6925 /* CDVPlugin+Resources.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = "CDVPlugin+Resources.m"; path = "Classes/CDVPlugin+Resources.m";
sourceTree = "<group>"; };
 		306ADADC1AAA739800CAC885 /* CDVHandleOpenURL.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = CDVHandleOpenURL.h; path = Classes/CDVHandleOpenURL.h;
sourceTree = "<group>"; };
 		306ADADE1AAA73A800CAC885 /* CDVHandleOpenURL.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = CDVHandleOpenURL.m; path = Classes/CDVHandleOpenURL.m;
sourceTree = "<group>"; };
 		306ADAE11AAA73E100CAC885 /* CDVUIWebViewEngine.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = CDVUIWebViewEngine.m; path = Classes/CDVUIWebViewEngine.m;
sourceTree = "<group>"; };
@@ -172,6 +176,8 @@
 				306ADAE21AAA73E100CAC885 /* CDVWebViewEngineProtocol.h */,
 				7E5D94161AB250F800F4D9EB /* CDVAppDelegate.h */,
 				7E5D94171AB250F800F4D9EB /* CDVAppDelegate.m */,
+				306A45001AB7B073003D6925 /* CDVPlugin+Resources.h */,
+				306A45011AB7B073003D6925 /* CDVPlugin+Resources.m */,
 			);
 			name = Public;
 			sourceTree = "<group>";
@@ -228,6 +234,7 @@
 				7E5D94151AB23DB400F4D9EB /* CDVPlugin+Private.h in Headers */,
 				306ADAE71AAA73E100CAC885 /* NSDictionary+CordovaPreferences.h in Headers */,
 				EB6A98571A77FA430013FCDB /* NSData+Base64.h in Headers */,
+				306A45021AB7B073003D6925 /* CDVPlugin+Resources.h in Headers */,
 				EBFF4DBD16D3FE2E008F452B /* CDVUIWebViewDelegate.h in Headers */,
 				306ADAEB1AAA747100CAC885 /* NSMutableArray+QueueAdditions.h in Headers */,
 				306ADAEC1AAA753300CAC885 /* CDVCommandDelegateImpl.h in Headers */,
@@ -297,6 +304,7 @@
 				30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
 				30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */,
 				7E5D94191AB250F800F4D9EB /* CDVAppDelegate.m in Sources */,
+				306A45031AB7B073003D6925 /* CDVPlugin+Resources.m in Sources */,
 				8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */,
 				3034979E1513D56A0090E688 /* CDVLocalStorage.m in Sources */,
 				306ADAE51AAA73E100CAC885 /* CDVUIWebViewEngine.m in Sources */,


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


Mime
View raw message