yesyoucam 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/project/yesyoucam.rb +21 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9208f8d396f559090d26d908e11e5ccdd19723da
4
- data.tar.gz: 9b46dba729b433f48a0f0dcc49338957eef8fea7
3
+ metadata.gz: 65dceb82e7c9c52267b755520051fea86edeb1d5
4
+ data.tar.gz: 9b3bdd2914b75582413d3b704cd5c4dd291cac9c
5
5
  SHA512:
6
- metadata.gz: 167482ff74f823b2367e142522621e81147e4abf79526174bd8f30f6579bdf1e0c51ea7d49b9f58bfe618c59a199fe47a144c7df28741e001b792cc3c886d2dc
7
- data.tar.gz: 2de83e738c72c798c8e031ae127c98edba689e4f1f8ab9f66dc1cb5ad184e4aebf62e123956632023e55e6d855acdabcb9a4cd125278ae31da42b259b044fa0c
6
+ metadata.gz: ea356be68df5c96b06a9eb567d786ccd256a2a8458142509b0cf230ea1aa697ffa7035e3bd5c9160ea91f7d869db0044175e2700c52736f6e68fb78c902f44da
7
+ data.tar.gz: b83ed311d441200af969a61a6e001eab485a59bc4fdb98488e9724b78b60f5af1d90ee14638799a39e8c716b8db305a46f0e6684ffd1a90249ff19651771d668
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Yes You Cam
2
2
  ## A **Ridiculous**ly Simple BluePotion Camera Library to help you achieve your dreams...
3
+ [![Gem Version](https://badge.fury.io/rb/yesyoucam.svg)](http://badge.fury.io/rb/yesyoucam)
3
4
  ![Don't Shia Way](_art/yyc.png)
4
5
 
5
6
  ## Usage ("Nothing is impossible")
@@ -71,9 +71,28 @@ class YesYouCam
71
71
 
72
72
  def pic_path_from_uri (content_uri)
73
73
  cursor = find.app.context.contentResolver.query(content_uri, nil, nil, nil, nil)
74
- column_index = cursor.getColumnIndexOrThrow(YesYouCam::DATA)
74
+ column_index = cursor.getColumnIndex(YesYouCam::DATA)
75
+ path = nil
75
76
  cursor.moveToFirst
76
- path = cursor.getString(column_index)
77
+
78
+ # Some devices have SD cards/google services that make this a living hell... protect the user!
79
+ if column_index >= 0
80
+ path = cursor.getString(column_index)
81
+ else
82
+ # We're probably on an SD card - check common places (We're not the first one to attempt this terrible idea... DAMN YOU ANDROID!)
83
+ external = Potion::Environment.getExternalStorageDirectory.getAbsolutePath
84
+ dcim = Potion::Environment.getExternalStoragePublicDirectory(Potion::Environment::DIRECTORY_DCIM).getAbsolutePath
85
+ pictures = Potion::Environment.getExternalStoragePublicDirectory(Potion::Environment::DIRECTORY_PICTURES).getAbsolutePath
86
+
87
+ potential_dirs = ["#{dcim}/Camera/", "#{dcim}/100Media/", "#{dcim}/100ANDRO/", "#{dcim}/100LGDSC/", "#{external}/Images/", "#{pictures}/", "#{dcim}"]
88
+
89
+ potential_dirs.each do |current_path|
90
+ potential_file = current_path + cursor.getString(0)
91
+ path = potential_file if Potion::File.new(potential_file).exists
92
+ break if path #shortcircuit now that we've found it!
93
+ end
94
+ end
95
+
77
96
  cursor.close
78
97
 
79
98
  path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yesyoucam
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake