Skip to content

Commit 3332e3d

Browse files
committed
Merge pull request #6 from initialxy/develop
r0.2.1
2 parents 9f9cb31 + 8a97d6b commit 3332e3d

File tree

5 files changed

+56
-11
lines changed

5 files changed

+56
-11
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,32 @@ One thing to note is that all image resources reference to **native** resource b
158158

159159
You may have noticed that ThemedBrowser added an optional menu as well as custom buttons, which you can utilize to respond to some simple user actions.
160160

161+
Import Native Images
162+
--------------------
163+
164+
If you are a native developer and are already aware how to import native image resources, feel free to skip this section. Otherwise, here are some tips. First of all, your native iOS and Android projects are located at:
165+
166+
<cordova_project_root>/platforms/ios
167+
<cordova_project_root>/platforms/android
168+
169+
Let's start with Android, which is quite straightforward. Prepare your images for all of the pixel densities that you'd like to support. [Here is a documentation](http://developer.android.com/guide/practices/screens_support.html) that explains this concept. The gist is that on higher pixel density screens, your images will have to have higher resolution in order to look sharp on an actual device, so you want to prepare multiple files for the same image at different resolutions for their respective pixel density. In Android, there are a lot of densities due to diversity of devices, so you have to decide which ones you want to support. Fortunately if you don't have an image for a particular pixel density, Android will automatically pick up the closest one and try to down scale or up scale it. Of course this process is not very efficient, so you have to make your decisions. The directory where you want to place your images are under
170+
171+
<cordova_project_root>/platforms/android/res
172+
173+
Notice how there are multiple folders named `drawble-.*`. Each file for the same image should be named the same, but it will need to be moved under the correct directory with respect to its target density. eg. If `icon.png` is intended for xhdpi, then it needs to go under `drawable-xhdpi` directory. In your JavaScript config, you can then reference to this iamge without extension. eg. With the previous example, simply `icon` will suffice.
174+
175+
To import image resources for iOS, it is slightly trickier, because you **have** to register your file in Xcode project file with help from Xcode, and there are two ways of doing this. Let's start with the old school way. iOS also shares similar concept with Android in terms of pixel density. iPhone to iPhone 3GS uses 1x the resolution, iPhone 4 to iPhone 6 uses 2x the resolution while iPhone 6 Plus and above uses 3x the resolution (even though it's actually down scaled, but that's a different discussion). In the old school way, you have to name your images with `@1x`, `@2x`, and `@3x` suffix with respect to their target density. eg. `[email protected]`. [Here is a documentation](https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreensInViews/SupportingHiResScreensInViews.html) that explains this concept. You then have to move it under
176+
177+
<cordova_project_root>/platforms/ios/<project_name>/Resources
178+
179+
Then open your native iOS project with Xcode by double clicking on
180+
181+
<cordova_project_root>/platforms/ios/<project_name>.xcodeproj
182+
183+
In the left hand side panel, make sure you are in Project navigator tab. Then you can see a list of directories under your project. One of them being `Resources`, but you don't see your newly added images there. Now you need to drag your images fron Finder to Xcode and drop it under `Resource` folder. In your JavaScript config, you can then reference to them without suffix or extension. eg. With the previous example, simply `icon` will suffice.
184+
185+
The new school way is to use [Asset Catalog](https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/Recipe.html). This is the recommended technique from Xcode 5+ and iOS 7+. It gives you better management of all of your image resources. ie. No more suffix, and you can see all your images for different densities in one table etc. However there are more steps involved to set it up. Please reference to [this guide](http://www.intertech.com/Blog/xcode-assets-xcassets/) for a step by step walkthrough.
186+
161187
FAQ
162188
---
163189

RELEASENOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
Release Notes
2222
=============
2323

24+
0.2.1
25+
=====
26+
27+
Debug and stablization.
28+
2429
0.2.0
2530
=====
2631

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-themeablebrowser",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Cordova ThemeableBrowser Plugin",
55
"cordova": {
66
"id": "com.initialxy.cordova.themeablebrowser",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2222
id="com.initialxy.cordova.themeablebrowser"
23-
version="0.2.0">
23+
version="0.2.1">
2424

2525
<name>ThemeableBrowser</name>
2626
<description>Cordova ThemeableBrowser Plugin</description>

src/ios/CDVThemeableBrowser.m

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,10 +1184,14 @@ - (void)webViewDidStartLoad:(UIWebView*)theWebView
11841184
// loading url, start spinner, update back/forward
11851185

11861186
self.addressLabel.text = NSLocalizedString(@"Loading...", nil);
1187-
if (!_browserOptions.backButtonCanClose && self.backButton) {
1188-
self.backButton.enabled = theWebView.canGoBack;
1187+
if (self.backButton) {
1188+
self.backButton.enabled
1189+
= _browserOptions.backButtonCanClose || theWebView.canGoBack;
11891190
}
1190-
self.forwardButton.enabled = theWebView.canGoForward;
1191+
1192+
if (self.forwardButton) {
1193+
self.forwardButton.enabled = theWebView.canGoForward;
1194+
}
11911195

11921196
[self.spinner startAnimating];
11931197

@@ -1209,10 +1213,15 @@ - (void)webViewDidFinishLoad:(UIWebView*)theWebView
12091213
// update url, stop spinner, update back/forward
12101214

12111215
self.addressLabel.text = [self.currentURL absoluteString];
1212-
if (!_browserOptions.backButtonCanClose && self.backButton) {
1213-
self.backButton.enabled = theWebView.canGoBack;
1216+
if (self.backButton) {
1217+
self.backButton.enabled
1218+
= _browserOptions.backButtonCanClose || theWebView.canGoBack;
12141219
}
1215-
self.forwardButton.enabled = theWebView.canGoForward;
1220+
1221+
if (self.forwardButton) {
1222+
self.forwardButton.enabled = theWebView.canGoForward;
1223+
}
1224+
12161225
if (self.titleLabel && _browserOptions.title
12171226
&& !_browserOptions.title[kThemeableBrowserPropStaticText]
12181227
&& [self getBoolFromDict:_browserOptions.title withKey:kThemeableBrowserPropShowPageTitle]) {
@@ -1247,10 +1256,15 @@ - (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
12471256
// log fail message, stop spinner, update back/forward
12481257
NSLog(@"webView:didFailLoadWithError - %ld: %@", (long)error.code, [error localizedDescription]);
12491258

1250-
if (!_browserOptions.backButtonCanClose && self.backButton) {
1251-
self.backButton.enabled = theWebView.canGoBack;
1259+
if (self.backButton) {
1260+
self.backButton.enabled
1261+
= _browserOptions.backButtonCanClose || theWebView.canGoBack;
12521262
}
1253-
self.forwardButton.enabled = theWebView.canGoForward;
1263+
1264+
if (self.forwardButton) {
1265+
self.forwardButton.enabled = theWebView.canGoForward;
1266+
}
1267+
12541268
[self.spinner stopAnimating];
12551269

12561270
self.addressLabel.text = NSLocalizedString(@"Load Error", nil);

0 commit comments

Comments
 (0)