├── .gitattributes ├── .gitignore ├── MultiImagePicker.sln ├── MultiImagePicker ├── MultiImagePicker.Android │ ├── Assets │ │ └── AboutAssets.txt │ ├── ImageHelpers.cs │ ├── MainActivity.cs │ ├── MediaService.cs │ ├── MultiImagePicker.Android.csproj │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ └── Resources │ │ ├── AboutResources.txt │ │ ├── Resource.designer.cs │ │ ├── layout │ │ ├── Tabbar.axml │ │ └── Toolbar.axml │ │ ├── mipmap-anydpi-v26 │ │ ├── icon.xml │ │ └── icon_round.xml │ │ ├── mipmap-hdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-mdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xxhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xxxhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── values │ │ ├── colors.xml │ │ └── styles.xml │ │ └── xml │ │ └── file_paths.xml ├── MultiImagePicker.iOS │ ├── AppDelegate.cs │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon1024.png │ │ │ ├── Icon120.png │ │ │ ├── Icon152.png │ │ │ ├── Icon167.png │ │ │ ├── Icon180.png │ │ │ ├── Icon20.png │ │ │ ├── Icon29.png │ │ │ ├── Icon40.png │ │ │ ├── Icon58.png │ │ │ ├── Icon60.png │ │ │ ├── Icon76.png │ │ │ ├── Icon80.png │ │ │ └── Icon87.png │ ├── Entitlements.plist │ ├── GMMultiImpagePickerImplementation.cs │ ├── Info.plist │ ├── Main.cs │ ├── MessagingExtensions.cs │ ├── MultiImagePicker.iOS.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Resources │ │ ├── Default-568h@2x.png │ │ ├── Default-Portrait.png │ │ ├── Default-Portrait@2x.png │ │ ├── Default.png │ │ ├── Default@2x.png │ │ └── LaunchScreen.storyboard └── MultiImagePicker │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── ImagePickers │ ├── Android │ │ ├── ICompressImages.cs │ │ └── IMediaService.cs │ └── iOS │ │ ├── GMMultiImagePicker.cs │ │ └── IGMMultiImagePicker.cs │ ├── ImageSelectionPage.xaml │ ├── ImageSelectionPage.xaml.cs │ └── MultiImagePicker.csproj └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /MultiImagePicker.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29009.5 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiImagePicker.Android", "MultiImagePicker\MultiImagePicker.Android\MultiImagePicker.Android.csproj", "{A93F6A49-1A8D-4D6A-834A-E8B459C4886C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiImagePicker.iOS", "MultiImagePicker\MultiImagePicker.iOS\MultiImagePicker.iOS.csproj", "{24374527-06CD-4BE8-A5FC-A5C64662FC8D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiImagePicker", "MultiImagePicker\MultiImagePicker\MultiImagePicker.csproj", "{A49E2E61-D199-497D-94B4-1F89C9AB7361}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|iPhone = Debug|iPhone 16 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 17 | Release|Any CPU = Release|Any CPU 18 | Release|iPhone = Release|iPhone 19 | Release|iPhoneSimulator = Release|iPhoneSimulator 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 25 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhone.ActiveCfg = Debug|Any CPU 26 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhone.Build.0 = Debug|Any CPU 27 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhone.Deploy.0 = Debug|Any CPU 28 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 29 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 30 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU 31 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|Any CPU.Deploy.0 = Release|Any CPU 34 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhone.ActiveCfg = Release|Any CPU 35 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhone.Build.0 = Release|Any CPU 36 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhone.Deploy.0 = Release|Any CPU 37 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 38 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 39 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU 40 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator 41 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator 42 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|Any CPU.Deploy.0 = Debug|iPhoneSimulator 43 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhone.ActiveCfg = Debug|iPhone 44 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhone.Build.0 = Debug|iPhone 45 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhone.Deploy.0 = Debug|iPhone 46 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator 47 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator 48 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Debug|iPhoneSimulator.Deploy.0 = Debug|iPhoneSimulator 49 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|Any CPU.ActiveCfg = Release|iPhone 50 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|Any CPU.Build.0 = Release|iPhone 51 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|Any CPU.Deploy.0 = Release|iPhone 52 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhone.ActiveCfg = Release|iPhone 53 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhone.Build.0 = Release|iPhone 54 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhone.Deploy.0 = Release|iPhone 55 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator 56 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator 57 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator 58 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 61 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhone.ActiveCfg = Debug|Any CPU 62 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhone.Build.0 = Debug|Any CPU 63 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhone.Deploy.0 = Debug|Any CPU 64 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 65 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 66 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU 67 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|Any CPU.ActiveCfg = Release|Any CPU 68 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|Any CPU.Build.0 = Release|Any CPU 69 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|Any CPU.Deploy.0 = Release|Any CPU 70 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhone.ActiveCfg = Release|Any CPU 71 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhone.Build.0 = Release|Any CPU 72 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhone.Deploy.0 = Release|Any CPU 73 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 74 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 75 | {A49E2E61-D199-497D-94B4-1F89C9AB7361}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU 76 | EndGlobalSection 77 | GlobalSection(SolutionProperties) = preSolution 78 | HideSolutionNode = FALSE 79 | EndGlobalSection 80 | GlobalSection(ExtensibilityGlobals) = postSolution 81 | SolutionGuid = {625FF90E-4165-43B8-954A-0EAC5DBC46FD} 82 | EndGlobalSection 83 | EndGlobal 84 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); 20 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/ImageHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Android.Graphics; 4 | using Android.Widget; 5 | using MultiImagePicker.Droid.Helpers; 6 | using Plugin.CurrentActivity; 7 | 8 | [assembly: Xamarin.Forms.Dependency(typeof(ImageHelpers))] 9 | namespace MultiImagePicker.Droid.Helpers 10 | { 11 | public class ImageHelpers : ICompressImages 12 | { 13 | //collectionName is the name of the folder in your Android Pictures directory. 14 | public static readonly string collectionName = "TmpPictures"; 15 | 16 | public string SaveFile(byte[] imageByte, string fileName) 17 | { 18 | Java.IO.File fileDir; 19 | if ((int)Android.OS.Build.VERSION.SdkInt >= 29) 20 | { 21 | fileDir = new Java.IO.File(Android.App.Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures), collectionName); 22 | } 23 | else 24 | { 25 | fileDir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), collectionName); 26 | } 27 | 28 | if (!fileDir.Exists()) 29 | { 30 | fileDir.Mkdirs(); 31 | } 32 | 33 | var file = new Java.IO.File(fileDir, fileName); 34 | System.IO.File.WriteAllBytes(file.Path, imageByte); 35 | 36 | return file.Path; 37 | } 38 | 39 | public string CompressImage(string path) 40 | { 41 | byte[] imageBytes; 42 | 43 | //Get the bitmap. 44 | var originalImage = BitmapFactory.DecodeFile(path); 45 | 46 | //Set imageSize and imageCompression parameters. 47 | var imageSize = .86; 48 | var imageCompression = 67; 49 | 50 | //Resize it and then compress it to Jpeg. 51 | var width = (originalImage.Width * imageSize); 52 | var height = (originalImage.Height * imageSize); 53 | var scaledImage = Bitmap.CreateScaledBitmap(originalImage, (int)width, (int)height, true); 54 | 55 | using (MemoryStream ms = new MemoryStream()) 56 | { 57 | scaledImage.Compress(Bitmap.CompressFormat.Jpeg, imageCompression, ms); 58 | imageBytes = ms.ToArray(); 59 | } 60 | 61 | originalImage.Recycle(); 62 | originalImage.Dispose(); 63 | GC.Collect(); 64 | 65 | return SaveFile(imageBytes, Guid.NewGuid().ToString()); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Android.App; 4 | using Android.Content.PM; 5 | using Android.Runtime; 6 | using Android.Views; 7 | using Android.Widget; 8 | using Android.OS; 9 | using Plugin.CurrentActivity; 10 | using Android.Content; 11 | using System.Collections.Generic; 12 | using Xamarin.Forms; 13 | using Android.Database; 14 | using Android.Provider; 15 | using CarouselView.FormsPlugin.Android; 16 | 17 | namespace MultiImagePicker.Droid 18 | { 19 | [Activity(Label = "MultiImagePicker", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 20 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity 21 | { 22 | protected override void OnCreate(Bundle savedInstanceState) 23 | { 24 | TabLayoutResource = Resource.Layout.Tabbar; 25 | ToolbarResource = Resource.Layout.Toolbar; 26 | 27 | //NuGet Initializations 28 | CrossCurrentActivity.Current.Init(this, savedInstanceState); 29 | CarouselViewRenderer.Init(); 30 | FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: false); 31 | 32 | 33 | 34 | base.OnCreate(savedInstanceState); 35 | Xamarin.Essentials.Platform.Init(this, savedInstanceState); 36 | global::Xamarin.Forms.Forms.Init(this, savedInstanceState); 37 | LoadApplication(new App()); 38 | } 39 | 40 | public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) 41 | { 42 | Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); 43 | 44 | base.OnRequestPermissionsResult(requestCode, permissions, grantResults); 45 | } 46 | 47 | #region Image Picker Implementation 48 | public static int OPENGALLERYCODE = 100; 49 | protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) 50 | { 51 | base.OnActivityResult(requestCode, resultCode, data); 52 | 53 | //If we are calling multiple image selection, enter into here and return photos and their filepaths. 54 | if (requestCode == OPENGALLERYCODE && resultCode == Result.Ok) 55 | { 56 | List images = new List(); 57 | 58 | if (data != null) 59 | { 60 | //Separate all photos and get the path from them all individually. 61 | ClipData clipData = data.ClipData; 62 | if (clipData != null) 63 | { 64 | for (int i = 0; i < clipData.ItemCount; i++) 65 | { 66 | ClipData.Item item = clipData.GetItemAt(i); 67 | Android.Net.Uri uri = item.Uri; 68 | var path = GetRealPathFromURI(uri); 69 | 70 | 71 | if (path != null) 72 | { 73 | images.Add(path); 74 | } 75 | } 76 | } 77 | else 78 | { 79 | Android.Net.Uri uri = data.Data; 80 | var path = GetRealPathFromURI(uri); 81 | 82 | if (path != null) 83 | { 84 | images.Add(path); 85 | } 86 | } 87 | 88 | //Send our images to the carousel view. 89 | MessagingCenter.Send>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images); 90 | } 91 | } 92 | } 93 | 94 | /// 95 | /// Get the real path for the current image passed. 96 | /// 97 | public String GetRealPathFromURI(Android.Net.Uri contentURI) 98 | { 99 | try 100 | { 101 | ICursor imageCursor = null; 102 | string fullPathToImage = ""; 103 | 104 | imageCursor = ContentResolver.Query(contentURI, null, null, null, null); 105 | imageCursor.MoveToFirst(); 106 | int idx = imageCursor.GetColumnIndex(MediaStore.Images.ImageColumns.Data); 107 | 108 | if (idx != -1) 109 | { 110 | fullPathToImage = imageCursor.GetString(idx); 111 | } 112 | else 113 | { 114 | ICursor cursor = null; 115 | var docID = DocumentsContract.GetDocumentId(contentURI); 116 | var id = docID.Split(':')[1]; 117 | var whereSelect = MediaStore.Images.ImageColumns.Id + "=?"; 118 | var projections = new string[] { MediaStore.Images.ImageColumns.Data }; 119 | 120 | cursor = ContentResolver.Query(MediaStore.Images.Media.InternalContentUri, projections, whereSelect, new string[] { id }, null); 121 | if (cursor.Count == 0) 122 | { 123 | cursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, projections, whereSelect, new string[] { id }, null); 124 | } 125 | var colData = cursor.GetColumnIndexOrThrow(MediaStore.Images.ImageColumns.Data); 126 | cursor.MoveToFirst(); 127 | fullPathToImage = cursor.GetString(colData); 128 | } 129 | return fullPathToImage; 130 | } 131 | catch (Exception ex) 132 | { 133 | Toast.MakeText(Android.App.Application.Context, "Unable to get path", ToastLength.Long).Show(); 134 | } 135 | return null; 136 | } 137 | #endregion 138 | } 139 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/MediaService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Android.App; 4 | using Android.Content; 5 | using Android.Widget; 6 | using MultiImagePicker.Droid; 7 | using MultiImagePicker.Services; 8 | using Xamarin.Forms; 9 | using MultiImagePicker.Droid.Helpers; 10 | using Plugin.CurrentActivity; 11 | 12 | [assembly: Xamarin.Forms.Dependency(typeof(MediaService))] 13 | namespace MultiImagePicker.Droid 14 | { 15 | public class MediaService : Java.Lang.Object, IMediaService 16 | { 17 | public static int OPENGALLERYCODE = 100; 18 | public void OpenGallery() 19 | { 20 | try 21 | { 22 | var imageIntent = new Intent(Intent.ActionPick); 23 | imageIntent.SetType("image/*"); 24 | imageIntent.PutExtra(Intent.ExtraAllowMultiple, true); 25 | imageIntent.SetAction(Intent.ActionGetContent); 26 | ((Activity)CrossCurrentActivity.Current.Activity).StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), OPENGALLERYCODE); 27 | Toast.MakeText(CrossCurrentActivity.Current.Activity, "Tap and hold to select multiple photos.", ToastLength.Short).Show(); 28 | } 29 | catch (Exception ex) 30 | { 31 | Console.WriteLine(ex.ToString()); 32 | Toast.MakeText(CrossCurrentActivity.Current.Activity, "Error. Can not continue, try again.", ToastLength.Long).Show(); 33 | } 34 | } 35 | 36 | /// 37 | /// Call this when you want to delete our temporary images. 38 | /// Recommendation: Call this after successfully uploading images to Azure Blob Storage. 39 | /// 40 | void IMediaService.ClearFileDirectory() 41 | { 42 | string directory; 43 | if ((int)Android.OS.Build.VERSION.SdkInt >= 29) 44 | { 45 | directory = new Java.IO.File(Android.App.Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures), ImageHelpers.collectionName).Path.ToString(); 46 | } 47 | else 48 | { 49 | directory = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), ImageHelpers.collectionName).Path.ToString(); 50 | } 51 | 52 | if (Directory.Exists(directory)) 53 | { 54 | var list = Directory.GetFiles(directory, "*"); 55 | if (list.Length > 0) 56 | { 57 | for (int i = 0; i < list.Length; i++) 58 | { 59 | File.Delete(list[i]); 60 | } 61 | } 62 | } 63 | } 64 | 65 | /* 66 | Example of how to call ClearFileDirectory(): 67 | 68 | if (Device.RuntimePlatform == Device.Android) 69 | { 70 | DependencyService.Get().ClearFileDirectory(); 71 | } 72 | if (Device.RuntimePlatform == Device.iOS) 73 | { 74 | GMMultiImagePicker.Current.ClearFileDirectory(); 75 | } 76 | 77 | */ 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/MultiImagePicker.Android.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {A93F6A49-1A8D-4D6A-834A-E8B459C4886C} 7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | {c9e5eea5-ca05-42a1-839b-61506e0a37df} 9 | Library 10 | MultiImagePicker.Droid 11 | MultiImagePicker.Android 12 | True 13 | Resources\Resource.designer.cs 14 | Resource 15 | Properties\AndroidManifest.xml 16 | Resources 17 | Assets 18 | false 19 | v10.0 20 | true 21 | Xamarin.Android.Net.AndroidClientHandler 22 | 23 | 24 | 25 | 26 | true 27 | portable 28 | false 29 | bin\Debug 30 | DEBUG; 31 | prompt 32 | 4 33 | None 34 | 35 | 36 | true 37 | portable 38 | true 39 | bin\Release 40 | prompt 41 | 4 42 | true 43 | false 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 5.2.0 57 | 58 | 59 | 11.0.0 60 | 61 | 62 | 2.1.0.4 63 | 64 | 65 | 4.0.1.5 66 | 67 | 68 | 1.2.2.1 69 | 70 | 71 | 1.0.0.7 72 | 73 | 74 | 2.4.11.982 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | {05BFA12E-18E5-43DE-B8A5-5590728BEC94} 126 | MultiImagePicker 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Android.App; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("MultiImagePicker.Android")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("MultiImagePicker.Android")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: ComVisible(false)] 18 | [assembly: UsesFeature("android.hardware.camera", Required = false)] 19 | [assembly: UsesFeature("android.hardware.camera.autofocus", Required = false)] 20 | 21 | // Version information for an assembly consists of the following four values: 22 | // 23 | // Major Version 24 | // Minor Version 25 | // Build Number 26 | // Revision 27 | // 28 | // You can specify all the values or you can default the Build and Revision Numbers 29 | // by using the '*' as shown below: 30 | // [assembly: AssemblyVersion("1.0.*")] 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] 33 | 34 | // Add some common permissions, these can be removed if not needed 35 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)] 36 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] 37 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.xml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable-hdpi/ 12 | icon.png 13 | 14 | drawable-ldpi/ 15 | icon.png 16 | 17 | drawable-mdpi/ 18 | icon.png 19 | 20 | layout/ 21 | main.xml 22 | 23 | values/ 24 | strings.xml 25 | 26 | In order to get the build system to recognize Android resources, set the build action to 27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 28 | instead operate on resource IDs. When you compile an Android application that uses resources, 29 | the build system will package the resources for distribution and generate a class called 30 | "Resource" that contains the tokens for each one of the resources included. For example, 31 | for the above Resources layout, this is what the Resource class would expose: 32 | 33 | public class Resource { 34 | public class drawable { 35 | public const int icon = 0x123; 36 | } 37 | 38 | public class layout { 39 | public const int main = 0x456; 40 | } 41 | 42 | public class strings { 43 | public const int first_string = 0xabc; 44 | public const int second_string = 0xbcd; 45 | } 46 | } 47 | 48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main 49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first 50 | string in the dictionary file values/strings.xml. 51 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/layout/Tabbar.axml: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/layout/Toolbar.axml: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-anydpi-v26/icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-anydpi-v26/icon_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-hdpi/icon.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-hdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-hdpi/launcher_foreground.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-mdpi/icon.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-mdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-mdpi/launcher_foreground.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xhdpi/icon.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxhdpi/icon.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxxhdpi/icon.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #3F51B5 5 | #303F9F 6 | #FF4081 7 | 8 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 26 | 27 | 30 | 31 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.Android/Resources/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using CarouselView.FormsPlugin.iOS; 5 | using FFImageLoading; 6 | using FFImageLoading.Forms.Platform; 7 | using Foundation; 8 | using UIKit; 9 | 10 | namespace MultiImagePicker.iOS 11 | { 12 | // The UIApplicationDelegate for the application. This class is responsible for launching the 13 | // User Interface of the application, as well as listening (and optionally responding) to 14 | // application events from iOS. 15 | [Register("AppDelegate")] 16 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate 17 | { 18 | // 19 | // This method is invoked when the application has loaded and is ready to run. In this 20 | // method you should instantiate the window, load the UI into it and then make the window 21 | // visible. 22 | // 23 | // You have 17 seconds to return from this method, or iOS will terminate your application. 24 | // 25 | public override bool FinishedLaunching(UIApplication app, NSDictionary options) 26 | { 27 | global::Xamarin.Forms.Forms.Init(); 28 | 29 | //NuGet Initializations 30 | CarouselViewRenderer.Init(); 31 | CachedImageRenderer.Init(); 32 | var config = new FFImageLoading.Config.Configuration() 33 | { 34 | MaxMemoryCacheSize = (int)(NSProcessInfo.ProcessInfo.PhysicalMemory * 0.0001d), 35 | ClearMemoryCacheOnOutOfMemory = true, 36 | DiskCacheDuration = TimeSpan.FromSeconds(2) 37 | }; 38 | ImageService.Instance.Initialize(config); 39 | 40 | 41 | LoadApplication(new App()); 42 | return base.FinishedLaunching(app, options); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "scale": "2x", 5 | "size": "20x20", 6 | "idiom": "iphone", 7 | "filename": "Icon40.png" 8 | }, 9 | { 10 | "scale": "3x", 11 | "size": "20x20", 12 | "idiom": "iphone", 13 | "filename": "Icon60.png" 14 | }, 15 | { 16 | "scale": "2x", 17 | "size": "29x29", 18 | "idiom": "iphone", 19 | "filename": "Icon58.png" 20 | }, 21 | { 22 | "scale": "3x", 23 | "size": "29x29", 24 | "idiom": "iphone", 25 | "filename": "Icon87.png" 26 | }, 27 | { 28 | "scale": "2x", 29 | "size": "40x40", 30 | "idiom": "iphone", 31 | "filename": "Icon80.png" 32 | }, 33 | { 34 | "scale": "3x", 35 | "size": "40x40", 36 | "idiom": "iphone", 37 | "filename": "Icon120.png" 38 | }, 39 | { 40 | "scale": "2x", 41 | "size": "60x60", 42 | "idiom": "iphone", 43 | "filename": "Icon120.png" 44 | }, 45 | { 46 | "scale": "3x", 47 | "size": "60x60", 48 | "idiom": "iphone", 49 | "filename": "Icon180.png" 50 | }, 51 | { 52 | "scale": "1x", 53 | "size": "20x20", 54 | "idiom": "ipad", 55 | "filename": "Icon20.png" 56 | }, 57 | { 58 | "scale": "2x", 59 | "size": "20x20", 60 | "idiom": "ipad", 61 | "filename": "Icon40.png" 62 | }, 63 | { 64 | "scale": "1x", 65 | "size": "29x29", 66 | "idiom": "ipad", 67 | "filename": "Icon29.png" 68 | }, 69 | { 70 | "scale": "2x", 71 | "size": "29x29", 72 | "idiom": "ipad", 73 | "filename": "Icon58.png" 74 | }, 75 | { 76 | "scale": "1x", 77 | "size": "40x40", 78 | "idiom": "ipad", 79 | "filename": "Icon40.png" 80 | }, 81 | { 82 | "scale": "2x", 83 | "size": "40x40", 84 | "idiom": "ipad", 85 | "filename": "Icon80.png" 86 | }, 87 | { 88 | "scale": "1x", 89 | "size": "76x76", 90 | "idiom": "ipad", 91 | "filename": "Icon76.png" 92 | }, 93 | { 94 | "scale": "2x", 95 | "size": "76x76", 96 | "idiom": "ipad", 97 | "filename": "Icon152.png" 98 | }, 99 | { 100 | "scale": "2x", 101 | "size": "83.5x83.5", 102 | "idiom": "ipad", 103 | "filename": "Icon167.png" 104 | }, 105 | { 106 | "scale": "1x", 107 | "size": "1024x1024", 108 | "idiom": "ios-marketing", 109 | "filename": "Icon1024.png" 110 | } 111 | ], 112 | "properties": {}, 113 | "info": { 114 | "version": 1, 115 | "author": "xcode" 116 | } 117 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/GMMultiImpagePickerImplementation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using CoreFoundation; 8 | using CoreGraphics; 9 | using Foundation; 10 | using GMImagePicker; 11 | using MultiImagePicker; 12 | using MultiImagePicker.iOS; 13 | using Photos; 14 | using UIKit; 15 | using Xamarin.Forms; 16 | using Xamarin.Forms.Platform.iOS; 17 | 18 | [assembly: Dependency(typeof(GMMultiImpagePickerImplementation))] 19 | namespace MultiImagePicker.iOS 20 | { 21 | [Foundation.Preserve(AllMembers = true)] 22 | public class GMMultiImpagePickerImplementation : IGMMultiImagePicker 23 | { 24 | private int GetRequestId() 25 | { 26 | var id = _requestId; 27 | if (_requestId == int.MaxValue) 28 | _requestId = 0; 29 | else 30 | _requestId++; 31 | return id; 32 | } 33 | 34 | private int _requestId; 35 | private TaskCompletionSource> _completionSource; 36 | 37 | /// 38 | /// Called if the images are not modified. 39 | /// 40 | /// 41 | public Task> PickMultiImage() 42 | { 43 | var id = GetRequestId(); 44 | 45 | var ntcs = new TaskCompletionSource>(id); 46 | if (Interlocked.CompareExchange(ref _completionSource, ntcs, null) != null) 47 | { 48 | #if DEBUG 49 | throw new InvalidOperationException("Only one operation can be active at a time"); 50 | #else 51 | return null; 52 | #endif 53 | } 54 | 55 | //init media picker without high quality format. 56 | ShowImagePicker(false); 57 | return _completionSource.Task; 58 | } 59 | 60 | /// 61 | /// Called if the images are modified. 62 | /// 63 | /// 64 | public Task> PickMultiImage(bool needsHighQuality) 65 | { 66 | var id = GetRequestId(); 67 | 68 | var ntcs = new TaskCompletionSource>(id); 69 | if (Interlocked.CompareExchange(ref _completionSource, ntcs, null) != null) 70 | { 71 | #if DEBUG 72 | throw new InvalidOperationException("Only one operation can be active at a time"); 73 | #else 74 | return null; 75 | #endif 76 | } 77 | 78 | //init media picker with high quality format. 79 | ShowImagePicker(needsHighQuality); 80 | return _completionSource.Task; 81 | } 82 | 83 | private PHAsset[] _preselectedAssets; 84 | 85 | public void ShowImagePicker(bool needsHighQuality) 86 | { 87 | //Create the image gallery picker. 88 | var picker = new GMImagePickerController 89 | { 90 | Title = "Select Photo", 91 | CustomDoneButtonTitle = "Finished", 92 | CustomCancelButtonTitle = "Cancel", 93 | ColsInPortrait = 4, 94 | ColsInLandscape = 7, 95 | MinimumInteritemSpacing = 2.0f, 96 | DisplaySelectionInfoToolbar = true, 97 | AllowsMultipleSelection = true, 98 | ShowCameraButton = true, 99 | AutoSelectCameraImages = true, 100 | ModalPresentationStyle = UIModalPresentationStyle.Popover, 101 | MediaTypes = new[] { PHAssetMediaType.Image }, 102 | CustomSmartCollections = new[] 103 | { 104 | PHAssetCollectionSubtype.SmartAlbumUserLibrary, 105 | PHAssetCollectionSubtype.AlbumRegular 106 | }, 107 | NavigationBarTextColor = Color.White.ToUIColor(), 108 | NavigationBarBarTintColor = Color.FromHex("#c5dd36").ToUIColor(), 109 | PickerTextColor = Color.Black.ToUIColor(), 110 | ToolbarTextColor = Color.FromHex("#c5dd36").ToUIColor(), 111 | NavigationBarTintColor = Color.White.ToUIColor() 112 | }; 113 | 114 | //Set a limit on the number of photos the user can select. I use 12 selected photos beause of memory limitations on iOS. 115 | picker.ShouldSelectAsset += (sender, args) => args.Cancel = picker.SelectedAssets.Count > 11; 116 | 117 | // select image handler 118 | GMImagePickerController.MultiAssetEventHandler[] handler = { null }; 119 | //cancel handler 120 | EventHandler[] cancelHandler = { null }; 121 | 122 | //define the handler 123 | handler[0] = (sender, args) => 124 | { 125 | var tcs = Interlocked.Exchange(ref _completionSource, null); 126 | picker.FinishedPickingAssets -= handler[0]; 127 | picker.Canceled -= cancelHandler[0]; 128 | System.Diagnostics.Debug.WriteLine("User finished picking assets. {0} items selected.", args.Assets.Length); 129 | var imageManager = new PHImageManager(); 130 | var RequestImageOption = new PHImageRequestOptions(); 131 | 132 | if (needsHighQuality) 133 | { 134 | RequestImageOption.DeliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat; 135 | } 136 | else 137 | { 138 | RequestImageOption.DeliveryMode = PHImageRequestOptionsDeliveryMode.FastFormat; 139 | } 140 | 141 | RequestImageOption.ResizeMode = PHImageRequestOptionsResizeMode.Fast; 142 | RequestImageOption.NetworkAccessAllowed = true; 143 | RequestImageOption.Synchronous = false; 144 | _preselectedAssets = args.Assets; 145 | if (!_preselectedAssets.Any()) 146 | { 147 | //no image selected 148 | tcs.TrySetResult(null); 149 | } 150 | else 151 | { 152 | var images = new List(); 153 | var documentsDirectory = Environment.GetFolderPath 154 | (Environment.SpecialFolder.Personal); 155 | int cnt = 1; 156 | foreach (var asset in _preselectedAssets) 157 | { 158 | DispatchQueue.MainQueue.DispatchAsync(() => 159 | { 160 | //For each image, create a file path for it. 161 | imageManager.RequestImageForAsset(asset, 162 | PHImageManager.MaximumSize, 163 | PHImageContentMode.Default, 164 | RequestImageOption, 165 | (image, info) => 166 | { 167 | using (NSAutoreleasePool autoreleasePool = new NSAutoreleasePool()) 168 | { 169 | System.Diagnostics.Debug.WriteLine("Total memory being used: {0}", GC.GetTotalMemory(false)); 170 | var filename = Guid.NewGuid().ToString(); 171 | System.Diagnostics.Debug.WriteLine("filename: " + filename); 172 | string filepath = Save(image, filename.ToString(), documentsDirectory); 173 | System.Diagnostics.Debug.WriteLine("filepath: " + filepath); 174 | images.Add(filepath); 175 | 176 | //When we are on the last image, send the images to the carousel view. 177 | if (cnt == args.Assets.Length) 178 | { 179 | Device.BeginInvokeOnMainThread(() => 180 | { 181 | MessagingCenter.Send>((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS", images); 182 | }); 183 | } 184 | cnt++; 185 | 186 | //Dispose of objects and call the garbage collector. 187 | asset.Dispose(); 188 | autoreleasePool.Dispose(); 189 | GC.Collect(); 190 | } 191 | }); 192 | }); 193 | } 194 | tcs.TrySetResult(images); 195 | } 196 | }; 197 | picker.FinishedPickingAssets += handler[0]; 198 | 199 | cancelHandler[0] = (sender, args) => 200 | { 201 | var tcs = Interlocked.Exchange(ref _completionSource, null); 202 | picker.FinishedPickingAssets -= handler[0]; 203 | picker.Canceled -= cancelHandler[0]; 204 | tcs.TrySetResult(null); 205 | }; 206 | picker.Canceled += cancelHandler[0]; 207 | 208 | //show picker 209 | picker.PresentUsingRootViewController(); 210 | } 211 | 212 | string Save(UIImage origImage, string name, string documentsDirectory) 213 | { 214 | var compressionQuality = 0.46f; 215 | string jpgFilename = System.IO.Path.Combine(documentsDirectory, name); 216 | var resizedImage = MaxResizeImage(origImage, 1920f, 1080f); 217 | NSData imgData = resizedImage.AsJPEG(compressionQuality); 218 | NSError err = null; 219 | if (imgData.Save(jpgFilename, NSDataWritingOptions.Atomic, out err)) 220 | { 221 | //Dispose of objects. 222 | origImage.Dispose(); 223 | resizedImage.Dispose(); 224 | imgData.Dispose(); 225 | return jpgFilename; 226 | } 227 | else 228 | { 229 | Console.WriteLine("NOT saved as " + jpgFilename + " because" + err.LocalizedDescription); 230 | return null; 231 | } 232 | } 233 | 234 | UIImage MaxResizeImage(UIImage sourceImage, float maxWidth, float maxHeight) 235 | { 236 | var sourceSize = sourceImage.Size; 237 | var maxResizeFactor = Math.Max(maxWidth / sourceSize.Width, maxHeight / sourceSize.Height); 238 | if (maxResizeFactor > 1) return sourceImage; 239 | var width = maxResizeFactor * sourceSize.Width; 240 | var height = maxResizeFactor * sourceSize.Height; 241 | UIGraphics.BeginImageContext(new System.Drawing.SizeF((float)width, (float)height)); 242 | sourceImage.Draw(new System.Drawing.RectangleF(0, 0, (float)width, (float)height)); 243 | var resultImage = UIGraphics.GetImageFromCurrentImageContext(); 244 | UIGraphics.EndImageContext(); 245 | return resultImage; 246 | } 247 | 248 | /// 249 | /// Call this when you want to delete our temporary images. 250 | /// Recommendation: Call this after successfully uploading images to Azure Blob Storage. 251 | /// 252 | void IGMMultiImagePicker.ClearFileDirectory() 253 | { 254 | var directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); 255 | var list = Directory.GetFiles(directory, "*"); 256 | 257 | if (Directory.Exists(directory)) 258 | { 259 | if (list.Length > 0) 260 | { 261 | for (int i = 0; i < list.Length; i++) 262 | { 263 | File.Delete(list[i]); 264 | } 265 | } 266 | } 267 | } 268 | 269 | /* 270 | Example of how to call ClearFileDirectory(): 271 | 272 | if (Device.RuntimePlatform == Device.Android) 273 | { 274 | DependencyService.Get().ClearFileDirectory(); 275 | } 276 | if (Device.RuntimePlatform == Device.iOS) 277 | { 278 | GMMultiImagePicker.Current.ClearFileDirectory(); 279 | } 280 | 281 | */ 282 | } 283 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UISupportedInterfaceOrientations 11 | 12 | UIInterfaceOrientationPortrait 13 | UIInterfaceOrientationLandscapeLeft 14 | UIInterfaceOrientationLandscapeRight 15 | 16 | UISupportedInterfaceOrientations~ipad 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationPortraitUpsideDown 20 | UIInterfaceOrientationLandscapeLeft 21 | UIInterfaceOrientationLandscapeRight 22 | 23 | MinimumOSVersion 24 | 8.0 25 | CFBundleDisplayName 26 | MultiImagePicker 27 | CFBundleIdentifier 28 | com.companyname.MultiImagePicker 29 | CFBundleVersion 30 | 1.0 31 | UILaunchStoryboardName 32 | LaunchScreen 33 | CFBundleName 34 | MultiImagePicker 35 | XSAppIconAssets 36 | Assets.xcassets/AppIcon.appiconset 37 | NSCameraUsageDescription 38 | This app needs access to the camera to take photos. 39 | NSPhotoLibraryUsageDescription 40 | This app needs access to photos. 41 | NSMicrophoneUsageDescription 42 | This app needs access to microphone. 43 | NSPhotoLibraryAddUsageDescription 44 | This app needs access to the photo gallery. 45 | 46 | 47 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace MultiImagePicker.iOS 9 | { 10 | public class Application 11 | { 12 | // This is the main entry point of the application. 13 | static void Main(string[] args) 14 | { 15 | // if you want to use a different Application Delegate class from "AppDelegate" 16 | // you can specify it here. 17 | UIApplication.Main(args, null, "AppDelegate"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/MessagingExtensions.cs: -------------------------------------------------------------------------------- 1 | using Photos; 2 | using System; 3 | using System.IO; 4 | using UIKit; 5 | using Xamarin.Forms; 6 | 7 | #if __UNIFIED__ 8 | 9 | #else 10 | using MonoTouch.UIKit; 11 | #endif 12 | 13 | namespace MultiImagePicker.iOS 14 | { 15 | internal static class MessagingExtensions 16 | { 17 | #region Methods 18 | /// 19 | /// show view controller via extension. 20 | /// 21 | /// 22 | public static void PresentUsingRootViewController(this UIViewController controller) 23 | { 24 | if (controller == null) 25 | #if DEBUG 26 | throw new ArgumentNullException(nameof(controller)); 27 | #else 28 | return; 29 | #endif 30 | var visibleViewController = GetVisibleViewController(null); 31 | visibleViewController?.PresentViewController(controller, true, null); 32 | } 33 | 34 | public static void DissmissUsingRootViewController(this UIViewController controller) 35 | { 36 | var visibleViewController = GetVisibleViewController(null); 37 | visibleViewController?.DismissModalViewController(true); 38 | } 39 | 40 | public static UIViewController GetVisibleViewController(UIViewController controller) 41 | { 42 | if (controller == null) 43 | { 44 | controller = UIApplication.SharedApplication.KeyWindow.RootViewController; 45 | } 46 | 47 | if (controller?.NavigationController?.VisibleViewController != null) 48 | { 49 | return controller.NavigationController.VisibleViewController; 50 | } 51 | 52 | if (controller != null && (controller.IsViewLoaded && controller.View?.Window != null)) 53 | { 54 | return controller; 55 | } 56 | 57 | if (controller != null) 58 | { 59 | foreach (var childViewController in controller.ChildViewControllers) 60 | { 61 | var foundVisibleViewController = GetVisibleViewController(childViewController); 62 | if (foundVisibleViewController == null) 63 | continue; 64 | 65 | return foundVisibleViewController; 66 | } 67 | } 68 | return GetVisibleViewController(controller.PresentedViewController); 69 | } 70 | 71 | public static ImageSource GetImageSourceFromUIImage(this UIImage uiImage) 72 | { 73 | try 74 | { 75 | return uiImage == null ? null : ImageSource.FromStream(() => uiImage.AsJPEG().AsStream()); 76 | } 77 | catch (Exception e) 78 | { 79 | Console.WriteLine(e); 80 | return null; 81 | } 82 | } 83 | 84 | public static Stream GetImageStreamFromUIImage(this UIImage uiImage) 85 | { 86 | try 87 | { 88 | return uiImage == null ? null : uiImage.AsJPEG().AsStream(); 89 | } 90 | catch (Exception e) 91 | { 92 | Console.WriteLine(e); 93 | return null; 94 | } 95 | } 96 | 97 | #endregion 98 | } 99 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/MultiImagePicker.iOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | iPhoneSimulator 6 | 8.0.30703 7 | 2.0 8 | {24374527-06CD-4BE8-A5FC-A5C64662FC8D} 9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | {6143fdea-f3c2-4a09-aafa-6e230626515e} 11 | Exe 12 | MultiImagePicker.iOS 13 | Resources 14 | MultiImagePicker.iOS 15 | true 16 | NSUrlSessionHandler 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\iPhoneSimulator\Debug 23 | DEBUG 24 | prompt 25 | 4 26 | false 27 | x86_64 28 | None 29 | true 30 | 31 | 32 | none 33 | true 34 | bin\iPhoneSimulator\Release 35 | prompt 36 | 4 37 | None 38 | x86_64 39 | false 40 | 41 | 42 | true 43 | full 44 | false 45 | bin\iPhone\Debug 46 | DEBUG 47 | prompt 48 | 4 49 | false 50 | ARM64 51 | iPhone Developer 52 | true 53 | Entitlements.plist 54 | 55 | 56 | none 57 | true 58 | bin\iPhone\Release 59 | prompt 60 | 4 61 | ARM64 62 | false 63 | iPhone Developer 64 | Entitlements.plist 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | false 79 | 80 | 81 | false 82 | 83 | 84 | false 85 | 86 | 87 | false 88 | 89 | 90 | false 91 | 92 | 93 | false 94 | 95 | 96 | false 97 | 98 | 99 | false 100 | 101 | 102 | false 103 | 104 | 105 | false 106 | 107 | 108 | false 109 | 110 | 111 | false 112 | 113 | 114 | false 115 | 116 | 117 | false 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 5.2.0 131 | 132 | 133 | 2.3.4 134 | 135 | 136 | 11.0.0 137 | 138 | 139 | 4.0.1.5 140 | 141 | 142 | 2.4.11.982 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | {05BFA12E-18E5-43DE-B8A5-5590728BEC94} 151 | MultiImagePicker 152 | 153 | 154 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MultiImagePicker.iOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MultiImagePicker.iOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Resources/Default-Portrait.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Resources/Default-Portrait@2x.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Resources/Default.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkon96/MultiImagePicker/9e45ab5bc5906c10d533607537c1784101539734/MultiImagePicker/MultiImagePicker.iOS/Resources/Default@2x.png -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker.iOS/Resources/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xamarin.Forms; 3 | using Xamarin.Forms.Xaml; 4 | 5 | namespace MultiImagePicker 6 | { 7 | public partial class App : Application 8 | { 9 | public App() 10 | { 11 | InitializeComponent(); 12 | 13 | MainPage = new ImageSelectionPage(); 14 | } 15 | 16 | protected override void OnStart() 17 | { 18 | // Handle when your app starts 19 | } 20 | 21 | protected override void OnSleep() 22 | { 23 | // Handle when your app sleeps 24 | } 25 | 26 | protected override void OnResume() 27 | { 28 | // Handle when your app resumes 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms.Xaml; 2 | 3 | [assembly: XamlCompilation(XamlCompilationOptions.Compile)] -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImagePickers/Android/ICompressImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MultiImagePicker 6 | { 7 | /// 8 | /// Code implementation found in Android Project -> ImageHelpers.cs 9 | /// 10 | public interface ICompressImages 11 | { 12 | string CompressImage(string path); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImagePickers/Android/IMediaService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace MultiImagePicker.Services 6 | { 7 | /// 8 | /// Code implementation found in Android Project -> MediaService.cs 9 | /// 10 | public interface IMediaService 11 | { 12 | void OpenGallery(); 13 | void ClearFileDirectory(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImagePickers/iOS/GMMultiImagePicker.cs: -------------------------------------------------------------------------------- 1 | using MultiImagePicker; 2 | using System; 3 | using Xamarin.Forms; 4 | 5 | namespace MultiImagePicker 6 | { 7 | /* 8 | how to use in Xamarin project: 9 | 10 | var result = await GMMultiImagePicker.Current.PickMultiImage(); 11 | */ 12 | public class GMMultiImagePicker 13 | { 14 | private static readonly Lazy Implementation = new Lazy(CreateModalView, 15 | System.Threading.LazyThreadSafetyMode.PublicationOnly); 16 | 17 | /// 18 | /// Current settings to use 19 | /// 20 | public static IGMMultiImagePicker Current 21 | { 22 | get 23 | { 24 | var ret = Implementation.Value; 25 | if (ret == null) 26 | { 27 | throw NotImplementedInReferenceAssembly(); 28 | } 29 | return ret; 30 | } 31 | } 32 | private static IGMMultiImagePicker CreateModalView() 33 | { 34 | #if PORTABLE 35 | return null; 36 | #else 37 | return DependencyService.Get(); 38 | #endif 39 | } 40 | 41 | internal static Exception NotImplementedInReferenceAssembly() 42 | { 43 | return 44 | new NotImplementedException( 45 | "This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation."); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImagePickers/iOS/IGMMultiImagePicker.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace MultiImagePicker 5 | { 6 | /// 7 | /// Code implementation found in iOS Project -> MultiMediaChooserPickerImplementation.cs 8 | /// 9 | public interface IGMMultiImagePicker 10 | { 11 | Task> PickMultiImage(); 12 | Task> PickMultiImage(bool needsHighQuality); 13 | void ClearFileDirectory(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImageSelectionPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 11 | 12 | 13 | 14 | 20 | 21 | 24 | 27 | 30 | 31 | 39 | 40 | 41 | 42 | 43 | 44 | 74 | 75 | -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/ImageSelectionPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Azure.Storage; 2 | using Microsoft.Azure.Storage.Blob; 3 | using MultiImagePicker.Services; 4 | using Plugin.Media; 5 | using Plugin.Permissions; 6 | using Plugin.Permissions.Abstractions; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Threading.Tasks; 10 | using Xamarin.Forms; 11 | using Xamarin.Forms.Xaml; 12 | 13 | namespace MultiImagePicker 14 | { 15 | [XamlCompilation(XamlCompilationOptions.Compile)] 16 | public partial class ImageSelectionPage : ContentPage 17 | { 18 | public ImageSelectionPage() 19 | { 20 | InitializeComponent(); 21 | Device.BeginInvokeOnMainThread(async () => await AskForPermissions() ); 22 | } 23 | 24 | private async void SelectImagesButton_Clicked(object sender, EventArgs e) 25 | { 26 | //Check users permissions. 27 | var storagePermissions = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); 28 | var photoPermissions = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Photos); 29 | if (storagePermissions == PermissionStatus.Granted && photoPermissions == PermissionStatus.Granted) 30 | { 31 | //If we are on iOS, call GMMultiImagePicker. 32 | if (Device.RuntimePlatform == Device.iOS) 33 | { 34 | //If the image is modified (drawings, etc) by the users, you will need to change the delivery mode to HighQualityFormat. 35 | bool imageModifiedWithDrawings = false; 36 | if (imageModifiedWithDrawings) 37 | { 38 | await GMMultiImagePicker.Current.PickMultiImage(true); 39 | } 40 | else 41 | { 42 | await GMMultiImagePicker.Current.PickMultiImage(); 43 | } 44 | 45 | MessagingCenter.Unsubscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS"); 46 | MessagingCenter.Subscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS", (s, images) => 47 | { 48 | //If we have selected images, put them into the carousel view. 49 | if (images.Count > 0) 50 | { 51 | ImgCarouselView.ItemsSource = images; 52 | InfoText.IsVisible = true; //InfoText is optional 53 | } 54 | }); 55 | } 56 | //If we are on Android, call IMediaService. 57 | else if (Device.RuntimePlatform == Device.Android) 58 | { 59 | DependencyService.Get().OpenGallery(); 60 | 61 | MessagingCenter.Unsubscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid"); 62 | MessagingCenter.Subscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", (s, images) => 63 | { 64 | //If we have selected images, put them into the carousel view. 65 | if (images.Count > 0) 66 | { 67 | ImgCarouselView.ItemsSource = images; 68 | InfoText.IsVisible = true; //InfoText is optional 69 | } 70 | }); 71 | } 72 | } 73 | else 74 | { 75 | await DisplayAlert("Permission Denied!", "\nPlease go to your app settings and enable permissions.", "Ok"); 76 | } 77 | } 78 | 79 | private async void UploadImagesButton_Clicked(object sender, EventArgs e) 80 | { 81 | // Get the list of images we have selected. 82 | List imagePaths = ImgCarouselView.ItemsSource as List; 83 | 84 | // If user is using Android, compress the images. (Optional) 85 | if (Device.RuntimePlatform == Device.Android) 86 | { 87 | imagePaths = CompressAllImages(imagePaths); 88 | } 89 | 90 | // Retrieve storage account from connection string. 91 | CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=your_account_name_here;AccountKey=your_account_key_here"); 92 | 93 | // Create the blob client. 94 | CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 95 | 96 | // Retrieve reference to a previously created container. 97 | CloudBlobContainer container = blobClient.GetContainerReference("multiimagepickercontainer"); 98 | 99 | // Create the container if it doesn't already exist. 100 | await container.CreateIfNotExistsAsync(); 101 | 102 | // Set the container access permissions (Optional) 103 | BlobContainerPermissions blobPermissions = new BlobContainerPermissions(); 104 | blobPermissions.PublicAccess = BlobContainerPublicAccessType.Blob; 105 | await container.SetPermissionsAsync(blobPermissions); 106 | 107 | // Change info text. (Optional) 108 | InfoText.Text = "Uploading to Azure Blob Storage..."; 109 | 110 | // Upload all the selected images to Azure Blob Storage. 111 | int count = 1; 112 | foreach (string img in imagePaths) 113 | { 114 | // Retrieve reference to a blob named "newphoto#.jpg". 115 | CloudBlockBlob blockBlob = container.GetBlockBlobReference("newphoto" + count + ".jpg"); 116 | 117 | // Create the "newphoto#.jpg" blob with the current image in our list. 118 | await blockBlob.UploadFromFileAsync(img); 119 | 120 | count++; 121 | } 122 | 123 | // Change info text. (Optional) 124 | InfoText.Text = "Upload complete."; 125 | 126 | // Clear temp files after upload. 127 | if (Device.RuntimePlatform == Device.Android) 128 | { 129 | DependencyService.Get().ClearFileDirectory(); 130 | } 131 | if (Device.RuntimePlatform == Device.iOS) 132 | { 133 | GMMultiImagePicker.Current.ClearFileDirectory(); 134 | } 135 | } 136 | 137 | /// 138 | /// Compress Android images before uploading them to Azure Blob Storage. 139 | /// 140 | /// 141 | /// 142 | private List CompressAllImages(List totalImages) 143 | { 144 | int displayCount = 1; 145 | int totalCount = totalImages.Count; 146 | List compressedImages = new List(); 147 | foreach (string path in totalImages) 148 | { 149 | compressedImages.Add(DependencyService.Get().CompressImage(path)); 150 | displayCount++; 151 | } 152 | return compressedImages; 153 | } 154 | 155 | /// 156 | /// Make sure Permissions are given to the users storage. 157 | /// 158 | /// 159 | private async Task AskForPermissions() 160 | { 161 | try 162 | { 163 | await CrossMedia.Current.Initialize(); 164 | 165 | var storagePermissions = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); 166 | var photoPermissions = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Photos); 167 | if (storagePermissions != PermissionStatus.Granted || photoPermissions != PermissionStatus.Granted) 168 | { 169 | var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage, Permission.Photos }); 170 | storagePermissions = results[Permission.Storage]; 171 | photoPermissions = results[Permission.Photos]; 172 | } 173 | 174 | if (storagePermissions != PermissionStatus.Granted || photoPermissions != PermissionStatus.Granted) 175 | { 176 | await DisplayAlert("Permissions Denied!", "Please go to your app settings and enable permissions.", "Ok"); 177 | return false; 178 | } 179 | else 180 | { 181 | return true; 182 | } 183 | } 184 | catch (Exception ex) 185 | { 186 | System.Diagnostics.Debug.WriteLine("error. permissions not set. here is the stacktrace: \n" + ex.StackTrace); 187 | return false; 188 | } 189 | } 190 | 191 | /// 192 | /// Unsubsribe from the MessagingCenter on disappearing. 193 | /// 194 | protected override void OnDisappearing() 195 | { 196 | base.OnDisappearing(); 197 | MessagingCenter.Unsubscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid"); 198 | MessagingCenter.Unsubscribe>((App)Xamarin.Forms.Application.Current, "ImagesSelectediOS"); 199 | GC.Collect(); 200 | } 201 | } 202 | } -------------------------------------------------------------------------------- /MultiImagePicker/MultiImagePicker/MultiImagePicker.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | pdbonly 10 | true 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MultiImagePicker 2 | How to select multiple images using Xamarin Forms. 3 | 4 | 5 | Preview on Android (Functionality is the same on iOS): 6 | 7 | ![](https://i.imgur.com/drun9eZ.gif) 8 | 9 | 10 | ## Disclaimer 11 | 12 | You have the permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. The software is provided "as is" and the author disclaims all warranties with regard to this software including all implied warranties of merchantability and fitness. in no event shall the author be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software. 13 | --------------------------------------------------------------------------------