Update flutter_photo_manager
This commit is contained in:
parent
3bf844f834
commit
fa8b26b155
255 changed files with 19640 additions and 6 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
|||
[submodule "thirdparty/flutter_photo_manager"]
|
||||
path = thirdparty/flutter_photo_manager
|
||||
url = https://github.com/vishnukvmd/flutter_photo_manager
|
||||
url = https://github.com/ente-io/flutter_photo_manager
|
||||
branch = master
|
||||
[submodule "thirdparty/extended_image"]
|
||||
path = thirdparty/extended_image
|
||||
|
|
|
@ -630,10 +630,10 @@ packages:
|
|||
photo_manager:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: photo_manager
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
path: "thirdparty/flutter_photo_manager"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.2.2"
|
||||
photo_view:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -23,7 +23,8 @@ dependencies:
|
|||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.0
|
||||
photo_manager: ^1.0.6
|
||||
photo_manager:
|
||||
path: thirdparty/flutter_photo_manager
|
||||
provider: ^3.1.0
|
||||
sqflite: ^2.0.0+3
|
||||
sqflite_migration: ^0.3.0
|
||||
|
|
4
thirdparty/flutter_photo_manager/.gitattributes
vendored
Normal file
4
thirdparty/flutter_photo_manager/.gitattributes
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
*.m linguist-language=dart
|
||||
*.h linguist-language=dart
|
||||
*.java linguist-language=dart
|
||||
*.kt linguist-language=dart
|
43
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
43
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Flutter version**
|
||||
<!--
|
||||
use flutter doctor -v to get version
|
||||
-->
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Log**
|
||||
|
||||
If applicable, add logs to help explain your problem.
|
||||
|
||||
```bash
|
||||
|
||||
```
|
20
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[Feature]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
15
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/how-to-use-it.md
vendored
Normal file
15
thirdparty/flutter_photo_manager/.github/ISSUE_TEMPLATE/how-to-use-it.md
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
name: How to use it
|
||||
about: If you have questions about how to use it, or other questions, you can use
|
||||
this
|
||||
title: "[Custom]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Expect
|
||||
What you want to achieve
|
||||
|
||||
## ScreenShots
|
||||
Screenshots showing the purpose.
|
40
thirdparty/flutter_photo_manager/.github/workflows/pr.yml
vendored
Normal file
40
thirdparty/flutter_photo_manager/.github/workflows/pr.yml
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
name: CI
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
test_iOS:
|
||||
name: Test iOS on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: "12.x"
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: beta
|
||||
- run: flutter pub get
|
||||
- run: flutter analyze lib example/lib
|
||||
- run: cd example ; flutter build ios --no-codesign
|
||||
test_android:
|
||||
name: Test android on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: "12.x"
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: beta
|
||||
- run: flutter pub get
|
||||
- run: flutter analyze lib example/lib
|
||||
- run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;20.0.5594570"
|
||||
- run: cd example; flutter build apk --debug
|
22
thirdparty/flutter_photo_manager/.github/workflows/publish.yml
vendored
Normal file
22
thirdparty/flutter_photo_manager/.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Publish to pub
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Publish
|
||||
uses: sakebook/actions-flutter-pub-publisher@v1.3.1
|
||||
with:
|
||||
credential: ${{ secrets.CREDENTIAL_JSON }}
|
||||
flutter_package: false
|
||||
skip_test: true
|
||||
dry_run: false
|
17
thirdparty/flutter_photo_manager/.gitignore
vendored
Normal file
17
thirdparty/flutter_photo_manager/.gitignore
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
pubspec.lock
|
||||
|
||||
build/
|
||||
.idea/
|
||||
|
||||
fvm
|
||||
.vscode/settings.json
|
||||
|
||||
android/.settings/org.eclipse.buildship.core.prefs
|
||||
doc/
|
||||
|
||||
.env
|
20
thirdparty/flutter_photo_manager/.vscode/launch.json
vendored
Normal file
20
thirdparty/flutter_photo_manager/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Flutter",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "example/lib/main.dart"
|
||||
},
|
||||
{
|
||||
"name": "Flutter-attach",
|
||||
"request": "attach",
|
||||
"type": "dart",
|
||||
"program": "example/lib/main.dart"
|
||||
}
|
||||
]
|
||||
}
|
451
thirdparty/flutter_photo_manager/CHANGELOG.md
vendored
Normal file
451
thirdparty/flutter_photo_manager/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,451 @@
|
|||
# CHANGELOG
|
||||
|
||||
- [CHANGELOG](#changelog)
|
||||
- [1.2.2](#122)
|
||||
- [1.2.1](#121)
|
||||
- [1.2.0](#120)
|
||||
- [1.1.6](#116)
|
||||
- [1.1.5](#115)
|
||||
- [1.1.4](#114)
|
||||
- [1.1.3](#113)
|
||||
- [1.1.2](#112)
|
||||
- [1.1.1](#111)
|
||||
- [1.1.0](#110)
|
||||
- [1.0.6](#106)
|
||||
- [1.0.4](#104)
|
||||
- [1.0.3](#103)
|
||||
- [1.0.2](#102)
|
||||
- [1.0.1](#101)
|
||||
- [1.0.0](#100)
|
||||
- [0.6.0](#060)
|
||||
- [0.5.8](#058)
|
||||
- [0.5.7](#057)
|
||||
- [0.5.6](#056)
|
||||
- [0.5.5+1](#0551)
|
||||
- [0.5.5](#055)
|
||||
- [0.5.4](#054)
|
||||
- [0.5.3+1](#0531)
|
||||
- [0.5.3](#053)
|
||||
- [0.5.2](#052)
|
||||
- [0.5.1](#051)
|
||||
- [0.5.0](#050)
|
||||
- [0.4.8](#048)
|
||||
- [0.4.7](#047)
|
||||
- [0.4.6](#046)
|
||||
- [0.4.5](#045)
|
||||
- [0.4.4](#044)
|
||||
- [0.4.3](#043)
|
||||
- [0.4.2](#042)
|
||||
- [0.4.1](#041)
|
||||
- [0.4.0](#040)
|
||||
- [0.3.5](#035)
|
||||
- [0.3.4](#034)
|
||||
- [0.3.3](#033)
|
||||
- [0.3.2](#032)
|
||||
- [0.3.1](#031)
|
||||
- [0.3.0](#030)
|
||||
- [0.2.1](#021)
|
||||
- [0.2.0](#020)
|
||||
- [0.1.10](#0110)
|
||||
- [0.1.9](#019)
|
||||
- [0.1.8 sort asset by data](#018-sort-asset-by-data)
|
||||
- [0.1.7 fix bug](#017-fix-bug)
|
||||
- [0.1.6](#016)
|
||||
- [0.1.5](#015)
|
||||
- [0.1.4 fix bug](#014-fix-bug)
|
||||
- [0.1.3 add params](#013-add-params)
|
||||
- [0.1.2 fix bug](#012-fix-bug)
|
||||
- [0.1.1 fix ios video](#011-fix-ios-video)
|
||||
- [0.1.0 support video](#010-support-video)
|
||||
- [0.0.3 fix bug](#003-fix-bug)
|
||||
- [0.0.2 update readme](#002-update-readme)
|
||||
- [0.0.1](#001)
|
||||
|
||||
## 1.2.2
|
||||
|
||||
Fix:
|
||||
- Add request permissions result listener when activity re-attached. [#515](../../pull/515)
|
||||
|
||||
## 1.2.1
|
||||
|
||||
Fix:
|
||||
- An error of iOS. See [#509](../../pull/509), [#510](../../pull/510).
|
||||
|
||||
## 1.2.0
|
||||
|
||||
Feature:
|
||||
- Add requestPermissionExtend code to support iOS 14 permission.
|
||||
- Add update limited photos method for iOS 14.
|
||||
|
||||
Fix:
|
||||
- Permissions dialog of launch on old iOS versions. [#503](../../pull/503)
|
||||
|
||||
## 1.1.6
|
||||
|
||||
The MEDIA_LOCATION permission of android can be removed through configuration.
|
||||
|
||||
## 1.1.5
|
||||
|
||||
Revert [#478](../../pull/478)
|
||||
|
||||
Fix:
|
||||
- Thumb size of the entity on iOS/macOS.
|
||||
|
||||
## 1.1.4
|
||||
|
||||
Merged [#478](../../pull/478)
|
||||
|
||||
## 1.1.3
|
||||
|
||||
Merged the code of macos and ios.
|
||||
|
||||
## 1.1.2
|
||||
|
||||
- Updated the code in the macOS part.
|
||||
|
||||
## 1.1.1
|
||||
|
||||
- Fix: `thumbWithSize` of `AssetEntity`.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Feature: `modified` of `AssetPathEntity`.
|
||||
- Feature: Update constructor of `FilterOptionGroup`.
|
||||
|
||||
- Fix: Order option of the `FilterOptionGroup`.
|
||||
|
||||
## 1.0.6
|
||||
|
||||
- Add relative path when saving files to the MediaStore on Android 29+ (#462)
|
||||
- Fix deleteWithIds typecast issue with Android 29- (#460)
|
||||
|
||||
## 1.0.4
|
||||
|
||||
- Add mime type for android.
|
||||
|
||||
## 1.0.3
|
||||
|
||||
- Fix serious code usage issue in convert utils.
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- Improve the constructor for `AssetEntity`.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Fix
|
||||
- orientation bug.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
Breaking change:
|
||||
- Migrate to null safety.
|
||||
- Correct type in `PMRequestState` .
|
||||
|
||||
## 0.6.0
|
||||
|
||||
- Feature
|
||||
- Support android API 30.
|
||||
- Support show empty album in iOS([#365](../../issues/365)).
|
||||
- User can ignore check permission(User can choose favorite permission plugin, but at the same time user have to bear the risks corresponding to the permission).
|
||||
- Support clean file cache.
|
||||
- Experimental
|
||||
- Preload image (Use `PhotoCachingManager` api.)
|
||||
- Add `OrderOption` as sort condition. The option default value is order by create date desc;
|
||||
- Support icloud asset progress.
|
||||
|
||||
- Fixes
|
||||
- [#362](../../issues/362)
|
||||
- Delete assets in androidQ.
|
||||
- Edited image data in iOS.
|
||||
- Fix delete error in androidR.
|
||||
|
||||
Breaking change:
|
||||
|
||||
- Feature
|
||||
- Support multiple sorting conditions, and the `asc` of `DateTimeCond` is removed.
|
||||
|
||||
## 0.5.8
|
||||
|
||||
Fix:
|
||||
|
||||
Delete assets in androidQ.
|
||||
|
||||
## 0.5.7
|
||||
|
||||
Fix:
|
||||
- Audio asset error for androidQ. See [#340](../../issues/340) [#341](../../pull/341).
|
||||
|
||||
## 0.5.6
|
||||
|
||||
Fix save image with path for android.
|
||||
|
||||
## 0.5.5+1
|
||||
|
||||
Remove verbose log.
|
||||
|
||||
## 0.5.5
|
||||
|
||||
Add `merge` for `FilterOptionGroup` and `FilterOption` .
|
||||
|
||||
## 0.5.4
|
||||
|
||||
Add `copyWith` for `FilterOption` .
|
||||
|
||||
## 0.5.3+1
|
||||
|
||||
Support android v2 model.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
Fix:
|
||||
|
||||
- Cannot get audio problem in androidQ.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
Support MacOS
|
||||
|
||||
From the version, Starting from this version, 1.9 or earlier versions are not supported.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
Feature:
|
||||
- Save image asset with file path.
|
||||
- Copy asset to another album.
|
||||
- Create AssetEntity with id.
|
||||
- Create AssetPathEntity from id.
|
||||
- Only iOS
|
||||
- Create folder or album.
|
||||
- Remove assets in album.
|
||||
- Delete folder or album.
|
||||
- Favorite asset.
|
||||
- Only android
|
||||
- move asset to another path.
|
||||
- Remove all non-existing rows.
|
||||
- add `relativePath` for android.
|
||||
|
||||
Fix:
|
||||
- Problem of AssetPathEntity.refreshPathProperties.
|
||||
- Open setting in iOS.
|
||||
- Edited asset in iOS.
|
||||
- Audio properties of FilterOption.
|
||||
- Android onlyAll assetCount bug.
|
||||
|
||||
Change:
|
||||
|
||||
- Modified `AssetEntity.file`'s behavior on iOS, currently it will return a picture in jpg format instead of heic/gif/png. Now more in line with the description in the doc, this is suitable for uploading images (theoretically, no Exif information will be included).
|
||||
- Update android change media url from file scheme to content scheme.
|
||||
- Clean up some unused code.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
Feature:
|
||||
- Add `getSubPathEntities` for `AssetPathEntity`.
|
||||
- Add `quality` for `AssetEntity.thumbDataWithSize`.
|
||||
- Add `orientation` for `AssetEntity`.
|
||||
- Add `onlyAll` for `getAssetPathList`.
|
||||
- Support audio type(Only android, iOS Photos have no audio)
|
||||
- **Breaking change**, Add date condition to filter datetime
|
||||
- Add class `DateTimeCond`
|
||||
- Add `dateTimeCond` to `FilterOptionGroup`
|
||||
- Remove `fetchDateTime` from `getAssetPathList`
|
||||
- Remove param `dt` from `AssetPathEntity.refreshPathProperties`, and add `refreshPathProperties` params to the method.
|
||||
|
||||
Update
|
||||
|
||||
- **Breaking change**, Split video filter and image filter
|
||||
- iOS code is running background thread.
|
||||
- getThumb is running in background thread.
|
||||
|
||||
Fix
|
||||
|
||||
- exists error on android.
|
||||
- use edited origin file on iOS.
|
||||
- galleryName maybe is null in android.
|
||||
- thumb of android 10.
|
||||
|
||||
## 0.4.8
|
||||
|
||||
Fixes:
|
||||
|
||||
- [#169](../../issues/169)
|
||||
- [#170](../../issues/170)
|
||||
|
||||
## 0.4.7
|
||||
|
||||
New feature:
|
||||
|
||||
- Add `FilterOption` for method `getAssetPathList`.
|
||||
|
||||
## 0.4.6
|
||||
|
||||
Fix:
|
||||
|
||||
- originFile of `AssetEntity`
|
||||
|
||||
Add:
|
||||
|
||||
- location(`latitude`,`longitude`) of `AssetEntity`
|
||||
- `title` of `AssetEntity`
|
||||
- `originBytes` of `AssetEntity`
|
||||
- param `format` in `thumbDataWithSize` of assetEntity.
|
||||
|
||||
## 0.4.5
|
||||
|
||||
Fix:
|
||||
|
||||
- Can't get thumb/file of video on androidQ.
|
||||
|
||||
## 0.4.4
|
||||
|
||||
Fix:
|
||||
|
||||
- Compatibility code, when the width and height of the video is empty, it can still be scanned.
|
||||
- Add a default value to `type` of `getAssetPathList`.
|
||||
|
||||
## 0.4.3
|
||||
|
||||
Add:
|
||||
|
||||
- Delete asset.
|
||||
- Add Image.
|
||||
- Add Video.
|
||||
- Add modifiDate property.
|
||||
- Fix videoDuration error.
|
||||
|
||||
Fix:
|
||||
|
||||
- CreateDate error.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
- Fix ios get full file size error.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
Fix:
|
||||
|
||||
- Fix ios build error.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
Breaking change.
|
||||
|
||||
- Some properties in the entity were modified from asynchronous to synchronous.
|
||||
- Remove `isCache` params. Now, `getAssetPathList` will reload info everytime. If user want to cache `List<AssetPathEntity>`, then user must do it self.
|
||||
|
||||
Added:
|
||||
|
||||
- Added a method `getAssetListPaged` for paging loading resources to path. The paging implementation is lazy loading, that is, the resource corresponding information is loaded when requested. The entity corresponding to the path is no longer placed in the memory, but is implemented by PHPhoto (ios) and sqlite's limit offset (android).
|
||||
- Support AndroidQ privacy.
|
||||
|
||||
## 0.3.5
|
||||
|
||||
Fix
|
||||
|
||||
- ICloud image problem.
|
||||
|
||||
## 0.3.4
|
||||
|
||||
Support flutter 1.6.0 android's thread changes for channel.
|
||||
|
||||
## 0.3.3
|
||||
|
||||
Fix customizing album containing folders on iOS.
|
||||
|
||||
## 0.3.2
|
||||
|
||||
`AssetEntity` add property: `originFile`
|
||||
|
||||
## 0.3.1
|
||||
|
||||
`AssetEntity` add property: `exists`
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Support Android X.
|
||||
- **Breaking change**. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
|
||||
|
||||
fix NPE for image crash on android.
|
||||
|
||||
add a method to create `AssetEntity` with id
|
||||
|
||||
add `isCache` for method `getImageAsset`,`getVideoAsset` or `getAssetPathList`
|
||||
|
||||
add observer for photo change.
|
||||
|
||||
add field `createTime` for `AssetEntity`
|
||||
|
||||
## 0.2.1
|
||||
|
||||
add two method to load video / image
|
||||
|
||||
`getVideoAsset` `getImageAsset`
|
||||
|
||||
## 0.2.0
|
||||
|
||||
add asset size field
|
||||
|
||||
release cache method
|
||||
|
||||
## 0.1.10
|
||||
|
||||
fix
|
||||
|
||||
when number of photo/video is 0, will crash
|
||||
|
||||
## 0.1.9
|
||||
|
||||
add video duration
|
||||
|
||||
## 0.1.8 sort asset by data
|
||||
|
||||
## 0.1.7 fix bug
|
||||
|
||||
fix bug: Android's latest picture won't be found
|
||||
|
||||
update gradle wrapper version.
|
||||
|
||||
update kotlin version
|
||||
|
||||
## 0.1.6
|
||||
|
||||
Fix Android to get pictures that are empty bug.
|
||||
|
||||
## 0.1.5
|
||||
|
||||
support ios icloud image and video
|
||||
|
||||
## 0.1.4 fix bug
|
||||
|
||||
update all path hasVideo property
|
||||
|
||||
## 0.1.3 add params
|
||||
|
||||
add a params to help user disable get video
|
||||
|
||||
## 0.1.2 fix bug
|
||||
|
||||
ios get video file is async
|
||||
|
||||
## 0.1.1 fix ios video
|
||||
|
||||
fix 'ios video full file is a jpg' problem
|
||||
|
||||
## 0.1.0 support video
|
||||
|
||||
support video in android.
|
||||
and will change api from ImageXXXX to AssetXXXX
|
||||
|
||||
## 0.0.3 fix bug
|
||||
|
||||
update for the issue #1 (NPE when request other permission on android)
|
||||
|
||||
## 0.0.2 update readme
|
||||
|
||||
## 0.0.1
|
||||
|
||||
first version
|
||||
|
||||
api for photo
|
201
thirdparty/flutter_photo_manager/LICENSE
vendored
Normal file
201
thirdparty/flutter_photo_manager/LICENSE
vendored
Normal file
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2018] caijinglong
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
51
thirdparty/flutter_photo_manager/Migration-Guide.md
vendored
Normal file
51
thirdparty/flutter_photo_manager/Migration-Guide.md
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Migration Guide
|
||||
|
||||
The document only describes the equivalent changes to the API.
|
||||
If you want to see the new feature support, please refer to [readme][] and [change log][].
|
||||
|
||||
- [Migration Guide](#migration-guide)
|
||||
- [0.6.x to 1.0.0](#06x-to-100)
|
||||
- [0.5.x To 0.6.x](#05x-to-06x)
|
||||
|
||||
## 0.6.x to 1.0.0
|
||||
|
||||
This version is a null-safety version.
|
||||
|
||||
Please read document for null-safety information in [dart][dart-safe] or [flutter][flutter-safe].
|
||||
|
||||
[flutter-safe]: https://flutter.dev/docs/null-safety
|
||||
[dart-safe]: https://dart.dev/null-safety
|
||||
|
||||
## 0.5.x To 0.6.x
|
||||
|
||||
0.5.x:
|
||||
|
||||
```dart
|
||||
final dtCond = DateTimeCond(
|
||||
min: startDt,
|
||||
max: endDt,
|
||||
asc: asc,
|
||||
);
|
||||
|
||||
FilterOptionGroup().dateTimeCond = dtCond;
|
||||
```
|
||||
|
||||
0.6.x
|
||||
|
||||
```dart
|
||||
final dtCond = DateTimeCond(
|
||||
min: startDt,
|
||||
max: endDt,
|
||||
);
|
||||
|
||||
final orderOption = OrderOption(
|
||||
type: OrderOptionType.createDate,
|
||||
asc: asc,
|
||||
);
|
||||
|
||||
final filterOptionGroup = FilterOptionGroup()
|
||||
..addOrderOption(orderOption);
|
||||
```
|
||||
|
||||
[readme]: ./README.md
|
||||
[change log]: ./CHANGELOG.md
|
566
thirdparty/flutter_photo_manager/README.md
vendored
Normal file
566
thirdparty/flutter_photo_manager/README.md
vendored
Normal file
|
@ -0,0 +1,566 @@
|
|||
# photo_manager
|
||||
|
||||
[![pub package](https://img.shields.io/pub/v/photo_manager.svg)](https://pub.dartlang.org/packages/photo_manager)
|
||||
[![GitHub](https://img.shields.io/github/license/Caijinglong/flutter_photo_manager.svg)](https://github.com/Caijinglong/flutter_photo_manager)
|
||||
[![GitHub stars](https://img.shields.io/github/stars/Caijinglong/flutter_photo_manager.svg?style=social&label=Stars)](https://github.com/Caijinglong/flutter_photo_manager)
|
||||
|
||||
A flutter api for photo, you can get image/video from ios or android.
|
||||
|
||||
一个提供相册 api 的插件, android ios 可用,没有 ui,以便于自定义自己的界面, 你可以通过提供的 api 来制作图片相关的 ui 或插件
|
||||
|
||||
## Other projects using this library
|
||||
|
||||
If you just need a picture selector, you can choose to use [photo](https://pub.dartlang.org/packages/photo) library , a multi image picker. All UI create by flutter.
|
||||
|
||||
| name | owner | description | pub | github |
|
||||
| :------------------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| photo | Caijinglong | A selector for multiple pictures / videos, The style is like the 6.0 version of wechat. | [![pub package](https://img.shields.io/pub/v/photo.svg)](https://pub.dev/packages/photo) | [![star](https://img.shields.io/github/stars/Caijinglong/flutter_photo?style=social)](https://github.com/fluttercandies/flutter_wechat_assets_picker) |
|
||||
| wechat_assets_picker | fluttercandies | An assets picker in WeChat 7.x style, support multi assets picking. | [![pub package](https://img.shields.io/pub/v/wechat_assets_picker.svg)](https://pub.dev/packages/wechat_assets_picker) | [![star](https://img.shields.io/github/stars/fluttercandies/flutter_wechat_assets_picker?style=social)](https://github.com/fluttercandies/flutter_wechat_assets_picker) |
|
||||
| photo_widget | fluttercandies | Not just selectors, but to provide each widget as a separate component, which is convenient for quickly combining and customizing your own style. | [![pub package](https://img.shields.io/pub/v/photo_widget.svg)](https://pub.dev/packages/photo_widget) | [![star](https://img.shields.io/github/stars/fluttercandies/photo_widget?style=social)](https://github.com/fluttercandies/photo_widget) |
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [photo_manager](#photo_manager)
|
||||
- [Other projects using this library](#other-projects-using-this-library)
|
||||
- [Table of contents](#table-of-contents)
|
||||
- [install](#install)
|
||||
- [Add to pubspec](#add-to-pubspec)
|
||||
- [import in dart code](#import-in-dart-code)
|
||||
- [Usage](#usage)
|
||||
- [Configure your flutter project to use the plugin](#configure-your-flutter-project-to-use-the-plugin)
|
||||
- [request permission](#request-permission)
|
||||
- [About `requestPermissionExtend`](#about-requestpermissionextend)
|
||||
- [Limit photos](#limit-photos)
|
||||
- [you get all of asset list (gallery)](#you-get-all-of-asset-list-gallery)
|
||||
- [FilterOption](#filteroption)
|
||||
- [Get asset list from `AssetPathEntity`](#get-asset-list-from-assetpathentity)
|
||||
- [paged](#paged)
|
||||
- [range](#range)
|
||||
- [Old version](#old-version)
|
||||
- [AssetEntity](#assetentity)
|
||||
- [location info of android Q](#location-info-of-android-q)
|
||||
- [Origin description](#origin-description)
|
||||
- [Create with id](#create-with-id)
|
||||
- [observer](#observer)
|
||||
- [Clear file cache](#clear-file-cache)
|
||||
- [Experimental](#experimental)
|
||||
- [Preload thumb](#preload-thumb)
|
||||
- [Delete item](#delete-item)
|
||||
- [Insert new item](#insert-new-item)
|
||||
- [Copy asset](#copy-asset)
|
||||
- [Only for iOS](#only-for-ios)
|
||||
- [Only for Android](#only-for-android)
|
||||
- [iOS config](#ios-config)
|
||||
- [iOS plist config](#ios-plist-config)
|
||||
- [enabling localized system albums names](#enabling-localized-system-albums-names)
|
||||
- [Cache problem of iOS](#cache-problem-of-ios)
|
||||
- [android config](#android-config)
|
||||
- [Cache problem of android](#cache-problem-of-android)
|
||||
- [about androidX](#about-androidx)
|
||||
- [Android Q (android10 , API 29)](#android-q-android10--api-29)
|
||||
- [Android R (android 11, API30)](#android-r-android-11-api30)
|
||||
- [glide](#glide)
|
||||
- [Remove Media Location permission](#remove-media-location-permission)
|
||||
- [common issues](#common-issues)
|
||||
- [ios build error](#ios-build-error)
|
||||
- [Some articles about to use this library](#some-articles-about-to-use-this-library)
|
||||
- [Migration Guide](#migration-guide)
|
||||
|
||||
## install
|
||||
|
||||
### Add to pubspec
|
||||
|
||||
the latest version is [![pub package](https://img.shields.io/pub/v/photo_manager.svg)](https://pub.dartlang.org/packages/photo_manager)
|
||||
|
||||
```yaml
|
||||
dependencies:
|
||||
photo_manager: $latest_version
|
||||
```
|
||||
|
||||
### import in dart code
|
||||
|
||||
```dart
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Configure your flutter project to use the plugin
|
||||
|
||||
Before using the plug-in, there are several points to note.
|
||||
Please click the link below.
|
||||
|
||||
1. [Android](#android-config)
|
||||
2. [iOS](#ios-config)
|
||||
|
||||
### request permission
|
||||
|
||||
You must get the user's permission on android/ios.
|
||||
|
||||
```dart
|
||||
var result = await PhotoManager.requestPermissionExtend();
|
||||
if (result.isAuth) {
|
||||
// success
|
||||
} else {
|
||||
// fail
|
||||
/// if result is fail, you can call `PhotoManager.openSetting();` to open android/ios applicaton's setting to get permission
|
||||
}
|
||||
```
|
||||
|
||||
#### About `requestPermissionExtend`
|
||||
|
||||
In iOS14, Apple inclue "LimitedPhotos Library" to iOS.
|
||||
|
||||
We need use the `PhotoManager.requestPermissionExtend()` to request permission.
|
||||
|
||||
The method will return `PermissionState`. See it in [document of Apple](https://developer.apple.com/documentation/photokit/phauthorizationstatus?language=objc).
|
||||
|
||||
So, because of compatibility, Android also recommends using this method to request permission, use `state.isAuth`, use a to be equivalent to the previous method `requestPermission`.
|
||||
|
||||
#### Limit photos
|
||||
|
||||
Because apple inclue "LimitedPhotos Library" to iOS.
|
||||
|
||||
Let the user select the visible image for app again, we can use `PhotoManager.presentLimited()` to repick again.
|
||||
|
||||
The method is only valid when iOS14 and user authorization mode is `PermissionState.limited`, other platform will ignore.
|
||||
|
||||
### you get all of asset list (gallery)
|
||||
|
||||
```dart
|
||||
List<AssetPathEntity> list = await PhotoManager.getAssetPathList();
|
||||
```
|
||||
|
||||
| name | description |
|
||||
| ------------ | ---------------------------------- |
|
||||
| hasAll | Is there an album containing "all" |
|
||||
| type | image/video/all , default all. |
|
||||
| filterOption | See [FilterOption](#FilterOption). |
|
||||
|
||||
#### FilterOption
|
||||
|
||||
| name | description |
|
||||
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| needTitle | The title attribute of the picture must be included in android (even if it is false), it is more performance-consuming in iOS, please consider whether you need it. The default is false. |
|
||||
| sizeConstraint | Constraints on resource size. |
|
||||
| durationConstraint | Constraints of time, pictures will ignore this constraint. |
|
||||
| createDateTimeCond | Create date filter |
|
||||
| updateDateTimeCond | Update date filter |
|
||||
| orders | The sort option, use `addOrderOption`. |
|
||||
|
||||
Example see [filter_option_page.dart](https://github.com/CaiJingLong/flutter_photo_manager/blob/master/example/lib/page/filter_option_page.dart).
|
||||
|
||||
Most classes of FilterOption support `copyWith`.
|
||||
|
||||
### Get asset list from `AssetPathEntity`
|
||||
|
||||
#### paged
|
||||
|
||||
```dart
|
||||
// page: The page number of the page, starting at 0.
|
||||
// perPage: The number of pages per page.
|
||||
final assetList = await path.getAssetListPaged(page, perPage);
|
||||
```
|
||||
|
||||
The old version, it is not recommended for continued use, because there may be performance issues on some phones. Now the internal implementation of this method is also paged, but the paged count is assetCount of AssetPathEntity.
|
||||
|
||||
#### range
|
||||
|
||||
```dart
|
||||
final assetList = await path.getAssetListRange(start: 0, end: 88); // use start and end to get asset.
|
||||
// Example: 0~10 will return 10 assets. Special case: If there are only 5, return 5
|
||||
```
|
||||
|
||||
#### Old version
|
||||
|
||||
```dart
|
||||
AssetPathEntity data = list[0]; // 1st album in the list, typically the "Recent" or "All" album
|
||||
List<AssetEntity> imageList = await data.assetList;
|
||||
```
|
||||
|
||||
### AssetEntity
|
||||
|
||||
```dart
|
||||
AssetEntity entity = imageList[0];
|
||||
|
||||
File file = await entity.file; // image file
|
||||
|
||||
Uint8List originBytes = await entity.originBytes; // image/video original file content,
|
||||
|
||||
Uint8List thumbBytes = await entity.thumbData; // thumb data ,you can use Image.memory(thumbBytes); size is 64px*64px;
|
||||
|
||||
Uint8List thumbDataWithSize = await entity.thumbDataWithSize(width,height); //Just like thumbnails, you can specify your own size. unit is px; format is optional support jpg and png.
|
||||
|
||||
AssetType type = entity.type; // the type of asset enum of other,image,video
|
||||
|
||||
Duration duration = entity.videoDuration; //if type is not video, then return null.
|
||||
|
||||
Size size = entity.size
|
||||
|
||||
int width = entity.width;
|
||||
|
||||
int height = entity.height;
|
||||
|
||||
DateTime createDt = entity.createDateTime;
|
||||
|
||||
DateTime modifiedDt = entity.modifiedDateTime;
|
||||
|
||||
/// Gps info of asset. If latitude and longitude is 0, it means that no positioning information was obtained.
|
||||
/// This information is not necessarily available, because the photo source is not necessarily the camera.
|
||||
/// Even the camera, due to privacy issues, this property must not be available on androidQ and above.
|
||||
double latitude = entity.latitude;
|
||||
double longitude = entiry.longitude;
|
||||
|
||||
Latlng latlng = await entity.latlngAsync(); // In androidQ or higher, need use the method to get location info.
|
||||
|
||||
String mediaUrl = await entity.getMediaUrl(); /// It can be used in some video player plugin to preview, such as [flutter_ijkplayer](https://pub.dev/packages/flutter_ijkplayer)
|
||||
|
||||
String title = entity.title; // Since this property is fetched using KVO in iOS, the default is null, please use titleAsync to get it.
|
||||
|
||||
String relativePath = entity.relativePath; // It is always null in iOS.
|
||||
```
|
||||
|
||||
About title: if the title is null or empty string, need use the titleAsync to get it. See below for the definition of attributes.
|
||||
|
||||
```dart
|
||||
/// It is title `MediaStore.MediaColumns.DISPLAY_NAME` in MediaStore on android.
|
||||
///
|
||||
/// It is `PHAssetResource.filename` on iOS.
|
||||
///
|
||||
/// Nullable in iOS. If you must need it, See [FilterOption.needTitle] or use [titleAsync].
|
||||
String title;
|
||||
|
||||
/// It is [title] in Android.
|
||||
///
|
||||
/// It is [PHAsset valueForKey:@"filename"] in iOS.
|
||||
Future<String> get titleAsync => _plugin.getTitleAsync(this);
|
||||
```
|
||||
|
||||
#### location info of android Q
|
||||
|
||||
Because of AndroidQ's privacy policy issues, it is necessary to locate permissions in order to obtain the original image, and to obtain location information by reading the Exif metadata of the data.
|
||||
|
||||
#### Origin description
|
||||
|
||||
The `originFile` and `originBytes` will return the original content.
|
||||
|
||||
Not guaranteed to be available in flutter.
|
||||
Because flutter's Image does not support heic.
|
||||
The video is also the original format, non-exported format, compatibility does not guarantee usability.
|
||||
|
||||
#### Create with id
|
||||
|
||||
The id of the Asset corresponds to the id field of the MediaStore on android, and the localIdentity of PHAsset on iOS.
|
||||
|
||||
The user can store the id to any place if necessary, and next time use the [`AssetEntity.fromId(id)`](https://github.com/CaiJingLong/flutter_photo_manager/blob/add49c1e4125540a9fc612521a8441398f9d72ad/lib/src/entity.dart#L126-L138) method to create the AssetEntity instace.
|
||||
|
||||
```dart
|
||||
final asset = await AssetEntity.fromId(id);
|
||||
```
|
||||
|
||||
### observer
|
||||
|
||||
use `addChangeCallback` to regiser observe.
|
||||
|
||||
```dart
|
||||
PhotoManager.addChangeCallback(changeNotify);
|
||||
PhotoManager.startChangeNotify();
|
||||
```
|
||||
|
||||
```dart
|
||||
PhotoManager.removeChangeCallback(changeNotify);
|
||||
PhotoManager.stopChangeNotify();
|
||||
```
|
||||
|
||||
### Clear file cache
|
||||
|
||||
You can use `PhotoManager.clearFileCache()` to clear all of cache.
|
||||
|
||||
The cache is generated at runtime when your call some methods.
|
||||
The following table will tell the user when the cache file will be generated.
|
||||
|
||||
| Platform | thumb | file/originFile |
|
||||
| ------------------------------------------ | ----- | --------------- |
|
||||
| Android(28 or lower) | Yes | No |
|
||||
| Android(29) (requestLegacyExternalStorage) | Yes | No |
|
||||
| Android(29) | Yes | Yes |
|
||||
| Android(30) | Yes | No |
|
||||
| iOS | No | Yes |
|
||||
|
||||
### Experimental
|
||||
|
||||
**Important**: The functions are not guaranteed to be fully usable, because it involves data modification, some APIs will cause irreversible deletion / movement of the data, so please use test equipment to make sure that there is no problem before using it.
|
||||
|
||||
#### Preload thumb
|
||||
|
||||
```dart
|
||||
PhotoCachingManager().requestCacheAssets(
|
||||
assets: assets,
|
||||
option: thumbOption,
|
||||
);
|
||||
```
|
||||
|
||||
And, if you want to stop, call `PhotoCachingManager().cancelCacheRequest();`
|
||||
|
||||
Usually, when we preview an album, we use thumbnails.
|
||||
In flutter, because `ListView.builder` and `GridView.builder` rendering that loads, but sometimes we might want to pre-load some pictures in advance to make them display faster.
|
||||
|
||||
Now, I try to create a caching image manager (just like [PHCachingImageManager](https://developer.apple.com/documentation/photokit/phcachingimagemanager?language=objc)) to do it. In IOS, I use the system API directly, and Android will use glide and use glide's file cache to complete this step.
|
||||
This function is completely optional.
|
||||
|
||||
#### Delete item
|
||||
|
||||
Hint: this will delete the asset from your device. For iOS, it's not just about removing from the album.
|
||||
|
||||
```dart
|
||||
final List<String> result = await PhotoManager.editor.deleteWithIds([entity.id]); // The deleted id will be returned, if it fails, an empty array will be returned.
|
||||
```
|
||||
|
||||
Tip: You need to call the corresponding `PathEntity`'s `refreshPathProperties` method to refresh the latest assetCount.
|
||||
|
||||
And [range](#range) way to get the latest data to ensure the accuracy of the current data. Such as [example](https://github.com/CaiJingLong/flutter_photo_manager/blob/0298d19464c05b231e2e97989f068ec3a72b0ab0/example/lib/model/photo_provider.dart#L104-L113).
|
||||
|
||||
#### Insert new item
|
||||
|
||||
```dart
|
||||
final AssetEntity imageEntity = await PhotoManager.editor.saveImage(uint8list); // nullable
|
||||
|
||||
final AssetEntity imageEntity = await PhotoManager.editor.saveImageWithPath(path); // nullable
|
||||
|
||||
File videoFile = File("video path");
|
||||
final AssetEntity videoEntity = await await PhotoManager.editor.saveVideo(videoFile); // nullable
|
||||
```
|
||||
|
||||
#### Copy asset
|
||||
|
||||
Availability:
|
||||
|
||||
- iOS: some albums are smart albums, their content is automatically managed by the system and cannot be inserted manually.
|
||||
- android:
|
||||
- Before api 28, the method will copy some column from origin row.
|
||||
- In api 29 or higher, There are some restrictions that cannot be guaranteed, See [document of relative_path](https://developer.android.com/reference/android/provider/MediaStore.MediaColumns#RELATIVE_PATH).
|
||||
|
||||
##### Only for iOS
|
||||
|
||||
Create folder:
|
||||
|
||||
```dart
|
||||
PhotoManager.editor.iOS.createFolder(
|
||||
name,
|
||||
parent: parent, // It is a folder or Recent album.
|
||||
);
|
||||
```
|
||||
|
||||
Create album:
|
||||
|
||||
```dart
|
||||
PhotoManager.editor.iOS.createAlbum(
|
||||
name,
|
||||
parent: parent, // It is a folder or Recent album.
|
||||
);
|
||||
```
|
||||
|
||||
Remove asset in album, the asset can't be delete in device, just remove of album.
|
||||
|
||||
```dart
|
||||
PhotoManager.editor.iOS.removeInAlbum(); // remove single asset.
|
||||
PhotoManager.editor.iOS.removeAssetsInAlbum(); // Batch remove asset in album.
|
||||
```
|
||||
|
||||
Delete the path in device. Both folders and albums can be deleted, except for smart albums.
|
||||
|
||||
```dart
|
||||
PhotoManager.editor.iOS.deletePath();
|
||||
```
|
||||
|
||||
##### Only for Android
|
||||
|
||||
Move asset to another album
|
||||
|
||||
```dart
|
||||
PhotoManager.editor.android.moveAssetToAnother(entity: assetEntity, target: pathEntity);
|
||||
```
|
||||
|
||||
Remove all non-existing rows. For normal Android users, this problem doesn't happened.
|
||||
A row record exists in the Android MediaStore, but the corresponding file has been deleted. This kind of abnormal deletion usually comes from file manager, helper to clear cache or adb.
|
||||
This is a very resource-consuming operation. If the first one is not completed, the second one cannot be opened.
|
||||
|
||||
```dart
|
||||
await PhotoManager.editor.android.removeAllNoExistsAsset();
|
||||
```
|
||||
|
||||
## iOS config
|
||||
|
||||
### iOS plist config
|
||||
|
||||
Because the album is a privacy privilege, you need user permission to access it. You must to modify the `Info.plist` file in Runner project.
|
||||
|
||||
like next
|
||||
|
||||
```xml
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>App need your agree, can visit your album</string>
|
||||
```
|
||||
|
||||
xcode like image
|
||||
![in xcode](https://raw.githubusercontent.com/CaiJingLong/some_asset/master/flutter_photo2.png)
|
||||
|
||||
In ios11+, if you want to save or delete asset, you also need add `NSPhotoLibraryAddUsageDescription` to plist.
|
||||
|
||||
### enabling localized system albums names
|
||||
|
||||
By default iOS will retrieve system album names only in English whatever the device's language currently set.
|
||||
To change this you need to open the ios project of your flutter app using xCode
|
||||
|
||||
![in xcode](https://raw.githubusercontent.com/CaiJingLong/some_asset/master/iosFlutterProjectEditinginXcode.png)
|
||||
|
||||
Select the project "Runner" and in the localizations table, click on the + icon
|
||||
|
||||
![in xcode](https://raw.githubusercontent.com/CaiJingLong/some_asset/master/iosFlutterAddLocalization.png)
|
||||
|
||||
Select the adequate language(s) you want to retrieve localized strings.
|
||||
Validate the popup screen without any modification
|
||||
Close xCode
|
||||
Rebuild your flutter project
|
||||
Now, the system albums should be displayed according to the device's language
|
||||
|
||||
### Cache problem of iOS
|
||||
|
||||
iOS does not directly provide APIs to access the original files of the album. The corresponding object is PHAsset,
|
||||
|
||||
So when you want to use file or originFile, a cache file will be generated locally.
|
||||
|
||||
So if you are sensitive to space, please delete it after using file(just iOS), and if it is only used for preview, you can consider using thumb or thumbWithSize.
|
||||
|
||||
```dart
|
||||
|
||||
void useEntity(AssetEntity entity) async {
|
||||
File file = null;
|
||||
try{
|
||||
file = await entity.file;
|
||||
doUpload(); // do upload
|
||||
}finally{
|
||||
if(Platform.isIOS){
|
||||
file?.deleteSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## android config
|
||||
|
||||
### Cache problem of android
|
||||
|
||||
Because androidQ restricts the application’s ability to directly access the resource path, some large image caches will be generated. This is because: When the file/originFile attribute is used, the plugin will save a file in the cache folder and provide it to dart:io use.
|
||||
|
||||
Fortunately, in androidP, the path attribute can be used again, but for androidQ, this is not good news, but we can use requestLegacyExternalStorage to avoid using androidQ's api, and I also recommend you to do so. See [Android Q](#android-q-android10--api-29) to add the attribute.
|
||||
|
||||
### about androidX
|
||||
|
||||
Google recommends completing all support-to-AndroidX migrations in 2019. Documentation is also provided.
|
||||
|
||||
This library has been migrated in version 0.2.2, but it brings a problem. Sometimes your upstream library has not been migrated yet. At this time, you need to add an option to deal with this problem.
|
||||
|
||||
The complete migration method can be consulted [gitbook](https://caijinglong.gitbooks.io/migrate-flutter-to-androidx/content/).
|
||||
|
||||
### Android Q (android10 , API 29)
|
||||
|
||||
Now, the android part of the plugin uses api 29 to compile the plugin, so your android sdk environment must contain api 29 (androidQ).
|
||||
|
||||
AndroidQ has a new privacy policy, users can't access the original file.
|
||||
|
||||
If your compileSdkVersion and targetSdkVersion are both below 28, you can use `PhotoManager.forceOldApi` to force the old api to access the album. If you are not sure about this part, don't call this method. And, I recommand you add `android:requestLegacyExternalStorage="true"` to your `AndroidManifest.xml`, just like next.
|
||||
|
||||
```xml
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="top.kikt.imagescannerexample">
|
||||
|
||||
<application
|
||||
android:name="io.flutter.app.FlutterApplication"
|
||||
android:label="image_scanner_example"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
```
|
||||
|
||||
### Android R (android 11, API30)
|
||||
|
||||
Unlike androidQ, this version of `requestLegacyExternalStorage` is invalid, but I still recommend that you add this attribute to make it easier to use the old API on android29 of android device.
|
||||
|
||||
### glide
|
||||
|
||||
Android native use glide to create image thumb bytes, version is 4.11.0.
|
||||
|
||||
If your other android library use the library, and version is not same, then you need edit your android project's build.gradle.
|
||||
|
||||
```gradle
|
||||
rootProject.allprojects {
|
||||
|
||||
subprojects {
|
||||
project.configurations.all {
|
||||
resolutionStrategy.eachDependency { details ->
|
||||
if (details.requested.group == 'com.github.bumptech.glide'
|
||||
&& details.requested.name.contains('glide')) {
|
||||
details.useVersion '4.11.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And, if you want to use ProGuard, you can see the [ProGuard of Glide](https://github.com/bumptech/glide#proguard).
|
||||
|
||||
### Remove Media Location permission
|
||||
|
||||
Android contains [ACCESS_MEDIA_LOCATION](https://developer.android.com/training/data-storage/shared/media#media-location-permission) permission by default.
|
||||
|
||||
This permission is introduced in Android Q. If your app doesn't need this permission, you need to add the following node to the Android manifest in your app.
|
||||
|
||||
```xml
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_MEDIA_LOCATION"
|
||||
tools:node="remove"
|
||||
/>
|
||||
```
|
||||
|
||||
See code in the [example](https://github.com/CaiJingLong/flutter_photo_manager/blob/e083c7d5f4eb5f5b355a75357c0a0c3e2d534b2e/example/android/app/src/main/AndroidManifest.xml#L11-L14).
|
||||
|
||||
## common issues
|
||||
|
||||
### ios build error
|
||||
|
||||
if your flutter print like the log. see [stackoverflow](https://stackoverflow.com/questions/27776497/include-of-non-modular-header-inside-framework-module)
|
||||
|
||||
```bash
|
||||
Xcode's output:
|
||||
↳
|
||||
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
|
||||
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
|
||||
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
|
||||
While building module 'photo_manager' imported from /Users/cai/IdeaProjects/flutter/sxw_order/ios/Runner/GeneratedPluginRegistrant.m:9:
|
||||
In file included from <module-includes>:1:
|
||||
In file included from /Users/cai/IdeaProjects/flutter/sxw_order/build/ios/Debug-iphonesimulator/photo_manager/photo_manager.framework/Headers/photo_manager-umbrella.h:16:
|
||||
/Users/cai/IdeaProjects/flutter/sxw_order/build/ios/Debug-iphonesimulator/photo_manager/photo_manager.framework/Headers/MD5Utils.h:5:9: error: include of non-modular header inside framework module 'photo_manager.MD5Utils': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk/usr/include/CommonCrypto/CommonDigest.h' [-Werror,-Wnon-modular-include-in-framework-module]
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
^
|
||||
1 error generated.
|
||||
/Users/cai/IdeaProjects/flutter/sxw_order/ios/Runner/GeneratedPluginRegistrant.m:9:9: fatal error: could not build module 'photo_manager'
|
||||
#import <photo_manager/ImageScannerPlugin.h>
|
||||
~~~~~~~^
|
||||
2 errors generated.
|
||||
```
|
||||
|
||||
## Some articles about to use this library
|
||||
|
||||
[How To: Create a custom media picker in Flutter to select photos and videos from the gallery](https://medium.com/@mhstoller.it/how-to-create-a-custom-media-picker-in-flutter-to-select-photos-and-videos-from-the-gallery-988eea477643?sk=cb395a7c20f6002f92f83374b3cc3875)
|
||||
|
||||
[Flutter 开发日记-如何实现一个照片选择器 plugin](https://juejin.im/post/5df797706fb9a016107974fc)
|
||||
|
||||
If you have other articles about this library, you can contact me or open PR here.
|
||||
|
||||
## Migration Guide
|
||||
|
||||
See [Migration-Guide](./Migration-Guide.md)
|
6
thirdparty/flutter_photo_manager/android/.classpath
vendored
Normal file
6
thirdparty/flutter_photo_manager/android/.classpath
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
8
thirdparty/flutter_photo_manager/android/.gitignore
vendored
Normal file
8
thirdparty/flutter_photo_manager/android/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
23
thirdparty/flutter_photo_manager/android/.project
vendored
Normal file
23
thirdparty/flutter_photo_manager/android/.project
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>photo_manager</name>
|
||||
<comment>Project android created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
47
thirdparty/flutter_photo_manager/android/build.gradle
vendored
Normal file
47
thirdparty/flutter_photo_manager/android/build.gradle
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
group 'top.kikt.imagescanner'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.61'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
implementation group: 'androidx.exifinterface', name: 'exifinterface', version: '1.2.0'
|
||||
}
|
1
thirdparty/flutter_photo_manager/android/gradle.properties
vendored
Normal file
1
thirdparty/flutter_photo_manager/android/gradle.properties
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
org.gradle.jvmargs=-Xmx1536M
|
BIN
thirdparty/flutter_photo_manager/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
thirdparty/flutter_photo_manager/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
thirdparty/flutter_photo_manager/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Mon Sep 16 14:30:05 CST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
172
thirdparty/flutter_photo_manager/android/gradlew
vendored
Normal file
172
thirdparty/flutter_photo_manager/android/gradlew
vendored
Normal file
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
thirdparty/flutter_photo_manager/android/gradlew.bat
vendored
Normal file
84
thirdparty/flutter_photo_manager/android/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
thirdparty/flutter_photo_manager/android/settings.gradle
vendored
Normal file
1
thirdparty/flutter_photo_manager/android/settings.gradle
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
rootProject.name = 'image_scanner'
|
8
thirdparty/flutter_photo_manager/android/src/main/AndroidManifest.xml
vendored
Normal file
8
thirdparty/flutter_photo_manager/android/src/main/AndroidManifest.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="top.kikt.imagescanner">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,94 @@
|
|||
package top.kikt.imagescanner
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.BinaryMessenger
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
|
||||
import top.kikt.imagescanner.core.PhotoManagerPlugin
|
||||
import top.kikt.imagescanner.permission.PermissionsUtils
|
||||
|
||||
class ImageScannerPlugin : FlutterPlugin, ActivityAware {
|
||||
private var plugin: PhotoManagerPlugin? = null
|
||||
private val permissionsUtils = PermissionsUtils()
|
||||
|
||||
private var binding: ActivityPluginBinding? = null
|
||||
|
||||
private var requestPermissionsResultListener: RequestPermissionsResultListener? = null
|
||||
|
||||
companion object {
|
||||
fun register(plugin: PhotoManagerPlugin, messenger: BinaryMessenger) {
|
||||
val newChannel = MethodChannel(messenger, "top.kikt/photo_manager")
|
||||
newChannel.setMethodCallHandler(plugin)
|
||||
}
|
||||
|
||||
fun createAddRequestPermissionsResultListener(permissionsUtils: PermissionsUtils): RequestPermissionsResultListener {
|
||||
return RequestPermissionsResultListener { id, permissions, grantResults ->
|
||||
permissionsUtils.dealResult(id, permissions, grantResults)
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
plugin = PhotoManagerPlugin(binding.applicationContext, binding.binaryMessenger, null, permissionsUtils)
|
||||
register(plugin!!, binding.binaryMessenger)
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
plugin = null
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivity() {
|
||||
binding?.let {
|
||||
onRemoveRequestPermissionResultListener(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activityAttached(binding)
|
||||
}
|
||||
|
||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
||||
activityAttached(binding)
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivityForConfigChanges() {
|
||||
plugin?.bindActivity(null)
|
||||
}
|
||||
|
||||
private fun activityAttached(binding: ActivityPluginBinding) {
|
||||
if (this.binding != null) {
|
||||
onRemoveRequestPermissionResultListener(this.binding!!)
|
||||
}
|
||||
|
||||
this.binding = binding
|
||||
plugin?.bindActivity(binding.activity)
|
||||
addRequestPermissionsResultListener(binding)
|
||||
}
|
||||
|
||||
private fun addRequestPermissionsResultListener(binding: ActivityPluginBinding) {
|
||||
val listener = createAddRequestPermissionsResultListener(permissionsUtils)
|
||||
requestPermissionsResultListener = listener
|
||||
binding.addRequestPermissionsResultListener(listener)
|
||||
plugin?.let {
|
||||
binding.addActivityResultListener(it.deleteManager)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onRemoveRequestPermissionResultListener(oldBinding: ActivityPluginBinding) {
|
||||
requestPermissionsResultListener?.let { listener ->
|
||||
oldBinding.removeRequestPermissionsResultListener(listener)
|
||||
}
|
||||
plugin?.let { p ->
|
||||
oldBinding.removeActivityResultListener(p.deleteManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class AssetType {
|
||||
Image,
|
||||
Video,
|
||||
Audio,
|
||||
}
|
302
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/core/PhotoManager.kt
vendored
Normal file
302
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/core/PhotoManager.kt
vendored
Normal file
|
@ -0,0 +1,302 @@
|
|||
package top.kikt.imagescanner.core
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.FutureTarget
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.GalleryEntity
|
||||
import top.kikt.imagescanner.core.entity.ThumbLoadOption
|
||||
import top.kikt.imagescanner.core.utils.*
|
||||
import top.kikt.imagescanner.thumb.ThumbnailUtil
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
import top.kikt.imagescanner.util.ResultHandler
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
/// Do some business logic assembly
|
||||
@SuppressLint("LongLogTag")
|
||||
class PhotoManager(private val context: Context) {
|
||||
|
||||
companion object {
|
||||
const val ALL_ID = "isAll"
|
||||
|
||||
private val threadPool = Executors.newFixedThreadPool(5)
|
||||
}
|
||||
|
||||
var useOldApi: Boolean = false
|
||||
|
||||
private val dbUtils: IDBUtils
|
||||
get() {
|
||||
return if (IDBUtils.isAndroidR) {
|
||||
Android30DbUtils
|
||||
} else if (useOldApi || Build.VERSION.SDK_INT < 29) {
|
||||
DBUtils
|
||||
} else {
|
||||
AndroidQDBUtils
|
||||
}
|
||||
}
|
||||
|
||||
fun getGalleryList(type: Int, hasAll: Boolean, onlyAll: Boolean, option: FilterOption): List<GalleryEntity> {
|
||||
if (onlyAll) {
|
||||
return dbUtils.getOnlyGalleryList(context, type, option)
|
||||
}
|
||||
|
||||
val fromDb = dbUtils.getGalleryList(context, type, option)
|
||||
|
||||
if (!hasAll) {
|
||||
return fromDb
|
||||
}
|
||||
|
||||
// make is all to the gallery list
|
||||
val entity = fromDb.run {
|
||||
var count = 0
|
||||
for (item in this) {
|
||||
count += item.length
|
||||
}
|
||||
GalleryEntity(ALL_ID, "Recent", count, type, true)
|
||||
}
|
||||
|
||||
return listOf(entity) + fromDb
|
||||
}
|
||||
|
||||
fun getAssetList(galleryId: String, page: Int, pageCount: Int, typeInt: Int = 0, option: FilterOption): List<AssetEntity> {
|
||||
val gId = if (galleryId == ALL_ID) "" else galleryId
|
||||
return dbUtils.getAssetFromGalleryId(context, gId, page, pageCount, typeInt, option)
|
||||
}
|
||||
|
||||
fun getAssetListWithRange(galleryId: String, type: Int, start: Int, end: Int, option: FilterOption): List<AssetEntity> {
|
||||
val gId = if (galleryId == ALL_ID) "" else galleryId
|
||||
return dbUtils.getAssetFromGalleryIdRange(context, gId, start, end, type, option)
|
||||
}
|
||||
|
||||
fun getThumb(id: String, option: ThumbLoadOption, resultHandler: ResultHandler) {
|
||||
val width = option.width
|
||||
val height = option.height
|
||||
val quality = option.quality
|
||||
val format = option.format
|
||||
try {
|
||||
if (useFilePath()) {
|
||||
val asset = dbUtils.getAssetEntity(context, id)
|
||||
if (asset == null) {
|
||||
resultHandler.replyError("The asset not found!")
|
||||
return
|
||||
}
|
||||
ThumbnailUtil.getThumbnailByGlide(context, asset.path, option.width, option.height, format, quality, resultHandler.result)
|
||||
} else {
|
||||
// need use android Q MediaStore thumbnail api
|
||||
val asset = dbUtils.getAssetEntity(context, id)
|
||||
val type = asset?.type
|
||||
val uri = dbUtils.getThumbUri(context, id, width, height, type)
|
||||
?: throw RuntimeException("Cannot load uri of $id.")
|
||||
ThumbnailUtil.getThumbOfUri(context, uri, width, height, format, quality) {
|
||||
resultHandler.reply(it)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(LogUtils.TAG, "get $id thumb error, width : $width, height: $height", e)
|
||||
dbUtils.logRowWithId(context, id)
|
||||
resultHandler.replyError("201", "get thumb error", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun getOriginBytes(id: String, cacheOriginBytes: Boolean, haveLocationPermission: Boolean, resultHandler: ResultHandler) {
|
||||
val asset = dbUtils.getAssetEntity(context, id)
|
||||
|
||||
if (asset == null) {
|
||||
resultHandler.replyError("The asset not found")
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (useFilePath()) {
|
||||
val byteArray = File(asset.path).readBytes()
|
||||
resultHandler.reply(byteArray)
|
||||
} else {
|
||||
val byteArray = dbUtils.getOriginBytes(context, asset, haveLocationPermission)
|
||||
resultHandler.reply(byteArray)
|
||||
if (cacheOriginBytes) {
|
||||
dbUtils.cacheOriginFile(context, asset, byteArray)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
dbUtils.logRowWithId(context, id)
|
||||
resultHandler.replyError("202", "get origin Bytes error", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearCache() {
|
||||
dbUtils.clearCache()
|
||||
}
|
||||
|
||||
|
||||
fun clearFileCache() {
|
||||
ThumbnailUtil.clearCache(context)
|
||||
dbUtils.clearFileCache(context)
|
||||
}
|
||||
|
||||
fun getPathEntity(id: String, type: Int, option: FilterOption): GalleryEntity? {
|
||||
if (id == ALL_ID) {
|
||||
val allGalleryList = dbUtils.getGalleryList(context, type, option)
|
||||
return if (allGalleryList.isEmpty()) {
|
||||
null
|
||||
} else {
|
||||
// make is all to the gallery list
|
||||
allGalleryList.run {
|
||||
var count = 0
|
||||
for (item in this) {
|
||||
count += item.length
|
||||
}
|
||||
GalleryEntity(ALL_ID, "Recent", count, type, true).apply {
|
||||
if (option.containsPathModified) {
|
||||
dbUtils.injectModifiedDate(context, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val galleryEntity = dbUtils.getGalleryEntity(context, id, type, option)
|
||||
|
||||
if (galleryEntity != null && option.containsPathModified) {
|
||||
dbUtils.injectModifiedDate(context, galleryEntity)
|
||||
}
|
||||
|
||||
return galleryEntity
|
||||
}
|
||||
|
||||
fun getFile(id: String, isOrigin: Boolean, resultHandler: ResultHandler) {
|
||||
val path = dbUtils.getFilePath(context, id, isOrigin)
|
||||
resultHandler.reply(path)
|
||||
}
|
||||
|
||||
fun saveImage(image: ByteArray, title: String, description: String, relativePath: String?): AssetEntity? {
|
||||
return dbUtils.saveImage(context, image, title, description, relativePath)
|
||||
}
|
||||
|
||||
fun saveImage(path: String, title: String, description: String, relativePath: String?): AssetEntity? {
|
||||
return dbUtils.saveImage(context, path, title, description, relativePath)
|
||||
}
|
||||
|
||||
fun saveVideo(path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
if (!File(path).exists()) {
|
||||
return null
|
||||
}
|
||||
return dbUtils.saveVideo(context, path, title, desc, relativePath)
|
||||
}
|
||||
|
||||
fun assetExists(id: String, resultHandler: ResultHandler) {
|
||||
val exists: Boolean = dbUtils.exists(context, id)
|
||||
resultHandler.reply(exists)
|
||||
}
|
||||
|
||||
fun getLocation(id: String): Map<String, Double> {
|
||||
val exifInfo = dbUtils.getExif(context, id)
|
||||
val latLong = exifInfo?.latLong
|
||||
return if (latLong == null) {
|
||||
mapOf(
|
||||
"lat" to 0.0,
|
||||
"lng" to 0.0
|
||||
)
|
||||
} else {
|
||||
mapOf(
|
||||
"lat" to latLong[0],
|
||||
"lng" to latLong[1]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getMediaUri(id: String, type: Int): String {
|
||||
return dbUtils.getMediaUri(context, id, type)
|
||||
}
|
||||
|
||||
fun copyToGallery(assetId: String, galleryId: String, resultHandler: ResultHandler) {
|
||||
try {
|
||||
val assetEntity = dbUtils.copyToGallery(context, assetId, galleryId)
|
||||
if (assetEntity == null) {
|
||||
resultHandler.reply(null)
|
||||
return
|
||||
}
|
||||
resultHandler.reply(ConvertUtils.convertToAssetResult(assetEntity))
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error(e)
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
|
||||
fun moveToGallery(assetId: String, albumId: String, resultHandler: ResultHandler) {
|
||||
try {
|
||||
val assetEntity = dbUtils.moveToGallery(context, assetId, albumId)
|
||||
if (assetEntity == null) {
|
||||
resultHandler.reply(null)
|
||||
return
|
||||
}
|
||||
resultHandler.reply(ConvertUtils.convertToAssetResult(assetEntity))
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error(e)
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeAllExistsAssets(resultHandler: ResultHandler) {
|
||||
val result = dbUtils.removeAllExistsAssets(context)
|
||||
resultHandler.reply(result)
|
||||
}
|
||||
|
||||
fun getAssetProperties(id: String): AssetEntity? {
|
||||
return dbUtils.getAssetEntity(context, id)
|
||||
}
|
||||
|
||||
fun getUri(id: String): Uri? {
|
||||
val asset = dbUtils.getAssetEntity(context, id)
|
||||
return asset?.getUri()
|
||||
}
|
||||
|
||||
private val cacheFutures = ArrayList<FutureTarget<Bitmap>>()
|
||||
|
||||
fun requestCache(ids: List<String>, option: ThumbLoadOption, resultHandler: ResultHandler) {
|
||||
if (useFilePath()) {
|
||||
val pathList = dbUtils.getAssetsPath(context, ids)
|
||||
for (s in pathList) {
|
||||
val future = ThumbnailUtil.requestCacheThumb(context, s, option)
|
||||
cacheFutures.add(future)
|
||||
}
|
||||
|
||||
} else {
|
||||
val uriList = dbUtils.getAssetsUri(context, ids)
|
||||
|
||||
for (uri in uriList) {
|
||||
val future = ThumbnailUtil.requestCacheThumb(context, uri, option)
|
||||
cacheFutures.add(future)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resultHandler.reply(1)
|
||||
|
||||
val needExecuteFutures = cacheFutures.toList()
|
||||
for (cacheFuture in needExecuteFutures) {
|
||||
threadPool.execute {
|
||||
if (cacheFuture.isCancelled) {
|
||||
return@execute
|
||||
}
|
||||
cacheFuture.get()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun cancelCacheRequests() {
|
||||
val needCancelFutures = cacheFutures.toList()
|
||||
cacheFutures.clear()
|
||||
for (futureTarget in needCancelFutures) {
|
||||
Glide.with(context).clear(futureTarget)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package top.kikt.imagescanner.core
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.RecoverableSecurityException
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.MediaStore
|
||||
import androidx.annotation.RequiresApi
|
||||
import io.flutter.plugin.common.PluginRegistry
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils
|
||||
import top.kikt.imagescanner.util.ResultHandler
|
||||
|
||||
class PhotoManagerDeleteManager(val context: Context, var activity: Activity?) : PluginRegistry.ActivityResultListener {
|
||||
|
||||
fun bindActivity(activity: Activity?) {
|
||||
this.activity = activity
|
||||
}
|
||||
|
||||
private var requestCodeIndex = 3000
|
||||
private var androidRDeleteRequestCode = 40069
|
||||
|
||||
private val uriMap = HashMap<Int, Uri>()
|
||||
|
||||
private val cr: ContentResolver
|
||||
get() = context.contentResolver
|
||||
|
||||
private fun isHandleCode(requestCode: Int): Boolean {
|
||||
return uriMap.containsKey(requestCode)
|
||||
}
|
||||
|
||||
private fun addRequestUri(uri: Uri): Int {
|
||||
val requestCode = requestCodeIndex
|
||||
requestCodeIndex++
|
||||
uriMap[requestCode] = uri
|
||||
return requestCode
|
||||
}
|
||||
|
||||
private val androidQResult = arrayListOf<String>()
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||
if (requestCode == androidRDeleteRequestCode) {
|
||||
handleAndroidRDelete(resultCode, data)
|
||||
return true
|
||||
}
|
||||
if (!isHandleCode(requestCode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
val uri = uriMap.remove(requestCode) ?: return true
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
// User allow delete asset.
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
deleteWithUriInApi29(uri, true)
|
||||
uri.lastPathSegment?.let {
|
||||
androidQResult.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uriMap.isEmpty()) {
|
||||
androidQHandler?.reply(androidQResult)
|
||||
androidQResult.clear()
|
||||
androidQHandler = null
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun deleteWithUriInApi29(uri: Uri, havePermission: Boolean) {
|
||||
try {
|
||||
cr.delete(uri, null, null)
|
||||
} catch (e: Exception) {
|
||||
if (e is RecoverableSecurityException) {
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
if (havePermission) {
|
||||
return
|
||||
}
|
||||
val requestCode = addRequestUri(uri)
|
||||
activity?.startIntentSenderForResult(
|
||||
e.userAction.actionIntent.intentSender,
|
||||
requestCode,
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleAndroidRDelete(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
androidRHandler?.apply {
|
||||
val ids = call?.argument<List<String>>("ids") ?: return@apply
|
||||
androidRHandler?.reply(ids)
|
||||
}
|
||||
} else {
|
||||
androidRHandler?.reply(listOf<String>())
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteInApi28(ids: List<String>) {
|
||||
val where = ids.joinToString(",") { "?" }
|
||||
cr.delete(IDBUtils.allUri, "${MediaStore.MediaColumns._ID} in ($where)", ids.toTypedArray())
|
||||
}
|
||||
|
||||
private var androidRHandler: ResultHandler? = null
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
fun deleteInApi30(uris: List<Uri?>, resultHandler: ResultHandler) {
|
||||
this.androidRHandler = resultHandler
|
||||
val pendingIntent = MediaStore.createTrashRequest(cr, uris.mapNotNull { it }, true)
|
||||
activity?.startIntentSenderForResult(pendingIntent.intentSender, androidRDeleteRequestCode, null, 0, 0, 0)
|
||||
}
|
||||
|
||||
private var androidQHandler: ResultHandler? = null
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun deleteWithUriInApi29(ids: List<String>, uris: List<Uri>, resultHandler: ResultHandler, havePermission: Boolean) {
|
||||
if (Environment.isExternalStorageLegacy()) {
|
||||
deleteInApi28(ids)
|
||||
resultHandler.reply(ids)
|
||||
return
|
||||
}
|
||||
|
||||
androidQHandler = resultHandler
|
||||
androidQResult.clear()
|
||||
for (uri in uris) {
|
||||
deleteWithUriInApi29(uri, havePermission)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package top.kikt.imagescanner.core
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.database.ContentObserver
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore
|
||||
import android.provider.MediaStore.Files.FileColumns.*
|
||||
import io.flutter.plugin.common.BinaryMessenger
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.PluginRegistry
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
|
||||
/// create 2019-09-09 by cai
|
||||
|
||||
|
||||
class PhotoManagerNotifyChannel(val applicationContext: Context, private val messenger: BinaryMessenger, handler: Handler) {
|
||||
|
||||
private var notifying = false
|
||||
|
||||
private val videoObserver = MediaObserver(MEDIA_TYPE_VIDEO, handler)
|
||||
private val imageObserver = MediaObserver(MEDIA_TYPE_IMAGE, handler)
|
||||
private val audioObserver = MediaObserver(MEDIA_TYPE_AUDIO, handler)
|
||||
private val allUri = IDBUtils.allUri
|
||||
private val imageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
private val videoUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
private val audioUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
private val methodChannel = MethodChannel(messenger, "top.kikt/photo_manager/notify")
|
||||
|
||||
private val context
|
||||
get() = applicationContext
|
||||
|
||||
fun startNotify() {
|
||||
if (notifying) {
|
||||
return
|
||||
}
|
||||
registerObserver(imageObserver, imageUri)
|
||||
registerObserver(videoObserver, videoUri)
|
||||
registerObserver(audioObserver, audioUri)
|
||||
|
||||
notifying = true
|
||||
}
|
||||
|
||||
private fun registerObserver(mediaObserver: MediaObserver, uri: Uri) {
|
||||
context.contentResolver.registerContentObserver(uri, false, mediaObserver)
|
||||
mediaObserver.uri = uri
|
||||
}
|
||||
|
||||
fun stopNotify() {
|
||||
if (!notifying) {
|
||||
return
|
||||
}
|
||||
notifying = false
|
||||
context.contentResolver.unregisterContentObserver(imageObserver)
|
||||
context.contentResolver.unregisterContentObserver(videoObserver)
|
||||
context.contentResolver.unregisterContentObserver(audioObserver)
|
||||
}
|
||||
|
||||
fun onOuterChange(uri: Uri?, changeType: String, id: Long?, galleryId: Long?, observerType: Int) {
|
||||
val resultMap = hashMapOf<String, Any?>(
|
||||
"platform" to "android",
|
||||
"uri" to uri.toString(),
|
||||
"type" to changeType,
|
||||
"mediaType" to observerType
|
||||
)
|
||||
if (id != null) {
|
||||
resultMap["id"] = id
|
||||
}
|
||||
if (galleryId != null) {
|
||||
resultMap["galleryId"] = galleryId
|
||||
}
|
||||
|
||||
LogUtils.debug(resultMap)
|
||||
|
||||
methodChannel.invokeMethod("change", resultMap)
|
||||
}
|
||||
|
||||
fun setAndroidQExperimental(open: Boolean) {
|
||||
methodChannel.invokeMethod("setAndroidQExperimental", mapOf("open" to open))
|
||||
}
|
||||
|
||||
private inner class MediaObserver(val type: Int, handler: Handler = Handler(Looper.getMainLooper())) : ContentObserver(handler) {
|
||||
var uri: Uri = Uri.parse("content://${MediaStore.AUTHORITY}")
|
||||
|
||||
val context: Context
|
||||
get() = applicationContext
|
||||
|
||||
val cr: ContentResolver
|
||||
get() = context.contentResolver
|
||||
|
||||
override fun onChange(selfChange: Boolean, uri: Uri?) {
|
||||
super.onChange(selfChange, uri)
|
||||
if (uri == null) {
|
||||
return
|
||||
}
|
||||
val last = uri.lastPathSegment
|
||||
val id = last?.toLongOrNull()
|
||||
|
||||
if (id != null) { // insert or update
|
||||
val cursor = cr.query(
|
||||
allUri,
|
||||
arrayOf(DATE_ADDED, DATE_MODIFIED, MEDIA_TYPE),
|
||||
"${BaseColumns._ID} = ?",
|
||||
arrayOf(id.toString()),
|
||||
null
|
||||
)
|
||||
cursor?.use {
|
||||
// find date to know insert or update
|
||||
if (cursor.moveToNext()) {
|
||||
return
|
||||
}
|
||||
val addTimestampSecond = cursor.getLong(cursor.getColumnIndex(DATE_ADDED))
|
||||
val currentTimeMillis = System.currentTimeMillis()
|
||||
|
||||
val diffTime = currentTimeMillis / 1000 - addTimestampSecond
|
||||
|
||||
// Within 30s, it is considered to be inserted, if it is exceeded, it is considered to be changed
|
||||
|
||||
val typeString = if (diffTime < 30) {
|
||||
"insert"
|
||||
} else {
|
||||
"update"
|
||||
}
|
||||
// get Type
|
||||
val type = cursor.getInt(cursor.getColumnIndex(MEDIA_TYPE))
|
||||
val (gId, gName) = getGalleryIdAndName(id, type)
|
||||
|
||||
if (gId == null || gName == null) {
|
||||
return
|
||||
}
|
||||
onOuterChange(uri, typeString, id, gId, type)
|
||||
}
|
||||
} else { // delete
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (uri == this.uri) {
|
||||
onOuterChange(uri, "insert", null, null, type)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
onOuterChange(uri, "delete", null, null, type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGalleryIdAndName(id: Long, type: Int): Pair<Long?, String?> {
|
||||
when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> {
|
||||
val cursor = cr.query(
|
||||
allUri,
|
||||
arrayOf(MediaStore.MediaColumns.BUCKET_ID, MediaStore.MediaColumns.BUCKET_DISPLAY_NAME),
|
||||
"${BaseColumns._ID} = ?",
|
||||
arrayOf(id.toString()),
|
||||
null
|
||||
)
|
||||
cursor?.use {
|
||||
if (cursor.moveToNext()) {
|
||||
val galleryId = cursor.getLong(cursor.getColumnIndex(MediaStore.MediaColumns.BUCKET_ID))
|
||||
val galleryName = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.BUCKET_DISPLAY_NAME))
|
||||
return Pair(galleryId, galleryName)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
type == MEDIA_TYPE_AUDIO -> {
|
||||
val cursor = cr.query(
|
||||
allUri,
|
||||
arrayOf(MediaStore.Audio.AudioColumns.ALBUM_ID, MediaStore.Audio.AudioColumns.ALBUM),
|
||||
"${BaseColumns._ID} = ?",
|
||||
arrayOf(id.toString()),
|
||||
null
|
||||
)
|
||||
|
||||
cursor?.use {
|
||||
if (cursor.moveToNext()) {
|
||||
val galleryId = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.AudioColumns.ALBUM_ID))
|
||||
val galleryName = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.AudioColumns.ALBUM))
|
||||
return Pair(galleryId, galleryName)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
val cursor = cr.query(
|
||||
allUri,
|
||||
arrayOf("bucket_id", "bucket_display_name"),
|
||||
"${BaseColumns._ID} = ?",
|
||||
arrayOf(id.toString()),
|
||||
null
|
||||
)
|
||||
|
||||
cursor?.use {
|
||||
if (cursor.moveToNext()) {
|
||||
val galleryId = cursor.getLong(cursor.getColumnIndex("bucket_id"))
|
||||
val galleryName = cursor.getString(cursor.getColumnIndex("bucket_display_name"))
|
||||
return Pair(galleryId, galleryName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Pair(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,472 @@
|
|||
package top.kikt.imagescanner.core
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.bumptech.glide.Glide
|
||||
import io.flutter.plugin.common.BinaryMessenger
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.PermissionResult
|
||||
import top.kikt.imagescanner.core.entity.ThumbLoadOption
|
||||
import top.kikt.imagescanner.core.utils.ConvertUtils
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils
|
||||
import top.kikt.imagescanner.core.utils.belowSdk
|
||||
import top.kikt.imagescanner.permission.PermissionsListener
|
||||
import top.kikt.imagescanner.permission.PermissionsUtils
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
import top.kikt.imagescanner.util.ResultHandler
|
||||
import java.util.concurrent.ArrayBlockingQueue
|
||||
import java.util.concurrent.ThreadPoolExecutor
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
|
||||
|
||||
class PhotoManagerPlugin(
|
||||
private val applicationContext: Context,
|
||||
private val messenger: BinaryMessenger,
|
||||
private var activity: Activity?,
|
||||
private val permissionsUtils: PermissionsUtils
|
||||
) : MethodChannel.MethodCallHandler {
|
||||
|
||||
val deleteManager = PhotoManagerDeleteManager(applicationContext, activity)
|
||||
|
||||
fun bindActivity(activity: Activity?) {
|
||||
this.activity = activity
|
||||
deleteManager.bindActivity(activity)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val poolSize = 8
|
||||
private val threadPool: ThreadPoolExecutor = ThreadPoolExecutor(
|
||||
poolSize + 3,
|
||||
1000,
|
||||
200,
|
||||
TimeUnit.MINUTES,
|
||||
ArrayBlockingQueue<Runnable>(poolSize + 3)
|
||||
)
|
||||
|
||||
fun runOnBackground(runnable: () -> Unit) {
|
||||
threadPool.execute(runnable)
|
||||
}
|
||||
|
||||
var cacheOriginBytes = true
|
||||
|
||||
}
|
||||
|
||||
private val notifyChannel = PhotoManagerNotifyChannel(applicationContext, messenger, Handler())
|
||||
|
||||
init {
|
||||
permissionsUtils.permissionsListener = object : PermissionsListener {
|
||||
override fun onDenied(deniedPermissions: MutableList<String>, grantedPermissions: MutableList<String>) {
|
||||
}
|
||||
|
||||
override fun onGranted() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val photoManager = PhotoManager(applicationContext)
|
||||
|
||||
private var ignorePermissionCheck = false;
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||
val resultHandler = ResultHandler(result, call)
|
||||
|
||||
if (call.method == "ignorePermissionCheck") {
|
||||
val ignore = call.argument<Boolean>("ignore")!!
|
||||
ignorePermissionCheck = ignore
|
||||
resultHandler.reply(ignore)
|
||||
return
|
||||
}
|
||||
|
||||
var needLocationPermissions = false
|
||||
|
||||
val handleResult = when (call.method) {
|
||||
"releaseMemCache" -> {
|
||||
photoManager.clearCache()
|
||||
resultHandler.reply(1)
|
||||
true
|
||||
}
|
||||
"log" -> {
|
||||
LogUtils.isLog = call.arguments()
|
||||
resultHandler.reply(1)
|
||||
true
|
||||
}
|
||||
"openSetting" -> {
|
||||
permissionsUtils.getAppDetailSettingIntent(activity)
|
||||
resultHandler.reply(1)
|
||||
true
|
||||
}
|
||||
"clearFileCache" -> {
|
||||
Glide.get(applicationContext).clearMemory()
|
||||
runOnBackground {
|
||||
photoManager.clearFileCache()
|
||||
resultHandler.reply(1)
|
||||
}
|
||||
true
|
||||
}
|
||||
"forceOldApi" -> {
|
||||
photoManager.useOldApi = true
|
||||
resultHandler.reply(1)
|
||||
true
|
||||
}
|
||||
"systemVersion" -> {
|
||||
resultHandler.reply(Build.VERSION.SDK_INT.toString())
|
||||
true
|
||||
}
|
||||
"cacheOriginBytes" -> {
|
||||
cacheOriginBytes = call.arguments<Boolean>()
|
||||
resultHandler.reply(cacheOriginBytes)
|
||||
true
|
||||
}
|
||||
"getLatLngAndroidQ" -> {
|
||||
/// 这里不拦截, 然后额外添加gps权限
|
||||
needLocationPermissions = true
|
||||
false
|
||||
}
|
||||
"copyAsset" -> {
|
||||
needLocationPermissions = true
|
||||
false
|
||||
}
|
||||
"getFullFile" -> {
|
||||
val isOrigin = call.argument<Boolean>("isOrigin")!!
|
||||
if (isOrigin && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
needLocationPermissions = true
|
||||
}
|
||||
false
|
||||
}
|
||||
"getOriginBytes" -> {
|
||||
needLocationPermissions = true
|
||||
false
|
||||
}
|
||||
"getMediaUrl" -> {
|
||||
false
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
|
||||
if (handleResult) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ignorePermissionCheck) {
|
||||
onHandlePermissionResult(call, resultHandler, true)
|
||||
return
|
||||
}
|
||||
|
||||
val utils = permissionsUtils.apply {
|
||||
withActivity(activity)
|
||||
permissionsListener = object : PermissionsListener {
|
||||
override fun onDenied(deniedPermissions: MutableList<String>, grantedPermissions: MutableList<String>) {
|
||||
LogUtils.info("onDenied call.method = ${call.method}")
|
||||
if (call.method == "requestPermissionExtend") {
|
||||
resultHandler.reply(PermissionResult.Denied.value)
|
||||
} else {
|
||||
if (grantedPermissions.containsAll(arrayListOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE))) {
|
||||
LogUtils.info("onGranted call.method = ${call.method}")
|
||||
onHandlePermissionResult(call, resultHandler, false)
|
||||
} else {
|
||||
replyPermissionError(resultHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGranted() {
|
||||
LogUtils.info("onGranted call.method = ${call.method}")
|
||||
onHandlePermissionResult(call, resultHandler, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val permissions = arrayListOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
|
||||
if (needLocationPermissions && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && haveManifestMediaLocation(applicationContext)) {
|
||||
permissions.add(Manifest.permission.ACCESS_MEDIA_LOCATION)
|
||||
}
|
||||
|
||||
utils.getPermissions(activity, 3001, permissions)
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun haveManifestMediaLocation(context: Context): Boolean {
|
||||
// Debug.waitForDebugger()
|
||||
val applicationInfo = context.applicationInfo
|
||||
val packageInfo = context.packageManager.getPackageInfo(
|
||||
applicationInfo.packageName,
|
||||
PackageManager.GET_PERMISSIONS
|
||||
)
|
||||
return packageInfo.requestedPermissions.contains(Manifest.permission.ACCESS_MEDIA_LOCATION)
|
||||
}
|
||||
|
||||
|
||||
private fun replyPermissionError(resultHandler: ResultHandler) {
|
||||
resultHandler.replyError("Request for permission failed.", "User denied permission.", null)
|
||||
}
|
||||
|
||||
private fun onHandlePermissionResult(call: MethodCall, resultHandler: ResultHandler, haveLocationPermission: Boolean) {
|
||||
when (call.method) {
|
||||
"requestPermissionExtend" -> resultHandler.reply(PermissionResult.Authorized.value)
|
||||
"getGalleryList" -> {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
notifyChannel.setAndroidQExperimental(true)
|
||||
}
|
||||
runOnBackground {
|
||||
val type = call.argument<Int>("type")!!
|
||||
val hasAll = call.argument<Boolean>("hasAll")!!
|
||||
val option = call.getOption()
|
||||
val onlyAll = call.argument<Boolean>("onlyAll")!!
|
||||
|
||||
val list = photoManager.getGalleryList(type, hasAll, onlyAll, option)
|
||||
resultHandler.reply(ConvertUtils.convertToGalleryResult(list))
|
||||
}
|
||||
}
|
||||
"getAssetWithGalleryId" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val page = call.argument<Int>("page")!!
|
||||
val pageCount = call.argument<Int>("pageCount")!!
|
||||
val type = call.argument<Int>("type")!!
|
||||
val option = call.getOption()
|
||||
val list = photoManager.getAssetList(id, page, pageCount, type, option)
|
||||
resultHandler.reply(ConvertUtils.convertToAssetResult(list))
|
||||
}
|
||||
}
|
||||
"getAssetListWithRange" -> {
|
||||
runOnBackground {
|
||||
val galleryId = call.getString("galleryId")
|
||||
val type = call.getInt("type")
|
||||
val start = call.getInt("start")
|
||||
val end = call.getInt("end")
|
||||
val option = call.getOption()
|
||||
val list: List<AssetEntity> = photoManager.getAssetListWithRange(galleryId, type, start, end, option)
|
||||
resultHandler.reply(ConvertUtils.convertToAssetResult(list))
|
||||
}
|
||||
}
|
||||
"getThumb" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val optionMap = call.argument<Map<*, *>>("option")!!
|
||||
val option = ThumbLoadOption.fromMap(optionMap)
|
||||
photoManager.getThumb(id, option, resultHandler)
|
||||
}
|
||||
}
|
||||
"requestCacheAssetsThumb" -> {
|
||||
runOnBackground {
|
||||
val ids = call.argument<List<String>>("ids")!!
|
||||
val optionMap = call.argument<Map<*, *>>("option")!!
|
||||
val option = ThumbLoadOption.fromMap(optionMap)
|
||||
photoManager.requestCache(ids, option, resultHandler)
|
||||
}
|
||||
}
|
||||
"cancelCacheRequests" -> {
|
||||
runOnBackground {
|
||||
photoManager.cancelCacheRequests()
|
||||
}
|
||||
}
|
||||
"assetExists" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
photoManager.assetExists(id, resultHandler)
|
||||
}
|
||||
}
|
||||
"getFullFile" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val isOrigin = if (!haveLocationPermission) false else call.argument<Boolean>("isOrigin")!!
|
||||
photoManager.getFile(id, isOrigin, resultHandler)
|
||||
}
|
||||
}
|
||||
"getOriginBytes" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
photoManager.getOriginBytes(id, cacheOriginBytes, haveLocationPermission, resultHandler)
|
||||
}
|
||||
}
|
||||
"getMediaUrl" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val type = call.argument<Int>("type")!!
|
||||
val mediaUri = photoManager.getMediaUri(id, type)
|
||||
resultHandler.reply(mediaUri)
|
||||
}
|
||||
}
|
||||
"getPropertiesFromAssetEntity" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val asset = photoManager.getAssetProperties(id)
|
||||
val assetResult = if (asset != null) {
|
||||
ConvertUtils.convertToAssetResult(asset)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
resultHandler.reply(assetResult)
|
||||
}
|
||||
}
|
||||
"fetchPathProperties" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
val type = call.argument<Int>("type")!!
|
||||
val option = call.getOption()
|
||||
val pathEntity = photoManager.getPathEntity(id, type, option)
|
||||
if (pathEntity != null) {
|
||||
val mapResult = ConvertUtils.convertToGalleryResult(listOf(pathEntity))
|
||||
resultHandler.reply(mapResult)
|
||||
} else {
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
"getLatLngAndroidQ" -> {
|
||||
runOnBackground {
|
||||
val id = call.argument<String>("id")!!
|
||||
// 读取id
|
||||
val location = photoManager.getLocation(id)
|
||||
resultHandler.reply(location)
|
||||
}
|
||||
}
|
||||
"notify" -> {
|
||||
runOnBackground {
|
||||
val notify = call.argument<Boolean>("notify")
|
||||
if (notify == true) {
|
||||
notifyChannel.startNotify()
|
||||
} else {
|
||||
notifyChannel.stopNotify()
|
||||
}
|
||||
}
|
||||
}
|
||||
"deleteWithIds" -> {
|
||||
runOnBackground {
|
||||
try {
|
||||
val ids = call.argument<List<String>>("ids")!!
|
||||
if (belowSdk(29)) {
|
||||
deleteManager.deleteInApi28(ids)
|
||||
resultHandler.reply(ids)
|
||||
} else if (IDBUtils.isAndroidR) {
|
||||
val uris = ids.map {
|
||||
photoManager.getUri(it)
|
||||
}.toList()
|
||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||
deleteManager.deleteInApi30(uris, resultHandler)
|
||||
}
|
||||
} else {
|
||||
val uris = ids.mapNotNull { photoManager.getUri(it) }
|
||||
// for (id in ids) {
|
||||
// val uri = photoManager.getUri(id)
|
||||
// if (uri != null) {
|
||||
// deleteManager.deleteWithUriInApi29(uri, false)
|
||||
// }
|
||||
// }
|
||||
deleteManager.deleteWithUriInApi29(ids, uris, resultHandler, false)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error("deleteWithIds failed", e)
|
||||
resultHandler.replyError("deleteWithIds failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
"saveImage" -> {
|
||||
runOnBackground {
|
||||
try {
|
||||
val image = call.argument<ByteArray>("image")!!
|
||||
val title = call.argument<String>("title") ?: ""
|
||||
val desc = call.argument<String>("desc") ?: ""
|
||||
val relativePath = call.argument<String>("relativePath") ?: ""
|
||||
val entity = photoManager.saveImage(image, title, desc, relativePath)
|
||||
if (entity == null) {
|
||||
resultHandler.reply(null)
|
||||
return@runOnBackground
|
||||
}
|
||||
val map = ConvertUtils.convertToAssetResult(entity)
|
||||
resultHandler.reply(map)
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error("save image error", e)
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
"saveImageWithPath" -> {
|
||||
runOnBackground {
|
||||
try {
|
||||
val imagePath = call.argument<String>("path")!!
|
||||
val title = call.argument<String>("title") ?: ""
|
||||
val desc = call.argument<String>("desc") ?: ""
|
||||
val relativePath = call.argument<String>("relativePath") ?: ""
|
||||
val entity = photoManager.saveImage(imagePath, title, desc, relativePath)
|
||||
if (entity == null) {
|
||||
resultHandler.reply(null)
|
||||
return@runOnBackground
|
||||
}
|
||||
val map = ConvertUtils.convertToAssetResult(entity)
|
||||
resultHandler.reply(map)
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error("save image error", e)
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
"saveVideo" -> {
|
||||
runOnBackground {
|
||||
try {
|
||||
val videoPath = call.argument<String>("path")!!
|
||||
val title = call.argument<String>("title")!!
|
||||
val desc = call.argument<String>("desc") ?: ""
|
||||
val relativePath = call.argument<String>("relativePath") ?: ""
|
||||
val entity = photoManager.saveVideo(videoPath, title, desc, relativePath)
|
||||
if (entity == null) {
|
||||
resultHandler.reply(null)
|
||||
return@runOnBackground
|
||||
}
|
||||
val map = ConvertUtils.convertToAssetResult(entity)
|
||||
resultHandler.reply(map)
|
||||
} catch (e: Exception) {
|
||||
LogUtils.error("save video error", e)
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
"copyAsset" -> {
|
||||
runOnBackground {
|
||||
val assetId = call.argument<String>("assetId")!!
|
||||
val galleryId = call.argument<String>("galleryId")!!
|
||||
photoManager.copyToGallery(assetId, galleryId, resultHandler)
|
||||
}
|
||||
}
|
||||
"moveAssetToPath" -> {
|
||||
runOnBackground {
|
||||
val assetId = call.argument<String>("assetId")!!
|
||||
val albumId = call.argument<String>("albumId")!!
|
||||
photoManager.moveToGallery(assetId, albumId, resultHandler)
|
||||
}
|
||||
}
|
||||
"removeNoExistsAssets" -> {
|
||||
runOnBackground {
|
||||
photoManager.removeAllExistsAssets(resultHandler)
|
||||
}
|
||||
}
|
||||
else -> resultHandler.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
private fun MethodCall.getString(key: String): String {
|
||||
return this.argument<String>(key)!!
|
||||
}
|
||||
|
||||
private fun MethodCall.getInt(key: String): Int {
|
||||
return this.argument<Int>(key)!!
|
||||
}
|
||||
|
||||
private fun MethodCall.getOption(): FilterOption {
|
||||
val arguments = argument<Map<*, *>>("option")!!
|
||||
return ConvertUtils.convertFilterOptionsFromMap(arguments)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package top.kikt.imagescanner.core.cache
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import androidx.annotation.RequiresApi
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.utils.AndroidQDBUtils
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.lang.Exception
|
||||
|
||||
/// create 2019-09-10 by cai
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
class AndroidQCache {
|
||||
|
||||
fun getCacheFile(context: Context, id: String, displayName: String, isOrigin: Boolean): File {
|
||||
val originString =
|
||||
if (isOrigin) {
|
||||
"_origin"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val name = "$id${originString}_${displayName}"
|
||||
return File(context.cacheDir, name)
|
||||
}
|
||||
|
||||
fun getCacheFile(context: Context, assetId: String, extName: String, type: Int, isOrigin: Boolean): File? {
|
||||
val targetFile = getCacheFile(context, assetId, extName, isOrigin)
|
||||
|
||||
if (targetFile.exists()) {
|
||||
return targetFile
|
||||
}
|
||||
|
||||
val contentResolver = context.contentResolver
|
||||
|
||||
var uri = AndroidQDBUtils.getUri(assetId, type, isOrigin)
|
||||
if (uri == Uri.EMPTY) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
val inputStream = contentResolver.openInputStream(uri)
|
||||
val outputStream = FileOutputStream(targetFile)
|
||||
outputStream.use {
|
||||
inputStream?.copyTo(it)
|
||||
}
|
||||
}catch (e:Exception){
|
||||
LogUtils.info("$assetId , isOrigin: $isOrigin, copy file error:${e.localizedMessage}")
|
||||
return null
|
||||
}
|
||||
return targetFile
|
||||
}
|
||||
|
||||
fun saveAssetCache(context: Context, asset: AssetEntity, byteArray: ByteArray, isOrigin: Boolean = false) {
|
||||
val file = getCacheFile(context, asset.id, asset.displayName, isOrigin)
|
||||
if (file.exists()) {
|
||||
LogUtils.info("${asset.id} , isOrigin: $isOrigin, cache file exists, ignore save")
|
||||
return
|
||||
}
|
||||
|
||||
if (file.parentFile?.exists() != true) {
|
||||
file.mkdirs()
|
||||
}
|
||||
file.writeBytes(byteArray)
|
||||
|
||||
LogUtils.info("${asset.id} , isOrigin: $isOrigin, cached")
|
||||
}
|
||||
|
||||
fun clearAllCache(context: Context) {
|
||||
val files = context.cacheDir
|
||||
?.listFiles()
|
||||
?.filterNotNull() ?: return
|
||||
for (file in files) {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package top.kikt.imagescanner.core.cache
|
||||
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
|
||||
class CacheContainer {
|
||||
|
||||
// key is path
|
||||
// value is asset entity
|
||||
private val assetMap = HashMap<String, AssetEntity>()
|
||||
|
||||
fun putAsset(assetEntity: AssetEntity) {
|
||||
assetMap[assetEntity.id] = assetEntity
|
||||
}
|
||||
|
||||
fun getAsset(id: String): AssetEntity? {
|
||||
return assetMap[id]
|
||||
}
|
||||
|
||||
fun clearCache() {
|
||||
assetMap.clear()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package top.kikt.imagescanner.core.entity
|
||||
|
||||
import android.net.Uri
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils.Companion.isAndroidQ
|
||||
import top.kikt.imagescanner.core.utils.MediaStoreUtils
|
||||
import java.io.File
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
data class AssetEntity(
|
||||
val id: String,
|
||||
var path: String,
|
||||
val duration: Long,
|
||||
val createDt: Long,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
val type: Int,
|
||||
val displayName: String,
|
||||
val modifiedDate: Long,
|
||||
val orientation: Int,
|
||||
var lat: Double? = null,
|
||||
var lng: Double? = null,
|
||||
val androidQRelativePath: String? = null,
|
||||
val mimeType:String? = null
|
||||
) {
|
||||
|
||||
fun getUri(): Uri {
|
||||
return MediaStoreUtils.getDeleteUri(id, MediaStoreUtils.convertTypeToMediaType(type))
|
||||
}
|
||||
|
||||
val relativePath: String?
|
||||
get() {
|
||||
return if (isAndroidQ) {
|
||||
androidQRelativePath
|
||||
} else {
|
||||
File(path).parent
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package top.kikt.imagescanner.core.entity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.provider.MediaStore
|
||||
import top.kikt.imagescanner.AssetType
|
||||
import top.kikt.imagescanner.core.utils.ConvertUtils
|
||||
|
||||
class FilterOption(map: Map<*, *>) {
|
||||
val videoOption = ConvertUtils.getOptionFromType(map, AssetType.Video)
|
||||
val imageOption = ConvertUtils.getOptionFromType(map, AssetType.Image)
|
||||
val audioOption = ConvertUtils.getOptionFromType(map, AssetType.Audio)
|
||||
val createDateCond = ConvertUtils.convertToDateCond(map["createDate"] as Map<*, *>)
|
||||
val updateDateCond = ConvertUtils.convertToDateCond(map["updateDate"] as Map<*, *>)
|
||||
|
||||
private val orderByCond: List<OrderByCond> = ConvertUtils.convertOrderByCondList(map["orders"] as List<*>)
|
||||
|
||||
val containsPathModified = map["containsPathModified"] as Boolean
|
||||
|
||||
fun orderByCondString(): String? {
|
||||
if (orderByCond.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
return orderByCond.joinToString(",") {
|
||||
it.getOrder()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FilterCond {
|
||||
var isShowTitle = false
|
||||
lateinit var sizeConstraint: SizeConstraint
|
||||
lateinit var durationConstraint: DurationConstraint
|
||||
|
||||
companion object {
|
||||
private const val widthKey = MediaStore.Files.FileColumns.WIDTH
|
||||
private const val heightKey = MediaStore.Files.FileColumns.HEIGHT
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
private const val durationKey = MediaStore.Video.VideoColumns.DURATION
|
||||
}
|
||||
|
||||
fun sizeCond(): String {
|
||||
|
||||
return "$widthKey >= ? AND $widthKey <= ? AND $heightKey >= ? AND $heightKey <=?"
|
||||
}
|
||||
|
||||
fun sizeArgs(): Array<String> {
|
||||
return arrayOf(sizeConstraint.minWidth, sizeConstraint.maxWidth, sizeConstraint.minHeight, sizeConstraint.maxHeight).toList().map {
|
||||
it.toString()
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
||||
fun durationCond(): String {
|
||||
return "$durationKey >=? AND $durationKey <=?"
|
||||
}
|
||||
|
||||
fun durationArgs(): Array<String> {
|
||||
return arrayOf(durationConstraint.min, durationConstraint.max).toList().map {
|
||||
it.toString()
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
||||
class SizeConstraint {
|
||||
var minWidth = 0
|
||||
var maxWidth = 0
|
||||
var minHeight = 0
|
||||
var maxHeight = 0
|
||||
var ignoreSize = false
|
||||
}
|
||||
|
||||
class DurationConstraint {
|
||||
var min: Long = 0
|
||||
var max: Long = 0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data class DateCond(
|
||||
val minMs: Long,
|
||||
val maxMs: Long,
|
||||
val ignore: Boolean
|
||||
)
|
||||
|
||||
data class OrderByCond(
|
||||
val key: String,
|
||||
val asc: Boolean
|
||||
) {
|
||||
fun getOrder(): String {
|
||||
val ascValue = if (asc) {
|
||||
"asc"
|
||||
} else {
|
||||
"desc"
|
||||
}
|
||||
return "$key $ascValue"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package top.kikt.imagescanner.core.entity
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
data class GalleryEntity(
|
||||
val id: String,
|
||||
val name: String,
|
||||
var length: Int,
|
||||
val typeInt: Int,
|
||||
var isAll: Boolean = false,
|
||||
var modifiedDate: Long? = null
|
||||
)
|
|
@ -0,0 +1,7 @@
|
|||
package top.kikt.imagescanner.core.entity
|
||||
|
||||
enum class PermissionResult(val value: Int) {
|
||||
NotDetermined(0),
|
||||
Denied(2),
|
||||
Authorized(3),
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package top.kikt.imagescanner.core.entity
|
||||
|
||||
import android.graphics.Bitmap
|
||||
|
||||
data class ThumbLoadOption(val width: Int, val height: Int, val format: Bitmap.CompressFormat, val quality: Int) {
|
||||
|
||||
companion object Factory {
|
||||
fun fromMap(map: Map<*, *>): ThumbLoadOption {
|
||||
val width = map["width"] as Int
|
||||
val height = map["height"] as Int
|
||||
val format = map["format"] as Int
|
||||
val quality = map["quality"] as Int
|
||||
|
||||
val compressFormat =
|
||||
if (format == 0) {
|
||||
Bitmap.CompressFormat.JPEG
|
||||
} else {
|
||||
Bitmap.CompressFormat.PNG
|
||||
}
|
||||
|
||||
return ThumbLoadOption(width, height, compressFormat, quality)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,696 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore
|
||||
import android.provider.MediaStore.Files.FileColumns.*
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import top.kikt.imagescanner.core.PhotoManager
|
||||
import top.kikt.imagescanner.core.cache.AndroidQCache
|
||||
import top.kikt.imagescanner.core.cache.CacheContainer
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.GalleryEntity
|
||||
import top.kikt.imagescanner.core.utils.AndroidQDBUtils.getString
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.net.URLConnection
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
/// create 2020-09-23 by cai
|
||||
@Suppress("DEPRECATION")
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
@SuppressLint("Recycle")
|
||||
object Android30DbUtils : IDBUtils {
|
||||
private const val TAG = "PhotoManagerPlugin"
|
||||
|
||||
private var androidQCache = AndroidQCache()
|
||||
|
||||
private val galleryKeys = arrayOf(
|
||||
MediaStore.Images.Media.BUCKET_ID,
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME
|
||||
)
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selections = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, galleryKeys, selections, args.toTypedArray(), option.orderByCondString())
|
||||
?: return list
|
||||
|
||||
LogUtils.logCursor(cursor, BUCKET_ID)
|
||||
|
||||
val nameMap = HashMap<String, String>()
|
||||
val countMap = HashMap<String, Int>()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val galleryId = cursor.getString(MediaStore.Images.Media.BUCKET_ID)
|
||||
|
||||
if (nameMap.containsKey(galleryId)) {
|
||||
countMap[galleryId] = countMap[galleryId]!! + 1
|
||||
continue
|
||||
}
|
||||
val galleryName = cursor.getString(MediaStore.Images.Media.BUCKET_DISPLAY_NAME) ?: ""
|
||||
|
||||
nameMap[galleryId] = galleryName
|
||||
countMap[galleryId] = 1
|
||||
}
|
||||
|
||||
nameMap.forEach {
|
||||
val id = it.key
|
||||
val name = it.value
|
||||
val count = countMap[id]!!
|
||||
|
||||
val entity = GalleryEntity(id, name, count, requestType, false)
|
||||
|
||||
if (option.containsPathModified) {
|
||||
injectModifiedDate(context, entity)
|
||||
}
|
||||
|
||||
list.add(entity)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getOnlyGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selections = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, galleryKeys, selections, args.toTypedArray(), option.orderByCondString())
|
||||
?: return list
|
||||
|
||||
cursor.use {
|
||||
val count = cursor.count
|
||||
val galleryEntity = GalleryEntity(PhotoManager.ALL_ID, "Recent", count, requestType, true)
|
||||
list.add(galleryEntity)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getSortOrder(start: Int, pageSize: Int, filterOption: FilterOption): String? {
|
||||
return filterOption.orderByCondString()
|
||||
}
|
||||
|
||||
|
||||
private fun cursorWithRange(cursor: Cursor, start: Int, pageSize: Int, block: (cursor: Cursor) -> Unit) {
|
||||
cursor.moveToPosition(start - 1)
|
||||
|
||||
for (i in 0 until pageSize) {
|
||||
if (cursor.moveToNext()) {
|
||||
block(cursor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getAssetFromGalleryId(context: Context, galleryId: String, page: Int, pageSize: Int, requestType: Int, option: FilterOption, cacheContainer: CacheContainer?): List<AssetEntity> {
|
||||
|
||||
val isAll = galleryId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(galleryId)
|
||||
}
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
// val sizeWhere = ""
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val keys = (assetKeys()).distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val sortOrder = getSortOrder(page * pageSize, pageSize, option)
|
||||
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
cursorWithRange(cursor, page * pageSize, pageSize) {
|
||||
val asset = convertCursorToAssetEntity(cursor)
|
||||
list.add(asset)
|
||||
}
|
||||
|
||||
// while (cursor.moveToNext()) {
|
||||
// val asset = convertCursorToAssetEntity(cursor)
|
||||
// list.add(asset)
|
||||
// }
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun getAssetFromGalleryIdRange(context: Context, gId: String, start: Int, end: Int, requestType: Int, option: FilterOption): List<AssetEntity> {
|
||||
val isAll = gId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(gId)
|
||||
}
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val keys = assetKeys().distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val pageSize = end - start
|
||||
|
||||
val sortOrder = getSortOrder(start, pageSize, option)
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
cursorWithRange(cursor, start, pageSize) {
|
||||
val asset = convertCursorToAssetEntity(cursor)
|
||||
list.add(asset)
|
||||
}
|
||||
|
||||
// while (cursor.moveToNext()) {
|
||||
// val asset = convertCursorToAssetEntity(cursor)
|
||||
// list.add(asset)
|
||||
// }
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
private fun assetKeys() = IDBUtils.storeImageKeys + IDBUtils.storeVideoKeys + IDBUtils.typeKeys + arrayOf(MediaStore.MediaColumns.RELATIVE_PATH)
|
||||
|
||||
private fun convertCursorToAssetEntity(cursor: Cursor): AssetEntity {
|
||||
val id = cursor.getString(MediaStore.MediaColumns._ID)
|
||||
val path = cursor.getString(MediaStore.MediaColumns.DATA)
|
||||
val date = cursor.getLong(MediaStore.Images.Media.DATE_ADDED)
|
||||
val type = cursor.getInt(MEDIA_TYPE)
|
||||
|
||||
val mimeType = cursor.getString(MIME_TYPE)
|
||||
|
||||
val duration = if (type == MEDIA_TYPE_IMAGE) 0 else cursor.getLong(MediaStore.Video.VideoColumns.DURATION)
|
||||
val width = cursor.getInt(MediaStore.MediaColumns.WIDTH)
|
||||
val height = cursor.getInt(MediaStore.MediaColumns.HEIGHT)
|
||||
val displayName = cursor.getString(MediaStore.Images.Media.DISPLAY_NAME)
|
||||
val modifiedDate = cursor.getLong(MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
val orientation: Int = cursor.getInt(MediaStore.MediaColumns.ORIENTATION)
|
||||
val relativePath: String = cursor.getString(MediaStore.MediaColumns.RELATIVE_PATH)
|
||||
return AssetEntity(id, path, duration, date, width, height, getMediaType(type), displayName, modifiedDate, orientation, androidQRelativePath = relativePath, mimeType = mimeType)
|
||||
}
|
||||
|
||||
override fun getAssetEntity(context: Context, id: String): AssetEntity? {
|
||||
val keys = assetKeys().distinct().toTypedArray()
|
||||
|
||||
val selection = "$_ID = ?"
|
||||
|
||||
val args = arrayOf(id)
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, keys, selection, args, null)
|
||||
cursor?.use {
|
||||
return if (cursor.moveToNext()) {
|
||||
val dbAsset = convertCursorToAssetEntity(cursor)
|
||||
cursor.close()
|
||||
dbAsset
|
||||
} else {
|
||||
cursor.close()
|
||||
null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getGalleryEntity(context: Context, galleryId: String, type: Int, option: FilterOption): GalleryEntity? {
|
||||
val uri = allUri
|
||||
val projection = IDBUtils.storeBucketKeys
|
||||
|
||||
val isAll = galleryId == ""
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(type, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val idSelection: String
|
||||
if (isAll) {
|
||||
idSelection = ""
|
||||
} else {
|
||||
idSelection = "AND ${MediaStore.Images.Media.BUCKET_ID} = ?"
|
||||
args.add(galleryId)
|
||||
}
|
||||
|
||||
val sizeWhere = sizeWhere(null, option)
|
||||
|
||||
val selection = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $idSelection $sizeWhere"
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, args.toTypedArray(), null)
|
||||
?: return null
|
||||
|
||||
val name: String?
|
||||
if (cursor.moveToNext()) {
|
||||
name = cursor.getString(1) ?: ""
|
||||
} else {
|
||||
cursor.close()
|
||||
return null
|
||||
}
|
||||
return GalleryEntity(galleryId, name, cursor.count, type, isAll)
|
||||
}
|
||||
|
||||
override fun getExif(context: Context, id: String): ExifInterface? {
|
||||
try {
|
||||
val asset = getAssetEntity(context, id) ?: return null
|
||||
|
||||
val uri = getUri(asset)
|
||||
|
||||
val originalUri = MediaStore.setRequireOriginal(uri)
|
||||
|
||||
val inputStream = context.contentResolver.openInputStream(originalUri) ?: return null
|
||||
return ExifInterface(inputStream)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearCache() {
|
||||
}
|
||||
|
||||
override fun getFilePath(context: Context, id: String, origin: Boolean): String? {
|
||||
val assetEntity = getAssetEntity(context, id) ?: return null
|
||||
return assetEntity.path
|
||||
}
|
||||
|
||||
override fun getThumbUri(context: Context, id: String, width: Int, height: Int, type: Int?): Uri? {
|
||||
if (type == null) {
|
||||
return null
|
||||
}
|
||||
return getUri(id, type)
|
||||
}
|
||||
|
||||
private fun getUri(asset: AssetEntity, isOrigin: Boolean = false): Uri = getUri(asset.id, asset.type, isOrigin)
|
||||
|
||||
override fun getOriginBytes(context: Context, asset: AssetEntity, haveLocationPermission: Boolean): ByteArray {
|
||||
val file = androidQCache.getCacheFile(context, asset.id, asset.displayName, true)
|
||||
if (file.exists()) {
|
||||
LogUtils.info("the origin bytes come from ${file.absolutePath}")
|
||||
return file.readBytes()
|
||||
}
|
||||
|
||||
val uri = getUri(asset, haveLocationPermission)
|
||||
val inputStream = context.contentResolver.openInputStream(uri)
|
||||
|
||||
LogUtils.info("the cache file no exists, will read from MediaStore: $uri")
|
||||
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
inputStream?.use {
|
||||
outputStream.write(it.readBytes())
|
||||
}
|
||||
val byteArray = outputStream.toByteArray()
|
||||
|
||||
if (LogUtils.isLog) {
|
||||
LogUtils.info("The asset ${asset.id} origin byte length : ${byteArray.count()}")
|
||||
}
|
||||
|
||||
return byteArray
|
||||
}
|
||||
|
||||
override fun cacheOriginFile(context: Context, asset: AssetEntity, byteArray: ByteArray) {
|
||||
androidQCache.saveAssetCache(context, asset, byteArray, true)
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, image: ByteArray, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val (width, height) =
|
||||
try {
|
||||
val bmp = BitmapFactory.decodeByteArray(image, 0, image.count())
|
||||
Pair(bmp.width, bmp.height)
|
||||
} catch (e: Exception) {
|
||||
Pair(0, 0)
|
||||
}
|
||||
|
||||
val inputStream = ByteArrayInputStream(image)
|
||||
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
|
||||
val typeFromStream: String = if (title.contains(".")) {
|
||||
// title contains file extension, form mimeType from it
|
||||
"image/${File(title).extension}"
|
||||
} else {
|
||||
URLConnection.guessContentTypeFromStream(inputStream) ?: "image/*"
|
||||
}
|
||||
|
||||
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.Media.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Images.ImageColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
val inputStream = FileInputStream(path)
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "image/${File(path).extension}"
|
||||
|
||||
val (width, height) =
|
||||
try {
|
||||
val bmp = BitmapFactory.decodeFile(path)
|
||||
Pair(bmp.width, bmp.height)
|
||||
} catch (e: Exception) {
|
||||
Pair(0, 0)
|
||||
}
|
||||
|
||||
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Images.ImageColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.DURATION, 0)
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Images.ImageColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
override fun copyToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throwMsg("Cannot get gallery id of $assetId")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throwMsg("No copy required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val asset = getAssetEntity(context, assetId)
|
||||
?: throwMsg("No copy required, because the target gallery is the same as the current one.")
|
||||
|
||||
val copyKeys = arrayListOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME,
|
||||
MediaStore.Video.VideoColumns.TITLE,
|
||||
MediaStore.Video.VideoColumns.DATE_ADDED,
|
||||
MediaStore.Video.VideoColumns.DATE_MODIFIED,
|
||||
MediaStore.Video.VideoColumns.DATE_TAKEN,
|
||||
MediaStore.Video.VideoColumns.DURATION,
|
||||
MediaStore.Video.VideoColumns.WIDTH,
|
||||
MediaStore.Video.VideoColumns.HEIGHT
|
||||
)
|
||||
|
||||
val mediaType = convertTypeToMediaType(asset.type)
|
||||
|
||||
if (mediaType == MEDIA_TYPE_VIDEO) {
|
||||
copyKeys.add(MediaStore.Video.VideoColumns.DESCRIPTION)
|
||||
}
|
||||
|
||||
val cursor = cr.query(allUri, copyKeys.toTypedArray() + arrayOf(MediaStore.Video.VideoColumns.RELATIVE_PATH), idSelection, arrayOf(assetId), null)
|
||||
?: throwMsg("Cannot find asset.")
|
||||
|
||||
if (!cursor.moveToNext()) {
|
||||
throwMsg("Cannot find asset.")
|
||||
}
|
||||
|
||||
val insertUri = MediaStoreUtils.getInsertUri(mediaType)
|
||||
|
||||
val relativePath = getRelativePath(context, galleryId)
|
||||
|
||||
val cv = ContentValues().apply {
|
||||
for (key in copyKeys) {
|
||||
put(key, cursor.getString(key))
|
||||
}
|
||||
put(MEDIA_TYPE, mediaType)
|
||||
put(RELATIVE_PATH, relativePath)
|
||||
}
|
||||
|
||||
val insertedUri = cr.insert(insertUri, cv) ?: throwMsg("Cannot insert new asset.")
|
||||
val outputStream = cr.openOutputStream(insertedUri)
|
||||
?: throwMsg("Cannot open output stream for $insertedUri.")
|
||||
val inputUri = getUri(asset, true)
|
||||
val inputStream = cr.openInputStream(inputUri)
|
||||
?: throwMsg("Cannot open input stream for $inputUri")
|
||||
inputStream.use {
|
||||
outputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val insertedId = insertedUri.lastPathSegment
|
||||
?: throwMsg("Cannot open output stream for $insertedUri.")
|
||||
|
||||
return getAssetEntity(context, insertedId)
|
||||
}
|
||||
|
||||
override fun moveToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throwMsg("Cannot get gallery id of $assetId")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throwMsg("No move required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val targetPath = getRelativePath(context, galleryId)
|
||||
|
||||
val contentValues = ContentValues().apply {
|
||||
put(MediaStore.MediaColumns.RELATIVE_PATH, targetPath)
|
||||
}
|
||||
|
||||
val count = cr.update(allUri, contentValues, idSelection, arrayOf(assetId))
|
||||
if (count > 0) {
|
||||
return getAssetEntity(context, assetId)
|
||||
}
|
||||
throwMsg("Cannot update $assetId relativePath")
|
||||
}
|
||||
|
||||
private val deleteLock = ReentrantLock()
|
||||
|
||||
override fun removeAllExistsAssets(context: Context): Boolean {
|
||||
if (deleteLock.isLocked) {
|
||||
Log.i(TAG, "The removeAllExistsAssets is running.")
|
||||
return false
|
||||
}
|
||||
deleteLock.withLock {
|
||||
Log.i(TAG, "The removeAllExistsAssets is starting.")
|
||||
val removedList = ArrayList<String>()
|
||||
val cr = context.contentResolver
|
||||
|
||||
val queryCursor = cr.query(
|
||||
allUri,
|
||||
arrayOf(BaseColumns._ID, MEDIA_TYPE, DATA),
|
||||
"$MEDIA_TYPE in ( ?,?,? )",
|
||||
arrayOf(MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO, MEDIA_TYPE_IMAGE).map { it.toString() }.toTypedArray(),
|
||||
null
|
||||
) ?: return false
|
||||
queryCursor.use {
|
||||
var count = 0
|
||||
while (queryCursor.moveToNext()) {
|
||||
val id = queryCursor.getString(BaseColumns._ID)
|
||||
val mediaType = queryCursor.getInt(MEDIA_TYPE)
|
||||
val path = queryCursor.getStringOrNull(DATA)
|
||||
val type = getTypeFromMediaType(mediaType)
|
||||
val uri = getUri(id, type)
|
||||
val exists = try {
|
||||
cr.openInputStream(uri)?.close()
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
if (!exists) {
|
||||
removedList.add(id)
|
||||
Log.i(TAG, "The $id, $path media was not exists. ")
|
||||
}
|
||||
count++
|
||||
|
||||
if (count % 300 == 0) {
|
||||
Log.i(TAG, "Current checked count == $count")
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "The removeAllExistsAssets was stopped, will be delete ids = $removedList")
|
||||
}
|
||||
|
||||
val idWhere = removedList.joinToString(",") { "?" }
|
||||
|
||||
// Remove exists rows.
|
||||
val deleteRowCount = cr.delete(allUri, "${BaseColumns._ID} in ( $idWhere )", removedList.toTypedArray())
|
||||
Log.i("PhotoManagerPlugin", "Delete rows: $deleteRowCount")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getRelativePath(context: Context, galleryId: String): String? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(BUCKET_ID, RELATIVE_PATH), "$BUCKET_ID = ?", arrayOf(galleryId), null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
return cursor.getString(1)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSomeInfo(context: Context, assetId: String): Pair<String, String>? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(BUCKET_ID, RELATIVE_PATH), "$_ID = ?", arrayOf(assetId), null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val galleryID = cursor.getString(0)
|
||||
val path = cursor.getString(1)
|
||||
|
||||
return Pair(galleryID, File(path).parent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveVideo(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
val inputStream = FileInputStream(path)
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "video/${File(path).extension}"
|
||||
|
||||
val uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val info = VideoUtils.getPropertiesUseMediaPlayer(path)
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_VIDEO)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Video.VideoColumns.TITLE, title)
|
||||
put(MediaStore.Video.VideoColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Video.VideoColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Video.VideoColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.DURATION, info.duration)
|
||||
put(MediaStore.Video.VideoColumns.WIDTH, info.width)
|
||||
put(MediaStore.Video.VideoColumns.HEIGHT, info.height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Video.VideoColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,691 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore
|
||||
import android.provider.MediaStore.Files.FileColumns.*
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import top.kikt.imagescanner.core.PhotoManager
|
||||
import top.kikt.imagescanner.core.cache.AndroidQCache
|
||||
import top.kikt.imagescanner.core.cache.CacheContainer
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.GalleryEntity
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.net.URLConnection
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
/// create 2019-09-11 by cai
|
||||
@Suppress("DEPRECATION")
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
@SuppressLint("Recycle")
|
||||
object AndroidQDBUtils : IDBUtils {
|
||||
private const val TAG = "PhotoManagerPlugin"
|
||||
|
||||
private val cacheContainer = CacheContainer()
|
||||
|
||||
private var androidQCache = AndroidQCache()
|
||||
|
||||
private val galleryKeys = arrayOf(
|
||||
MediaStore.Images.Media.BUCKET_ID,
|
||||
MediaStore.Images.Media.BUCKET_DISPLAY_NAME
|
||||
)
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selections = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, galleryKeys, selections, args.toTypedArray(), option.orderByCondString())
|
||||
?: return list
|
||||
|
||||
LogUtils.logCursor(cursor)
|
||||
|
||||
val nameMap = HashMap<String, String>()
|
||||
val countMap = HashMap<String, Int>()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val galleryId = cursor.getString(0)
|
||||
|
||||
if (nameMap.containsKey(galleryId)) {
|
||||
countMap[galleryId] = countMap[galleryId]!! + 1
|
||||
continue
|
||||
}
|
||||
val galleryName = cursor.getString(1) ?: ""
|
||||
|
||||
nameMap[galleryId] = galleryName
|
||||
countMap[galleryId] = 1
|
||||
}
|
||||
|
||||
nameMap.forEach {
|
||||
val id = it.key
|
||||
val name = it.value
|
||||
val count = countMap[id]!!
|
||||
|
||||
val entity = GalleryEntity(id, name, count, requestType, false)
|
||||
|
||||
if (option.containsPathModified) {
|
||||
injectModifiedDate(context, entity)
|
||||
}
|
||||
|
||||
list.add(entity)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getOnlyGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selections = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, galleryKeys, selections, args.toTypedArray(), option.orderByCondString())
|
||||
?: return list
|
||||
|
||||
cursor.use {
|
||||
val count = cursor.count
|
||||
val galleryEntity = GalleryEntity(PhotoManager.ALL_ID, "Recent", count, requestType, true)
|
||||
list.add(galleryEntity)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getAssetFromGalleryId(context: Context, galleryId: String, page: Int, pageSize: Int, requestType: Int, option: FilterOption, cacheContainer: CacheContainer?): List<AssetEntity> {
|
||||
val cache = cacheContainer ?: this.cacheContainer
|
||||
|
||||
val isAll = galleryId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(galleryId)
|
||||
}
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val keys = (assetKeys()).distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val sortOrder = getSortOrder(page * pageSize, pageSize, option)
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val asset = convertCursorToAssetEntity(cursor)
|
||||
list.add(asset)
|
||||
cache.putAsset(asset)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
override fun getAssetFromGalleryIdRange(context: Context, gId: String, start: Int, end: Int, requestType: Int, option: FilterOption): List<AssetEntity> {
|
||||
val cache = cacheContainer
|
||||
|
||||
val isAll = gId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(gId)
|
||||
}
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val keys = assetKeys().distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val pageSize = end - start
|
||||
|
||||
val sortOrder = getSortOrder(start, pageSize, option)
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val asset = convertCursorToAssetEntity(cursor)
|
||||
list.add(asset)
|
||||
cache.putAsset(asset)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
private fun assetKeys() = IDBUtils.storeImageKeys + IDBUtils.storeVideoKeys + IDBUtils.typeKeys + arrayOf(MediaStore.MediaColumns.RELATIVE_PATH)
|
||||
|
||||
private fun convertCursorToAssetEntity(cursor: Cursor): AssetEntity {
|
||||
val id = cursor.getString(MediaStore.MediaColumns._ID)
|
||||
val path = cursor.getString(MediaStore.MediaColumns.DATA)
|
||||
val date = cursor.getLong(MediaStore.Images.Media.DATE_ADDED)
|
||||
val type = cursor.getInt(MEDIA_TYPE)
|
||||
val mimeType = cursor.getString(MIME_TYPE)
|
||||
|
||||
val duration = if (type == MEDIA_TYPE_IMAGE) 0 else cursor.getLong(MediaStore.Video.VideoColumns.DURATION)
|
||||
val width = cursor.getInt(MediaStore.MediaColumns.WIDTH)
|
||||
val height = cursor.getInt(MediaStore.MediaColumns.HEIGHT)
|
||||
val displayName = cursor.getString(MediaStore.Images.Media.DISPLAY_NAME)
|
||||
val modifiedDate = cursor.getLong(MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
val orientation: Int = cursor.getInt(MediaStore.MediaColumns.ORIENTATION)
|
||||
val relativePath: String = cursor.getString(MediaStore.MediaColumns.RELATIVE_PATH)
|
||||
return AssetEntity(id, path, duration, date, width, height, getMediaType(type), displayName, modifiedDate, orientation, androidQRelativePath = relativePath, mimeType = mimeType)
|
||||
}
|
||||
|
||||
override fun getAssetEntity(context: Context, id: String): AssetEntity? {
|
||||
val asset = cacheContainer.getAsset(id)
|
||||
if (asset != null) {
|
||||
return asset
|
||||
}
|
||||
|
||||
val keys = assetKeys().distinct().toTypedArray()
|
||||
|
||||
val selection = "$_ID = ?"
|
||||
|
||||
val args = arrayOf(id)
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, keys, selection, args, null)
|
||||
cursor?.use {
|
||||
return if (cursor.moveToNext()) {
|
||||
val dbAsset = convertCursorToAssetEntity(cursor)
|
||||
cacheContainer.putAsset(dbAsset)
|
||||
cursor.close()
|
||||
dbAsset
|
||||
} else {
|
||||
cursor.close()
|
||||
null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getGalleryEntity(context: Context, galleryId: String, type: Int, option: FilterOption): GalleryEntity? {
|
||||
val uri = allUri
|
||||
val projection = IDBUtils.storeBucketKeys
|
||||
|
||||
val isAll = galleryId == ""
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(type, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val idSelection: String
|
||||
if (isAll) {
|
||||
idSelection = ""
|
||||
} else {
|
||||
idSelection = "AND ${MediaStore.Images.Media.BUCKET_ID} = ?"
|
||||
args.add(galleryId)
|
||||
}
|
||||
|
||||
val sizeWhere = sizeWhere(null, option)
|
||||
|
||||
val selection = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $idSelection $sizeWhere"
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, args.toTypedArray(), null)
|
||||
?: return null
|
||||
|
||||
val name: String?
|
||||
if (cursor.moveToNext()) {
|
||||
name = cursor.getString(1) ?: ""
|
||||
} else {
|
||||
cursor.close()
|
||||
return null
|
||||
}
|
||||
return GalleryEntity(galleryId, name, cursor.count, type, isAll)
|
||||
}
|
||||
|
||||
override fun getExif(context: Context, id: String): ExifInterface? {
|
||||
try {
|
||||
val asset = getAssetEntity(context, id) ?: return null
|
||||
|
||||
val uri = getUri(asset)
|
||||
|
||||
val originalUri = MediaStore.setRequireOriginal(uri)
|
||||
|
||||
val inputStream = context.contentResolver.openInputStream(originalUri) ?: return null
|
||||
return ExifInterface(inputStream)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearCache() {
|
||||
cacheContainer.clearCache()
|
||||
}
|
||||
|
||||
override fun clearFileCache(context: Context) {
|
||||
androidQCache.clearAllCache(context)
|
||||
}
|
||||
|
||||
override fun getFilePath(context: Context, id: String, origin: Boolean): String? {
|
||||
val assetEntity = getAssetEntity(context, id) ?: return null
|
||||
|
||||
if (useFilePath()) {
|
||||
return assetEntity.path
|
||||
}
|
||||
|
||||
val cacheFile = androidQCache.getCacheFile(context, id, assetEntity.displayName, assetEntity.type, origin)
|
||||
?: return null
|
||||
return cacheFile.path
|
||||
}
|
||||
|
||||
override fun getThumbUri(context: Context, id: String, width: Int, height: Int, type: Int?): Uri? {
|
||||
if (type == null) {
|
||||
return null
|
||||
}
|
||||
return getUri(id, type)
|
||||
}
|
||||
|
||||
private fun getUri(asset: AssetEntity, isOrigin: Boolean = false): Uri = getUri(asset.id, asset.type, isOrigin)
|
||||
|
||||
override fun getOriginBytes(context: Context, asset: AssetEntity, haveLocationPermission: Boolean): ByteArray {
|
||||
val file = androidQCache.getCacheFile(context, asset.id, asset.displayName, true)
|
||||
if (file.exists()) {
|
||||
LogUtils.info("the origin bytes come from ${file.absolutePath}")
|
||||
return file.readBytes()
|
||||
}
|
||||
|
||||
val uri = getUri(asset, haveLocationPermission)
|
||||
val inputStream = context.contentResolver.openInputStream(uri)
|
||||
|
||||
LogUtils.info("the cache file no exists, will read from MediaStore: $uri")
|
||||
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
inputStream?.use {
|
||||
outputStream.write(it.readBytes())
|
||||
}
|
||||
val byteArray = outputStream.toByteArray()
|
||||
|
||||
if (LogUtils.isLog) {
|
||||
LogUtils.info("The asset ${asset.id} origin byte length : ${byteArray.count()}")
|
||||
}
|
||||
|
||||
return byteArray
|
||||
}
|
||||
|
||||
override fun cacheOriginFile(context: Context, asset: AssetEntity, byteArray: ByteArray) {
|
||||
androidQCache.saveAssetCache(context, asset, byteArray, true)
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, image: ByteArray, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val (width, height) =
|
||||
try {
|
||||
val bmp = BitmapFactory.decodeByteArray(image, 0, image.count())
|
||||
Pair(bmp.width, bmp.height)
|
||||
} catch (e: Exception) {
|
||||
Pair(0, 0)
|
||||
}
|
||||
|
||||
val inputStream = ByteArrayInputStream(image)
|
||||
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
|
||||
val typeFromStream: String = if (title.contains(".")) {
|
||||
// title contains file extension, form mimeType from it
|
||||
"image/${File(title).extension}"
|
||||
} else {
|
||||
URLConnection.guessContentTypeFromStream(inputStream) ?: "image/*"
|
||||
}
|
||||
|
||||
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.Media.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Images.ImageColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
val inputStream = FileInputStream(path)
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "image/${File(path).extension}"
|
||||
|
||||
val (width, height) =
|
||||
try {
|
||||
val bmp = BitmapFactory.decodeFile(path)
|
||||
Pair(bmp.width, bmp.height)
|
||||
} catch (e: Exception) {
|
||||
Pair(0, 0)
|
||||
}
|
||||
|
||||
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Images.ImageColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.DURATION, 0)
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Images.ImageColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
override fun copyToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throwMsg("Cannot get gallery id of $assetId")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throwMsg("No copy required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val asset = getAssetEntity(context, assetId)
|
||||
?: throwMsg("No copy required, because the target gallery is the same as the current one.")
|
||||
|
||||
val copyKeys = arrayListOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME,
|
||||
MediaStore.Video.VideoColumns.TITLE,
|
||||
MediaStore.Video.VideoColumns.DATE_ADDED,
|
||||
MediaStore.Video.VideoColumns.DATE_MODIFIED,
|
||||
MediaStore.Video.VideoColumns.DATE_TAKEN,
|
||||
MediaStore.Video.VideoColumns.DURATION,
|
||||
MediaStore.Video.VideoColumns.WIDTH,
|
||||
MediaStore.Video.VideoColumns.HEIGHT
|
||||
)
|
||||
|
||||
val mediaType = convertTypeToMediaType(asset.type)
|
||||
|
||||
if (mediaType == MEDIA_TYPE_VIDEO) {
|
||||
copyKeys.add(MediaStore.Video.VideoColumns.DESCRIPTION)
|
||||
}
|
||||
|
||||
val cursor = cr.query(allUri, copyKeys.toTypedArray() + arrayOf(MediaStore.Video.VideoColumns.RELATIVE_PATH), idSelection, arrayOf(assetId), null)
|
||||
?: throwMsg("Cannot find asset.")
|
||||
|
||||
if (!cursor.moveToNext()) {
|
||||
throwMsg("Cannot find asset.")
|
||||
}
|
||||
|
||||
val insertUri = MediaStoreUtils.getInsertUri(mediaType)
|
||||
|
||||
val relativePath = getRelativePath(context, galleryId)
|
||||
|
||||
val cv = ContentValues().apply {
|
||||
for (key in copyKeys) {
|
||||
put(key, cursor.getString(key))
|
||||
}
|
||||
put(MEDIA_TYPE, mediaType)
|
||||
put(RELATIVE_PATH, relativePath)
|
||||
}
|
||||
|
||||
val insertedUri = cr.insert(insertUri, cv) ?: throwMsg("Cannot insert new asset.")
|
||||
val outputStream = cr.openOutputStream(insertedUri)
|
||||
?: throwMsg("Cannot open output stream for $insertedUri.")
|
||||
val inputUri = getUri(asset, true)
|
||||
val inputStream = cr.openInputStream(inputUri)
|
||||
?: throwMsg("Cannot open input stream for $inputUri")
|
||||
inputStream.use {
|
||||
outputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val insertedId = insertedUri.lastPathSegment
|
||||
?: throwMsg("Cannot open output stream for $insertedUri.")
|
||||
|
||||
return getAssetEntity(context, insertedId)
|
||||
}
|
||||
|
||||
override fun moveToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throwMsg("Cannot get gallery id of $assetId")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throwMsg("No move required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val targetPath = getRelativePath(context, galleryId)
|
||||
|
||||
val contentValues = ContentValues().apply {
|
||||
put(MediaStore.MediaColumns.RELATIVE_PATH, targetPath)
|
||||
}
|
||||
|
||||
val count = cr.update(allUri, contentValues, idSelection, arrayOf(assetId))
|
||||
if (count > 0) {
|
||||
return getAssetEntity(context, assetId)
|
||||
}
|
||||
throwMsg("Cannot update $assetId relativePath")
|
||||
}
|
||||
|
||||
private val deleteLock = ReentrantLock()
|
||||
|
||||
override fun removeAllExistsAssets(context: Context): Boolean {
|
||||
if (deleteLock.isLocked) {
|
||||
Log.i(TAG, "The removeAllExistsAssets is running.")
|
||||
return false
|
||||
}
|
||||
deleteLock.withLock {
|
||||
Log.i(TAG, "The removeAllExistsAssets is starting.")
|
||||
val removedList = ArrayList<String>()
|
||||
val cr = context.contentResolver
|
||||
|
||||
val queryCursor = cr.query(
|
||||
allUri,
|
||||
arrayOf(BaseColumns._ID, MEDIA_TYPE, DATA),
|
||||
"$MEDIA_TYPE in ( ?,?,? )",
|
||||
arrayOf(MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO, MEDIA_TYPE_IMAGE).map { it.toString() }.toTypedArray(),
|
||||
null
|
||||
) ?: return false
|
||||
queryCursor.use {
|
||||
var count = 0
|
||||
while (queryCursor.moveToNext()) {
|
||||
val id = queryCursor.getString(BaseColumns._ID)
|
||||
val mediaType = queryCursor.getInt(MEDIA_TYPE)
|
||||
val path = queryCursor.getStringOrNull(DATA)
|
||||
val type = getTypeFromMediaType(mediaType)
|
||||
val uri = getUri(id, type)
|
||||
val exists = try {
|
||||
cr.openInputStream(uri)?.close()
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
if (!exists) {
|
||||
removedList.add(id)
|
||||
Log.i(TAG, "The $id, $path media was not exists. ")
|
||||
}
|
||||
count++
|
||||
|
||||
if (count % 300 == 0) {
|
||||
Log.i(TAG, "Current checked count == $count")
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "The removeAllExistsAssets was stopped, will be delete ids = $removedList")
|
||||
}
|
||||
|
||||
val idWhere = removedList.joinToString(",") { "?" }
|
||||
|
||||
// Remove exists rows.
|
||||
val deleteRowCount = cr.delete(allUri, "${BaseColumns._ID} in ( $idWhere )", removedList.toTypedArray())
|
||||
Log.i("PhotoManagerPlugin", "Delete rows: $deleteRowCount")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getRelativePath(context: Context, galleryId: String): String? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(BUCKET_ID, RELATIVE_PATH), "$BUCKET_ID = ?", arrayOf(galleryId), null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
return cursor.getString(1)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSomeInfo(context: Context, assetId: String): Pair<String, String>? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(BUCKET_ID, RELATIVE_PATH), "$_ID = ?", arrayOf(assetId), null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val galleryID = cursor.getString(0)
|
||||
val path = cursor.getString(1)
|
||||
|
||||
return Pair(galleryID, File(path).parent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveVideo(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
val inputStream = FileInputStream(path)
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "video/${File(path).extension}"
|
||||
|
||||
val uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val info = VideoUtils.getPropertiesUseMediaPlayer(path)
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MEDIA_TYPE, MEDIA_TYPE_VIDEO)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Video.VideoColumns.TITLE, title)
|
||||
put(MediaStore.Video.VideoColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Video.VideoColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Video.VideoColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.DURATION, info.duration)
|
||||
put(MediaStore.Video.VideoColumns.WIDTH, info.width)
|
||||
put(MediaStore.Video.VideoColumns.HEIGHT, info.height)
|
||||
}
|
||||
if (relativePath != null) values.put(MediaStore.Video.VideoColumns.RELATIVE_PATH, relativePath)
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val outputStream = cr.openOutputStream(contentUri)
|
||||
|
||||
outputStream?.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
|
||||
fun belowSdk(int: Int): Boolean {
|
||||
return Build.VERSION.SDK_INT < int
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to read the file path directly.
|
||||
*
|
||||
* When the sdk is 28 or lower, use file path
|
||||
*
|
||||
* When the sdk is 30,
|
||||
*/
|
||||
fun useFilePath(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT <= 28) {
|
||||
true
|
||||
} else if (Build.VERSION.SDK_INT == 29) {
|
||||
Environment.isExternalStorageLegacy()
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.provider.MediaStore
|
||||
import top.kikt.imagescanner.AssetType
|
||||
import top.kikt.imagescanner.core.entity.*
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
|
||||
|
||||
object ConvertUtils {
|
||||
fun convertToGalleryResult(list: List<GalleryEntity>): Map<String, Any> {
|
||||
val data = ArrayList<Map<String, Any>>()
|
||||
|
||||
for (entity in list) {
|
||||
val element = mutableMapOf<String, Any>(
|
||||
"id" to entity.id,
|
||||
"name" to entity.name,
|
||||
"length" to entity.length,
|
||||
"isAll" to entity.isAll
|
||||
)
|
||||
|
||||
if (entity.modifiedDate != null) {
|
||||
element["modified"] = entity.modifiedDate!!
|
||||
}
|
||||
|
||||
if (entity.length > 0) {
|
||||
data.add(element)
|
||||
}
|
||||
}
|
||||
|
||||
return mapOf(
|
||||
"data" to data
|
||||
)
|
||||
}
|
||||
|
||||
fun convertToAssetResult(list: List<AssetEntity>): Map<String, Any?> {
|
||||
val data = ArrayList<Map<String, Any?>>()
|
||||
|
||||
for (entity in list) {
|
||||
val element = hashMapOf(
|
||||
"id" to entity.id,
|
||||
"duration" to entity.duration / 1000,
|
||||
"type" to entity.type,
|
||||
"createDt" to entity.createDt,
|
||||
"width" to entity.width,
|
||||
"height" to entity.height,
|
||||
"orientation" to entity.orientation,
|
||||
"modifiedDt" to entity.modifiedDate,
|
||||
"lat" to entity.lat,
|
||||
"lng" to entity.lng,
|
||||
"title" to entity.displayName,
|
||||
"relativePath" to entity.relativePath
|
||||
)
|
||||
|
||||
if (entity.mimeType != null) {
|
||||
element["mimeType"] = entity.mimeType
|
||||
}
|
||||
|
||||
data.add(element)
|
||||
}
|
||||
|
||||
return mapOf(
|
||||
"data" to data
|
||||
)
|
||||
}
|
||||
|
||||
fun convertToAssetResult(entity: AssetEntity): Map<String, Any?> {
|
||||
|
||||
val data = hashMapOf(
|
||||
"id" to entity.id,
|
||||
"duration" to entity.duration / 1000,
|
||||
"type" to entity.type,
|
||||
"createDt" to entity.createDt,
|
||||
"width" to entity.width,
|
||||
"height" to entity.height,
|
||||
"modifiedDt" to entity.modifiedDate,
|
||||
"lat" to entity.lat,
|
||||
"lng" to entity.lng,
|
||||
"title" to entity.displayName,
|
||||
"relativePath" to entity.relativePath
|
||||
)
|
||||
|
||||
if (entity.mimeType != null) {
|
||||
data["mimeType"] = entity.mimeType
|
||||
}
|
||||
|
||||
return mapOf(
|
||||
"data" to data
|
||||
)
|
||||
}
|
||||
|
||||
private fun getOptionWithKey(map: Map<*, *>, key: String): FilterCond {
|
||||
if (map.containsKey(key)) {
|
||||
val value = map[key]
|
||||
if (value is Map<*, *>) {
|
||||
return convertToOption(value)
|
||||
}
|
||||
}
|
||||
return FilterCond()
|
||||
}
|
||||
|
||||
fun getOptionFromType(map: Map<*, *>, type: AssetType): FilterCond {
|
||||
return when (type) {
|
||||
AssetType.Video -> {
|
||||
getOptionWithKey(map, "video")
|
||||
}
|
||||
AssetType.Image -> {
|
||||
getOptionWithKey(map, "image")
|
||||
}
|
||||
AssetType.Audio -> {
|
||||
getOptionWithKey(map, "audio")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertToOption(map: Map<*, *>): FilterCond {
|
||||
val filterOptions = FilterCond()
|
||||
filterOptions.isShowTitle = map["title"] as Boolean
|
||||
|
||||
val sizeConstraint = FilterCond.SizeConstraint()
|
||||
filterOptions.sizeConstraint = sizeConstraint
|
||||
val sizeMap = map["size"] as Map<*, *>
|
||||
sizeConstraint.minWidth = sizeMap["minWidth"] as Int
|
||||
sizeConstraint.maxWidth = sizeMap["maxWidth"] as Int
|
||||
sizeConstraint.minHeight = sizeMap["minHeight"] as Int
|
||||
sizeConstraint.maxHeight = sizeMap["maxHeight"] as Int
|
||||
sizeConstraint.ignoreSize = sizeMap["ignoreSize"] as Boolean
|
||||
|
||||
val durationConstraint = FilterCond.DurationConstraint()
|
||||
filterOptions.durationConstraint = durationConstraint
|
||||
val durationMap = map["duration"] as Map<*, *>
|
||||
durationConstraint.min = (durationMap["min"] as Int).toLong()
|
||||
durationConstraint.max = (durationMap["max"] as Int).toLong()
|
||||
|
||||
return filterOptions
|
||||
}
|
||||
|
||||
fun convertToDateCond(map: Map<*, *>): DateCond {
|
||||
val min = map["min"].toString().toLong()
|
||||
val max = map["max"].toString().toLong()
|
||||
val ignore = map["ignore"].toString().toBoolean()
|
||||
return DateCond(min, max, ignore)
|
||||
}
|
||||
|
||||
fun convertFilterOptionsFromMap(map: Map<*, *>): FilterOption {
|
||||
return FilterOption(map)
|
||||
}
|
||||
|
||||
fun convertOrderByCondList(orders: List<*>): List<OrderByCond> {
|
||||
val list = ArrayList<OrderByCond>()
|
||||
|
||||
for (order in orders) {
|
||||
val map = order as Map<*, *>
|
||||
val keyIndex = map["type"] as Int
|
||||
val asc = map["asc"] as Boolean
|
||||
|
||||
val key = when (keyIndex) {
|
||||
0 -> MediaStore.MediaColumns.DATE_ADDED
|
||||
1 -> MediaStore.MediaColumns.DATE_MODIFIED
|
||||
else -> null
|
||||
} ?: continue
|
||||
|
||||
list.add(OrderByCond(key, asc))
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
}
|
735
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/core/utils/DBUtils.kt
vendored
Normal file
735
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/core/utils/DBUtils.kt
vendored
Normal file
|
@ -0,0 +1,735 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import android.provider.BaseColumns._ID
|
||||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import top.kikt.imagescanner.core.PhotoManager
|
||||
import top.kikt.imagescanner.core.cache.CacheContainer
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.GalleryEntity
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils.Companion.storeBucketKeys
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils.Companion.storeImageKeys
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils.Companion.storeVideoKeys
|
||||
import top.kikt.imagescanner.core.utils.IDBUtils.Companion.typeKeys
|
||||
import java.io.*
|
||||
import java.net.URLConnection
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
|
||||
/// create 2019-09-05 by cai
|
||||
/// Call the MediaStore API and get entity for the data.
|
||||
@Suppress("DEPRECATION")
|
||||
@SuppressLint("Recycle", "InlinedApi")
|
||||
object DBUtils : IDBUtils {
|
||||
|
||||
private val cacheContainer = CacheContainer()
|
||||
|
||||
private val locationKeys = arrayOf(
|
||||
MediaStore.Images.ImageColumns.LONGITUDE,
|
||||
MediaStore.Images.ImageColumns.LATITUDE
|
||||
)
|
||||
|
||||
override fun getGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
val uri = allUri
|
||||
val projection = storeBucketKeys + arrayOf("count(1)")
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selection = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere) GROUP BY (${MediaStore.Images.Media.BUCKET_ID}"
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, args.toTypedArray(), null)
|
||||
?: return emptyList()
|
||||
while (cursor.moveToNext()) {
|
||||
val id = cursor.getString(0)
|
||||
val name = cursor.getString(1) ?: ""
|
||||
val count = cursor.getInt(2)
|
||||
val entity = GalleryEntity(id, name, count, 0)
|
||||
if (option.containsPathModified) {
|
||||
injectModifiedDate(context, entity)
|
||||
}
|
||||
list.add(entity)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getOnlyGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity> {
|
||||
val list = ArrayList<GalleryEntity>()
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = AndroidQDBUtils.getCondFromType(requestType, option, args)
|
||||
val projection = storeBucketKeys + arrayOf("count(1)")
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val selections = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, projection, selections, args.toTypedArray(), null)
|
||||
?: return list
|
||||
|
||||
cursor.use {
|
||||
if (it.moveToNext()) {
|
||||
val countIndex = projection.indexOf("count(1)")
|
||||
val count = cursor.getInt(countIndex)
|
||||
val galleryEntity = GalleryEntity(PhotoManager.ALL_ID, "Recent", count, requestType, true)
|
||||
list.add(galleryEntity)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getGalleryEntity(context: Context, galleryId: String, type: Int, option: FilterOption): GalleryEntity? {
|
||||
val uri = allUri
|
||||
val projection = storeBucketKeys + arrayOf("count(1)")
|
||||
|
||||
val args = ArrayList<String>()
|
||||
val typeSelection: String = getCondFromType(type, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val idSelection: String
|
||||
if (galleryId == "") {
|
||||
idSelection = ""
|
||||
} else {
|
||||
idSelection = "AND ${MediaStore.Images.Media.BUCKET_ID} = ?"
|
||||
args.add(galleryId)
|
||||
}
|
||||
|
||||
val sizeWhere = sizeWhere(null, option)
|
||||
|
||||
val selection = "${MediaStore.Images.Media.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $idSelection $sizeWhere) GROUP BY (${MediaStore.Images.Media.BUCKET_ID}"
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, args.toTypedArray(), null)
|
||||
?: return null
|
||||
return if (cursor.moveToNext()) {
|
||||
val id = cursor.getString(0)
|
||||
val name = cursor.getString(1) ?: ""
|
||||
val count = cursor.getInt(2)
|
||||
cursor.close()
|
||||
GalleryEntity(id, name, count, 0)
|
||||
} else {
|
||||
cursor.close()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun getThumbUri(context: Context, id: String, width: Int, height: Int, type: Int?): Uri? {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getAssetFromGalleryId(
|
||||
context: Context,
|
||||
galleryId: String,
|
||||
page: Int,
|
||||
pageSize: Int,
|
||||
requestType: Int,
|
||||
option: FilterOption,
|
||||
cacheContainer: CacheContainer?
|
||||
): List<AssetEntity> {
|
||||
val cache = cacheContainer ?: this.cacheContainer
|
||||
|
||||
val isAll = galleryId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(galleryId)
|
||||
}
|
||||
val typeSelection = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val keys = (storeImageKeys + storeVideoKeys + typeKeys + locationKeys).distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val sortOrder = getSortOrder(page * pageSize, pageSize, option)
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val asset = convertCursorToAsset(cursor, requestType)
|
||||
list.add(asset)
|
||||
cache.putAsset(asset)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun getAssetFromGalleryIdRange(context: Context, gId: String, start: Int, end: Int, requestType: Int, option: FilterOption): List<AssetEntity> {
|
||||
val cache = cacheContainer
|
||||
|
||||
val isAll = gId.isEmpty()
|
||||
|
||||
val list = ArrayList<AssetEntity>()
|
||||
val uri = allUri
|
||||
|
||||
val args = ArrayList<String>()
|
||||
if (!isAll) {
|
||||
args.add(gId)
|
||||
}
|
||||
val typeSelection = getCondFromType(requestType, option, args)
|
||||
|
||||
val dateSelection = getDateCond(args, option)
|
||||
|
||||
val sizeWhere = sizeWhere(requestType, option)
|
||||
|
||||
val keys = (storeImageKeys + storeVideoKeys + typeKeys + locationKeys).distinct().toTypedArray()
|
||||
val selection = if (isAll) {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL $typeSelection $dateSelection $sizeWhere"
|
||||
} else {
|
||||
"${MediaStore.Images.ImageColumns.BUCKET_ID} = ? $typeSelection $dateSelection $sizeWhere"
|
||||
}
|
||||
|
||||
val pageSize = end - start
|
||||
|
||||
val sortOrder = getSortOrder(start, pageSize, option)
|
||||
val cursor = context.contentResolver.query(uri, keys, selection, args.toTypedArray(), sortOrder)
|
||||
?: return emptyList()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val asset = convertCursorToAsset(cursor, requestType)
|
||||
|
||||
list.add(asset)
|
||||
cache.putAsset(asset)
|
||||
}
|
||||
|
||||
cursor.close()
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
private fun convertCursorToAsset(cursor: Cursor, requestType: Int): AssetEntity {
|
||||
val id = cursor.getString(MediaStore.MediaColumns._ID)
|
||||
val path = cursor.getString(MediaStore.MediaColumns.DATA)
|
||||
val date = cursor.getLong(MediaStore.Images.Media.DATE_ADDED)
|
||||
val type = cursor.getInt(MediaStore.Files.FileColumns.MEDIA_TYPE)
|
||||
val duration = if (requestType == 1) 0 else cursor.getLong(MediaStore.Video.VideoColumns.DURATION)
|
||||
val width = cursor.getInt(MediaStore.MediaColumns.WIDTH)
|
||||
val height = cursor.getInt(MediaStore.MediaColumns.HEIGHT)
|
||||
val displayName = File(path).name
|
||||
val modifiedDate = cursor.getLong(MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
|
||||
val lat = cursor.getDouble(MediaStore.Images.ImageColumns.LATITUDE)
|
||||
val lng = cursor.getDouble(MediaStore.Images.ImageColumns.LONGITUDE)
|
||||
val orientation: Int = cursor.getInt(MediaStore.MediaColumns.ORIENTATION)
|
||||
|
||||
val mimeType = cursor.getString(MediaStore.Files.FileColumns.MIME_TYPE)
|
||||
|
||||
return AssetEntity(id, path, duration, date, width, height, getMediaType(type), displayName, modifiedDate, orientation, lat, lng, mimeType = mimeType)
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
override fun getAssetEntity(context: Context, id: String): AssetEntity? {
|
||||
val asset = cacheContainer.getAsset(id)
|
||||
if (asset != null) {
|
||||
return asset
|
||||
}
|
||||
|
||||
val keys = (storeImageKeys + storeVideoKeys + locationKeys + typeKeys).distinct().toTypedArray()
|
||||
|
||||
val selection = "${MediaStore.Files.FileColumns._ID} = ?"
|
||||
|
||||
val args = arrayOf(id)
|
||||
|
||||
val cursor = context.contentResolver.query(allUri, keys, selection, args, null)
|
||||
?: return null
|
||||
|
||||
return if (cursor.moveToNext()) {
|
||||
val type = cursor.getInt(MediaStore.Files.FileColumns.MEDIA_TYPE)
|
||||
val dbAsset = convertCursorToAsset(cursor, type)
|
||||
|
||||
cacheContainer.putAsset(dbAsset)
|
||||
|
||||
cursor.close()
|
||||
dbAsset
|
||||
} else {
|
||||
cursor.close()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun getOriginBytes(context: Context, asset: AssetEntity, haveLocationPermission: Boolean): ByteArray {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun cacheOriginFile(context: Context, asset: AssetEntity, byteArray: ByteArray) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun getExif(context: Context, id: String): ExifInterface? {
|
||||
val asset = getAssetEntity(context, id) ?: return null
|
||||
return ExifInterface(asset.path)
|
||||
}
|
||||
|
||||
override fun getFilePath(context: Context, id: String, origin: Boolean): String? {
|
||||
val assetEntity = getAssetEntity(context, id) ?: return null
|
||||
return assetEntity.path
|
||||
}
|
||||
|
||||
override fun clearCache() {
|
||||
cacheContainer.clearCache()
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, image: ByteArray, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val cr = context.contentResolver
|
||||
var inputStream = ByteArrayInputStream(image)
|
||||
|
||||
fun refreshInputStream() {
|
||||
inputStream = ByteArrayInputStream(image)
|
||||
}
|
||||
|
||||
|
||||
val latLong = kotlin.run {
|
||||
val exifInterface = try {
|
||||
ExifInterface(ByteArrayInputStream(image))
|
||||
} catch (e: Exception) {
|
||||
return@run doubleArrayOf(0.0, 0.0)
|
||||
}
|
||||
exifInterface.latLong ?: doubleArrayOf(0.0, 0.0)
|
||||
}
|
||||
|
||||
val degrees =
|
||||
try {
|
||||
val exifInterface = ExifInterface(inputStream)
|
||||
exifInterface.rotationDegrees
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
refreshInputStream()
|
||||
val bmp = BitmapFactory.decodeStream(inputStream)
|
||||
val width = bmp.width
|
||||
val height = bmp.height
|
||||
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
refreshInputStream()
|
||||
|
||||
val typeFromStream: String = if (title.contains(".")) {
|
||||
// title contains file extension, form mimeType from it
|
||||
"image/${File(title).extension}"
|
||||
} else {
|
||||
URLConnection.guessContentTypeFromStream(inputStream) ?: "image/*"
|
||||
}
|
||||
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Images.ImageColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
put(MediaStore.Images.ImageColumns.LATITUDE, latLong[0])
|
||||
put(MediaStore.Images.ImageColumns.LONGITUDE, latLong[1])
|
||||
put(MediaStore.Images.ImageColumns.ORIENTATION, degrees)
|
||||
}
|
||||
|
||||
val insertUri = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) ?: return null
|
||||
val id = ContentUris.parseId(insertUri)
|
||||
|
||||
// write bytes
|
||||
val cursor = cr.query(insertUri, arrayOf(MediaStore.Images.ImageColumns.DATA), null, null, null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (cursor.moveToNext()) {
|
||||
val targetPath = cursor.getString(0)
|
||||
val outputStream = FileOutputStream(targetPath)
|
||||
refreshInputStream()
|
||||
outputStream.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getAssetEntity(context, id.toString())
|
||||
}
|
||||
|
||||
override fun saveImage(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val inputStream = FileInputStream(path)
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
|
||||
val latLong = kotlin.run {
|
||||
val exifInterface = try {
|
||||
ExifInterface(path)
|
||||
} catch (e: Exception) {
|
||||
return@run doubleArrayOf(0.0, 0.0)
|
||||
}
|
||||
exifInterface.latLong ?: doubleArrayOf(0.0, 0.0)
|
||||
}
|
||||
|
||||
|
||||
val (width, height) =
|
||||
try {
|
||||
val bmp = BitmapFactory.decodeFile(path)
|
||||
Pair(bmp.width, bmp.height)
|
||||
} catch (e: Exception) {
|
||||
Pair(0, 0)
|
||||
}
|
||||
|
||||
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "image/${File(path).extension}"
|
||||
|
||||
val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val dir = Environment.getExternalStorageDirectory()
|
||||
val savePath = File(path).absolutePath.startsWith(dir.path)
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE)
|
||||
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Images.ImageColumns.TITLE, title)
|
||||
put(MediaStore.Images.ImageColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Images.ImageColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Images.ImageColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Images.ImageColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Images.ImageColumns.LATITUDE, latLong[0])
|
||||
put(MediaStore.Images.ImageColumns.LONGITUDE, latLong[1])
|
||||
put(MediaStore.Images.ImageColumns.WIDTH, width)
|
||||
put(MediaStore.Images.ImageColumns.HEIGHT, height)
|
||||
|
||||
if (savePath) {
|
||||
put(MediaStore.Video.VideoColumns.DATA, path)
|
||||
}
|
||||
}
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
val assetEntity = getAssetEntity(context, id.toString())
|
||||
if (savePath) {
|
||||
inputStream.close()
|
||||
} else {
|
||||
val tmpPath = assetEntity?.path!!
|
||||
val tmpFile = File(tmpPath)
|
||||
val targetPath = "${tmpFile.parent}/$title"
|
||||
val targetFile = File(targetPath)
|
||||
|
||||
if (targetFile.exists()) {
|
||||
throw IOException("save target path is ")
|
||||
}
|
||||
|
||||
tmpFile.renameTo(targetFile)
|
||||
val updateDataValues = ContentValues().apply {
|
||||
put(MediaStore.Video.VideoColumns.DATA, targetPath)
|
||||
}
|
||||
cr.update(contentUri, updateDataValues, null, null)
|
||||
|
||||
val outputStream = FileOutputStream(targetFile)
|
||||
outputStream.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
assetEntity.path = targetPath
|
||||
}
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return assetEntity
|
||||
}
|
||||
|
||||
override fun copyToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throw RuntimeException("Cannot get gallery id of $assetId")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throw RuntimeException("No copy required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val asset = getAssetEntity(context, assetId)
|
||||
?: throw RuntimeException("No copy required, because the target gallery is the same as the current one.")
|
||||
|
||||
val copyKeys = arrayListOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME,
|
||||
MediaStore.Video.VideoColumns.TITLE,
|
||||
MediaStore.Video.VideoColumns.DATE_ADDED,
|
||||
MediaStore.Video.VideoColumns.DATE_MODIFIED,
|
||||
MediaStore.Video.VideoColumns.DATE_TAKEN,
|
||||
MediaStore.Video.VideoColumns.DURATION,
|
||||
MediaStore.Video.VideoColumns.LONGITUDE,
|
||||
MediaStore.Video.VideoColumns.LATITUDE,
|
||||
MediaStore.Video.VideoColumns.WIDTH,
|
||||
MediaStore.Video.VideoColumns.HEIGHT
|
||||
)
|
||||
val mediaType = convertTypeToMediaType(asset.type)
|
||||
|
||||
if (mediaType != MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO) {
|
||||
copyKeys.add(MediaStore.Video.VideoColumns.DESCRIPTION)
|
||||
}
|
||||
|
||||
val cursor = cr.query(allUri, copyKeys.toTypedArray() + arrayOf(MediaStore.Video.VideoColumns.DATA), idSelection, arrayOf(assetId), null)
|
||||
?: throw RuntimeException("Cannot find asset .")
|
||||
|
||||
if (!cursor.moveToNext()) {
|
||||
throw RuntimeException("Cannot find asset .")
|
||||
}
|
||||
|
||||
|
||||
val insertUri = MediaStoreUtils.getInsertUri(mediaType)
|
||||
val galleryInfo = getGalleryInfo(context, galleryId) ?: throwMsg("Cannot find gallery info")
|
||||
val outputPath = "${galleryInfo.path}/${asset.displayName}"
|
||||
|
||||
val cv = ContentValues().apply {
|
||||
for (key in copyKeys) {
|
||||
put(key, cursor.getString(key))
|
||||
}
|
||||
put(MediaStore.Files.FileColumns.MEDIA_TYPE, mediaType)
|
||||
put(MediaStore.Files.FileColumns.DATA, outputPath)
|
||||
}
|
||||
|
||||
val insertedUri = cr.insert(insertUri, cv) ?: throw RuntimeException("Cannot insert new asset.")
|
||||
val outputStream = cr.openOutputStream(insertedUri)
|
||||
?: throw RuntimeException("Cannot open output stream for $insertedUri.")
|
||||
val inputStream = File(asset.path).inputStream()
|
||||
inputStream.use {
|
||||
outputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
val insertedId = insertedUri.lastPathSegment
|
||||
?: throw RuntimeException("Cannot open output stream for $insertedUri.")
|
||||
|
||||
return getAssetEntity(context, insertedId)
|
||||
}
|
||||
|
||||
override fun moveToGallery(context: Context, assetId: String, galleryId: String): AssetEntity? {
|
||||
|
||||
val (currentGalleryId, _) = getSomeInfo(context, assetId)
|
||||
?: throwMsg("Cannot get gallery id of $assetId")
|
||||
|
||||
val targetGalleryInfo = getGalleryInfo(context, galleryId)
|
||||
?: throwMsg("Cannot get target gallery info")
|
||||
|
||||
if (galleryId == currentGalleryId) {
|
||||
throwMsg("No move required, because the target gallery is the same as the current one.")
|
||||
}
|
||||
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(MediaStore.MediaColumns.DATA), idSelection, arrayOf(assetId), null)
|
||||
?: throwMsg("Cannot find $assetId path")
|
||||
|
||||
val targetPath = if (cursor.moveToNext()) {
|
||||
val srcPath = cursor.getString(0)
|
||||
cursor.close()
|
||||
val target = "${targetGalleryInfo.path}/${File(srcPath).name}"
|
||||
File(srcPath).renameTo(File(target))
|
||||
target
|
||||
} else {
|
||||
throwMsg("Cannot find $assetId path")
|
||||
}
|
||||
|
||||
val contentValues = ContentValues().apply {
|
||||
put(MediaStore.MediaColumns.DATA, targetPath)
|
||||
put(MediaStore.MediaColumns.BUCKET_ID, galleryId)
|
||||
put(MediaStore.MediaColumns.BUCKET_DISPLAY_NAME, targetGalleryInfo.galleryName)
|
||||
}
|
||||
|
||||
val count = cr.update(allUri, contentValues, idSelection, arrayOf(assetId))
|
||||
if (count > 0) {
|
||||
return getAssetEntity(context, assetId)
|
||||
}
|
||||
throwMsg("Cannot update $assetId relativePath")
|
||||
}
|
||||
|
||||
private val deleteLock = ReentrantLock()
|
||||
|
||||
override fun removeAllExistsAssets(context: Context): Boolean {
|
||||
if (deleteLock.isLocked) {
|
||||
return false
|
||||
}
|
||||
deleteLock.withLock {
|
||||
val removedList = ArrayList<String>()
|
||||
val cr = context.contentResolver
|
||||
|
||||
val queryCursor = cr.query(allUri, arrayOf(_ID, MediaStore.MediaColumns.DATA), null, null, null)
|
||||
?: return false
|
||||
queryCursor.use {
|
||||
while (queryCursor.moveToNext()) {
|
||||
val id = queryCursor.getString(_ID)
|
||||
val path = queryCursor.getString(MediaStore.MediaColumns.DATA)
|
||||
if (!File(path).exists()) {
|
||||
removedList.add(id)
|
||||
Log.i("PhotoManagerPlugin", "The $path was not exists. ")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Log.i("PhotoManagerPlugin", "will be delete ids = $removedList")
|
||||
}
|
||||
|
||||
val idWhere = removedList.joinToString(",") { "?" }
|
||||
|
||||
// Remove exists rows.
|
||||
val deleteRowCount = cr.delete(allUri, "$_ID in ( $idWhere )", removedList.toTypedArray())
|
||||
Log.i("PhotoManagerPlugin", "Delete rows: $deleteRowCount")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 0 : gallery id
|
||||
* 1 : current asset parent path
|
||||
*/
|
||||
override fun getSomeInfo(context: Context, assetId: String): Pair<String, String>? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val cursor = cr.query(allUri, arrayOf(MediaStore.Files.FileColumns.BUCKET_ID, MediaStore.Files.FileColumns.DATA), "${MediaStore.Files.FileColumns._ID} = ?", arrayOf(assetId), null)
|
||||
?: return null
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val galleryID = cursor.getString(0)
|
||||
val path = cursor.getString(1)
|
||||
|
||||
return Pair(galleryID, File(path).parent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGalleryInfo(context: Context, galleryId: String): GalleryInfo? {
|
||||
val cr = context.contentResolver
|
||||
|
||||
val keys = arrayOf(
|
||||
MediaStore.Files.FileColumns.BUCKET_ID,
|
||||
MediaStore.Files.FileColumns.BUCKET_DISPLAY_NAME,
|
||||
MediaStore.Files.FileColumns.DATA
|
||||
)
|
||||
val cursor = cr.query(allUri, keys, "${MediaStore.Files.FileColumns.BUCKET_ID} = ?", arrayOf(galleryId), null)
|
||||
?: return null
|
||||
|
||||
|
||||
cursor.use {
|
||||
if (!cursor.moveToNext()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val path = cursor.getStringOrNull(MediaStore.Files.FileColumns.DATA) ?: return null
|
||||
val name = cursor.getStringOrNull(MediaStore.Files.FileColumns.BUCKET_DISPLAY_NAME)
|
||||
?: return null
|
||||
|
||||
val galleryPath = File(path).parentFile?.absolutePath ?: return null
|
||||
return GalleryInfo(galleryPath, galleryId, name)
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveVideo(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity? {
|
||||
val inputStream = FileInputStream(path)
|
||||
val cr = context.contentResolver
|
||||
val timestamp = System.currentTimeMillis() / 1000
|
||||
|
||||
val typeFromStream = URLConnection.guessContentTypeFromStream(inputStream)
|
||||
?: "video/${File(path).extension}"
|
||||
|
||||
val uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
|
||||
val dir = Environment.getExternalStorageDirectory()
|
||||
val savePath = File(path).absolutePath.startsWith(dir.path)
|
||||
|
||||
|
||||
val info = VideoUtils.getPropertiesUseMediaPlayer(path)
|
||||
|
||||
val values = ContentValues().apply {
|
||||
put(MediaStore.MediaColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.MIME_TYPE, typeFromStream)
|
||||
put(MediaStore.Video.VideoColumns.TITLE, title)
|
||||
put(MediaStore.Video.VideoColumns.DESCRIPTION, desc)
|
||||
put(MediaStore.Video.VideoColumns.DATE_ADDED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_MODIFIED, timestamp)
|
||||
put(MediaStore.Video.VideoColumns.DATE_TAKEN, timestamp * 1000)
|
||||
put(MediaStore.Video.VideoColumns.DISPLAY_NAME, title)
|
||||
put(MediaStore.Video.VideoColumns.DURATION, info.duration)
|
||||
put(MediaStore.Video.VideoColumns.WIDTH, info.width)
|
||||
put(MediaStore.Video.VideoColumns.HEIGHT, info.height)
|
||||
|
||||
if (savePath) {
|
||||
put(MediaStore.Video.VideoColumns.DATA, path)
|
||||
}
|
||||
}
|
||||
|
||||
val contentUri = cr.insert(uri, values) ?: return null
|
||||
val id = ContentUris.parseId(contentUri)
|
||||
|
||||
val assetEntity = getAssetEntity(context, id.toString())
|
||||
if (savePath) {
|
||||
inputStream.close()
|
||||
} else {
|
||||
val tmpPath = assetEntity?.path!!
|
||||
val tmpFile = File(tmpPath)
|
||||
val targetPath = "${tmpFile.parent}/$title"
|
||||
val targetFile = File(targetPath)
|
||||
|
||||
if (targetFile.exists()) {
|
||||
throw IOException("save target path is ")
|
||||
}
|
||||
|
||||
tmpFile.renameTo(targetFile)
|
||||
val updateDataValues = ContentValues().apply {
|
||||
put(MediaStore.Video.VideoColumns.DATA, targetPath)
|
||||
}
|
||||
cr.update(contentUri, updateDataValues, null, null)
|
||||
|
||||
val outputStream = FileOutputStream(targetFile)
|
||||
outputStream.use {
|
||||
inputStream.use {
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
assetEntity.path = targetPath
|
||||
}
|
||||
|
||||
cr.notifyChange(contentUri, null)
|
||||
return assetEntity
|
||||
}
|
||||
|
||||
private data class GalleryInfo(val path: String, val galleryId: String, val galleryName: String)
|
||||
}
|
|
@ -0,0 +1,506 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import android.provider.MediaStore.Files.FileColumns.*
|
||||
import android.provider.MediaStore.VOLUME_EXTERNAL
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import top.kikt.imagescanner.core.PhotoManager
|
||||
import top.kikt.imagescanner.core.cache.CacheContainer
|
||||
import top.kikt.imagescanner.core.entity.AssetEntity
|
||||
import top.kikt.imagescanner.core.entity.DateCond
|
||||
import top.kikt.imagescanner.core.entity.FilterOption
|
||||
import top.kikt.imagescanner.core.entity.GalleryEntity
|
||||
import top.kikt.imagescanner.util.LogUtils
|
||||
|
||||
|
||||
/// create 2019-09-11 by cai
|
||||
@Suppress("DEPRECATION")
|
||||
@SuppressLint("InlinedApi")
|
||||
interface IDBUtils {
|
||||
|
||||
companion object {
|
||||
val isAndroidQ = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
val isAndroidR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||
|
||||
val storeImageKeys = arrayOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME, // 显示的名字
|
||||
MediaStore.MediaColumns.DATA, // 数据
|
||||
MediaStore.MediaColumns._ID, // id
|
||||
MediaStore.MediaColumns.TITLE, // id
|
||||
MediaStore.MediaColumns.BUCKET_ID, // dir id 目录
|
||||
MediaStore.MediaColumns.BUCKET_DISPLAY_NAME, // dir name 目录名字
|
||||
MediaStore.MediaColumns.WIDTH, // 宽
|
||||
MediaStore.MediaColumns.HEIGHT, // 高
|
||||
MediaStore.MediaColumns.ORIENTATION, // 角度
|
||||
DATE_ADDED,
|
||||
MediaStore.MediaColumns.DATE_MODIFIED, // 修改时间
|
||||
MediaStore.MediaColumns.MIME_TYPE, // mime type
|
||||
MediaStore.MediaColumns.DATE_TAKEN //日期
|
||||
)
|
||||
|
||||
val storeVideoKeys = arrayOf(
|
||||
MediaStore.MediaColumns.DISPLAY_NAME, // 显示的名字
|
||||
MediaStore.MediaColumns.DATA, // 数据
|
||||
MediaStore.MediaColumns._ID, // id
|
||||
MediaStore.MediaColumns.TITLE, // id
|
||||
MediaStore.MediaColumns.BUCKET_ID, // dir id 目录
|
||||
MediaStore.MediaColumns.BUCKET_DISPLAY_NAME, // dir name 目录名字
|
||||
MediaStore.MediaColumns.DATE_TAKEN, //日期
|
||||
MediaStore.MediaColumns.WIDTH, // 宽
|
||||
MediaStore.MediaColumns.HEIGHT, // 高
|
||||
MediaStore.MediaColumns.ORIENTATION, // 角度
|
||||
MediaStore.MediaColumns.DATE_MODIFIED, // 修改时间
|
||||
MediaStore.MediaColumns.MIME_TYPE, // mime type
|
||||
MediaStore.MediaColumns.DURATION //时长
|
||||
)
|
||||
|
||||
val typeKeys = arrayOf(
|
||||
MEDIA_TYPE,
|
||||
MediaStore.Images.Media.DISPLAY_NAME
|
||||
)
|
||||
|
||||
val storeBucketKeys = arrayOf(
|
||||
MediaStore.Images.Media.BUCKET_ID,
|
||||
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME
|
||||
)
|
||||
|
||||
// fun galleryIdKey(@MediaTypeDef mediaType: Int) :String{
|
||||
// if(mediaType == MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO)
|
||||
// return MediaStore.Audio.AudioColumns.ALBUM
|
||||
// }
|
||||
val allUri: Uri
|
||||
get() = MediaStore.Files.getContentUri(VOLUME_EXTERNAL)
|
||||
|
||||
}
|
||||
|
||||
val idSelection: String
|
||||
get() = "${MediaStore.Images.Media._ID} = ?"
|
||||
|
||||
val allUri: Uri
|
||||
get() = IDBUtils.allUri
|
||||
|
||||
private val typeUtils: RequestTypeUtils
|
||||
get() = RequestTypeUtils
|
||||
|
||||
fun getGalleryList(context: Context, requestType: Int = 0, option: FilterOption): List<GalleryEntity>
|
||||
|
||||
fun getAssetFromGalleryId(context: Context, galleryId: String, page: Int, pageSize: Int, requestType: Int = 0, option: FilterOption, cacheContainer: CacheContainer? = null): List<AssetEntity>
|
||||
|
||||
fun getAssetEntity(context: Context, id: String): AssetEntity?
|
||||
|
||||
fun getMediaType(type: Int): Int {
|
||||
return when (type) {
|
||||
MEDIA_TYPE_IMAGE -> 1
|
||||
MEDIA_TYPE_VIDEO -> 2
|
||||
MEDIA_TYPE_AUDIO -> 3
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun convertTypeToMediaType(type: Int): Int {
|
||||
return MediaStoreUtils.convertTypeToMediaType(type)
|
||||
}
|
||||
|
||||
fun getTypeFromMediaType(mediaType: Int): Int {
|
||||
return when (mediaType) {
|
||||
MEDIA_TYPE_IMAGE -> 1
|
||||
MEDIA_TYPE_VIDEO -> 2
|
||||
MEDIA_TYPE_AUDIO -> 3
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
fun Cursor.getInt(columnName: String): Int {
|
||||
return getInt(getColumnIndex(columnName))
|
||||
}
|
||||
|
||||
fun Cursor.getString(columnName: String): String {
|
||||
return getString(getColumnIndex(columnName)) ?: ""
|
||||
}
|
||||
|
||||
fun Cursor.getStringOrNull(columnName: String): String? {
|
||||
return getString(getColumnIndex(columnName))
|
||||
}
|
||||
|
||||
fun Cursor.getLong(columnName: String): Long {
|
||||
return getLong(getColumnIndex(columnName))
|
||||
}
|
||||
|
||||
fun Cursor.getDouble(columnName: String): Double {
|
||||
return getDouble(getColumnIndex(columnName))
|
||||
}
|
||||
|
||||
fun getGalleryEntity(context: Context, galleryId: String, type: Int, option: FilterOption): GalleryEntity?
|
||||
|
||||
fun clearCache()
|
||||
|
||||
fun getFilePath(context: Context, id: String, origin: Boolean): String?
|
||||
|
||||
fun getThumbUri(context: Context, id: String, width: Int, height: Int, type: Int?): Uri?
|
||||
|
||||
fun getAssetFromGalleryIdRange(context: Context, gId: String, start: Int, end: Int, requestType: Int, option: FilterOption): List<AssetEntity>
|
||||
|
||||
fun findDeleteUri(context: Context, id: String): Uri? {
|
||||
val assetEntity = getAssetEntity(context, id) ?: return null
|
||||
return assetEntity.getUri()
|
||||
}
|
||||
|
||||
fun saveImage(context: Context, image: ByteArray, title: String, desc: String, relativePath: String?): AssetEntity?
|
||||
|
||||
fun saveImage(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity?
|
||||
|
||||
fun saveVideo(context: Context, path: String, title: String, desc: String, relativePath: String?): AssetEntity?
|
||||
|
||||
fun exists(context: Context, id: String): Boolean {
|
||||
val columns = arrayOf(_ID)
|
||||
context.contentResolver.query(allUri, columns, "$_ID = ?", arrayOf(id), null).use {
|
||||
if (it == null) {
|
||||
return false
|
||||
}
|
||||
return it.count >= 1
|
||||
}
|
||||
}
|
||||
|
||||
fun getExif(context: Context, id: String): ExifInterface?
|
||||
|
||||
fun getOriginBytes(context: Context, asset: AssetEntity, haveLocationPermission: Boolean): ByteArray
|
||||
|
||||
fun cacheOriginFile(context: Context, asset: AssetEntity, byteArray: ByteArray)
|
||||
|
||||
/**
|
||||
* Just filter [MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE]
|
||||
*/
|
||||
fun sizeWhere(requestType: Int?, option: FilterOption): String {
|
||||
if (option.imageOption.sizeConstraint.ignoreSize) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (requestType == null || !typeUtils.containsImage(requestType)) {
|
||||
return ""
|
||||
}
|
||||
val mediaType = MEDIA_TYPE
|
||||
|
||||
|
||||
var result = ""
|
||||
|
||||
if (typeUtils.containsVideo(requestType)) {
|
||||
result = "OR ( $mediaType = $MEDIA_TYPE_VIDEO )"
|
||||
}
|
||||
|
||||
if (typeUtils.containsAudio(requestType)) {
|
||||
result = "$result OR ( $mediaType = $MEDIA_TYPE_AUDIO )"
|
||||
}
|
||||
|
||||
val size = "${MediaStore.MediaColumns.WIDTH} > 0 AND ${MediaStore.MediaColumns.HEIGHT} > 0"
|
||||
|
||||
val imageCondString = "( $mediaType = $MEDIA_TYPE_IMAGE AND $size )"
|
||||
|
||||
result = "AND ($imageCondString $result)"
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
fun getCondFromType(type: Int, filterOption: FilterOption, args: ArrayList<String>): String {
|
||||
val cond = StringBuilder()
|
||||
val typeKey = MEDIA_TYPE
|
||||
|
||||
val haveImage = RequestTypeUtils.containsImage(type)
|
||||
val haveVideo = RequestTypeUtils.containsVideo(type)
|
||||
val haveAudio = RequestTypeUtils.containsAudio(type)
|
||||
|
||||
var imageCondString = ""
|
||||
var videoCondString = ""
|
||||
var audioCondString = ""
|
||||
|
||||
if (haveImage) {
|
||||
val imageCond = filterOption.imageOption
|
||||
imageCondString = "$typeKey = ? "
|
||||
args.add(MEDIA_TYPE_IMAGE.toString())
|
||||
|
||||
if (!imageCond.sizeConstraint.ignoreSize) {
|
||||
val sizeCond = imageCond.sizeCond()
|
||||
val sizeArgs = imageCond.sizeArgs()
|
||||
imageCondString = "$imageCondString AND $sizeCond"
|
||||
args.addAll(sizeArgs)
|
||||
}
|
||||
}
|
||||
|
||||
if (haveVideo) {
|
||||
val videoCond = filterOption.videoOption
|
||||
val durationCond = videoCond.durationCond()
|
||||
val durationArgs = videoCond.durationArgs()
|
||||
videoCondString = "$typeKey = ? AND $durationCond"
|
||||
args.add(MEDIA_TYPE_VIDEO.toString())
|
||||
args.addAll(durationArgs)
|
||||
}
|
||||
|
||||
if (haveAudio) {
|
||||
val audioCond = filterOption.audioOption
|
||||
val durationCond = audioCond.durationCond()
|
||||
val durationArgs = audioCond.durationArgs()
|
||||
audioCondString = "$typeKey = ? AND $durationCond"
|
||||
args.add(MEDIA_TYPE_AUDIO.toString())
|
||||
args.addAll(durationArgs)
|
||||
}
|
||||
|
||||
if (haveImage) {
|
||||
cond.append("( $imageCondString )")
|
||||
}
|
||||
|
||||
if (haveVideo) {
|
||||
if (cond.isNotEmpty()) {
|
||||
cond.append("OR ")
|
||||
}
|
||||
|
||||
cond.append("( $videoCondString )")
|
||||
}
|
||||
|
||||
|
||||
if (haveAudio) {
|
||||
if (cond.isNotEmpty()) {
|
||||
cond.append("OR ")
|
||||
}
|
||||
|
||||
cond.append("( $audioCondString )")
|
||||
}
|
||||
|
||||
return "AND ( $cond )"
|
||||
}
|
||||
|
||||
fun logRowWithId(context: Context, id: String) {
|
||||
if (LogUtils.isLog) {
|
||||
val splitter = "".padStart(40, '-')
|
||||
LogUtils.info("log error row $id start $splitter")
|
||||
val cursor = context.contentResolver.query(allUri, null, "$_ID = ?", arrayOf(id), null)
|
||||
cursor?.use {
|
||||
val names = it.columnNames
|
||||
if (cursor.moveToNext()) {
|
||||
for (i in 0 until names.count()) {
|
||||
LogUtils.info("${names[i]} : ${cursor.getString(i)}")
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtils.info("log error row $id end $splitter")
|
||||
}
|
||||
}
|
||||
|
||||
fun getMediaUri(context: Context, id: String, type: Int): String {
|
||||
val uri = AndroidQDBUtils.getUri(id, type, false)
|
||||
return uri.toString()
|
||||
}
|
||||
|
||||
fun getOnlyGalleryList(context: Context, requestType: Int, option: FilterOption): List<GalleryEntity>
|
||||
|
||||
fun getDateCond(args: ArrayList<String>, option: FilterOption): String {
|
||||
val createDateCond = addDateCond(args, option.createDateCond, MediaStore.Images.Media.DATE_ADDED)
|
||||
val updateDateCond = addDateCond(args, option.updateDateCond, MediaStore.Images.Media.DATE_MODIFIED)
|
||||
return "$createDateCond $updateDateCond"
|
||||
}
|
||||
|
||||
private fun addDateCond(args: ArrayList<String>, dateCond: DateCond, dbKey: String): String {
|
||||
if (dateCond.ignore) {
|
||||
return ""
|
||||
}
|
||||
|
||||
val minMs = dateCond.minMs
|
||||
val maxMs = dateCond.maxMs
|
||||
|
||||
val dateSelection = "AND ( $dbKey >= ? AND $dbKey <= ? )"
|
||||
args.add((minMs / 1000).toString())
|
||||
args.add((maxMs / 1000).toString())
|
||||
|
||||
return dateSelection
|
||||
}
|
||||
|
||||
fun getSortOrder(start: Int, pageSize: Int, filterOption: FilterOption): String? {
|
||||
val orderBy = filterOption.orderByCondString()
|
||||
return "$orderBy LIMIT $pageSize OFFSET $start"
|
||||
}
|
||||
|
||||
fun copyToGallery(context: Context, assetId: String, galleryId: String): AssetEntity?
|
||||
|
||||
fun moveToGallery(context: Context, assetId: String, galleryId: String): AssetEntity?
|
||||
|
||||
fun getSomeInfo(context: Context, assetId: String): Pair<String, String>?
|
||||
|
||||
fun getUri(id: String, type: Int, isOrigin: Boolean = false): Uri {
|
||||
var uri =
|
||||
when (type) {
|
||||
1 -> Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id)
|
||||
2 -> Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, id)
|
||||
3 -> Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id)
|
||||
else -> return Uri.EMPTY
|
||||
}
|
||||
|
||||
if (isOrigin) {
|
||||
uri = MediaStore.setRequireOriginal(uri)
|
||||
}
|
||||
return uri
|
||||
}
|
||||
|
||||
|
||||
fun getUriFromMediaType(id: String, mediaType: Int, isOrigin: Boolean = false): Uri {
|
||||
var uri =
|
||||
when (mediaType) {
|
||||
MEDIA_TYPE_IMAGE -> Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id)
|
||||
MEDIA_TYPE_VIDEO -> Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, id)
|
||||
MEDIA_TYPE_AUDIO -> Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id)
|
||||
MEDIA_TYPE_PLAYLIST -> Uri.withAppendedPath(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, id)
|
||||
else -> return Uri.EMPTY
|
||||
}
|
||||
|
||||
if (isOrigin) {
|
||||
uri = MediaStore.setRequireOriginal(uri)
|
||||
}
|
||||
return uri
|
||||
}
|
||||
|
||||
|
||||
fun throwMsg(msg: String): Nothing {
|
||||
throw RuntimeException(msg)
|
||||
}
|
||||
|
||||
fun removeAllExistsAssets(context: Context): Boolean
|
||||
|
||||
fun clearFileCache(context: Context) {}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
fun getAssetsUri(context: Context, ids: List<String>): List<Uri> {
|
||||
if (ids.count() > 500) {
|
||||
val result = ArrayList<Uri>()
|
||||
|
||||
val total = ids.count()
|
||||
var count = total / 500
|
||||
|
||||
if (total % 500 != 0) {
|
||||
count++
|
||||
}
|
||||
|
||||
for (i in 0 until count) {
|
||||
val end = if (i == count - 1) {
|
||||
ids.count()
|
||||
} else {
|
||||
(i + 1) * 500 - 1
|
||||
}
|
||||
val start = i * 500
|
||||
|
||||
val tmp = getAssetsUri(context, ids.subList(start, end))
|
||||
result.addAll(tmp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
val key = arrayOf(_ID, MEDIA_TYPE)
|
||||
val idSelection = ids.joinToString(",") { "?" }
|
||||
val selection = "$_ID in ($idSelection)"
|
||||
val cursor = context.contentResolver.query(allUri, key, selection, ids.toTypedArray(), null)
|
||||
?: return emptyList()
|
||||
|
||||
val list = ArrayList<Uri>()
|
||||
|
||||
val map = HashMap<String, Uri>()
|
||||
|
||||
cursor.use {
|
||||
while (it.moveToNext()) {
|
||||
val id = it.getString(_ID)
|
||||
val type = it.getInt(MEDIA_TYPE)
|
||||
map[id] = getUriFromMediaType(id, type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (id in ids) {
|
||||
map[id]?.let {
|
||||
list.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
fun getAssetsPath(context: Context, ids: List<String>): List<String> {
|
||||
|
||||
if (ids.count() > 500) {
|
||||
val result = ArrayList<String>()
|
||||
|
||||
val total = ids.count()
|
||||
var count = total / 500
|
||||
|
||||
if (total % 500 != 0) {
|
||||
count++
|
||||
}
|
||||
|
||||
for (i in 0 until count) {
|
||||
val end = if (i == count - 1) {
|
||||
ids.count()
|
||||
} else {
|
||||
(i + 1) * 500 - 1
|
||||
}
|
||||
val start = i * 500
|
||||
|
||||
val tmp = getAssetsPath(context, ids.subList(start, end))
|
||||
result.addAll(tmp)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
val key = arrayOf(_ID, MEDIA_TYPE, DATA)
|
||||
val idSelection = ids.joinToString(",") { "?" }
|
||||
val selection = "$_ID in ($idSelection)"
|
||||
val cursor = context.contentResolver.query(allUri, key, selection, ids.toTypedArray(), null)
|
||||
?: return emptyList()
|
||||
|
||||
val list = ArrayList<String>()
|
||||
|
||||
val map = HashMap<String, String>()
|
||||
|
||||
cursor.use {
|
||||
while (it.moveToNext()) {
|
||||
val id = it.getString(_ID)
|
||||
val path = it.getString(DATA)
|
||||
map[id] = path
|
||||
}
|
||||
}
|
||||
|
||||
for (id in ids) {
|
||||
map[id]?.let {
|
||||
list.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
fun injectModifiedDate(context: Context, entity: GalleryEntity) {
|
||||
val modifiedDate = getPathModifiedDate(context, entity.id)
|
||||
entity.modifiedDate = modifiedDate
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
fun getPathModifiedDate(context: Context, pathId: String): Long {
|
||||
val columns = arrayOf(MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
val sortOrder = "${MediaStore.MediaColumns.DATE_MODIFIED} desc"
|
||||
val cursor =
|
||||
if (pathId == PhotoManager.ALL_ID) {
|
||||
context.contentResolver.query(allUri, columns, null, null, sortOrder)
|
||||
} else {
|
||||
context.contentResolver.query(allUri, columns, "${MediaStore.MediaColumns.BUCKET_ID} = ?", arrayOf(pathId), sortOrder)
|
||||
?: return 0
|
||||
}
|
||||
cursor?.use {
|
||||
if (cursor.moveToNext()) {
|
||||
return cursor.getLong(MediaStore.MediaColumns.DATE_MODIFIED)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.net.Uri
|
||||
import android.provider.MediaStore
|
||||
|
||||
object MediaStoreUtils {
|
||||
|
||||
fun getInsertUri(mediaType: Int): Uri {
|
||||
return when (mediaType) {
|
||||
MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO -> MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||
MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO -> MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE -> MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
else -> IDBUtils.allUri
|
||||
}
|
||||
}
|
||||
|
||||
fun getDeleteUri(id: String, mediaType: Int): Uri {
|
||||
return Uri.withAppendedPath(getInsertUri(mediaType), id)
|
||||
}
|
||||
|
||||
|
||||
fun convertTypeToMediaType(type: Int): Int {
|
||||
return when (type) {
|
||||
1 -> MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE
|
||||
2 -> MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO
|
||||
3 -> MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
/// create 2020-03-20 by cai
|
||||
object RequestTypeUtils {
|
||||
|
||||
private const val typeImage = 1
|
||||
private const val typeVideo = 1.shl(1)
|
||||
private const val typeAudio = 1.shl(2)
|
||||
|
||||
fun containsImage(type: Int): Boolean {
|
||||
return checkType(type, typeImage)
|
||||
}
|
||||
|
||||
fun containsVideo(type: Int): Boolean {
|
||||
return checkType(type, typeVideo)
|
||||
}
|
||||
|
||||
fun containsAudio(type: Int): Boolean {
|
||||
return checkType(type, typeAudio)
|
||||
}
|
||||
|
||||
private fun checkType(type: Int, targetType: Int): Boolean {
|
||||
return type and targetType == targetType
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package top.kikt.imagescanner.core.utils
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.MediaPlayer
|
||||
import android.util.SizeF
|
||||
|
||||
object VideoUtils {
|
||||
|
||||
data class VideoInfo(var width: Int?, var height: Int?, var duration: Int?)
|
||||
|
||||
fun getPropertiesUseMediaPlayer(path: String): VideoInfo {
|
||||
val mediaPlayer = MediaPlayer()
|
||||
mediaPlayer.setDataSource(path)
|
||||
mediaPlayer.setOnErrorListener { mp, what, extra ->
|
||||
true
|
||||
}
|
||||
try {
|
||||
mediaPlayer.prepare()
|
||||
} catch (e: Throwable) {
|
||||
mediaPlayer.release()
|
||||
return VideoInfo(null, null, null)
|
||||
}
|
||||
mediaPlayer.videoHeight
|
||||
val info = VideoInfo(mediaPlayer.videoWidth, mediaPlayer.videoHeight, mediaPlayer.duration)
|
||||
|
||||
mediaPlayer.stop()
|
||||
mediaPlayer.release()
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package top.kikt.imagescanner.permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2017/2/19.
|
||||
*/
|
||||
|
||||
public interface PermissionsListener {
|
||||
|
||||
void onDenied(List<String> deniedPermissions, List<String> grantedPermissions);
|
||||
|
||||
void onGranted();
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
package top.kikt.imagescanner.permission;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import top.kikt.imagescanner.util.LogUtils;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2017/2/19.
|
||||
*/
|
||||
|
||||
public final class PermissionsUtils {
|
||||
|
||||
/**
|
||||
* 需要申请权限的Activity
|
||||
*/
|
||||
private Activity mActivity;
|
||||
|
||||
/**
|
||||
* 需要申请的权限的List
|
||||
*/
|
||||
private List<String> needToRequestPermissionsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 拒绝授权的权限的List
|
||||
*/
|
||||
private List<String> deniedPermissionsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 允许的权限List
|
||||
*/
|
||||
private List<String> grantedPermissionsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 某次进行权限申请的requestCode
|
||||
*/
|
||||
private int requestCode;
|
||||
|
||||
/**
|
||||
* 授权监听回调
|
||||
*/
|
||||
private PermissionsListener mPermissionsListener;
|
||||
|
||||
/**
|
||||
* 未授权的权限的提示字符串的List
|
||||
*/
|
||||
private List<String> tipList;
|
||||
|
||||
/**
|
||||
* 被拒绝的权限的提示字符串List
|
||||
*/
|
||||
private List<String> deniedTipsList;
|
||||
|
||||
public PermissionsUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是哪一个Activity进行权限操作
|
||||
*
|
||||
* @param activity 哪一个Activity进行权限操作
|
||||
* @return 返回 {@link PermissionsUtils} 自身,进行链式调用
|
||||
*/
|
||||
public PermissionsUtils withActivity(Activity activity) {
|
||||
this.mActivity = activity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行权限申请,不带拒绝弹框提示
|
||||
*
|
||||
* @param requestCode 指定该次申请的requestCode
|
||||
* @param permissions 要申请的权限数组
|
||||
* @return 返回 {@link PermissionsUtils} 自身,进行链式调用
|
||||
*/
|
||||
public PermissionsUtils getPermissions(Activity activity, int requestCode, List<String> permissions) {
|
||||
return getPermissionsWithTips(activity, requestCode, null, permissions.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行权限申请,带拒绝弹框提示
|
||||
*
|
||||
* @param activity 告诉工具是Activity申请权限还是Fragment申请权限
|
||||
* @param requestCode 指定该次申请的requestCode
|
||||
* @param tips 要申请的权限的被拒绝后的提示的数组
|
||||
* @param permissions 要申请的权限数组
|
||||
* @return 返回 {@link PermissionsUtils} 自身,进行链式调用
|
||||
*/
|
||||
@TargetApi(23)
|
||||
private PermissionsUtils getPermissionsWithTips(Activity activity, int requestCode, String[] tips, String... permissions) {
|
||||
if (mActivity == null) {
|
||||
throw new NullPointerException("获取权限的Activity不存在");
|
||||
}
|
||||
this.requestCode = requestCode;
|
||||
if (!checkPermissions(tips, permissions)) {
|
||||
// 通过上面的checkPermissions,可以知道能得到进入到这里面的都是6.0的机子
|
||||
ActivityCompat.requestPermissions(mActivity
|
||||
, needToRequestPermissionsList.toArray(new String[needToRequestPermissionsList.size()])
|
||||
, requestCode);
|
||||
for (int i = 0; i < needToRequestPermissionsList.size(); i++) {
|
||||
LogUtils.info("需要申请的权限列表" + needToRequestPermissionsList.get(i));
|
||||
}
|
||||
} else if (mPermissionsListener != null) mPermissionsListener.onGranted();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查所需权限是否已获取
|
||||
*
|
||||
* @param permissions 所需权限数组
|
||||
* @return 是否全部已获取
|
||||
*/
|
||||
private boolean checkPermissions(String[] tips, String... permissions) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
resetStatus();
|
||||
// if (!needToRequestPermissionsList.isEmpty())
|
||||
// needToRequestPermissionsList.clear();
|
||||
if (tips != null) {
|
||||
if (tips.length != permissions.length) {
|
||||
throw new IndexOutOfBoundsException("传入的提示数组和需要申请的权限数组长度不一致");
|
||||
}
|
||||
if (this.tipList == null)
|
||||
this.tipList = new ArrayList<>();
|
||||
// else
|
||||
// this.tipList.clear();
|
||||
}
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
// 检查权限
|
||||
if (mActivity.checkSelfPermission(permissions[i]) == PackageManager.PERMISSION_DENIED) {
|
||||
needToRequestPermissionsList.add(permissions[i]);
|
||||
if (tips != null)
|
||||
tipList.add(tips[i]);
|
||||
}
|
||||
}
|
||||
// 全部权限获取成功返回true,否则返回false
|
||||
return needToRequestPermissionsList.isEmpty();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理申请权限返回
|
||||
* 由于某些rom对权限进行了处理,第一次选择了拒绝,则不会出现第二次询问(或者没有不再询问),故拒绝就回调onDenied
|
||||
*
|
||||
* @param requestCode 对应申请权限时的code
|
||||
* @param permissions 申请的权限数组
|
||||
* @param grantResults 是否申请到权限数组
|
||||
* @return 返回 {@link PermissionsUtils} 自身,进行链式调用
|
||||
*/
|
||||
public PermissionsUtils dealResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (requestCode == this.requestCode) {
|
||||
// if (!deniedPermissionsList.isEmpty())
|
||||
// deniedPermissionsList.clear();
|
||||
// if (deniedTipsList != null && !deniedTipsList.isEmpty())
|
||||
// deniedTipsList.clear();
|
||||
|
||||
// for (String permission : permissions) {
|
||||
// if (ActivityCompat.checkSelfPermission(mActivity,permission)== PackageManager.PERMISSION_DENIED){
|
||||
// deniedPermissionsList.add(permission);
|
||||
// }
|
||||
// }
|
||||
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
LogUtils.info("返回权限列表" + permissions[i]);
|
||||
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
|
||||
deniedPermissionsList.add(permissions[i]);
|
||||
if (tipList != null && deniedTipsList == null) {
|
||||
deniedTipsList = new ArrayList<>();
|
||||
}
|
||||
if (deniedTipsList != null && tipList != null && tipList.size() > 0)
|
||||
deniedTipsList.add(tipList.get(i));
|
||||
} else if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
grantedPermissionsList.add(permissions[i]);
|
||||
}
|
||||
}
|
||||
if (!deniedPermissionsList.isEmpty()) {
|
||||
if (tipList != null && tipList.size() > 0) {
|
||||
showDialog();
|
||||
}
|
||||
// 回调用户拒绝监听
|
||||
mPermissionsListener.onDenied(deniedPermissionsList, grantedPermissionsList);
|
||||
} else {
|
||||
// 回调用户同意监听
|
||||
mPermissionsListener.onGranted();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复状态
|
||||
*/
|
||||
private void resetStatus() {
|
||||
if (deniedPermissionsList != null) deniedPermissionsList.clear();
|
||||
if (deniedTipsList != null) deniedTipsList.clear();
|
||||
if (needToRequestPermissionsList != null) needToRequestPermissionsList.clear();
|
||||
if (tipList != null) tipList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示被拒绝的权限列表和对应的提示列表的dialog
|
||||
*/
|
||||
private void showDialog() {
|
||||
new AlertDialog.Builder(mActivity)
|
||||
.setTitle(dealStringWithColor())
|
||||
.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
getAppDetailSettingIntent(mActivity);
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表有颜色
|
||||
*/
|
||||
private CharSequence dealStringWithColor() {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
int start = 0;
|
||||
for (int i = 0; i < deniedPermissionsList.size(); i++) {
|
||||
String temp = deniedPermissionsList.get(i).split("\\.")[2];
|
||||
builder.append(temp);
|
||||
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor("#37ADA4"));
|
||||
builder.setSpan(foregroundColorSpan, start, start + temp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(":");
|
||||
builder.append(deniedTipsList.get(i));
|
||||
start = start + temp.length() + 2 + deniedTipsList.get(i).length();
|
||||
if (i != deniedPermissionsList.size() - 1)
|
||||
builder.append("\n");
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到应用的设置界面
|
||||
*
|
||||
* @param context 上下文
|
||||
*/
|
||||
public void getAppDetailSettingIntent(Context context) {
|
||||
Intent localIntent = new Intent();
|
||||
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
|
||||
localIntent.setData(Uri.fromParts("package", context.getPackageName(), null));
|
||||
context.startActivity(localIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取申请权限的回调监听器
|
||||
*
|
||||
* @return 监听器
|
||||
*/
|
||||
public PermissionsListener getPermissionsListener() {
|
||||
return mPermissionsListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置申请权限的回调监听器
|
||||
*
|
||||
* @param permissionsListener 监听器
|
||||
* @return 返回 {@link PermissionsUtils} 自身,进行链式调用
|
||||
*/
|
||||
public PermissionsUtils setPermissionsListener(PermissionsListener permissionsListener) {
|
||||
this.mPermissionsListener = permissionsListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package top.kikt.imagescanner.thumb
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
|
||||
/// create 2019-09-12 by cai
|
||||
|
||||
|
||||
abstract class BitmapTarget(width: Int, height: Int) : CustomTarget<Bitmap>(width, height) {
|
||||
|
||||
private var bitmap: Bitmap? = null
|
||||
|
||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||
this.bitmap = resource
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (bitmap?.isRecycled == false) {
|
||||
bitmap?.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package top.kikt.imagescanner.thumb;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.request.target.SizeReadyCallback;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.util.Util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Created by debuggerx on 18-9-27 下午1:40
|
||||
*/
|
||||
public abstract class CustomTarget<T> implements Target<T> {
|
||||
private final int width;
|
||||
private final int height;
|
||||
@Nullable
|
||||
private Request request;
|
||||
|
||||
/**
|
||||
* Creates a new {@link CustomTarget} that will attempt to load the resource in its original size.
|
||||
*
|
||||
* <p>This constructor can cause very memory inefficient loads if the resource is large and can
|
||||
* cause OOMs. It's provided as a convenience for when you'd like to specify dimensions with
|
||||
* {@link com.bumptech.glide.request.RequestOptions#override(int)}. In all other cases, prefer
|
||||
* {@link #CustomTarget(int, int)}.
|
||||
*/
|
||||
public CustomTarget() {
|
||||
this(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code CustomTarget} that will return the given {@code width} and {@link @code}
|
||||
* as the requested size (unless overridden by
|
||||
* {@link com.bumptech.glide.request.RequestOptions#override(int)} in the request).
|
||||
*
|
||||
* @param width The requested width (>= 0, or == Target.SIZE_ORIGINAL).
|
||||
* @param height The requested height (>= 0, or == Target.SIZE_ORIGINAL).
|
||||
*/
|
||||
CustomTarget(int width, int height) {
|
||||
if (!Util.isValidDimensions(width, height)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
|
||||
+ width + " and height: " + height);
|
||||
}
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
// Intentionally empty, this can be optionally implemented by subclasses.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
// Intentionally empty, this can be optionally implemented by subclasses.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// Intentionally empty, this can be optionally implemented by subclasses.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
// Intentionally empty, this can be optionally implemented by subclasses.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
// Intentionally empty, this can be optionally implemented by subclasses.
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getSize(@NonNull SizeReadyCallback cb) {
|
||||
cb.onSizeReady(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void removeCallback(@NonNull SizeReadyCallback cb) {
|
||||
// Do nothing, this class does not retain SizeReadyCallbacks.
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setRequest(@Nullable Request request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final Request getRequest() {
|
||||
return request;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package top.kikt.imagescanner.thumb
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.request.FutureTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import top.kikt.imagescanner.core.entity.ThumbLoadOption
|
||||
import top.kikt.imagescanner.util.ResultHandler
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Created by debuggerx on 18-9-27 下午2:08
|
||||
*/
|
||||
object ThumbnailUtil {
|
||||
|
||||
fun getThumbnailByGlide(ctx: Context, path: String, width: Int, height: Int, format: Bitmap.CompressFormat, quality: Int, result: MethodChannel.Result?) {
|
||||
val resultHandler = ResultHandler(result)
|
||||
|
||||
Glide.with(ctx)
|
||||
.asBitmap()
|
||||
.load(File(path))
|
||||
.priority(Priority.IMMEDIATE)
|
||||
.into(object : BitmapTarget(width, height) {
|
||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||
super.onResourceReady(resource, transition)
|
||||
val bos = ByteArrayOutputStream()
|
||||
|
||||
resource.compress(format, quality, bos)
|
||||
resultHandler.reply(bos.toByteArray())
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
|
||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||
resultHandler.reply(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun getThumbOfUri(context: Context, uri: Uri, width: Int, height: Int, format: Bitmap.CompressFormat, quality: Int, callback: (ByteArray?) -> Unit) {
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(uri)
|
||||
.priority(Priority.IMMEDIATE)
|
||||
.into(object : BitmapTarget(width, height) {
|
||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||
super.onResourceReady(resource, transition)
|
||||
val bos = ByteArrayOutputStream()
|
||||
|
||||
resource.compress(format, quality, bos)
|
||||
callback(bos.toByteArray())
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
callback(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun requestCacheThumb(context: Context, uri: Uri, thumbLoadOption: ThumbLoadOption): FutureTarget<Bitmap> {
|
||||
return Glide.with(context)
|
||||
.asBitmap()
|
||||
.priority(Priority.LOW)
|
||||
.load(uri)
|
||||
.submit(thumbLoadOption.width, thumbLoadOption.height)
|
||||
}
|
||||
|
||||
|
||||
fun requestCacheThumb(context: Context, path: String, thumbLoadOption: ThumbLoadOption): FutureTarget<Bitmap> {
|
||||
return Glide.with(context)
|
||||
.asBitmap()
|
||||
.priority(Priority.LOW)
|
||||
.load(path)
|
||||
.submit(thumbLoadOption.width, thumbLoadOption.height)
|
||||
}
|
||||
|
||||
fun clearCache(context: Context) {
|
||||
Glide.get(context).apply {
|
||||
clearDiskCache()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
116
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/util/LogUtils.java
vendored
Normal file
116
thirdparty/flutter_photo_manager/android/src/main/kotlin/top/kikt/imagescanner/util/LogUtils.java
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
package top.kikt.imagescanner.util;
|
||||
/// create 2019-07-16 by cai
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
public class LogUtils {
|
||||
|
||||
public static final String TAG = "PhotoManagerPluginLogger";
|
||||
|
||||
public static boolean isLog = false;
|
||||
|
||||
|
||||
public static void info(Object object) {
|
||||
if (!isLog) {
|
||||
return;
|
||||
}
|
||||
String msg;
|
||||
if (object == null) {
|
||||
msg = "null";
|
||||
} else {
|
||||
msg = object.toString();
|
||||
}
|
||||
Log.i(TAG, msg);
|
||||
}
|
||||
|
||||
public static void debug(Object object) {
|
||||
if (!isLog) {
|
||||
return;
|
||||
}
|
||||
String msg;
|
||||
if (object == null) {
|
||||
msg = "null";
|
||||
} else {
|
||||
msg = object.toString();
|
||||
}
|
||||
Log.d(TAG, msg);
|
||||
}
|
||||
|
||||
public static void error(Object object, Throwable error) {
|
||||
if (!isLog) {
|
||||
return;
|
||||
}
|
||||
String msg;
|
||||
if (object == null) {
|
||||
msg = "null";
|
||||
} else {
|
||||
msg = object.toString();
|
||||
}
|
||||
Log.e(TAG, msg, error);
|
||||
}
|
||||
|
||||
public static void error(Object object) {
|
||||
if (!isLog) {
|
||||
return;
|
||||
}
|
||||
String msg;
|
||||
if (object == null) {
|
||||
msg = "null";
|
||||
} else {
|
||||
msg = object.toString();
|
||||
}
|
||||
Log.e(TAG, msg);
|
||||
}
|
||||
|
||||
public static void logCursor(Cursor cursor) {
|
||||
logCursor(cursor, "_id");
|
||||
}
|
||||
|
||||
public static void logCursor(Cursor cursor, String idKey) {
|
||||
if (cursor == null) {
|
||||
debug("The cursor is null");
|
||||
return;
|
||||
}
|
||||
debug("The cursor row: " + cursor.getCount());
|
||||
cursor.moveToPosition(-1);
|
||||
while (cursor.moveToNext()) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
int idIndex = cursor.getColumnIndex(idKey);
|
||||
if (idIndex != -1) {
|
||||
String idValue = cursor.getString(idIndex);
|
||||
stringBuilder.append("\nid: ")
|
||||
.append(idValue)
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
for (String columnName : cursor.getColumnNames()) {
|
||||
String value = null;
|
||||
int columnIndex = cursor.getColumnIndex(columnName);
|
||||
try {
|
||||
value = cursor.getString(columnIndex);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
byte[] blob = cursor.getBlob(columnIndex);
|
||||
value = "blob(" + blob.length + ")";
|
||||
}
|
||||
if (!columnName.equalsIgnoreCase(idKey)) {
|
||||
stringBuilder.append("|--")
|
||||
.append(columnName)
|
||||
.append(" : ")
|
||||
.append(value)
|
||||
.append("\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
debug(stringBuilder);
|
||||
}
|
||||
cursor.moveToPosition(-1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package top.kikt.imagescanner.util
|
||||
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class ResultHandler( var result: MethodChannel.Result?,val call: MethodCall? = null) {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
}
|
||||
|
||||
init {
|
||||
handler.hasMessages(0) // just do it to init handler
|
||||
}
|
||||
|
||||
private var isReply = false
|
||||
|
||||
fun reply(any: Any?) {
|
||||
if (isReply) {
|
||||
return
|
||||
}
|
||||
isReply = true
|
||||
val result = this.result
|
||||
this.result = null
|
||||
handler.post {
|
||||
try {
|
||||
result?.success(any)
|
||||
} catch (e: IllegalStateException) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun replyError(code: String, message: String? = null, obj: Any? = null) {
|
||||
if (isReply) {
|
||||
return
|
||||
}
|
||||
isReply = true
|
||||
val result = this.result
|
||||
this.result = null
|
||||
handler.post {
|
||||
result?.error(code, message, obj)
|
||||
}
|
||||
}
|
||||
|
||||
fun notImplemented() {
|
||||
if (isReply) {
|
||||
return
|
||||
}
|
||||
isReply = true
|
||||
val result = this.result
|
||||
this.result = null
|
||||
handler.post {
|
||||
result?.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
51
thirdparty/flutter_photo_manager/develop.md
vendored
Normal file
51
thirdparty/flutter_photo_manager/develop.md
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
# api 列表
|
||||
|
||||
## 相册相关
|
||||
|
||||
### 获取相册 id 列表
|
||||
|
||||
通过 id 在 dart 端封装出列表数据
|
||||
|
||||
### 相册信息
|
||||
|
||||
通过 id 获取相册信息
|
||||
|
||||
特例: all, 则获取全部
|
||||
|
||||
### 分页获取图片
|
||||
|
||||
根据页码, 分页数量获取对应相册 id
|
||||
|
||||
## 图片相关
|
||||
|
||||
### 根据 id 获取信息
|
||||
|
||||
同步信息:
|
||||
|
||||
- 类型: 图片或视频
|
||||
- 时长: 秒, 图片为空
|
||||
- 修改日期: 10 位 unix 时间戳
|
||||
|
||||
- 根据需要获取图片定位信息(需要由用户自行申请权限)
|
||||
|
||||
异步信息:
|
||||
|
||||
每个异步信息均为单独接口
|
||||
|
||||
图片缩略图, 图片原图
|
||||
|
||||
## 接口统计
|
||||
|
||||
1. 获取 path 列表(返回所有同步数据, 数量,名称)
|
||||
2. 根据 path 异步获取数据列表(分页,所有同步数据)
|
||||
3. 根据 asset 异步资源
|
||||
1. 缩略图(根据尺寸)
|
||||
2. 原图
|
||||
|
||||
## 权限相关
|
||||
|
||||
申请权限(ios android)
|
||||
|
||||
开启应用设置的 channel
|
||||
|
||||
在 0.4.0中基本完成
|
10
thirdparty/flutter_photo_manager/example/.gitignore
vendored
Normal file
10
thirdparty/flutter_photo_manager/example/.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
|
||||
build/
|
||||
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
8
thirdparty/flutter_photo_manager/example/.metadata
vendored
Normal file
8
thirdparty/flutter_photo_manager/example/.metadata
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: eab5cd9853c13ec2207977d9b9ef7b6750fe0817
|
||||
channel: dev
|
8
thirdparty/flutter_photo_manager/example/README.md
vendored
Normal file
8
thirdparty/flutter_photo_manager/example/README.md
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
# image_scanner_example
|
||||
|
||||
Demonstrates how to use the image_scanner plugin.
|
||||
|
||||
## Getting Started
|
||||
|
||||
For help getting started with Flutter, view our online
|
||||
[documentation](https://flutter.io/).
|
10
thirdparty/flutter_photo_manager/example/android/.gitignore
vendored
Normal file
10
thirdparty/flutter_photo_manager/example/android/.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
*.iml
|
||||
*.class
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
GeneratedPluginRegistrant.java
|
17
thirdparty/flutter_photo_manager/example/android/.project
vendored
Normal file
17
thirdparty/flutter_photo_manager/example/android/.project
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>android</name>
|
||||
<comment>Project android created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
2
thirdparty/flutter_photo_manager/example/android/.settings/org.eclipse.buildship.core.prefs
vendored
Normal file
2
thirdparty/flutter_photo_manager/example/android/.settings/org.eclipse.buildship.core.prefs
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
connection.project.dir=
|
||||
eclipse.preferences.version=1
|
6
thirdparty/flutter_photo_manager/example/android/app/.classpath
vendored
Normal file
6
thirdparty/flutter_photo_manager/example/android/app/.classpath
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
23
thirdparty/flutter_photo_manager/example/android/app/.project
vendored
Normal file
23
thirdparty/flutter_photo_manager/example/android/app/.project
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>app</name>
|
||||
<comment>Project app created by Buildship.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
connection.project.dir=..
|
||||
eclipse.preferences.version=1
|
81
thirdparty/flutter_photo_manager/example/android/app/build.gradle
vendored
Normal file
81
thirdparty/flutter_photo_manager/example/android/app/build.gradle
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||
if (flutterRoot == null) {
|
||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||
}
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
def compileVersion = localProperties.getProperty('android.version')
|
||||
if (compileVersion == null) {
|
||||
compileVersion = "30"
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("${rootDir.absolutePath}/photo-manager-keystore")
|
||||
storePassword '123456'
|
||||
keyAlias 'key0'
|
||||
keyPassword '123456'
|
||||
}
|
||||
}
|
||||
|
||||
compileSdkVersion compileVersion.toInteger()
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "top.kikt.imagescannerexample"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion compileVersion.toInteger()
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source '../..'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
50
thirdparty/flutter_photo_manager/example/android/app/src/main/AndroidManifest.xml
vendored
Normal file
50
thirdparty/flutter_photo_manager/example/android/app/src/main/AndroidManifest.xml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="top.kikt.imagescannerexample">
|
||||
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_MEDIA_LOCATION"
|
||||
tools:node="remove"
|
||||
/>
|
||||
|
||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||
In most cases you can leave this as-is, but you if you want to provide
|
||||
additional functionality it is fine to subclass or reimplement
|
||||
FlutterApplication and put your custom class here. -->
|
||||
<application
|
||||
android:label="image_scanner_example"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- This keeps the window background of the activity showing
|
||||
until Flutter renders its first frame. It can be removed if
|
||||
there is no splash screen (such as the default splash screen
|
||||
defined in @style/LaunchTheme). -->
|
||||
<meta-data
|
||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||
android:value="true" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,61 @@
|
|||
package top.kikt.imagescannerexample
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import java.io.BufferedWriter
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
/// create 2019/2/18 by cai
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object CrashHandler : Thread.UncaughtExceptionHandler {
|
||||
|
||||
private var defaultHandler: Thread.UncaughtExceptionHandler? = null
|
||||
private lateinit var context: Context
|
||||
|
||||
private var df = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
|
||||
private var timeDf = SimpleDateFormat("hh:mm:ss", Locale.CHINA)
|
||||
|
||||
override fun uncaughtException(t: Thread, e: Throwable) {
|
||||
|
||||
|
||||
val file = context.externalCacheDir?.absoluteFile ?: return
|
||||
|
||||
val dt = df.format(Date())
|
||||
val fileName = "${file.absolutePath}/$dt.log"
|
||||
|
||||
Log.w("CrashTag", "output: $fileName")
|
||||
|
||||
var writer: BufferedWriter? = null
|
||||
var printWriter: PrintWriter? = null
|
||||
try {
|
||||
writer = File(fileName).outputStream().bufferedWriter()
|
||||
writer.write(getTimeString())
|
||||
writer.newLine()
|
||||
printWriter = PrintWriter(writer)
|
||||
e.printStackTrace(printWriter)
|
||||
writer.newLine()
|
||||
writer.write("------------")
|
||||
writer.newLine()
|
||||
writer.newLine()
|
||||
} finally {
|
||||
printWriter?.close()
|
||||
writer?.close()
|
||||
}
|
||||
|
||||
defaultHandler?.uncaughtException(t, e)
|
||||
}
|
||||
|
||||
private fun getTimeString(): String {
|
||||
return timeDf.format(Date())
|
||||
}
|
||||
|
||||
fun initHandler(context: Context) {
|
||||
this.context = context
|
||||
defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
|
||||
Thread.setDefaultUncaughtExceptionHandler(this)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package top.kikt.imagescannerexample
|
||||
|
||||
import com.bumptech.glide.module.AppGlideModule
|
||||
|
||||
@com.bumptech.glide.annotation.GlideModule
|
||||
class ExampleAppGlideModule : AppGlideModule()
|
|
@ -0,0 +1,12 @@
|
|||
package top.kikt.imagescannerexample
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity() : FlutterActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
CrashHandler.initHandler(this)
|
||||
}
|
||||
}
|
12
thirdparty/flutter_photo_manager/example/android/app/src/main/res/drawable/launch_background.xml
vendored
Normal file
12
thirdparty/flutter_photo_manager/example/android/app/src/main/res/drawable/launch_background.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 544 B |
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 442 B |
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 721 B |
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
8
thirdparty/flutter_photo_manager/example/android/app/src/main/res/values/styles.xml
vendored
Normal file
8
thirdparty/flutter_photo_manager/example/android/app/src/main/res/values/styles.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
Flutter draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true">
|
||||
<trust-anchors>
|
||||
<certificates src="system" />
|
||||
<certificates src="user" />
|
||||
</trust-anchors>
|
||||
</base-config>
|
||||
</network-security-config>
|
62
thirdparty/flutter_photo_manager/example/android/build.gradle
vendored
Normal file
62
thirdparty/flutter_photo_manager/example/android/build.gradle
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
import groovy.json.JsonSlurper
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.30'
|
||||
def isChina = false
|
||||
try {
|
||||
def connection = new URL('https://api.ip.sb/geoip').openConnection()
|
||||
connection.setRequestMethod('GET')
|
||||
def reader = new BufferedReader(new InputStreamReader(connection.inputStream))
|
||||
def text = reader.readLine()
|
||||
|
||||
def slurper = new JsonSlurper()
|
||||
def states = slurper.parseText(text)
|
||||
def country = states['country']
|
||||
isChina = country == 'China'
|
||||
} catch (e) {
|
||||
println(e)
|
||||
}
|
||||
|
||||
ext.isChina = isChina
|
||||
|
||||
repositories {
|
||||
if (isChina) {
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'http://download.flutter.io' }
|
||||
} else {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.4'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
if (isChina) {
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'http://download.flutter.io' }
|
||||
} else {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.buildDir = '../build'
|
||||
subprojects {
|
||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
4
thirdparty/flutter_photo_manager/example/android/gradle.properties
vendored
Normal file
4
thirdparty/flutter_photo_manager/example/android/gradle.properties
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
#android.enableR8=true
|
BIN
thirdparty/flutter_photo_manager/example/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
thirdparty/flutter_photo_manager/example/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
thirdparty/flutter_photo_manager/example/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Fri Jun 23 08:50:38 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
|
160
thirdparty/flutter_photo_manager/example/android/gradlew
vendored
Executable file
160
thirdparty/flutter_photo_manager/example/android/gradlew
vendored
Executable file
|
@ -0,0 +1,160 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
thirdparty/flutter_photo_manager/example/android/gradlew.bat
vendored
Normal file
90
thirdparty/flutter_photo_manager/example/android/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
BIN
thirdparty/flutter_photo_manager/example/android/photo-manager-keystore
vendored
Normal file
BIN
thirdparty/flutter_photo_manager/example/android/photo-manager-keystore
vendored
Normal file
Binary file not shown.
15
thirdparty/flutter_photo_manager/example/android/settings.gradle
vendored
Normal file
15
thirdparty/flutter_photo_manager/example/android/settings.gradle
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
include ':app'
|
||||
|
||||
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
|
||||
|
||||
def plugins = new Properties()
|
||||
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
|
||||
if (pluginsFile.exists()) {
|
||||
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
||||
}
|
||||
|
||||
plugins.each { name, path ->
|
||||
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
|
||||
include ":$name"
|
||||
project(":$name").projectDir = pluginDirectory
|
||||
}
|
32
thirdparty/flutter_photo_manager/example/ios/.gitignore
vendored
Normal file
32
thirdparty/flutter_photo_manager/example/ios/.gitignore
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
*.perspectivev3
|
||||
**/*sync/
|
||||
.sconsign.dblite
|
||||
.tags*
|
||||
**/.vagrant/
|
||||
**/DerivedData/
|
||||
Icon?
|
||||
**/Pods/
|
||||
**/.symlinks/
|
||||
profile
|
||||
xcuserdata
|
||||
**/.generated/
|
||||
Flutter/App.framework
|
||||
Flutter/Flutter.framework
|
||||
Flutter/Flutter.podspec
|
||||
Flutter/Generated.xcconfig
|
||||
Flutter/app.flx
|
||||
Flutter/app.zip
|
||||
Flutter/flutter_assets/
|
||||
Flutter/flutter_export_environment.sh
|
||||
ServiceDefinitions.json
|
||||
Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.pbxuser
|
||||
!default.perspectivev3
|
26
thirdparty/flutter_photo_manager/example/ios/Flutter/AppFrameworkInfo.plist
vendored
Normal file
26
thirdparty/flutter_photo_manager/example/ios/Flutter/AppFrameworkInfo.plist
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>App</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.flutter.flutter.app</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>App</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
</dict>
|
||||
</plist>
|
2
thirdparty/flutter_photo_manager/example/ios/Flutter/Debug.xcconfig
vendored
Normal file
2
thirdparty/flutter_photo_manager/example/ios/Flutter/Debug.xcconfig
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Generated.xcconfig"
|
2
thirdparty/flutter_photo_manager/example/ios/Flutter/Release.xcconfig
vendored
Normal file
2
thirdparty/flutter_photo_manager/example/ios/Flutter/Release.xcconfig
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Generated.xcconfig"
|
41
thirdparty/flutter_photo_manager/example/ios/Podfile
vendored
Normal file
41
thirdparty/flutter_photo_manager/example/ios/Podfile
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '9.0'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_ios_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_ios_build_settings(target)
|
||||
end
|
||||
end
|
35
thirdparty/flutter_photo_manager/example/ios/Podfile.lock
vendored
Normal file
35
thirdparty/flutter_photo_manager/example/ios/Podfile.lock
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
PODS:
|
||||
- Flutter (1.0.0)
|
||||
- path_provider (0.0.1):
|
||||
- Flutter
|
||||
- photo_manager (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- video_player (0.0.1):
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||
- photo_manager (from `.symlinks/plugins/photo_manager/ios`)
|
||||
- video_player (from `.symlinks/plugins/video_player/ios`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
path_provider:
|
||||
:path: ".symlinks/plugins/path_provider/ios"
|
||||
photo_manager:
|
||||
:path: ".symlinks/plugins/photo_manager/ios"
|
||||
video_player:
|
||||
:path: ".symlinks/plugins/video_player/ios"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
||||
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
|
||||
photo_manager: 61cdd6835af271b9ad1bb533fccf71d5db02fff3
|
||||
video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e
|
||||
|
||||
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
||||
|
||||
COCOAPODS: 1.10.1
|
551
thirdparty/flutter_photo_manager/example/ios/Runner.xcodeproj/project.pbxproj
vendored
Normal file
551
thirdparty/flutter_photo_manager/example/ios/Runner.xcodeproj/project.pbxproj
vendored
Normal file
|
@ -0,0 +1,551 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 51;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
1EAD534D59D53A3A4B5F543C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BCCDE43FFC8A487F1D7A7CF /* Pods_Runner.framework */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0F7FCBCF596490150EA460FC /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3BCCDE43FFC8A487F1D7A7CF /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
714F89C514A6F657F6BA5A64 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
B17FB35E2EDE9DED63760BDB /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
97C146EB1CF9000F007C117D /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1EAD534D59D53A3A4B5F543C /* Pods_Runner.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
14770E438C536ACA792E6C11 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3BCCDE43FFC8A487F1D7A7CF /* Pods_Runner.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
71C345CCA87FFEC9B6376D6E /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B17FB35E2EDE9DED63760BDB /* Pods-Runner.debug.xcconfig */,
|
||||
714F89C514A6F657F6BA5A64 /* Pods-Runner.release.xcconfig */,
|
||||
0F7FCBCF596490150EA460FC /* Pods-Runner.profile.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
);
|
||||
name = Flutter;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146E51CF9000F007C117D = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
71C345CCA87FFEC9B6376D6E /* Pods */,
|
||||
14770E438C536ACA792E6C11 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146EF1CF9000F007C117D /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146EE1CF9000F007C117D /* Runner.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146F01CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||
97C147021CF9000F007C117D /* Info.plist */,
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||
);
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
97C146ED1CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
A71F6FDA6B0A7CCBA6F847B6 /* [CP] Check Pods Manifest.lock */,
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
4FE45EE4BC12E9FEDEAD3DCE /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Runner;
|
||||
productName = Runner;
|
||||
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
97C146ED1CF9000F007C117D = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
LastSwiftMigration = 1100;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 97C146E51CF9000F007C117D;
|
||||
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
97C146ED1CF9000F007C117D /* Runner */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
97C146EC1CF9000F007C117D /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Thin Binary";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
4FE45EE4BC12E9FEDEAD3DCE /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Run Script";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
A71F6FDA6B0A7CCBA6F847B6 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
97C146EA1CF9000F007C117D /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C146FB1CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C147001CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
249021D4217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = top.kikt.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
97C147031CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147041CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
97C147061CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = top.kikt.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147071CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = top.kikt.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147031CF9000F007C117D /* Debug */,
|
||||
97C147041CF9000F007C117D /* Release */,
|
||||
249021D3217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147061CF9000F007C117D /* Debug */,
|
||||
97C147071CF9000F007C117D /* Release */,
|
||||
249021D4217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||
}
|
7
thirdparty/flutter_photo_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
7
thirdparty/flutter_photo_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Profile"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
10
thirdparty/flutter_photo_manager/example/ios/Runner.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
10
thirdparty/flutter_photo_manager/example/ios/Runner.xcworkspace/contents.xcworkspacedata
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
13
thirdparty/flutter_photo_manager/example/ios/Runner/AppDelegate.swift
vendored
Normal file
13
thirdparty/flutter_photo_manager/example/ios/Runner/AppDelegate.swift
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import UIKit
|
||||
import Flutter
|
||||
|
||||
@UIApplicationMain
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue