motion-assets-library 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da615ac915dba016769a5dbcf9269e17e43a3188
4
- data.tar.gz: 36a817182780265262386d0a64cc6548325461e9
3
+ metadata.gz: 9416c992c984c20be75b94e25de14015422b1b41
4
+ data.tar.gz: 4ba5af4191c8bf8783705561dd94b8e4eb4c4d4c
5
5
  SHA512:
6
- metadata.gz: 40e42acc0e021b1d2729ec92c8b1b212b7978ea0fc366fa44af6791eb67bfd1d681e6b0ac75f72b7ad01eb75a6688aa1266a269af8f7c53daf0d97f71bbd53f3
7
- data.tar.gz: 2d7a62bc4ce6037fbb2d4aa604f9e7463641e6dcbd834f93ab0e2564f776e547f3db719db36247fcf6b7bb3ccc1860114847988e51ef91d14fe583db67d2b1c6
6
+ metadata.gz: d14d3e289b83faaead1cf6acec55d8e0f0ffdcd6cc610dfac1960cfd5fd0b249c67b9d0756450322ff2032a2f827be86151492f3964595db5b643596c9acafb8
7
+ data.tar.gz: 6e6c16e1e8a405334a09282ee77a4489671d8dea0f4e8e3e075b3dfacd084f055f7f7d19e0692ea9d93fa4a04297adacbd51e4c1610bbdb38831a3954b20517f
data/README.md CHANGED
@@ -21,12 +21,27 @@ Implement the delegate method:
21
21
 
22
22
  ``` ruby
23
23
  def did_load_assets(assets)
24
- self.assets = assets
24
+ @assets = assets
25
25
 
26
26
  colletion_view.reloadData
27
27
  end
28
28
  ```
29
29
 
30
+ ### Handling denied access to the Photo Library
31
+
32
+ Set a denied callback:
33
+
34
+ ``` ruby
35
+ denied_callback = -> do
36
+ show_alert('Access to the Photo Library has been denied. Please update your privacy settings')
37
+ end
38
+
39
+ Motion::AssetsLibrary::Loader.new.tap do |loader|
40
+ loader.delegate = WeakRef.new(self)
41
+ loader.denied denied_callback
42
+ end
43
+ ```
44
+
30
45
  ## Setup
31
46
 
32
47
  Add this line to your application's Gemfile:
@@ -36,9 +36,23 @@ class Motion
36
36
  def asset_loader
37
37
  @_asset_loader ||= AssetsLibrary::Loader.new.tap do |loader|
38
38
  loader.delegate = WeakRef.new(self)
39
+ loader.denied denied_callback
39
40
  end
40
41
  end
41
42
 
43
+ def denied_callback
44
+ -> { show_alert('Access to the Photo Library has been denied') }
45
+ end
46
+
47
+ def show_alert(message)
48
+ UIAlertView.alloc.initWithTitle(
49
+ nil,
50
+ message: message,
51
+ delegate: nil,
52
+ cancelButtonTitle: 'Ok',
53
+ otherButtonTitles: nil).show
54
+ end
55
+
42
56
  def did_load_assets(asset)
43
57
  collection_view.reloadData
44
58
  end
@@ -14,6 +14,22 @@ class Motion
14
14
  failureBlock: album_failure_block)
15
15
  end
16
16
 
17
+ def denied(callback)
18
+ @denied_callback = callback
19
+ end
20
+
21
+ def denied_callback
22
+ @denied_callback ||= -> { }
23
+ end
24
+
25
+ def access_denied?
26
+ [ALAuthorizationStatusDenied, ALAuthorizationStatusRestricted].include? authorization_status
27
+ end
28
+
29
+ def authorization_status
30
+ ALAssetsLibrary.authorizationStatus
31
+ end
32
+
17
33
  def reset_assets
18
34
  @_assets = []
19
35
 
@@ -47,7 +63,11 @@ class Motion
47
63
  end
48
64
 
49
65
  def album_failure_block
50
- lambda { |error| p "Error: #{error.localizedDescription}" }
66
+ lambda do |error|
67
+ p "Error: #{error.localizedDescription}"
68
+
69
+ denied_callback.call if access_denied?
70
+ end
51
71
  end
52
72
 
53
73
  def asset_block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-assets-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devon Blandin