<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>[tim.dev] - Open Source</title><description>The blog and portfolio of Tim Oliver, an iOS engineer in Tokyo.</description><link>https://tim.dev</link><atom:link
    href="https://tim.dev/feed-oss.xml"
    rel="self" type="application/rss+xml"
/><language>en</language><generator>Ignite v0.6.0</generator><item><guid isPermaLink="true">https://tim.dev/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/</guid><title>TOCropViewController – An open source image cropper for iOS</title><link>https://tim.dev/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/</link><description><![CDATA[Over the years, I’ve built up a pretty crazy list of features that I want to add to iComics. One feature on that list that’s been kicking around since pretty much day 1 has been the ability to crop page images.]]></description><pubDate>Sun, 21 Jun 2015 13:31:14 +0000</pubDate><dc:creator><![CDATA[Tim Oliver]]></dc:creator><category><![CDATA[development]]></category><category><![CDATA[oss]]></category><content:encoded><![CDATA[<p>Over the years, I’ve built up a pretty crazy <a href="https://github.com/iComics/iComics-Issues/issues">list of features that I want to add to iComics</a>. One feature on that list that’s been kicking around since pretty much day 1 has been the ability to crop page images.</p><p>Photo cropping as a native feature is not new to iOS. It was originally introduced in iOS 5 wayyy back in 2011, and was touted during the unveiling of the iPhone 4S.</p><p><img src="https://tim.dev/img/posts/2015/06/iPhone-4S-Cropper.jpg" alt="iPhone-4S-Cropper" class="img-fluid"></p><p>Since then, it’s only gotten WAY cooler in iOS 8.</p><p><img src="https://tim.dev/img/posts/2015/06/iPhone-6-Cropper.jpg" alt="iPhone-6-Cropper" class="img-fluid"></p><p>I’ve wanted the ability to crop page images in iComics for mainly two reasons: to make comic thumbnails more configurable, and to make posting small portions of comic pages to social media possible. I’m also considering persistent image editing down the line as well, but that still requires a bit of research.</p><p>Sadly, Apple has never made the cropping feature of the Photos app accessible to third party apps. As a result of this, a LOT of third party cropping libraries have popped up over the years to get around the solution. Most notably, <a href="https://github.com/kishikawakatsumi">Katsumi Kishikawa</a><span style="line-height: 1.5;">, one of my colleagues from </span><a href="http://realm.io">Realm</a><span style="line-height: 1.5;"> released quite possibly the </span><a href="https://github.com/kishikawakatsumi/PEPhotoCropEditor">best iOS 5-styled cropper library</a><span style="line-height: 1.5;"> on GitHub.</span></p><p><img src="https://tim.dev/img/posts/2015/06/PEPhotoCropper.jpg" alt="PEPhotoCropper" class="img-fluid"></p><p>Initially, I was looking forward to using this one in iComics. But sadly, when iOS 7 hit, I was forced to put that feature on the back burner while I redesigned my app. When I finally had the app ready, iOS 8 had come around, and the cropper’s design both started looking dated, and was behaving strangely on my iPhone 6 Plus. Katsumi’s told me that he does want to upgrade the cropper at some point, but sadly simply hasn’t had the time lately.</p><p>As a result of all of that, I decided that it might be worth to write a new cropper from scratch after all; something designed from the start to match what users were already expecting on iOS 8. After a quick proof-of-concept, I started writing some code in March this year, and posted the finished library to GitHub two weeks ago:</p><p><img src="https://tim.dev/img/posts/2015/06/TOCropViewController-WWDC.jpg" alt="TOCropViewController-WWDC" class="img-fluid"></p><p>Named <a href="https://github.com/TimOliver/TOCropViewController">TOCropViewController</a>, the goal of this library was to provide the ability to crop a UIImage object and either return it to an object, or immediately share it. It was designed with the iOS 8 Photos app in mind, taking advantage of the system translucency and springy iOS 7 animations. As a few extra niceties, it also allows rotating images in 90-degree chunks and aspect-locking the crop box.</p><p>In terms of how everything actually works, here’s a 3D breakout of what layers comprise the view:</p><p><img src="https://tim.dev/img/posts/2015/06/TOCropViewController-3D-Breakdown.jpg" alt="TOCropViewController Breakdown" class="img-fluid">For most normal cropping implementations, it makes sense to simply have 4 views overlaying the image, creating the square ‘hole’ in the middle denoting which region will be cropped. Since having to do that with both the translucent layer, and the dimming layer was looking to be quite complex, I opted to try a new approach: place a copy of the image above the layers, clipped to a view that was denoting the cropping region, and then automatically line up the foreground image with the background image. This ended up working flawlessly, creating the illusion that there is a ‘hole’ in the middle of the view, and minimising the amount of views on screen needed to create that effect.</p><p>In any case, this was definitely one of the harder views I’ve worked on. There were a LOT of alignment issues involving the crop box and the floating point precision of the scroll view, so I spent a fair bit of time simply making sure float values were being clipped to integer values properly throughout the class.</p><p>Now that the view is finished, I’m very happy with the results and can’t wait to get it up and running in iComics as soon as I can. If you’re also writing iOS software and would like to use this library, it’s <a href="https://github.com/TimOliver/TOCropViewController">available on GitHub</a> under the MIT license.</p><p>Enjoy!</p>]]></content:encoded></item><item><guid isPermaLink="true">https://tim.dev/2014/07/27/towebviewcontroller-an-open-source-web-viewer-for-ios/</guid><title>TOWebViewController – An open source web viewer for iOS</title><link>https://tim.dev/2014/07/27/towebviewcontroller-an-open-source-web-viewer-for-ios/</link><description><![CDATA[Here’s a neat little thing I’ve been working on lately. 🙂]]></description><pubDate>Sun, 27 Jul 2014 22:58:09 +0000</pubDate><dc:creator><![CDATA[Tim Oliver]]></dc:creator><category><![CDATA[development]]></category><category><![CDATA[tech]]></category><category><![CDATA[oss]]></category><content:encoded><![CDATA[<p>Here’s a neat little thing I’ve been working on lately. 🙂</p><p>When it comes to building apps for iPhone and iPad, there’s often a design requirement in quickly displaying web pages to users, without needing to kick them out to another app in the process.</p><p>One example of this is social media apps; ones that deals with massive amounts of user-posted content, often with links attached. One of my most favourite apps on iOS, <a href="https://itunes.apple.com/au/app/tweetbot-3-for-twitter-iphone/id722294701">Tweetbot</a>, handles this incredibly elegantly.</p><p><img src="https://tim.dev/img/posts/2014/07/Tweetbot-Kotaku.jpg" alt="Tweetbot-Kotaku" class="img-fluid"></p><p>Another, lesser example of this sort of thing is when there might be a need to display a set of static information to the app user, but that this information may be subject to change in the future. <a href="https://itunes.apple.com/au/app/google-maps/id585027354">Google Maps app on iOS</a> employs for its legal services agreement:</p><p><img src="https://tim.dev/img/posts/2014/07/GoogleMaps-TOS-iPhone5s.jpg" alt="GoogleMaps-TOS-iPhone5s" class="img-fluid"></p><p>Apple makes building a web viewer a lot easier than it could be by providing a type of UI element called a <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html">UIWebView</a>, that can take a URL, and load and display its content. But unfortunately, that’s all it does. So any other bells and whistles (Like a back button, or a loading bar) must be done by the developers.</p><p>Last year, while I was working on <a href="http://icomics.co">my dinky little comic reader app</a>, I came up with 3 discrete needs for a web page viewer in my app’s design:</p><ul><li>Linking to a set of instructions on Apple.com on how to move comics into the app via iTunes (Something I intend to replace with a proper custom document at some point!).</li><li>Incidental links inside the app’s Settings menu (ie, links to third party library sites).</li><li>In a future release, the ability to navigate to websites inside the app, and queue up comic downloads directly from it (eg from sites like <a href="http://comics.drivethrustuff.com/">DriveThruComics</a>).</li></ul><p>That last point’s a bit of a doozy. So much so, that when I checked out all of the open source web viewers already on GitHub, I didn’t see one that would fit the bill for all the features I ultimately want to have.</p><p>So, I decided to roll my own. 🙂</p><p>Last year, I decided to start building a completely self-contained web viewer library. Named <a href="https://github.com/TimOliver/TOWebViewController">TOWebViewController</a>, the goal of the class is to be able to provide a ‘drop-in’ web viewer that can be used for a variety of different app UI configurations.</p><p><img src="https://tim.dev/img/posts/2014/07/TOWebViewController-iPod.jpg" alt="TOWebViewController on iPod touch" class="img-fluid"></p><p>It follows a very ‘system-standard’ visual design style, and has been built with a multitude of configuration options, but can be easily implemented with only a couple of lines of code. Some of its features include:</p><p><strong>Support for iOS 5 and up</strong><br />Supporting iOS devices even as far back as the iPhone 3GS, the 3rd generation iPod touch, and the 1st generation iPad, the class has been designed to be as flexible as possible with system requirements.</p><p><img src="https://tim.dev/img/posts/2014/07/TOWebViewController-iPhone4s.jpg" alt="TOWebViewController on iOS 5" class="img-fluid"></p><p><strong>A page loading progress bar</strong><br />Normally, it’s not possible to get a proper ‘page loaded amount’ from a UIWebView, so having a loading bar is actually quite tricky. Thankfully, an incredibly smart Japanese chap named Satoshi ‘ninjinkun’ Asano developed a brilliant algorithm that counts the number of requests that start and and finish within a UIWebView, to produce a surprisingly accurate page load progress value. TOWebViewController makes use of this algorithm, which I re-implemented from scratch to ensure complete, seamless integration.</p><p><strong>Procedurally generated artwork</strong><br />Between iPhone and iPad versions, Retina and non-Retina versions, iOS 6 and iOS 7 versions, I was looking at a relatively crazy number of graphics asset combinations that would needed to be included along with the viewer, to ensure proper compatibility across all devices and all versions. To minimize the redundancy of requiring image files that might end up never getting used, ALL of the assets in this bundle are generated procedurally using Apple’s Quartz technology at runtime, with both the device iOS version, and screen size taken into account.</p><blockquote class="embed_social" data-platform="instagram"><div class="header"><a class="name_header" href="https://www.instagram.com/timoliver/"><img class="avatar" src="https://tim.dev/img/site/avatars/timoliver.jpg" alt="" width="46" height="46"><div class="name"><span class="display_name">Tim Oliver</span><span class="account_name">@timoliver</span></div></a></div><div class="media"><a href="https://tim.dev/img/posts/instagram/mXv3C2syaI.jpg" data-lightbox data-caption="PaintCode is an absolutely amazing tool. It makes it really easy to generate drawing code that generates icon art at runtime. ^_^"><img src="https://tim.dev/img/posts/instagram/mXv3C2syaI.jpg" alt="Photo by @timoliver" loading="lazy" decoding="async"></a></div><p class="text">PaintCode is an absolutely amazing tool. It makes it really easy to generate drawing code that generates icon art at runtime. ^_^</p><p class="meta"><a href="https://www.instagram.com/p/mXv3C2syaI/"><time datetime="2014-04-04">4 April 2014</time></a></p></blockquote>
<p><strong>Custom device rotation animations</strong><br />Unlike Safari, for some strange reason, Apple never properly implemented dynamic rescaling in the UIWebView UI control. As a result, if the user rotates the device while it’s visible, more often than not, it glitches up.</p><p>Here’s how it looks in Google Chrome for iOS, which uses the default implementation:</p><blockquote class="embed_social" data-platform="instagram"><div class="header"><a class="name_header" href="https://www.instagram.com/timoliver/"><img class="avatar" src="https://tim.dev/img/site/avatars/timoliver.jpg" alt="" width="46" height="46"><div class="name"><span class="display_name">Tim Oliver</span><span class="account_name">@timoliver</span></div></a></div><div class="media"><a href="https://tim.dev/img/posts/instagram/qYhDcJsyZY.jpg" data-lightbox data-caption="For comparison, here's how it looked before I implemented the animation, as demonstrated by Chrome for iOS. XD (I'm picking on Chrome since I got to speak to one of its engineers last year at Google I/O, who totally said they might consider possibly fixing it. XD)"><img src="https://tim.dev/img/posts/instagram/qYhDcJsyZY.jpg" alt="Photo by @timoliver" loading="lazy" decoding="async"></a></div><p class="text">For comparison, here's how it looked before I implemented the animation, as demonstrated by Chrome for iOS. XD (I'm picking on Chrome since I got to speak to one of its engineers last year at Google I/O, who totally said they might consider possibly fixing it. XD)</p><p class="meta"><a href="https://www.instagram.com/p/qYhDcJsyZY/"><time datetime="2014-07-13">13 July 2014</time></a></p></blockquote>
<p>In TOWebViewController, I implemented a completely custom animation for handling device rotations, designed to mimic Safari:</p><blockquote class="embed_social" data-platform="instagram"><div class="header"><a class="name_header" href="https://www.instagram.com/timoliver/"><img class="avatar" src="https://tim.dev/img/site/avatars/timoliver.jpg" alt="" width="46" height="46"><div class="name"><span class="display_name">Tim Oliver</span><span class="account_name">@timoliver</span></div></a></div><div class="media"><a href="https://tim.dev/img/posts/instagram/qYgZzrMyYs.jpg" data-lightbox data-caption="One of the more hidden features inside my little inline web browser project is that I hand-rolled  the device rotation animation so it matches the same style of Safari. :)"><img src="https://tim.dev/img/posts/instagram/qYgZzrMyYs.jpg" alt="Photo by @timoliver" loading="lazy" decoding="async"></a></div><p class="text">One of the more hidden features inside my little inline web browser project is that I hand-rolled  the device rotation animation so it matches the same style of Safari. :)</p><p class="meta"><a href="https://www.instagram.com/p/qYgZzrMyYs/"><time datetime="2014-07-13">13 July 2014</time></a></p></blockquote>
<p>The animation works by taking a photo of the web content, overlays the photo on top of the web content, animates that, and then restores the web content once the animation is complete.</p><p><em>(NB: I’m picking on Google Chrome a bit here because I filed a bug report about that animation glitch back in 2013, that culminated in a face-to-face meeting with one of Google Chrome for iOS’ engineers at Google I/O 2013. So I know they’re aware of the issue! 😉 )</em></p><p>TOWebViewController is <a href="https://github.com/TimOliver/TOWebViewController">available to download from my GitHub account</a>, under the MIT license. The goal from this point onwards is to develop upon it concurrently along with my comic reader app, adding features to it as I require them in my app.</p><p>In any case, if you’re a fellow developer, and discover you need to display some web content in your app, hopefully this library will save you some time!</p>]]></content:encoded></item><item><guid isPermaLink="true">https://tim.dev/2011/08/26/open-source-also-github/</guid><title>Open Source! (Also GitHub)</title><link>https://tim.dev/2011/08/26/open-source-also-github/</link><description><![CDATA[As a result of being extremely lazy and hating having to reinvent the wheel, once I got the hang of OOP principles, I decided to always try and make my classes as low-level and as abstracted as possible, so I could always re-use them in later projects. 😛]]></description><pubDate>Fri, 26 Aug 2011 23:33:10 +0000</pubDate><dc:creator><![CDATA[Tim Oliver]]></dc:creator><category><![CDATA[development]]></category><category><![CDATA[oss]]></category><content:encoded><![CDATA[<div class="wp-caption alignleft" id="attachment_636" style="width: 275px"><img src="https://tim.dev/img/posts/2011/08/open_sauce.jpg" alt="Open Sauce :D">Oh wait. Or was that the other 'open sauce'...
</div>With a few websites, a few game mods, and even a few iOS apps under my belt, I think it’s safe to say that I’ve written a fair amount of programming code at this point. XD
<p>As a result of being extremely lazy and hating having to reinvent the wheel, once I got the hang of OOP principles, I decided to always try and make my classes as low-level and as abstracted as possible, so I could always re-use them in later projects. 😛</p><p>Over a period of developing, testing and refining, I’ve started coming up with a few common classes that I seem to be using a heck of a lot. For example, in PHP, I’ve ended up with a pretty decent MySQL manager class (which I then extended into SQLite), and in Objective-C, I’ve got a UITableViewController that automates loading content on separate threads. ^_^</p><p>Since I’ve been finding them so useful in my projects, and wondering if other people might find them useful too, I’ve been considering open-sourcing them.</p><p>In any case, I took the plunge this week. 😀 I’ve uploaded a pile of the PHP classes I use for client work and UberGames projects to my <a href="https://github.com/timoliver">GitHub account</a>.</p><p>That account’s been collecting digital dust for a while now, so I thought this would also be a good opportunity to start using it, as well as figuring out a bit more on how git actually works. ^_^;</p><p>I’ll be putting as much of my code up there as possible and improving it as I go. As I want to make sure it’s easy to use and understand, I’m also going to try and refine all of the formatting and internal documentation so they’re standard across the board (which it isn’t right now ^_^;).</p><p>All of the code is released under the MIT license, so go nuts with it. 😀</p><p>.<em>EDIT: Feel free to contribute to the classes as well! (Thanks @nekodex lol)</em></p>]]></content:encoded></item></channel></rss>