├── .gitignore
├── README.md
├── build.gradle
├── demo
├── .gitignore
├── KeyForEasyPhotos.jks
├── build.gradle
├── proguard-rules.pro
├── release
│ ├── demo-release.apk
│ └── output.json
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── huantansheng
│ │ └── easyphotos
│ │ └── demo
│ │ ├── GlideEngine.java
│ │ ├── MainAdapter.java
│ │ ├── MyApplication.java
│ │ ├── SampleActivity.java
│ │ └── SampleFragments.java
│ └── res
│ ├── drawable-nodpi
│ └── watermark.png
│ ├── drawable
│ └── side_nav_bar.xml
│ ├── layout
│ ├── activity_sample.xml
│ ├── activity_sample_fragments.xml
│ ├── ad_album_items.xml
│ ├── ad_photos.xml
│ ├── app_bar_sample.xml
│ ├── content_sample.xml
│ ├── fragment_sample_fragments.xml
│ ├── item.xml
│ └── nav_header_sample.xml
│ ├── menu
│ ├── activity_sample_drawer.xml
│ └── sample.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ad.jpg
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── file_paths_public.xml
├── easyPhotos
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── huantansheng
│ │ └── easyphotos
│ │ ├── Builder
│ │ └── AlbumBuilder.java
│ │ ├── EasyPhotos.java
│ │ ├── callback
│ │ ├── PuzzleCallback.java
│ │ └── SelectCallback.java
│ │ ├── constant
│ │ ├── Code.java
│ │ ├── Key.java
│ │ └── Type.java
│ │ ├── engine
│ │ └── ImageEngine.java
│ │ ├── models
│ │ ├── ad
│ │ │ ├── AdEntity.java
│ │ │ ├── AdListener.java
│ │ │ └── AdViewHolder.java
│ │ ├── album
│ │ │ ├── AlbumModel.java
│ │ │ └── entity
│ │ │ │ ├── Album.java
│ │ │ │ ├── AlbumItem.java
│ │ │ │ └── Photo.java
│ │ ├── puzzle
│ │ │ ├── Area.java
│ │ │ ├── DegreeSeekBar.java
│ │ │ ├── Line.java
│ │ │ ├── MatrixUtils.java
│ │ │ ├── PuzzleLayout.java
│ │ │ ├── PuzzlePiece.java
│ │ │ ├── PuzzleUtils.java
│ │ │ ├── PuzzleView.java
│ │ │ ├── SquarePuzzleView.java
│ │ │ ├── slant
│ │ │ │ ├── CrossoverPointF.java
│ │ │ │ ├── SlantArea.java
│ │ │ │ ├── SlantLine.java
│ │ │ │ ├── SlantPuzzleLayout.java
│ │ │ │ └── SlantUtils.java
│ │ │ ├── straight
│ │ │ │ ├── StraightArea.java
│ │ │ │ ├── StraightLine.java
│ │ │ │ ├── StraightPuzzleLayout.java
│ │ │ │ └── StraightUtils.java
│ │ │ └── template
│ │ │ │ ├── slant
│ │ │ │ ├── NumberSlantLayout.java
│ │ │ │ ├── OneSlantLayout.java
│ │ │ │ ├── SlantLayoutHelper.java
│ │ │ │ ├── ThreeSlantLayout.java
│ │ │ │ └── TwoSlantLayout.java
│ │ │ │ └── straight
│ │ │ │ ├── EightStraightLayout.java
│ │ │ │ ├── FiveStraightLayout.java
│ │ │ │ ├── FourStraightLayout.java
│ │ │ │ ├── NineStraightLayout.java
│ │ │ │ ├── NumberStraightLayout.java
│ │ │ │ ├── OneStraightLayout.java
│ │ │ │ ├── SevenStraightLayout.java
│ │ │ │ ├── SixStraightLayout.java
│ │ │ │ ├── StraightLayoutHelper.java
│ │ │ │ ├── ThreeStraightLayout.java
│ │ │ │ └── TwoStraightLayout.java
│ │ └── sticker
│ │ │ ├── StickerModel.java
│ │ │ ├── cache
│ │ │ └── StickerCache.java
│ │ │ ├── entity
│ │ │ └── TextStickerData.java
│ │ │ ├── listener
│ │ │ └── OnStickerClickListener.java
│ │ │ └── view
│ │ │ ├── BitmapSticker.java
│ │ │ ├── EditFragment.java
│ │ │ └── TextSticker.java
│ │ ├── result
│ │ └── Result.java
│ │ ├── setting
│ │ └── Setting.java
│ │ ├── ui
│ │ ├── EasyPhotosActivity.java
│ │ ├── PreviewActivity.java
│ │ ├── PreviewFragment.java
│ │ ├── PuzzleActivity.java
│ │ ├── PuzzleSelectorActivity.java
│ │ ├── adapter
│ │ │ ├── AlbumItemsAdapter.java
│ │ │ ├── PhotosAdapter.java
│ │ │ ├── PreviewPhotosAdapter.java
│ │ │ ├── PreviewPhotosFragmentAdapter.java
│ │ │ ├── PuzzleAdapter.java
│ │ │ ├── PuzzleSelectorAdapter.java
│ │ │ ├── PuzzleSelectorPreviewAdapter.java
│ │ │ └── TextStickerAdapter.java
│ │ ├── dialog
│ │ │ └── LoadingDialog.java
│ │ └── widget
│ │ │ ├── PressedImageView.java
│ │ │ ├── PressedTextView.java
│ │ │ └── PreviewRecyclerView.java
│ │ └── utils
│ │ ├── Color
│ │ └── ColorUtils.java
│ │ ├── String
│ │ └── StringUtils.java
│ │ ├── bitmap
│ │ ├── BitmapUtils.java
│ │ └── SaveBitmapCallBack.java
│ │ ├── file
│ │ └── FileUtils.java
│ │ ├── media
│ │ ├── DurationUtils.java
│ │ └── MediaScannerConnectionUtils.java
│ │ ├── permission
│ │ └── PermissionUtil.java
│ │ ├── result
│ │ ├── EasyResult.java
│ │ └── HolderFragment.java
│ │ ├── settings
│ │ └── SettingsUtils.java
│ │ ├── system
│ │ ├── MeiZuStatusUtils.java
│ │ └── SystemUtils.java
│ │ └── uri
│ │ └── UriUtils.java
│ └── res
│ ├── drawable
│ ├── bg_dialog_album_items_background_easy_photos.xml
│ ├── bg_dialog_loading_easy_photos.xml
│ ├── bg_menu_done_easy_photos.xml
│ ├── bg_second_level_menu_easy_photos.xml
│ ├── bg_seek_bar_alpha_easy_photos.xml
│ ├── bg_select_false_easy_photos.xml
│ ├── bg_select_false_unable_easy_photos.xml
│ ├── bg_select_true_easy_photos.xml
│ ├── bg_selected_frame_easy_photos.xml
│ ├── bg_selected_frame_puzzle_easy_photos.xml
│ ├── bg_text_sticker_editor_easy_photos.xml
│ ├── ic_album_item_choose_easy_photos.xml
│ ├── ic_album_items_name_easy_photos.xml
│ ├── ic_arrow_back_easy_photos.xml
│ ├── ic_arrow_down_easy_photos.xml
│ ├── ic_arrow_up_easy_photos.xml
│ ├── ic_black_easy_photos.xml
│ ├── ic_blue_easy_photos.xml
│ ├── ic_camera_easy_photos.xml
│ ├── ic_clear_easy_photos.xml
│ ├── ic_cyan_easy_photos.xml
│ ├── ic_delete_easyy_photos.xml
│ ├── ic_edit_easy_photos.xml
│ ├── ic_gray_easy_photos.xml
│ ├── ic_green_easy_photos.xml
│ ├── ic_notifications_easy_photos.xml
│ ├── ic_orange_easy_photos.xml
│ ├── ic_play_easy_photos.xml
│ ├── ic_purple_easy_photos.xml
│ ├── ic_puzzle_corner_easy_photos.xml
│ ├── ic_puzzle_flip_easy_photos.xml
│ ├── ic_puzzle_mirror_easy_photos.xml
│ ├── ic_puzzle_padding_easy_photos.xml
│ ├── ic_puzzle_replace_easy_photos.xml
│ ├── ic_puzzle_rotate_easy_photos.xml
│ ├── ic_red_easy_photos.xml
│ ├── ic_selector_easy_photos.xml
│ ├── ic_selector_true_easy_photos.xml
│ ├── ic_settings_easy_photos.xml
│ ├── ic_white_easy_photos.xml
│ ├── ic_yelow_easy_photos.xml
│ ├── progress_bar_easy_photos.xml
│ └── thumb_seek_bar_alpha_easy_photos.xml
│ ├── layout
│ ├── activity_easy_photos.xml
│ ├── activity_preview_easy_photos.xml
│ ├── activity_puzzle_easy_photos.xml
│ ├── activity_puzzle_selector_easy_photos.xml
│ ├── dialog_loading_easy_photos.xml
│ ├── fragment_preview_easy_photos.xml
│ ├── fragment_text_sticker_easy_photos.xml
│ ├── item_ad_easy_photos.xml
│ ├── item_camera_easy_photos.xml
│ ├── item_dialog_album_items_easy_photos.xml
│ ├── item_preview_photo_easy_photos.xml
│ ├── item_preview_selected_photos_easy_photos.xml
│ ├── item_puzzle_easy_photos.xml
│ ├── item_puzzle_selector_easy_photos.xml
│ ├── item_puzzle_selector_preview_easy_photos.xml
│ ├── item_rv_photos_easy_photos.xml
│ └── item_text_sticker_easy_photos.xml
│ ├── mipmap-xhdpi
│ ├── ic_controller_easy_photos.png
│ ├── ic_delete_easy_photos.png
│ ├── ic_editor_easy_photos.png
│ ├── ic_mirror_easy_photos.png
│ └── ic_rotate_easy_photos.png
│ ├── mipmap-xxhdpi
│ ├── ic_controller_easy_photos.png
│ ├── ic_delete_easy_photos.png
│ ├── ic_editor_easy_photos.png
│ ├── ic_mirror_easy_photos.png
│ └── ic_rotate_easy_photos.png
│ ├── values-v19
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w480dp
│ └── integers.xml
│ ├── values-w640dp
│ └── integers.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── integers.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── 01.png
├── 02.png
├── 03.png
├── 04.png
├── 05.png
├── 06.png
├── 07.png
├── 08.png
├── 09.png
├── 10.png
├── 11.png
├── 12.png
├── 13.png
├── 14.png
├── 15.png
├── 16.png
├── 17.png
└── 18.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Built application files
4 | *.ap_
5 |
6 | # Files for the ART/Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 | out/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # IntelliJ
37 | *.iml
38 | .idea
39 | .idea/workspace.xml
40 | .idea/modules.xml
41 | .idea/tasks.xml
42 | .idea/gradle.xml
43 | .idea/assetWizardSettings.xml
44 | .idea/dictionaries
45 | .idea/libraries
46 | .idea/caches
47 |
48 | # Keystore files
49 | # Uncomment the following line if you do not want to check your keystore files in.
50 | #*.jks
51 |
52 | # External native build folder generated in Android Studio 2.2 and later
53 | .externalNativeBuild
54 |
55 | # Google Services (e.g. APIs or Firebase)
56 | google-services.json
57 |
58 | # Freeline
59 | freeline.py
60 | freeline/
61 | freeline_project_description.json
62 |
63 | # fastlane
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 | fastlane/readme.md
69 |
70 | # test
71 | /src/test
72 | /src/androidTest
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | jcenter()
5 | mavenCentral()
6 | maven { url 'https://maven.google.com' }
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.2'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
12 |
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | mavenCentral()
20 | maven { url "https://jitpack.io" }
21 | google()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Built application files
4 | *.ap_
5 |
6 | # Files for the ART/Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 | out/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # IntelliJ
37 | *.iml
38 | .idea
39 | .idea/workspace.xml
40 | .idea/modules.xml
41 | .idea/tasks.xml
42 | .idea/gradle.xml
43 | .idea/assetWizardSettings.xml
44 | .idea/dictionaries
45 | .idea/libraries
46 | .idea/caches
47 |
48 | # Keystore files
49 | # Uncomment the following line if you do not want to check your keystore files in.
50 | #*.jks
51 |
52 | # External native build folder generated in Android Studio 2.2 and later
53 | .externalNativeBuild
54 |
55 | # Google Services (e.g. APIs or Firebase)
56 | google-services.json
57 |
58 | # Freeline
59 | freeline.py
60 | freeline/
61 | freeline_project_description.json
62 |
63 | # fastlane
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 | fastlane/readme.md
69 |
70 | # test
71 | /src/test
72 | /src/androidTest
--------------------------------------------------------------------------------
/demo/KeyForEasyPhotos.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/KeyForEasyPhotos.jks
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 |
6 | defaultConfig {
7 | applicationId "com.huantansheng.easyphotos.demo"
8 | minSdkVersion 15
9 | targetSdkVersion 30
10 | versionCode 2
11 | versionName "1.0.2"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 | //EasyPhotos asdfghjkl
22 | dependencies {
23 | implementation fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
28 | implementation 'androidx.appcompat:appcompat:1.1.0'
29 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
30 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
31 | implementation 'com.google.android.material:material:1.1.0'
32 | testImplementation 'junit:junit:4.12'
33 |
34 | implementation project(':easyPhotos')
35 |
36 | implementation("com.github.bumptech.glide:glide:4.11.0") {
37 | exclude group: "com.android.support"
38 | }
39 | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
40 | //检测内存泄漏
41 | debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
42 | releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
43 | }
44 |
--------------------------------------------------------------------------------
/demo/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | #EasyPhotos
2 |
3 | -keep class com.huantansheng.easyphotos.models.** { *; }
4 |
5 | #glide
6 | -keep public class * implements com.bumptech.glide.module.GlideModule
7 | -keep public class * extends com.bumptech.glide.AppGlideModule
8 | -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
9 | **[] $VALUES;
10 | public *;
11 | }
--------------------------------------------------------------------------------
/demo/release/demo-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/release/demo-release.apk
--------------------------------------------------------------------------------
/demo/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"1.0.2","enabled":true,"outputFile":"demo-release.apk","fullName":"release","baseName":"release"},"path":"demo-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
32 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/huantansheng/easyphotos/demo/GlideEngine.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.demo;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.net.Uri;
6 | import android.widget.ImageView;
7 |
8 | import androidx.annotation.NonNull;
9 |
10 | import com.bumptech.glide.Glide;
11 | import com.huantansheng.easyphotos.engine.ImageEngine;
12 |
13 | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
14 |
15 | /**
16 | * Glide4.x的加载图片引擎实现,单例模式
17 | * Glide4.x的缓存机制更加智能,已经达到无需配置的境界。如果使用Glide3.x,需要考虑缓存机制。
18 | * Created by huan on 2018/1/15.
19 | */
20 |
21 | public class GlideEngine implements ImageEngine {
22 | //单例
23 | private static GlideEngine instance = null;
24 | //单例模式,私有构造方法
25 | private GlideEngine() {
26 | }
27 | //获取单例
28 | public static GlideEngine getInstance() {
29 | if (null == instance) {
30 | synchronized (GlideEngine.class) {
31 | if (null == instance) {
32 | instance = new GlideEngine();
33 | }
34 | }
35 | }
36 | return instance;
37 | }
38 |
39 | /**
40 | * 加载图片到ImageView
41 | *
42 | * @param context 上下文
43 | * @param uri 图片路径Uri
44 | * @param imageView 加载到的ImageView
45 | */
46 | //安卓10推荐uri,并且path的方式不再可用
47 | @Override
48 | public void loadPhoto(@NonNull Context context, @NonNull Uri uri, @NonNull ImageView imageView) {
49 | Glide.with(context).load(uri).transition(withCrossFade()).into(imageView);
50 | }
51 |
52 | /**
53 | * 加载gif动图图片到ImageView,gif动图不动
54 | *
55 | * @param context 上下文
56 | * @param gifUri gif动图路径Uri
57 | * @param imageView 加载到的ImageView
58 | *
59 | * 备注:不支持动图显示的情况下可以不写
60 | */
61 | //安卓10推荐uri,并且path的方式不再可用
62 | @Override
63 | public void loadGifAsBitmap(@NonNull Context context, @NonNull Uri gifUri, @NonNull ImageView imageView) {
64 | Glide.with(context).asBitmap().load(gifUri).into(imageView);
65 | }
66 |
67 | /**
68 | * 加载gif动图到ImageView,gif动图动
69 | *
70 | * @param context 上下文
71 | * @param gifUri gif动图路径Uri
72 | * @param imageView 加载动图的ImageView
73 | *
74 | * 备注:不支持动图显示的情况下可以不写
75 | */
76 | //安卓10推荐uri,并且path的方式不再可用
77 | @Override
78 | public void loadGif(@NonNull Context context, @NonNull Uri gifUri, @NonNull ImageView imageView) {
79 | Glide.with(context).asGif().load(gifUri).transition(withCrossFade()).into(imageView);
80 | }
81 |
82 |
83 | /**
84 | * 获取图片加载框架中的缓存Bitmap,不用拼图功能可以直接返回null
85 | *
86 | * @param context 上下文
87 | * @param uri 图片路径
88 | * @param width 图片宽度
89 | * @param height 图片高度
90 | * @return Bitmap
91 | * @throws Exception 异常直接抛出,EasyPhotos内部处理
92 | */
93 | //安卓10推荐uri,并且path的方式不再可用
94 | @Override
95 | public Bitmap getCacheBitmap(@NonNull Context context, @NonNull Uri uri, int width, int height) throws Exception {
96 | return Glide.with(context).asBitmap().load(uri).submit(width, height).get();
97 | }
98 |
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/huantansheng/easyphotos/demo/MainAdapter.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.demo;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.bumptech.glide.RequestManager;
13 | import com.huantansheng.easyphotos.models.album.entity.Photo;
14 |
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * 返回图片的列表适配器
19 | * Created by huan on 2017/10/30.
20 | */
21 |
22 | public class MainAdapter extends RecyclerView.Adapter {
23 | private ArrayList list;
24 | private LayoutInflater mInflater;
25 | private RequestManager mGlide;
26 |
27 | MainAdapter(Context cxt, ArrayList list) {
28 | this.list = list;
29 | mInflater = LayoutInflater.from(cxt);
30 | mGlide = Glide.with(cxt);
31 | }
32 |
33 | @Override
34 | public MainVH onCreateViewHolder(ViewGroup parent, int viewType) {
35 | return new MainVH(mInflater.inflate(R.layout.item, parent, false));
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(MainVH holder, int position) {
40 | Photo photo = list.get(position);
41 | mGlide.load(photo.uri).into(holder.ivPhoto);
42 | holder.tvMessage.setText("[图片名称]: "+photo.name+"\n[宽]:"+photo.width+"\n[高]:"+photo.height+"\n[文件大小,单位bytes]:"+photo.size+"\n[日期,时间戳,毫秒]:"+photo.time+"\n[图片地址]:"+photo.path+"\n[图片类型]:"+photo.type+"\n[是否选择原图]:"+photo.selectedOriginal+"\n[视频时长]:"+photo.duration);
43 | }
44 |
45 | @Override
46 | public int getItemCount() {
47 | return list.size();
48 | }
49 |
50 | class MainVH extends RecyclerView.ViewHolder {
51 | ImageView ivPhoto;
52 | TextView tvMessage;
53 | MainVH(View itemView) {
54 | super(itemView);
55 | ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
56 | tvMessage = (TextView) itemView.findViewById(R.id.tv_message);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/huantansheng/easyphotos/demo/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.demo;
2 |
3 | import android.app.Application;
4 |
5 | import com.squareup.leakcanary.LeakCanary;
6 |
7 | /**
8 | * 主要用于检测内存泄漏
9 | * Created by huan on 2018/1/30.
10 | */
11 |
12 | public class MyApplication extends Application {
13 | @Override
14 | public void onCreate() {
15 | super.onCreate();
16 | if (LeakCanary.isInAnalyzerProcess(this)) {
17 | // This process is dedicated to LeakCanary for heap analysis.
18 | // You should not init your app in this process.
19 | return;
20 | }
21 | LeakCanary.install(this);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-nodpi/watermark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/drawable-nodpi/watermark.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_sample_fragments.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
27 |
28 |
29 |
30 |
34 |
35 |
40 |
41 |
46 |
47 |
52 |
53 |
54 |
55 |
56 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/ad_album_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
22 |
23 |
24 |
38 |
39 |
51 |
52 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/ad_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
20 |
21 |
34 |
35 |
47 |
48 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/app_bar_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/content_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/fragment_sample_fragments.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
15 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/nav_header_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
21 |
22 |
28 |
29 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/demo/src/main/res/menu/activity_sample_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
108 |
--------------------------------------------------------------------------------
/demo/src/main/res/menu/sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ad.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xxhdpi/ad.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #393a3f
4 | #303135//303135
5 | #FF4081
6 |
7 | #66000000
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 176dp
7 | 16dp
8 | 8dp
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyPhotosDemo
3 | SampleActivity
4 | Open navigation drawer
5 | Close navigation drawer
6 | Settings
7 | 相册(有相机单选,无宽高)
8 | 相册(有相机多选,无宽高)
9 | 相册(有宽高数据、链式调用写法)
10 | 相册(带默认勾选,不显示拼图按钮,无宽高)
11 | 相册(尺寸和大小限制)
12 | 相册(显示原图按钮,默认选中)
13 | 相册(显示原图按钮,不可用)
14 | 相册(支持video和gif)
15 | 相册(只显示video)
16 | 相册(不显示底部编辑图标按钮)
17 | 相册(无相机单选,无宽高)
18 | 相册(无相机多选,无宽高)
19 | 相册(带广告,无宽高)
20 | 相册 (复杂选择情况,2个视频3张图片)
21 | 相册 (复杂选择情况,动态单一类型)
22 | 相机(有宽高)
23 | 图片添加水印
24 | 人脸检测
25 | 拼图(作为单独功能使用)
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/demo/src/main/res/xml/file_paths_public.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Built application files
4 | *.apk
5 | *.ap_
6 |
7 | # Files for the ART/Dalvik VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 | out/
17 |
18 | # Gradle files
19 | .gradle/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # IntelliJ
38 | *.iml
39 | .idea
40 | .idea/workspace.xml
41 | .idea/modules.xml
42 | .idea/tasks.xml
43 | .idea/gradle.xml
44 | .idea/assetWizardSettings.xml
45 | .idea/dictionaries
46 | .idea/libraries
47 | .idea/caches
48 |
49 | # Keystore files
50 | # Uncomment the following line if you do not want to check your keystore files in.
51 | #*.jks
52 |
53 | # External native build folder generated in Android Studio 2.2 and later
54 | .externalNativeBuild
55 |
56 | # Google Services (e.g. APIs or Firebase)
57 | google-services.json
58 |
59 | # Freeline
60 | freeline.py
61 | freeline/
62 | freeline_project_description.json
63 |
64 | # fastlane
65 | fastlane/report.xml
66 | fastlane/Preview.html
67 | fastlane/screenshots
68 | fastlane/test_output
69 | fastlane/readme.md
70 |
71 | # test
72 | /src/test
73 | /src/androidTest
--------------------------------------------------------------------------------
/easyPhotos/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | group = 'com.github.HuanTanSheng'
4 |
5 | android {
6 | compileSdkVersion 30
7 |
8 | defaultConfig {
9 | minSdkVersion 15
10 | targetSdkVersion 30
11 | versionCode 1
12 | versionName "1.0"
13 | vectorDrawables.useSupportLibrary = true
14 | }
15 | }
16 |
17 | dependencies {
18 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
19 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
20 | implementation 'androidx.appcompat:appcompat:1.2.0'
21 | implementation 'com.google.android.material:material:1.1.0'
22 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
23 | implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
24 | implementation 'com.github.chrisbanes:PhotoView:2.3.0'
25 | }
26 |
27 | //// 指定编码
28 | //tasks.withType(JavaCompile) {
29 | // options.encoding = "UTF-8"
30 | //}
31 |
32 | // 打包源码
33 | task sourcesJar(type: Jar) {
34 | from android.sourceSets.main.java.srcDirs
35 | classifier = 'sources'
36 | }
37 |
38 | //制作文档
39 | //task javadoc(type: Javadoc) {
40 | // failOnError false
41 | // source = android.sourceSets.main.java.sourceFiles
42 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
43 | // classpath += configurations.compile
44 | //}
45 |
46 | // 打包文档
47 | //task javadocJar(type: Jar, dependsOn: javadoc) {
48 | // classifier = 'javadoc'
49 | // from javadoc.destinationDir
50 | //}
51 |
52 | artifacts {
53 | archives sourcesJar
54 | // archives javadocJar
55 | }
--------------------------------------------------------------------------------
/easyPhotos/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\androidSpace\android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
19 |
24 |
29 |
35 |
36 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/callback/PuzzleCallback.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.callback;
2 |
3 | import com.huantansheng.easyphotos.models.album.entity.Photo;
4 |
5 | /**
6 | * PuzzleCallback
7 | *
8 | * @author joker
9 | * @date 2019/4/9.
10 | */
11 | public abstract class PuzzleCallback {
12 | /**
13 | * 选择结果回调
14 | *
15 | * @param photo 返回对象:如果你需要了解图片的宽、高、大小、用户是否选中原图选项等信息,可以用这个
16 | */
17 | public abstract void onResult(Photo photo);
18 | /**
19 | * 什么都没选,取消选择回调
20 | */
21 | public abstract void onCancel();
22 | }
23 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/callback/SelectCallback.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.callback;
2 |
3 | import com.huantansheng.easyphotos.models.album.entity.Photo;
4 |
5 | import java.util.ArrayList;
6 |
7 | /**
8 | * SelectCallback
9 | *
10 | * @author joker
11 | * @date 2019/4/9.
12 | */
13 | public abstract class SelectCallback {
14 | /**
15 | * 选择结果回调
16 | *
17 | * @param photos 返回对象集合:如果你需要了解图片的宽、高、大小、用户是否选中原图选项等信息,可以用这个
18 | * @param isOriginal 返回图片地址集合时如果你需要知道用户选择图片时是否选择了原图选项,用如下方法获取
19 | */
20 | public abstract void onResult(ArrayList photos, boolean isOriginal);
21 |
22 | /**
23 | * 什么都没选,取消选择回调
24 | */
25 | public abstract void onCancel();
26 | }
27 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/constant/Code.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.constant;
2 |
3 | /**
4 | * Code常量
5 | * Created by huan on 2017/10/19.
6 | */
7 |
8 | public class Code {
9 | //相机请求码
10 | public static final int REQUEST_CAMERA = 11;
11 | //权限请求码
12 | public static final int REQUEST_PERMISSION = 12;
13 | //预览activity请求码
14 | public static final int REQUEST_PREVIEW_ACTIVITY = 13;
15 | //请求应用详情
16 | public static final int REQUEST_SETTING_APP_DETAILS = 14;
17 | //拼图activity请求吗
18 | public static final int REQUEST_PUZZLE = 15;
19 | //拼图选择activity请求吗
20 | public static final int REQUEST_PUZZLE_SELECTOR = 16;
21 | }
22 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/constant/Key.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.constant;
2 |
3 | /**
4 | * key的常量
5 | * Created by huan on 2017/10/19.
6 | */
7 |
8 | public class Key {
9 | //预览图片的当前角标
10 | public static final String PREVIEW_PHOTO_INDEX = "keyOfPreviewPhotoIndex";
11 | //当前预览界面的专辑index
12 | public static final String PREVIEW_ALBUM_ITEM_INDEX = "keyOfPreviewAlbumItemIndex";
13 | //预览界面是否点击完成
14 | public static final String PREVIEW_CLICK_DONE = "keyOfPreviewClickDone";
15 | //拼图界面图片类型,true-Photo,false-String
16 | public static final String PUZZLE_FILE_IS_PHOTO = "keyOfPuzzleFilesTypeIsPhoto";
17 | //拼图界面图片结合
18 | public static final String PUZZLE_FILES = "keyOfPuzzleFiles";
19 | //拼图界面图片保存文件夹地址
20 | public static final String PUZZLE_SAVE_DIR = "keyOfPuzzleSaveDir";
21 | //拼图界面图片保存文件名前缀
22 | public static final String PUZZLE_SAVE_NAME_PREFIX = "keyOfPuzzleSaveNamePrefix";
23 | }
24 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/constant/Type.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.constant;
2 |
3 | /**
4 | * Created by huan on 2018/1/9.
5 | */
6 |
7 | public class Type {
8 | public static final String GIF = "gif";
9 | public static final String VIDEO = "video";
10 | }
11 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/engine/ImageEngine.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.engine;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.net.Uri;
6 | import android.widget.ImageView;
7 |
8 | import androidx.annotation.NonNull;
9 |
10 | /**
11 | * 自定义图片加载方式
12 | * Created by huan on 2018/1/15.
13 | */
14 | public interface ImageEngine {
15 | /**
16 | * 加载图片到ImageView
17 | *
18 | * @param context 上下文
19 | * @param uri 图片Uri
20 | * @param imageView 加载到的ImageView
21 | */
22 | //安卓10推荐uri,并且path的方式不再可用
23 | void loadPhoto(@NonNull Context context, @NonNull Uri uri,@NonNull ImageView imageView);
24 |
25 | /**
26 | * 加载gif动图图片到ImageView,gif动图不动
27 | *
28 | * @param context 上下文
29 | * @param gifUri gif动图路径Uri
30 | * @param imageView 加载到的ImageView
31 | *
32 | * 备注:不支持动图显示的情况下可以不写
33 | */
34 | //安卓10推荐uri,并且path的方式不再可用
35 | void loadGifAsBitmap(@NonNull Context context,@NonNull Uri gifUri,@NonNull ImageView imageView);
36 |
37 | /**
38 | * 加载gif动图到ImageView,gif动图动
39 | *
40 | * @param context 上下文
41 | * @param gifUri gif动图路径Uri
42 | * @param imageView 加载动图的ImageView
43 | *
44 | * 备注:不支持动图显示的情况下可以不写
45 | */
46 | //安卓10推荐uri,并且path的方式不再可用
47 | void loadGif(@NonNull Context context,@NonNull Uri gifUri,@NonNull ImageView imageView);
48 |
49 | /**
50 | * 获取图片加载框架中的缓存Bitmap,不用拼图功能可以直接返回null
51 | *
52 | * @param context 上下文
53 | * @param uri 图片路径
54 | * @param width 图片宽度
55 | * @param height 图片高度
56 | * @return Bitmap
57 | * @throws Exception 异常直接抛出,EasyPhotos内部处理
58 | */
59 | //安卓10推荐uri,并且path的方式不再可用
60 | Bitmap getCacheBitmap(@NonNull Context context,@NonNull Uri uri, int width, int height) throws Exception;
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/ad/AdEntity.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.ad;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * 广告实体
7 | * Created by huan on 2017/10/24.
8 | */
9 |
10 | public class AdEntity {
11 | public View adView;
12 | public int lineIndex;
13 |
14 | public AdEntity(View adView, int lineIndex) {
15 | this.adView = adView;
16 | this.lineIndex = lineIndex;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/ad/AdListener.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.ad;
2 |
3 | /**
4 | * 广告监听
5 | * Created by huan on 2017/10/24.
6 | */
7 |
8 | public interface AdListener {
9 | void onPhotosAdLoaded();
10 | void onAlbumItemsAdLoaded();
11 | }
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/ad/AdViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.ad;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 | import android.view.View;
5 | import android.widget.FrameLayout;
6 |
7 | import com.huantansheng.easyphotos.R;
8 |
9 | /**
10 | * 广告viewolder
11 | * Created by huan on 2017/10/28.
12 | */
13 |
14 | public class AdViewHolder extends RecyclerView.ViewHolder {
15 | public FrameLayout adFrame;
16 | public AdViewHolder(View itemView) {
17 | super(itemView);
18 | adFrame = (FrameLayout) itemView.findViewById(R.id.ad_frame_easy_photos);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/album/entity/Album.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.album.entity;
2 |
3 | import android.net.Uri;
4 |
5 | import java.util.ArrayList;
6 | import java.util.LinkedHashMap;
7 |
8 | /**
9 | * 专辑模型实体类
10 | * Created by huan on 2017/10/20.
11 | */
12 |
13 | public class Album {
14 | public ArrayList albumItems;
15 | private LinkedHashMap hasAlbumItems;//用于记录专辑项目
16 |
17 | public Album() {
18 | albumItems = new ArrayList<>();
19 | hasAlbumItems = new LinkedHashMap<>();
20 | }
21 |
22 | private void addAlbumItem(AlbumItem albumItem) {
23 | this.hasAlbumItems.put(albumItem.name, albumItem);
24 | this.albumItems.add(albumItem);
25 | }
26 |
27 | public void addAlbumItem(String name, String folderPath, String coverImagePath, Uri coverImageUri) {
28 | if (null == hasAlbumItems.get(name)) {
29 | addAlbumItem(new AlbumItem(name, folderPath, coverImagePath,coverImageUri));
30 | }
31 | }
32 |
33 | public AlbumItem getAlbumItem(String name) {
34 | return hasAlbumItems.get(name);
35 | }
36 |
37 | public AlbumItem getAlbumItem(int currIndex) {
38 | return albumItems.get(currIndex);
39 | }
40 |
41 | public boolean isEmpty() {
42 | return albumItems.isEmpty();
43 | }
44 |
45 | public void clear() {
46 | albumItems.clear();
47 | hasAlbumItems.clear();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/album/entity/AlbumItem.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.album.entity;
2 |
3 | import android.net.Uri;
4 |
5 | import java.util.ArrayList;
6 |
7 | /**
8 | * 专辑项目实体类
9 | * Created by huan on 2017/10/20.
10 | */
11 |
12 | public class AlbumItem {
13 | public String name;
14 | public String folderPath;
15 | public String coverImagePath;
16 | public Uri coverImageUri;
17 | public ArrayList photos;
18 |
19 | AlbumItem(String name, String folderPath, String coverImagePath, Uri coverImageUri) {
20 | this.name = name;
21 | this.folderPath = folderPath;
22 | this.coverImagePath = coverImagePath;
23 | this.coverImageUri = coverImageUri;
24 | this.photos = new ArrayList<>();
25 | }
26 |
27 | public void addImageItem(Photo imageItem) {
28 | this.photos.add(imageItem);
29 | }
30 |
31 | public void addImageItem(int index, Photo imageItem) {
32 | this.photos.add(index, imageItem);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/album/entity/Photo.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.album.entity;
2 |
3 | import android.net.Uri;
4 | import android.os.Parcel;
5 | import android.os.Parcelable;
6 | import android.util.Log;
7 |
8 | /**
9 | * 图片item实体类
10 | * Created by huan on 2017/10/20.
11 | */
12 |
13 | public class Photo implements Parcelable {
14 | private static final String TAG = "Photo";
15 | public Uri uri;//图片Uri
16 | public String name;//图片名称
17 | public String path;//图片全路径
18 | public String type;//图片类型
19 | public int width;//图片宽度
20 | public int height;//图片高度
21 | public int orientation;//图片旋转角度
22 | public long size;//图片文件大小,单位:Bytes
23 | public long duration;//视频时长,单位:毫秒
24 | public long time;//图片拍摄的时间戳,单位:毫秒
25 | public boolean selected;//是否被选中,内部使用,无需关心
26 | public boolean selectedOriginal;//用户选择时是否选择了原图选项
27 |
28 | public Photo(String name, Uri uri, String path, long time, int width, int height,int orientation, long size, long duration, String type) {
29 | this.name = name;
30 | this.uri = uri;
31 | this.path = path;
32 | this.time = time;
33 | this.width = width;
34 | this.height = height;
35 | this.orientation = orientation;
36 | this.type = type;
37 | this.size = size;
38 | this.duration = duration;
39 | this.selected = false;
40 | this.selectedOriginal = false;
41 | }
42 |
43 | @Override
44 | public boolean equals(Object o) {
45 | try {
46 | Photo other = (Photo) o;
47 | return this.path.equalsIgnoreCase(other.path);
48 | } catch (ClassCastException e) {
49 | Log.e(TAG, "equals: " + Log.getStackTraceString(e));
50 | }
51 | return super.equals(o);
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | return "Photo{" +
57 | "name='" + name + '\'' +
58 | ", uri='" + uri.toString() + '\'' +
59 | ", path='" + path + '\'' +
60 | ", time=" + time + '\'' +
61 | ", minWidth=" + width + '\'' +
62 | ", minHeight=" + height +
63 | ", orientation=" + orientation +
64 | '}';
65 | }
66 |
67 | @Override
68 | public int describeContents() {
69 | return 0;
70 | }
71 |
72 | @Override
73 | public void writeToParcel(Parcel dest, int flags) {
74 | dest.writeParcelable(this.uri, flags);
75 | dest.writeString(this.name);
76 | dest.writeString(this.path);
77 | dest.writeString(this.type);
78 | dest.writeInt(this.width);
79 | dest.writeInt(this.height);
80 | dest.writeInt(this.orientation);
81 | dest.writeLong(this.size);
82 | dest.writeLong(this.duration);
83 | dest.writeLong(this.time);
84 | dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
85 | dest.writeByte(this.selectedOriginal ? (byte) 1 : (byte) 0);
86 | }
87 |
88 | protected Photo(Parcel in) {
89 | this.uri = in.readParcelable(Uri.class.getClassLoader());
90 | this.name = in.readString();
91 | this.path = in.readString();
92 | this.type = in.readString();
93 | this.width = in.readInt();
94 | this.height = in.readInt();
95 | this.orientation = in.readInt();
96 | this.size = in.readLong();
97 | this.duration = in.readLong();
98 | this.time = in.readLong();
99 | this.selected = in.readByte() != 0;
100 | this.selectedOriginal = in.readByte() != 0;
101 | }
102 |
103 | public static final Creator CREATOR = new Creator() {
104 | @Override
105 | public Photo createFromParcel(Parcel source) {
106 | return new Photo(source);
107 | }
108 |
109 | @Override
110 | public Photo[] newArray(int size) {
111 | return new Photo[size];
112 | }
113 | };
114 | }
115 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/Area.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle;
2 |
3 | import android.graphics.Path;
4 | import android.graphics.PointF;
5 | import android.graphics.RectF;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @author wupanjie
11 | */
12 | public interface Area {
13 | float left();
14 |
15 | float top();
16 |
17 | float right();
18 |
19 | float bottom();
20 |
21 | float centerX();
22 |
23 | float centerY();
24 |
25 | float width();
26 |
27 | float height();
28 |
29 | PointF getCenterPoint();
30 |
31 | boolean contains(PointF point);
32 |
33 | boolean contains(float x, float y);
34 |
35 | boolean contains(Line line);
36 |
37 | Path getAreaPath();
38 |
39 | RectF getAreaRect();
40 |
41 | List getLines();
42 |
43 | PointF[] getHandleBarPoints(Line line);
44 |
45 | float radian();
46 |
47 | void setRadian(float radian);
48 |
49 | float getPaddingLeft();
50 |
51 | float getPaddingTop();
52 |
53 | float getPaddingRight();
54 |
55 | float getPaddingBottom();
56 |
57 | void setPadding(float padding);
58 |
59 | void setPadding(float paddingLeft, float paddingTop, float paddingRight, float paddingBottom);
60 | }
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/Line.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle;
2 |
3 | import android.graphics.PointF;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public interface Line {
9 | enum Direction {
10 | HORIZONTAL, VERTICAL
11 | }
12 |
13 | float length();
14 |
15 | PointF startPoint();
16 |
17 | PointF endPoint();
18 |
19 | Line lowerLine();
20 |
21 | Line upperLine();
22 |
23 | Line attachStartLine();
24 |
25 | Line attachEndLine();
26 |
27 | void setLowerLine(Line lowerLine);
28 |
29 | void setUpperLine(Line upperLine);
30 |
31 | Direction direction();
32 |
33 | float slope();
34 |
35 | boolean contains(float x, float y, float extra);
36 |
37 | void prepareMove();
38 |
39 | boolean move(float offset, float extra);
40 |
41 | void update(float layoutWidth, float layoutHeight);
42 |
43 | float minX();
44 |
45 | float maxX();
46 |
47 | float minY();
48 |
49 | float maxY();
50 |
51 | void offset(float x, float y);
52 | }
53 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/PuzzleLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle;
2 |
3 | import android.graphics.RectF;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @author wupanjie
10 | */
11 | public interface PuzzleLayout {
12 | void setOuterBounds(RectF bounds);
13 |
14 | void layout();
15 |
16 | int getAreaCount();
17 |
18 | List getOuterLines();
19 |
20 | List getLines();
21 |
22 | Area getOuterArea();
23 |
24 | void update();
25 |
26 | void reset();
27 |
28 | Area getArea(int position);
29 |
30 | float width();
31 |
32 | float height();
33 |
34 | void setPadding(float padding);
35 |
36 | float getPadding();
37 |
38 | float getRadian();
39 |
40 | void setRadian(float radian);
41 |
42 | Info generateInfo();
43 |
44 | void setColor(int color);
45 |
46 | int getColor();
47 |
48 | class Info {
49 | public static final int TYPE_STRAIGHT = 0;
50 | public static final int TYPE_SLANT = 1;
51 |
52 | public int type;
53 | public ArrayList steps;
54 | public ArrayList lineInfos;
55 | public float padding;
56 | public float radian;
57 | public int color;
58 | }
59 |
60 | class Step {
61 | public static final int ADD_LINE = 0;
62 | public static final int ADD_CROSS = 1;
63 | public static final int CUT_EQUAL_PART_ONE = 2;
64 | public static final int CUT_EQUAL_PART_TWO = 3;
65 | public static final int CUT_SPIRAL = 4;
66 |
67 | public int type;
68 | public int direction;
69 | public int position;
70 | public int part;
71 | public int hSize;
72 | public int vSize;
73 | }
74 |
75 | class LineInfo {
76 | public float startX;
77 | public float startY;
78 | public float endX;
79 | public float endY;
80 |
81 | public LineInfo(Line line){
82 | startX = line.startPoint().x;
83 | startY = line.startPoint().y;
84 | endX = line.endPoint().x;
85 | endY = line.endPoint().y;
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/PuzzleUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle;
2 |
3 |
4 | import com.huantansheng.easyphotos.models.puzzle.template.slant.OneSlantLayout;
5 | import com.huantansheng.easyphotos.models.puzzle.template.slant.SlantLayoutHelper;
6 | import com.huantansheng.easyphotos.models.puzzle.template.slant.ThreeSlantLayout;
7 | import com.huantansheng.easyphotos.models.puzzle.template.slant.TwoSlantLayout;
8 | import com.huantansheng.easyphotos.models.puzzle.template.straight.EightStraightLayout;
9 | import com.huantansheng.easyphotos.models.puzzle.template.straight.FiveStraightLayout;
10 | import com.huantansheng.easyphotos.models.puzzle.template.straight.FourStraightLayout;
11 | import com.huantansheng.easyphotos.models.puzzle.template.straight.NineStraightLayout;
12 | import com.huantansheng.easyphotos.models.puzzle.template.straight.OneStraightLayout;
13 | import com.huantansheng.easyphotos.models.puzzle.template.straight.SevenStraightLayout;
14 | import com.huantansheng.easyphotos.models.puzzle.template.straight.SixStraightLayout;
15 | import com.huantansheng.easyphotos.models.puzzle.template.straight.StraightLayoutHelper;
16 | import com.huantansheng.easyphotos.models.puzzle.template.straight.ThreeStraightLayout;
17 | import com.huantansheng.easyphotos.models.puzzle.template.straight.TwoStraightLayout;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * @author wupanjie
24 | */
25 | public class PuzzleUtils {
26 | private static final String TAG = "PuzzleUtils";
27 |
28 | private PuzzleUtils() {
29 | //no instance
30 | }
31 |
32 | public static PuzzleLayout getPuzzleLayout(int type, int borderSize, int themeId) {
33 | if (type == 0) {
34 | switch (borderSize) {
35 | case 1:
36 | return new OneSlantLayout(themeId);
37 | case 2:
38 | return new TwoSlantLayout(themeId);
39 | case 3:
40 | return new ThreeSlantLayout(themeId);
41 | default:
42 | return new OneSlantLayout(themeId);
43 | }
44 | } else {
45 | switch (borderSize) {
46 | case 1:
47 | return new OneStraightLayout(themeId);
48 | case 2:
49 | return new TwoStraightLayout(themeId);
50 | case 3:
51 | return new ThreeStraightLayout(themeId);
52 | case 4:
53 | return new FourStraightLayout(themeId);
54 | case 5:
55 | return new FiveStraightLayout(themeId);
56 | case 6:
57 | return new SixStraightLayout(themeId);
58 | case 7:
59 | return new SevenStraightLayout(themeId);
60 | case 8:
61 | return new EightStraightLayout(themeId);
62 | case 9:
63 | return new NineStraightLayout(themeId);
64 | default:
65 | return new OneStraightLayout(themeId);
66 | }
67 | }
68 | }
69 |
70 | public static List getAllPuzzleLayouts() {
71 | List puzzleLayouts = new ArrayList<>();
72 | //slant layout
73 | puzzleLayouts.addAll(SlantLayoutHelper.getAllThemeLayout(2));
74 | puzzleLayouts.addAll(SlantLayoutHelper.getAllThemeLayout(3));
75 |
76 | // straight layout
77 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(2));
78 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(3));
79 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(4));
80 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(5));
81 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(6));
82 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(7));
83 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(8));
84 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(9));
85 | return puzzleLayouts;
86 | }
87 |
88 | public static List getPuzzleLayouts(int pieceCount) {
89 | List puzzleLayouts = new ArrayList<>();
90 | puzzleLayouts.addAll(SlantLayoutHelper.getAllThemeLayout(pieceCount));
91 | puzzleLayouts.addAll(StraightLayoutHelper.getAllThemeLayout(pieceCount));
92 | return puzzleLayouts;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/SquarePuzzleView.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | /**
7 | * @author wupanjie
8 | */
9 | public class SquarePuzzleView extends PuzzleView {
10 | public SquarePuzzleView(Context context) {
11 | super(context);
12 | }
13 |
14 | public SquarePuzzleView(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | public SquarePuzzleView(Context context, AttributeSet attrs, int defStyleAttr) {
19 | super(context, attrs, defStyleAttr);
20 | }
21 |
22 | @Override
23 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
24 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
25 |
26 | int width = getMeasuredWidth();
27 | int height = getMeasuredHeight();
28 | int length = width > height ? height : width;
29 |
30 | setMeasuredDimension(length, length);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/slant/CrossoverPointF.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.slant;
2 |
3 | import android.graphics.PointF;
4 |
5 | /**
6 | * 两条线的交点
7 | *
8 | * @author wupanjie
9 | */
10 | class CrossoverPointF extends PointF {
11 | SlantLine horizontal;
12 | SlantLine vertical;
13 |
14 | CrossoverPointF() {
15 |
16 | }
17 |
18 | CrossoverPointF(float x, float y) {
19 | this.x = x;
20 | this.y = y;
21 | }
22 |
23 | CrossoverPointF(SlantLine horizontal, SlantLine vertical) {
24 | this.horizontal = horizontal;
25 | this.vertical = vertical;
26 | }
27 |
28 | void update() {
29 | if (horizontal == null || vertical == null){
30 | return;
31 | }
32 | SlantUtils.intersectionOfLines(this, horizontal, vertical);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/slant/NumberSlantLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.slant;
2 |
3 | import android.util.Log;
4 |
5 | import com.huantansheng.easyphotos.models.puzzle.slant.SlantPuzzleLayout;
6 |
7 |
8 | /**
9 | * @author wupanjie
10 | */
11 |
12 | public abstract class NumberSlantLayout extends SlantPuzzleLayout {
13 |
14 | static final String TAG = "NumberSlantLayout";
15 | protected int theme;
16 |
17 | public NumberSlantLayout(int theme) {
18 | if (theme >= getThemeCount()) {
19 | Log.e(TAG, "NumberSlantLayout: the most theme count is "
20 | + getThemeCount()
21 | + " ,you should let theme from 0 to "
22 | + (getThemeCount() - 1)
23 | + " .");
24 | }
25 | this.theme = theme;
26 | }
27 |
28 | public abstract int getThemeCount();
29 |
30 | public int getTheme() {
31 | return theme;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/slant/OneSlantLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.slant;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 |
9 | public class OneSlantLayout extends NumberSlantLayout {
10 | public OneSlantLayout(int theme) {
11 | super(theme);
12 | }
13 |
14 | @Override
15 | public int getThemeCount() {
16 | return 4;
17 | }
18 |
19 | @Override
20 | public void layout() {
21 | switch (theme) {
22 | case 0:
23 | addLine(0, Line.Direction.HORIZONTAL, 0.56f, 0.44f);
24 | break;
25 | case 1:
26 | addLine(0, Line.Direction.VERTICAL, 0.56f, 0.44f);
27 | break;
28 | case 2:
29 | addCross(0, 0.56f, 0.44f, 0.56f, 0.44f);
30 | break;
31 | case 3:
32 | cutArea(0, 1, 2);
33 | break;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/slant/SlantLayoutHelper.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.slant;
2 |
3 |
4 |
5 | import com.huantansheng.easyphotos.models.puzzle.PuzzleLayout;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * @author wupanjie
12 | */
13 | public class SlantLayoutHelper {
14 | private SlantLayoutHelper() {
15 |
16 | }
17 |
18 | public static List getAllThemeLayout(int pieceCount) {
19 | List puzzleLayouts = new ArrayList<>();
20 | switch (pieceCount) {
21 | case 1:
22 | for (int i = 0; i < 4; i++) {
23 | puzzleLayouts.add(new OneSlantLayout(i));
24 | }
25 | break;
26 | case 2:
27 | for (int i = 0; i < 2; i++) {
28 | puzzleLayouts.add(new TwoSlantLayout(i));
29 | }
30 | break;
31 | case 3:
32 | for (int i = 0; i < 6; i++) {
33 | puzzleLayouts.add(new ThreeSlantLayout(i));
34 | }
35 | break;
36 | //case 4:
37 | // for (int i = 0; i < 8; i++) {
38 | // puzzleLayouts.add(new FourStraightLayout(i));
39 | // }
40 | // break;
41 | //case 5:
42 | // for (int i = 0; i < 17; i++) {
43 | // puzzleLayouts.add(new FiveStraightLayout(i));
44 | // }
45 | // break;
46 | //case 6:
47 | // for (int i = 0; i < 12; i++) {
48 | // puzzleLayouts.add(new SixStraightLayout(i));
49 | // }
50 | // break;
51 | //case 7:
52 | // for (int i = 0; i < 9; i++) {
53 | // puzzleLayouts.add(new SevenStraightLayout(i));
54 | // }
55 | // break;
56 | //case 8:
57 | // for (int i = 0; i < 11; i++) {
58 | // puzzleLayouts.add(new EightStraightLayout(i));
59 | // }
60 | // break;
61 | //case 9:
62 | // for (int i = 0; i < 8; i++) {
63 | // puzzleLayouts.add(new NineStraightLayout(i));
64 | // }
65 | // break;
66 | }
67 |
68 | return puzzleLayouts;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/slant/ThreeSlantLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.slant;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 |
9 | public class ThreeSlantLayout extends NumberSlantLayout {
10 | public ThreeSlantLayout(int theme) {
11 | super(theme);
12 | }
13 |
14 | @Override
15 | public int getThemeCount() {
16 | return 6;
17 | }
18 |
19 | @Override
20 | public void layout() {
21 | switch (theme) {
22 | case 0:
23 | addLine(0, Line.Direction.HORIZONTAL, 0.5f);
24 | addLine(0, Line.Direction.VERTICAL, 0.56f, 0.44f);
25 | break;
26 | case 1:
27 | addLine(0, Line.Direction.HORIZONTAL, 0.5f);
28 | addLine(1, Line.Direction.VERTICAL, 0.56f, 0.44f);
29 | break;
30 | case 2:
31 | addLine(0, Line.Direction.VERTICAL, 0.5f);
32 | addLine(0, Line.Direction.HORIZONTAL, 0.56f, 0.44f);
33 | break;
34 | case 3:
35 | addLine(0, Line.Direction.VERTICAL, 0.5f);
36 | addLine(1, Line.Direction.HORIZONTAL, 0.56f, 0.44f);
37 | break;
38 | case 4:
39 | addLine(0, Line.Direction.HORIZONTAL, 0.44f, 0.56f);
40 | addLine(0, Line.Direction.VERTICAL, 0.56f, 0.44f);
41 | break;
42 | case 5:
43 | addLine(0, Line.Direction.VERTICAL, 0.56f, 0.44f);
44 | addLine(1, Line.Direction.HORIZONTAL, 0.44f, 0.56f);
45 | break;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/slant/TwoSlantLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.slant;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 |
9 | public class TwoSlantLayout extends NumberSlantLayout {
10 | public TwoSlantLayout(int theme) {
11 | super(theme);
12 | }
13 |
14 | @Override
15 | public int getThemeCount() {
16 | return 2;
17 | }
18 |
19 | @Override
20 | public void layout() {
21 | switch (theme) {
22 | case 0:
23 | addLine(0, Line.Direction.HORIZONTAL, 0.56f, 0.44f);
24 | break;
25 | case 1:
26 | addLine(0, Line.Direction.VERTICAL, 0.56f, 0.44f);
27 | break;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/EightStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class EightStraightLayout extends NumberStraightLayout {
9 | public EightStraightLayout(int theme) {
10 | super(theme);
11 | }
12 |
13 | @Override
14 | public int getThemeCount() {
15 | return 11;
16 | }
17 |
18 | @Override
19 | public void layout() {
20 | switch (theme) {
21 | case 0:
22 | cutAreaEqualPart(0, 3, 1);
23 | break;
24 | case 1:
25 | cutAreaEqualPart(0, 1, 3);
26 | break;
27 | case 2:
28 | cutAreaEqualPart(0, 4, Line.Direction.VERTICAL);
29 | addLine(3, Line.Direction.HORIZONTAL, 4f / 5);
30 | addLine(2, Line.Direction.HORIZONTAL, 3f / 5);
31 | addLine(1, Line.Direction.HORIZONTAL, 2f / 5);
32 | addLine(0, Line.Direction.HORIZONTAL, 1f / 5);
33 | break;
34 | case 3:
35 | cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL);
36 | addLine(3, Line.Direction.VERTICAL, 4f / 5);
37 | addLine(2, Line.Direction.VERTICAL, 3f / 5);
38 | addLine(1, Line.Direction.VERTICAL, 2f / 5);
39 | addLine(0, Line.Direction.VERTICAL, 1f / 5);
40 | break;
41 | case 4:
42 | cutAreaEqualPart(0, 4, Line.Direction.VERTICAL);
43 | addLine(3, Line.Direction.HORIZONTAL, 1f / 5);
44 | addLine(2, Line.Direction.HORIZONTAL, 2f / 5);
45 | addLine(1, Line.Direction.HORIZONTAL, 3f / 5);
46 | addLine(0, Line.Direction.HORIZONTAL, 4f / 5);
47 | break;
48 | case 5:
49 | cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL);
50 | addLine(3, Line.Direction.VERTICAL, 1f / 5);
51 | addLine(2, Line.Direction.VERTICAL, 2f / 5);
52 | addLine(1, Line.Direction.VERTICAL, 3f / 5);
53 | addLine(0, Line.Direction.VERTICAL, 4f / 5);
54 | break;
55 | case 6:
56 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
57 | cutAreaEqualPart(2, 3, Line.Direction.VERTICAL);
58 | cutAreaEqualPart(1, 2, Line.Direction.VERTICAL);
59 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
60 | break;
61 | case 7:
62 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
63 | cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL);
64 | cutAreaEqualPart(1, 2, Line.Direction.HORIZONTAL);
65 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
66 | break;
67 | case 8:
68 | addLine(0, Line.Direction.HORIZONTAL, 4f / 5);
69 | cutAreaEqualPart(1, 5, Line.Direction.VERTICAL);
70 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
71 | addLine(1, Line.Direction.VERTICAL, 1f / 2);
72 | break;
73 | case 9:
74 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
75 | cutAreaEqualPart(2, 2, Line.Direction.VERTICAL);
76 | cutAreaEqualPart(1, 3, Line.Direction.VERTICAL);
77 | addLine(0, Line.Direction.VERTICAL, 3f / 4);
78 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
79 | break;
80 | case 10:
81 | cutAreaEqualPart(0, 2, 1);
82 | addLine(5, Line.Direction.VERTICAL, 1f / 2);
83 | addLine(4, Line.Direction.VERTICAL, 1f / 2);
84 | break;
85 | default:
86 | break;
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/FiveStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class FiveStraightLayout extends NumberStraightLayout {
9 |
10 | public FiveStraightLayout(int theme) {
11 | super(theme);
12 | }
13 |
14 | @Override
15 | public int getThemeCount() {
16 | return 15;
17 | }
18 |
19 | @Override
20 | public void layout() {
21 | switch (theme) {
22 | case 0:
23 | addLine(0, Line.Direction.HORIZONTAL, 2f / 5);
24 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
25 | cutAreaEqualPart(2, 3, Line.Direction.VERTICAL);
26 | break;
27 | case 1:
28 | addLine(0, Line.Direction.HORIZONTAL, 3f / 5);
29 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
30 | addLine(3, Line.Direction.VERTICAL, 1f / 2);
31 | break;
32 | case 2:
33 | addLine(0, Line.Direction.VERTICAL, 2f / 5);
34 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
35 | addLine(1, Line.Direction.HORIZONTAL, 1f / 2);
36 | break;
37 | case 3:
38 | addLine(0, Line.Direction.VERTICAL, 2f / 5);
39 | cutAreaEqualPart(1, 3, Line.Direction.HORIZONTAL);
40 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
41 | break;
42 | case 4:
43 | addLine(0, Line.Direction.HORIZONTAL, 3f / 4);
44 | cutAreaEqualPart(1, 4, Line.Direction.VERTICAL);
45 | break;
46 | case 5:
47 | addLine(0, Line.Direction.HORIZONTAL, 1f / 4);
48 | cutAreaEqualPart(0, 4, Line.Direction.VERTICAL);
49 | break;
50 | case 6:
51 | addLine(0, Line.Direction.VERTICAL, 3f / 4);
52 | cutAreaEqualPart(1, 4, Line.Direction.HORIZONTAL);
53 | break;
54 | case 7:
55 | addLine(0, Line.Direction.VERTICAL, 1f / 4);
56 | cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL);
57 | break;
58 | case 8:
59 | addLine(0, Line.Direction.HORIZONTAL, 1f / 4);
60 | addLine(1, Line.Direction.HORIZONTAL, 2f / 3);
61 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
62 | addLine(3, Line.Direction.VERTICAL, 1f / 2);
63 | break;
64 | case 9:
65 | addLine(0, Line.Direction.VERTICAL, 1f / 4);
66 | addLine(1, Line.Direction.VERTICAL, 2f / 3);
67 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
68 | addLine(2, Line.Direction.HORIZONTAL, 1f / 2);
69 | break;
70 | case 10:
71 | addCross(0, 1f / 3);
72 | addLine(2, Line.Direction.HORIZONTAL, 1f / 2);
73 | break;
74 | case 11:
75 | addCross(0, 2f / 3);
76 | addLine(1, Line.Direction.HORIZONTAL, 1f / 2);
77 | break;
78 | case 12:
79 | addCross(0, 1f / 3, 2f / 3);
80 | addLine(3, Line.Direction.HORIZONTAL, 1f / 2);
81 | break;
82 | case 13:
83 | addCross(0, 2f / 3, 1f / 3);
84 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
85 | break;
86 | case 14:
87 | cutSpiral(0);
88 | break;
89 | default:
90 | cutAreaEqualPart(0, 5, Line.Direction.HORIZONTAL);
91 | break;
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/FourStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class FourStraightLayout extends NumberStraightLayout {
9 | private static final String TAG = "FourStraightLayout";
10 |
11 | public FourStraightLayout(int theme) {
12 | super(theme);
13 | }
14 |
15 | @Override
16 | public int getThemeCount() {
17 | return 6;
18 | }
19 |
20 | @Override
21 | public void layout() {
22 | switch (theme) {
23 | case 0:
24 | addCross(0, 1f / 2);
25 | break;
26 | case 1:
27 | addLine(0, Line.Direction.HORIZONTAL, 1f / 3);
28 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
29 | break;
30 | case 2:
31 | addLine(0, Line.Direction.HORIZONTAL, 2f / 3);
32 | cutAreaEqualPart(1, 3, Line.Direction.VERTICAL);
33 | break;
34 | case 3:
35 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
36 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
37 | break;
38 | case 4:
39 | addLine(0, Line.Direction.VERTICAL, 2f / 3);
40 | cutAreaEqualPart(1, 3, Line.Direction.HORIZONTAL);
41 | break;
42 | case 5:
43 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
44 | addLine(1, Line.Direction.HORIZONTAL, 2f / 3);
45 | addLine(1, Line.Direction.HORIZONTAL, 1f / 3);
46 | break;
47 | default:
48 | cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL);
49 | break;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/NineStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class NineStraightLayout extends NumberStraightLayout {
9 | public NineStraightLayout(int theme) {
10 | super(theme);
11 | }
12 |
13 | @Override
14 | public int getThemeCount() {
15 | return 8;
16 | }
17 |
18 | @Override
19 | public void layout() {
20 | switch (theme) {
21 | case 0:
22 | cutAreaEqualPart(0, 2, 2);
23 | break;
24 | case 1:
25 | addLine(0, Line.Direction.VERTICAL, 3f / 4);
26 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
27 | cutAreaEqualPart(2, 4, Line.Direction.HORIZONTAL);
28 | cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL);
29 | break;
30 | case 2:
31 | addLine(0, Line.Direction.HORIZONTAL, 3f / 4);
32 | addLine(0, Line.Direction.HORIZONTAL, 1f / 3);
33 | cutAreaEqualPart(2, 4, Line.Direction.VERTICAL);
34 | cutAreaEqualPart(0, 4, Line.Direction.VERTICAL);
35 | break;
36 | case 3:
37 | addLine(0, Line.Direction.HORIZONTAL, 3f / 4);
38 | addLine(0, Line.Direction.HORIZONTAL, 1f / 3);
39 | cutAreaEqualPart(2, 3, Line.Direction.VERTICAL);
40 | addLine(1, Line.Direction.VERTICAL, 3f / 4);
41 | addLine(1, Line.Direction.VERTICAL, 1f / 3);
42 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
43 | break;
44 | case 4:
45 | addLine(0, Line.Direction.VERTICAL, 3f / 4);
46 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
47 | cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL);
48 | addLine(1, Line.Direction.HORIZONTAL, 3f / 4);
49 | addLine(1, Line.Direction.HORIZONTAL, 1f / 3);
50 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
51 | break;
52 | case 5:
53 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
54 | addLine(2, Line.Direction.HORIZONTAL, 3f / 4);
55 | addLine(2, Line.Direction.HORIZONTAL, 1f / 3);
56 | cutAreaEqualPart(1, 3, Line.Direction.HORIZONTAL);
57 | addLine(0, Line.Direction.HORIZONTAL, 3f / 4);
58 | addLine(0, Line.Direction.HORIZONTAL, 1f / 3);
59 | break;
60 | case 6:
61 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
62 | addLine(2, Line.Direction.VERTICAL, 3f / 4);
63 | addLine(2, Line.Direction.VERTICAL, 1f / 3);
64 | cutAreaEqualPart(1, 3, Line.Direction.VERTICAL);
65 | addLine(0, Line.Direction.VERTICAL, 3f / 4);
66 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
67 | break;
68 | case 7:
69 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
70 | cutAreaEqualPart(1, 1, 3);
71 | break;
72 | default:
73 | break;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/NumberStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import android.util.Log;
4 |
5 | import com.huantansheng.easyphotos.models.puzzle.straight.StraightPuzzleLayout;
6 |
7 |
8 | /**
9 | * @author wupanjie
10 | */
11 | public abstract class NumberStraightLayout extends StraightPuzzleLayout {
12 | static final String TAG = "NumberStraightLayout";
13 | protected int theme;
14 |
15 | public NumberStraightLayout(int theme) {
16 | if (theme >= getThemeCount()) {
17 | Log.e(TAG, "NumberStraightLayout: the most theme count is "
18 | + getThemeCount()
19 | + " ,you should let theme from 0 to "
20 | + (getThemeCount() - 1)
21 | + " .");
22 | }
23 | this.theme = theme;
24 | }
25 |
26 | public abstract int getThemeCount();
27 |
28 | public int getTheme() {
29 | return theme;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/OneStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class OneStraightLayout extends NumberStraightLayout {
9 |
10 | public OneStraightLayout(int theme) {
11 | super(theme);
12 | }
13 |
14 | @Override
15 | public int getThemeCount() {
16 | return 6;
17 | }
18 |
19 | @Override
20 | public void layout() {
21 | switch (theme) {
22 | case 0:
23 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
24 | break;
25 | case 1:
26 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
27 | break;
28 | case 2:
29 | addCross(0, 1f / 2);
30 | break;
31 | case 3:
32 | cutAreaEqualPart(0, 2, 1);
33 | break;
34 | case 4:
35 | cutAreaEqualPart(0, 1, 2);
36 | break;
37 | case 5:
38 | cutAreaEqualPart(0, 2, 2);
39 | break;
40 | default:
41 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
42 | break;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/SevenStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import com.huantansheng.easyphotos.models.puzzle.Line;
4 |
5 | /**
6 | * @author wupanjie
7 | */
8 | public class SevenStraightLayout extends NumberStraightLayout {
9 | public SevenStraightLayout(int theme) {
10 | super(theme);
11 | }
12 |
13 | @Override
14 | public int getThemeCount() {
15 | return 9;
16 | }
17 |
18 | @Override
19 | public void layout() {
20 | switch (theme) {
21 | case 0:
22 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
23 | cutAreaEqualPart(1, 4, Line.Direction.VERTICAL);
24 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
25 | break;
26 | case 1:
27 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
28 | cutAreaEqualPart(1, 4, Line.Direction.HORIZONTAL);
29 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
30 | break;
31 | case 2:
32 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
33 | cutAreaEqualPart(1, 1, 2);
34 | break;
35 | case 3:
36 | addLine(0, Line.Direction.HORIZONTAL, 2f / 3);
37 | cutAreaEqualPart(1, 3, Line.Direction.VERTICAL);
38 | addCross(0, 1f / 2);
39 | break;
40 | case 4:
41 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
42 | cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL);
43 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
44 | break;
45 | case 5:
46 | addLine(0, Line.Direction.HORIZONTAL, 2f / 3);
47 | addLine(1, Line.Direction.VERTICAL, 3f / 4);
48 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
49 | addLine(1, Line.Direction.VERTICAL, 2f / 5);
50 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
51 | break;
52 | case 6:
53 | addLine(0, Line.Direction.VERTICAL, 2f / 3);
54 | addLine(1, Line.Direction.HORIZONTAL, 3f / 4);
55 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
56 | addLine(1, Line.Direction.HORIZONTAL, 2f / 5);
57 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
58 | break;
59 | case 7:
60 | addLine(0, Line.Direction.VERTICAL, 1f / 4);
61 | addLine(1, Line.Direction.VERTICAL, 2f / 3);
62 | addLine(2, Line.Direction.HORIZONTAL, 1f / 2);
63 | addLine(1, Line.Direction.HORIZONTAL, 3f / 4);
64 | addLine(1, Line.Direction.HORIZONTAL, 1f / 3);
65 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
66 | break;
67 | case 8:
68 | addLine(0, Line.Direction.HORIZONTAL, 1f / 4);
69 | addLine(1, Line.Direction.HORIZONTAL, 2f / 3);
70 | cutAreaEqualPart(2, 3, Line.Direction.VERTICAL);
71 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
72 | break;
73 | default:
74 | break;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/SixStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 |
4 | import com.huantansheng.easyphotos.models.puzzle.Line;
5 |
6 | /**
7 | * @author wupanjie
8 | */
9 | public class SixStraightLayout extends NumberStraightLayout {
10 |
11 | public SixStraightLayout(int theme) {
12 | super(theme);
13 | }
14 |
15 | @Override
16 | public int getThemeCount() {
17 | return 12;
18 | }
19 |
20 | @Override
21 | public void layout() {
22 | switch (theme) {
23 | case 0:
24 | cutAreaEqualPart(0, 2, 1);
25 | break;
26 |
27 | case 1:
28 | cutAreaEqualPart(0, 1, 2);
29 | break;
30 | case 2:
31 | addCross(0, 2f / 3, 1f / 2);
32 | addLine(3, Line.Direction.VERTICAL, 1f / 2);
33 | addLine(2, Line.Direction.VERTICAL, 1f / 2);
34 | break;
35 | case 3:
36 | addCross(0, 1f / 2, 2f / 3);
37 | addLine(3, Line.Direction.HORIZONTAL, 1f / 2);
38 | addLine(1, Line.Direction.HORIZONTAL, 1f / 2);
39 | break;
40 | case 4:
41 | addCross(0, 1f / 2, 1f / 3);
42 | addLine(2, Line.Direction.HORIZONTAL, 1f / 2);
43 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
44 | break;
45 | case 5:
46 | addCross(0, 1f / 3, 1f / 2);
47 | addLine(1, Line.Direction.VERTICAL, 1f / 2);
48 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
49 | break;
50 | case 6:
51 | addLine(0, Line.Direction.HORIZONTAL, 4f / 5);
52 | cutAreaEqualPart(1, 5, Line.Direction.VERTICAL);
53 | break;
54 | case 7:
55 | addLine(0, Line.Direction.HORIZONTAL, 1f / 4);
56 | addLine(1, Line.Direction.HORIZONTAL, 2f / 3);
57 | addLine(1, Line.Direction.VERTICAL, 1f / 4);
58 | addLine(2, Line.Direction.VERTICAL, 2f / 3);
59 | addLine(4, Line.Direction.VERTICAL, 1f / 2);
60 | break;
61 | case 8:
62 | addCross(0, 1f / 3);
63 | addLine(1, Line.Direction.VERTICAL, 1f / 2);
64 | addLine(4, Line.Direction.HORIZONTAL, 1f / 2);
65 | break;
66 | case 9:
67 | addCross(0, 2f / 3, 1f / 3);
68 | addLine(3, Line.Direction.VERTICAL, 1f / 2);
69 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
70 | break;
71 | case 10:
72 | addCross(0, 2f / 3);
73 | addLine(2, Line.Direction.VERTICAL, 1f / 2);
74 | addLine(1, Line.Direction.HORIZONTAL, 1f / 2);
75 | break;
76 | case 11:
77 | addCross(0, 1f / 3, 2f / 3);
78 | addLine(3, Line.Direction.HORIZONTAL, 1f / 2);
79 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
80 | break;
81 | case 12:
82 | addCross(0, 1f / 3);
83 | addLine(2, Line.Direction.HORIZONTAL, 1f / 2);
84 | addLine(1, Line.Direction.VERTICAL, 1f / 2);
85 | break;
86 | default:
87 | addCross(0, 2f / 3, 1f / 2);
88 | addLine(3, Line.Direction.VERTICAL, 1f / 2);
89 | addLine(2, Line.Direction.VERTICAL, 1f / 2);
90 | break;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/StraightLayoutHelper.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 |
4 | import com.huantansheng.easyphotos.models.puzzle.PuzzleLayout;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @author wupanjie
11 | */
12 | public class StraightLayoutHelper {
13 | private StraightLayoutHelper() {
14 |
15 | }
16 |
17 | public static List getAllThemeLayout(int pieceCount) {
18 | List puzzleLayouts = new ArrayList<>();
19 | switch (pieceCount) {
20 | case 1:
21 | for (int i = 0; i < 6; i++) {
22 | puzzleLayouts.add(new OneStraightLayout(i));
23 | }
24 | break;
25 | case 2:
26 | for (int i = 0; i < 6; i++) {
27 | puzzleLayouts.add(new TwoStraightLayout(i));
28 | }
29 | break;
30 | case 3:
31 | for (int i = 0; i < 6; i++) {
32 | puzzleLayouts.add(new ThreeStraightLayout(i));
33 | }
34 | break;
35 | case 4:
36 | for (int i = 0; i < 8; i++) {
37 | puzzleLayouts.add(new FourStraightLayout(i));
38 | }
39 | break;
40 | case 5:
41 | for (int i = 0; i < 17; i++) {
42 | puzzleLayouts.add(new FiveStraightLayout(i));
43 | }
44 | break;
45 | case 6:
46 | for (int i = 0; i < 12; i++) {
47 | puzzleLayouts.add(new SixStraightLayout(i));
48 | }
49 | break;
50 | case 7:
51 | for (int i = 0; i < 9; i++) {
52 | puzzleLayouts.add(new SevenStraightLayout(i));
53 | }
54 | break;
55 | case 8:
56 | for (int i = 0; i < 11; i++) {
57 | puzzleLayouts.add(new EightStraightLayout(i));
58 | }
59 | break;
60 | case 9:
61 | for (int i = 0; i < 8; i++) {
62 | puzzleLayouts.add(new NineStraightLayout(i));
63 | }
64 | break;
65 | }
66 |
67 | return puzzleLayouts;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/ThreeStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 |
4 | import com.huantansheng.easyphotos.models.puzzle.Line;
5 |
6 | /**
7 | * @author wupanjie
8 | */
9 | public class ThreeStraightLayout extends NumberStraightLayout {
10 |
11 | public ThreeStraightLayout(int theme) {
12 | super(theme);
13 | }
14 |
15 | @Override
16 | public int getThemeCount() {
17 | return 6;
18 | }
19 |
20 | @Override
21 | public void layout() {
22 | switch (theme) {
23 | case 0:
24 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
25 | break;
26 | case 1:
27 | cutAreaEqualPart(0, 3, Line.Direction.VERTICAL);
28 | break;
29 | case 2:
30 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
31 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
32 | break;
33 | case 3:
34 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
35 | addLine(1, Line.Direction.VERTICAL, 1f / 2);
36 | break;
37 | case 4:
38 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
39 | addLine(0, Line.Direction.HORIZONTAL, 1f / 2);
40 | break;
41 | case 5:
42 | addLine(0, Line.Direction.VERTICAL, 1f / 2);
43 | addLine(1, Line.Direction.HORIZONTAL, 1f / 2);
44 | break;
45 | default:
46 | cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL);
47 | break;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/puzzle/template/straight/TwoStraightLayout.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.puzzle.template.straight;
2 |
3 | import android.util.Log;
4 |
5 | import com.huantansheng.easyphotos.models.puzzle.Line;
6 |
7 |
8 | /**
9 | * @author wupanjie
10 | */
11 | public class TwoStraightLayout extends NumberStraightLayout {
12 | private float mRadio = 1f / 2;
13 |
14 | public TwoStraightLayout(int theme) {
15 | super(theme);
16 | }
17 |
18 | public TwoStraightLayout(float radio, int theme) {
19 | super(theme);
20 | if (mRadio > 1) {
21 | Log.e(TAG, "CrossLayout: the radio can not greater than 1f");
22 | mRadio = 1f;
23 | }
24 | mRadio = radio;
25 | }
26 |
27 | @Override
28 | public int getThemeCount() {
29 | return 6;
30 | }
31 |
32 | @Override
33 | public void layout() {
34 | switch (theme) {
35 | case 0:
36 | addLine(0, Line.Direction.HORIZONTAL, mRadio);
37 | break;
38 | case 1:
39 | addLine(0, Line.Direction.VERTICAL, mRadio);
40 | break;
41 | case 2:
42 | addLine(0, Line.Direction.HORIZONTAL, 1f / 3);
43 | break;
44 | case 3:
45 | addLine(0, Line.Direction.HORIZONTAL, 2f / 3);
46 | break;
47 | case 4:
48 | addLine(0, Line.Direction.VERTICAL, 1f / 3);
49 | break;
50 | case 5:
51 | addLine(0, Line.Direction.VERTICAL, 2f / 3);
52 | break;
53 | default:
54 | addLine(0, Line.Direction.HORIZONTAL, mRadio);
55 | break;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/sticker/cache/StickerCache.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.sticker.cache;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Matrix;
7 | import androidx.annotation.IdRes;
8 |
9 | import com.huantansheng.easyphotos.EasyPhotos;
10 |
11 | import java.util.LinkedHashMap;
12 |
13 | /**
14 | * 贴纸的图片缓存器
15 | * Created by huan on 2017/12/8.
16 | */
17 |
18 | public class StickerCache {
19 | private static StickerCache instance = null;
20 |
21 | public static StickerCache get() {
22 | if (null == instance) {
23 | synchronized (StickerCache.class) {
24 | if (null == instance) {
25 | instance = new StickerCache();
26 | }
27 | }
28 | }
29 | return instance;
30 | }
31 |
32 | private LinkedHashMap srcBitmapCache = null;
33 | private LinkedHashMap mirrorBitmapCache = null;
34 | private LinkedHashMap bitmapUsedCount = null;
35 |
36 | private StickerCache() {
37 | srcBitmapCache = new LinkedHashMap<>();
38 | mirrorBitmapCache = new LinkedHashMap<>();
39 | bitmapUsedCount = new LinkedHashMap<>();
40 | }
41 |
42 | public Bitmap getSrcBitmap(String path) {
43 | Bitmap bitmap = srcBitmapCache.get(path);
44 | if (null == bitmap) {
45 | bitmap = BitmapFactory.decodeFile(path);
46 | srcBitmapCache.put(path, bitmap);
47 | bitmapUsedCount.put(path, 0);
48 | convertMirror(path, bitmap);
49 | }
50 |
51 | int count = bitmapUsedCount.get(path);
52 | bitmapUsedCount.put(path, ++count);
53 | return bitmap;
54 | }
55 |
56 | public Bitmap getSrcBitmap(Resources resources, @IdRes int resId) {
57 | String path = String.valueOf(resId);
58 | Bitmap bitmap = srcBitmapCache.get(path);
59 | if (null == bitmap) {
60 | bitmap = BitmapFactory.decodeResource(resources, resId);
61 | srcBitmapCache.put(path, bitmap);
62 | bitmapUsedCount.put(path, 0);
63 | convertMirror(path, bitmap);
64 | }
65 |
66 | int count = bitmapUsedCount.get(path);
67 | bitmapUsedCount.put(path, ++count);
68 | return bitmap;
69 | }
70 |
71 | public Bitmap getMirrorBitmap(String key) {
72 | return mirrorBitmapCache.get(key);
73 | }
74 |
75 |
76 | public void clear() {
77 | for (String key : srcBitmapCache.keySet()) {
78 | recycle(key);
79 | }
80 | }
81 |
82 | public void recycle(String key) {
83 | if (!srcBitmapCache.containsKey(key)) {
84 | return;
85 | }
86 |
87 | int count = bitmapUsedCount.get(key);
88 | if (count > 1) {
89 | count--;
90 | bitmapUsedCount.put(key, count);
91 | return;
92 | }
93 |
94 | EasyPhotos.recycle(srcBitmapCache.get(key), mirrorBitmapCache.get(key));
95 | removeKey(key);
96 | }
97 |
98 | private void convertMirror(String key, Bitmap a) {
99 | int w = a.getWidth();
100 | int h = a.getHeight();
101 |
102 | Matrix m = new Matrix();
103 | m.postScale(-1, 1); //镜像水平翻转
104 | Bitmap mirrorBitmap = Bitmap.createBitmap(a, 0, 0, w, h, m, true);
105 | mirrorBitmapCache.put(key, mirrorBitmap);
106 | }
107 |
108 |
109 | private void removeKey(String key) {
110 | srcBitmapCache.remove(key);
111 | mirrorBitmapCache.remove(key);
112 | bitmapUsedCount.remove(key);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/sticker/entity/TextStickerData.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.sticker.entity;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * 文字贴纸数据类
8 | * Created by huan on 2017/12/14.
9 | */
10 |
11 | public class TextStickerData implements Parcelable {
12 |
13 | public String stickerName;//文字贴纸的名字
14 | public String stickerValue;//文字贴纸的文字内容
15 |
16 | public TextStickerData(String stickerName, String stickerValue) {
17 | this.stickerName = stickerName;
18 | this.stickerValue = stickerValue;
19 | }
20 |
21 | @Override
22 | public int describeContents() {
23 | return 0;
24 | }
25 |
26 | @Override
27 | public void writeToParcel(Parcel dest, int flags) {
28 | dest.writeString(this.stickerName);
29 | dest.writeString(this.stickerValue);
30 | }
31 |
32 | protected TextStickerData(Parcel in) {
33 | this.stickerName = in.readString();
34 | this.stickerValue = in.readString();
35 | }
36 |
37 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
38 | @Override
39 | public TextStickerData createFromParcel(Parcel source) {
40 | return new TextStickerData(source);
41 | }
42 |
43 | @Override
44 | public TextStickerData[] newArray(int size) {
45 | return new TextStickerData[size];
46 | }
47 | };
48 | }
49 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/models/sticker/listener/OnStickerClickListener.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.models.sticker.listener;
2 |
3 | /**
4 | * 贴纸的点击监听
5 | * Created by huan on 2017/12/12.
6 | */
7 |
8 | public interface OnStickerClickListener {
9 | void onDelete();
10 |
11 | void onEditor();
12 |
13 | void onTop();
14 |
15 | void onUsing();
16 | }
17 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/PreviewFragment.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.recyclerview.widget.LinearLayoutManager;
7 | import androidx.recyclerview.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import com.huantansheng.easyphotos.R;
13 | import com.huantansheng.easyphotos.ui.adapter.PreviewPhotosFragmentAdapter;
14 |
15 |
16 | public class PreviewFragment extends Fragment implements PreviewPhotosFragmentAdapter.OnClickListener {
17 |
18 | private OnPreviewFragmentClickListener mListener;
19 |
20 | private RecyclerView rvPhotos;
21 | private PreviewPhotosFragmentAdapter adapter;
22 |
23 |
24 | @Override
25 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
26 | Bundle savedInstanceState) {
27 | View rootView = inflater.inflate(R.layout.fragment_preview_easy_photos, container, false);
28 | rvPhotos = (RecyclerView) rootView.findViewById(R.id.rv_preview_selected_photos);
29 | adapter = new PreviewPhotosFragmentAdapter(getActivity(), this);
30 | rvPhotos.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
31 | rvPhotos.setAdapter(adapter);
32 | return rootView;
33 | }
34 |
35 | @Override
36 | public void onAttach(Context context) {
37 | super.onAttach(context);
38 | if (context instanceof OnPreviewFragmentClickListener) {
39 | mListener = (OnPreviewFragmentClickListener) context;
40 | } else {
41 | throw new RuntimeException(context.toString()
42 | + " must implement OnPreviewFragmentClickListener");
43 | }
44 | }
45 |
46 | @Override
47 | public void onDetach() {
48 | super.onDetach();
49 | mListener = null;
50 | }
51 |
52 | @Override
53 | public void onPhotoClick(int position) {
54 | mListener.onPreviewPhotoClick(position);
55 | }
56 |
57 |
58 | public interface OnPreviewFragmentClickListener {
59 | void onPreviewPhotoClick(int position);
60 | }
61 |
62 | public void notifyDataSetChanged() {
63 | adapter.notifyDataSetChanged();
64 | }
65 |
66 | public void setSelectedPosition(int position) {
67 | adapter.setChecked(position);
68 | if (position != -1) {
69 | rvPhotos.smoothScrollToPosition(position);
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/adapter/PuzzleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.adapter;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.huantansheng.easyphotos.R;
9 | import com.huantansheng.easyphotos.models.puzzle.PuzzleLayout;
10 | import com.huantansheng.easyphotos.models.puzzle.SquarePuzzleView;
11 | import com.huantansheng.easyphotos.models.puzzle.template.slant.NumberSlantLayout;
12 | import com.huantansheng.easyphotos.models.puzzle.template.straight.NumberStraightLayout;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * @author wupanjie
19 | */
20 | public class PuzzleAdapter extends RecyclerView.Adapter {
21 |
22 | private List layoutData = new ArrayList<>();
23 | private OnItemClickListener onItemClickListener;
24 | private int selectedNumber = 0;
25 |
26 | @Override
27 | public PuzzleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
28 | View itemView =
29 | LayoutInflater.from(parent.getContext()).inflate(R.layout.item_puzzle_easy_photos, parent, false);
30 | return new PuzzleViewHolder(itemView);
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(PuzzleViewHolder holder, int position) {
35 | final PuzzleLayout puzzleLayout = layoutData.get(position);
36 | final int p = position;
37 | if (selectedNumber == position) {
38 | holder.mFrame.setVisibility(View.VISIBLE);
39 | } else {
40 | holder.mFrame.setVisibility(View.GONE);
41 | }
42 | holder.puzzleView.setNeedDrawLine(true);
43 | holder.puzzleView.setNeedDrawOuterLine(true);
44 | holder.puzzleView.setTouchEnable(false);
45 |
46 | holder.puzzleView.setPuzzleLayout(puzzleLayout);
47 |
48 | holder.itemView.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | if (selectedNumber == p) {
52 | return;
53 | }
54 | if (onItemClickListener != null) {
55 | int themeType = 0;
56 | int themeId = 0;
57 | if (puzzleLayout instanceof NumberSlantLayout) {
58 | themeType = 0;
59 | themeId = ((NumberSlantLayout) puzzleLayout).getTheme();
60 | } else if (puzzleLayout instanceof NumberStraightLayout) {
61 | themeType = 1;
62 | themeId = ((NumberStraightLayout) puzzleLayout).getTheme();
63 | }
64 | selectedNumber = p;
65 | onItemClickListener.onItemClick(themeType, themeId);
66 | notifyDataSetChanged();
67 | }
68 | }
69 | });
70 |
71 | }
72 |
73 | @Override
74 | public int getItemCount() {
75 | return layoutData == null ? 0 : layoutData.size();
76 | }
77 |
78 | public void refreshData(List layoutData) {
79 | this.layoutData = layoutData;
80 |
81 | notifyDataSetChanged();
82 | }
83 |
84 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
85 | this.onItemClickListener = onItemClickListener;
86 | }
87 |
88 | public static class PuzzleViewHolder extends RecyclerView.ViewHolder {
89 |
90 | SquarePuzzleView puzzleView;
91 | View mFrame;
92 |
93 | public PuzzleViewHolder(View itemView) {
94 | super(itemView);
95 | puzzleView = (SquarePuzzleView) itemView.findViewById(R.id.puzzle);
96 | mFrame = itemView.findViewById(R.id.m_selector);
97 | }
98 | }
99 |
100 | public interface OnItemClickListener {
101 | void onItemClick(int themeType, int themeId);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/adapter/PuzzleSelectorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.adapter;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | import android.net.Uri;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.huantansheng.easyphotos.R;
14 | import com.huantansheng.easyphotos.constant.Type;
15 | import com.huantansheng.easyphotos.models.album.entity.Photo;
16 | import com.huantansheng.easyphotos.setting.Setting;
17 | import com.huantansheng.easyphotos.utils.media.DurationUtils;
18 |
19 | import java.util.ArrayList;
20 |
21 | /**
22 | * 拼图相册适配器
23 | * Created by huan on 2017/10/23.
24 | */
25 |
26 | public class PuzzleSelectorAdapter extends RecyclerView.Adapter {
27 |
28 |
29 | private ArrayList dataList;
30 | private LayoutInflater mInflater;
31 | private OnClickListener listener;
32 |
33 |
34 | public PuzzleSelectorAdapter(Context cxt, ArrayList dataList, OnClickListener listener) {
35 | this.dataList = dataList;
36 | this.listener = listener;
37 | this.mInflater = LayoutInflater.from(cxt);
38 | }
39 |
40 | @Override
41 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
42 |
43 | return new PhotoViewHolder(mInflater.inflate(R.layout.item_puzzle_selector_easy_photos, parent, false));
44 |
45 | }
46 |
47 | @Override
48 | public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
49 |
50 | final int p = position;
51 | Photo photo = dataList.get(position);
52 | String path = photo.path;
53 | String type = photo.type;
54 | Uri uri = photo.uri;
55 | long duration = photo.duration;
56 | final boolean isGif = path.endsWith(Type.GIF) || type.endsWith(Type.GIF);
57 | if (Setting.showGif && isGif) {
58 | Setting.imageEngine.loadGifAsBitmap(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
59 | ((PhotoViewHolder) holder).tvType.setText(R.string.gif_easy_photos);
60 | ((PhotoViewHolder) holder).tvType.setVisibility(View.VISIBLE);
61 | } else if (Setting.showVideo && type.contains(Type.VIDEO)) {
62 | Setting.imageEngine.loadPhoto(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
63 | ((PhotoViewHolder) holder).tvType.setText(DurationUtils.format(duration));
64 | ((PhotoViewHolder) holder).tvType.setVisibility(View.VISIBLE);
65 | } else {
66 | Setting.imageEngine.loadPhoto(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
67 | ((PhotoViewHolder) holder).tvType.setVisibility(View.GONE);
68 | }
69 |
70 | ((PhotoViewHolder) holder).ivPhoto.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | listener.onPhotoClick(p);
74 | }
75 | });
76 | }
77 |
78 |
79 | @Override
80 | public int getItemCount() {
81 | return null == dataList ? 0 : dataList.size();
82 | }
83 |
84 |
85 | public interface OnClickListener {
86 | void onPhotoClick(int position);
87 | }
88 |
89 | public class PhotoViewHolder extends RecyclerView.ViewHolder {
90 | ImageView ivPhoto;
91 | TextView tvType;
92 |
93 | public PhotoViewHolder(View itemView) {
94 | super(itemView);
95 | this.ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
96 | this.tvType = (TextView) itemView.findViewById(R.id.tv_type);
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/adapter/PuzzleSelectorPreviewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.adapter;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | import android.net.Uri;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.huantansheng.easyphotos.R;
14 | import com.huantansheng.easyphotos.constant.Type;
15 | import com.huantansheng.easyphotos.models.album.entity.Photo;
16 | import com.huantansheng.easyphotos.setting.Setting;
17 | import com.huantansheng.easyphotos.utils.media.DurationUtils;
18 |
19 | import java.util.ArrayList;
20 |
21 | /**
22 | * 拼图相册适配器
23 | * Created by huan on 2017/10/23.
24 | */
25 |
26 | public class PuzzleSelectorPreviewAdapter extends RecyclerView.Adapter {
27 |
28 |
29 | private ArrayList dataList;
30 | private LayoutInflater mInflater;
31 | private OnClickListener listener;
32 |
33 |
34 | public PuzzleSelectorPreviewAdapter(Context cxt, ArrayList dataList, OnClickListener listener) {
35 | this.dataList = dataList;
36 | this.listener = listener;
37 | this.mInflater = LayoutInflater.from(cxt);
38 | }
39 |
40 | @Override
41 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
42 |
43 | return new PhotoViewHolder(mInflater.inflate(R.layout.item_puzzle_selector_preview_easy_photos, parent, false));
44 |
45 | }
46 |
47 | @Override
48 | public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
49 |
50 | final int p = position;
51 | Photo photo = dataList.get(position);
52 | String path = photo.path;
53 | String type = photo.type;
54 | Uri uri = photo.uri;
55 | long duration = photo.duration;
56 | final boolean isGif = path.endsWith(Type.GIF) || type.endsWith(Type.GIF);
57 | if (Setting.showGif && isGif) {
58 | Setting.imageEngine.loadGifAsBitmap(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
59 | ((PhotoViewHolder) holder).tvType.setText(R.string.gif_easy_photos);
60 | ((PhotoViewHolder) holder).tvType.setVisibility(View.VISIBLE);
61 | } else if (Setting.showVideo && type.contains(Type.VIDEO)) {
62 | Setting.imageEngine.loadPhoto(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
63 | ((PhotoViewHolder) holder).tvType.setText(DurationUtils.format(duration));
64 | ((PhotoViewHolder) holder).tvType.setVisibility(View.VISIBLE);
65 | } else {
66 | Setting.imageEngine.loadPhoto(((PhotoViewHolder) holder).ivPhoto.getContext(), uri, ((PhotoViewHolder) holder).ivPhoto);
67 | ((PhotoViewHolder) holder).tvType.setVisibility(View.GONE);
68 | }
69 |
70 | ((PhotoViewHolder) holder).ivDelete.setOnClickListener(new View.OnClickListener() {
71 | @Override
72 | public void onClick(View v) {
73 | listener.onDeleteClick(p);
74 | }
75 | });
76 | }
77 |
78 |
79 | @Override
80 | public int getItemCount() {
81 | return null == dataList ? 0 : dataList.size();
82 | }
83 |
84 |
85 | public interface OnClickListener {
86 | void onDeleteClick(int position);
87 | }
88 |
89 | public class PhotoViewHolder extends RecyclerView.ViewHolder {
90 | ImageView ivPhoto;
91 | ImageView ivDelete;
92 | TextView tvType;
93 |
94 | public PhotoViewHolder(View itemView) {
95 | super(itemView);
96 | this.ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
97 | this.ivDelete = (ImageView) itemView.findViewById(R.id.iv_delete);
98 | this.tvType = (TextView) itemView.findViewById(R.id.tv_type);
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/adapter/TextStickerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.adapter;
2 |
3 | import android.content.Context;
4 | import androidx.recyclerview.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.huantansheng.easyphotos.R;
11 | import com.huantansheng.easyphotos.models.sticker.StickerModel;
12 | import com.huantansheng.easyphotos.models.sticker.entity.TextStickerData;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * @author huan
19 | */
20 | public class TextStickerAdapter extends RecyclerView.Adapter {
21 |
22 | private List datas;
23 | private OnItemClickListener onItemClickListener;
24 |
25 | public TextStickerAdapter(Context cxt, OnItemClickListener listener) {
26 | super();
27 | this.onItemClickListener = listener;
28 | this.datas = new ArrayList<>();
29 | TextStickerData data = new TextStickerData(cxt.getString(R.string.text_sticker_hint_name_easy_photos), cxt.getString(R.string.text_sticker_hint_easy_photos));
30 | this.datas.add(0, data);
31 | TextStickerData d = new TextStickerData(cxt.getString(R.string.text_sticker_date_easy_photos), "-1");
32 | datas.add(d);
33 | datas.addAll(StickerModel.textDataList);
34 | }
35 |
36 | @Override
37 | public TextViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
38 | View itemView =
39 | LayoutInflater.from(parent.getContext()).inflate(R.layout.item_text_sticker_easy_photos, parent, false);
40 | return new TextViewHolder(itemView);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(TextViewHolder holder, int position) {
45 | final TextStickerData data = datas.get(position);
46 |
47 | holder.tvSticker.setText(data.stickerName);
48 |
49 | holder.itemView.setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | if (onItemClickListener != null) {
53 | onItemClickListener.onItemClick(data.stickerValue);
54 | notifyDataSetChanged();
55 | }
56 | }
57 | });
58 |
59 | }
60 |
61 | @Override
62 | public int getItemCount() {
63 | return datas == null ? 0 : datas.size();
64 | }
65 |
66 |
67 | public static class TextViewHolder extends RecyclerView.ViewHolder {
68 |
69 | TextView tvSticker;
70 |
71 | public TextViewHolder(View itemView) {
72 | super(itemView);
73 | tvSticker = (TextView) itemView.findViewById(R.id.puzzle);
74 | }
75 | }
76 |
77 | public interface OnItemClickListener {
78 | void onItemClick(String stickerValue);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/dialog/LoadingDialog.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.dialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | import androidx.annotation.NonNull;
12 |
13 | import com.huantansheng.easyphotos.R;
14 |
15 | public class LoadingDialog extends Dialog {
16 |
17 | private LoadingDialog(@NonNull Context context) {
18 | super(context);
19 | Window window = getWindow();
20 | if (null != window) {
21 | window.requestFeature(Window.FEATURE_NO_TITLE);
22 | }
23 | }
24 |
25 | public static LoadingDialog get(Context context) {
26 | LoadingDialog loading = new LoadingDialog(context);
27 | View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading_easy_photos, null);
28 | loading.setContentView(view);
29 | loading.setCancelable(false);
30 | loading.setCanceledOnTouchOutside(false);
31 | return loading;
32 | }
33 |
34 | @Override
35 | public void show() {
36 | Window window = getWindow();
37 | if (null != window) {
38 | WindowManager.LayoutParams attributes = window.getAttributes();
39 | window.setBackgroundDrawableResource(R.color.transparent_easy_photos);
40 | window.setGravity(Gravity.CENTER);
41 | attributes.width = WindowManager.LayoutParams.MATCH_PARENT;
42 | attributes.height = WindowManager.LayoutParams.WRAP_CONTENT;
43 | window.setAttributes(attributes);
44 | }
45 | super.show();
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/widget/PressedImageView.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.widget;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import android.util.AttributeSet;
6 |
7 | /**
8 | * 自带点击效果的imageview
9 | * Created by huan on 2017/8/15.
10 | */
11 |
12 | public class PressedImageView extends androidx.appcompat.widget.AppCompatImageView {
13 | private float scaleSize;//按压颜色
14 |
15 | public PressedImageView(Context context) {
16 | super(context);
17 | this.scaleSize = 0.97f;
18 | }
19 |
20 | public PressedImageView(Context context, @Nullable AttributeSet attrs) {
21 | super(context, attrs);
22 | this.scaleSize = 0.97f;
23 |
24 | }
25 |
26 | public PressedImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
27 | super(context, attrs, defStyleAttr);
28 | this.scaleSize = 0.97f;
29 |
30 | }
31 |
32 | @Override
33 | public void setPressed(boolean pressed) {
34 | super.setPressed(pressed);
35 | if (isPressed()) {
36 | setScaleX(this.scaleSize);
37 | setScaleY(this.scaleSize);
38 | } else {
39 | setScaleX(1.0f);
40 | setScaleY(1.0f);
41 | }
42 | }
43 |
44 | public void setScaleSize(float scaleSize) {
45 | this.scaleSize = scaleSize;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/widget/PressedTextView.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.widget;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.ObjectAnimator;
5 | import android.content.Context;
6 | import androidx.annotation.Nullable;
7 | import android.util.AttributeSet;
8 |
9 | /**
10 | * 带点击状态的textview
11 | * Created by huan on 2017/9/15.
12 | */
13 |
14 | public class PressedTextView extends androidx.appcompat.widget.AppCompatTextView {
15 | private float pressedScale;
16 | private AnimatorSet set;
17 | private int pressedFlag;
18 |
19 | public PressedTextView(Context context) {
20 | super(context);
21 | this.pressedScale = 1.1f;
22 | this.pressedFlag = 1;
23 | }
24 |
25 | public PressedTextView(Context context, @Nullable AttributeSet attrs) {
26 | super(context, attrs);
27 | this.pressedScale = 1.1f;
28 | this.pressedFlag = 1;
29 | }
30 |
31 | public PressedTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | this.pressedScale = 1.1f;
34 | this.pressedFlag = 1;
35 | }
36 |
37 | @Override
38 | public void setPressed(boolean pressed) {
39 | super.setPressed(pressed);
40 | if (isPressed()) {
41 | pressedFlag = 1;
42 | if (null == set) {
43 | set = new AnimatorSet();
44 | set.setDuration(5);
45 | }
46 | if (set.isRunning()) set.cancel();
47 | ObjectAnimator pScaleX = ObjectAnimator.ofFloat(this, "scaleX", 1.0f, pressedScale);
48 | ObjectAnimator pScaleY = ObjectAnimator.ofFloat(this, "scaleY", 1.0f, pressedScale);
49 | set.play(pScaleX).with(pScaleY);
50 | set.start();
51 | } else {
52 | if (pressedFlag != 1) {
53 | return;
54 | }
55 | pressedFlag = 2;
56 | if (null == set) {
57 | set = new AnimatorSet();
58 | set.setDuration(5);
59 | }
60 | if (set.isRunning()) set.cancel();
61 | ObjectAnimator nScaleX = ObjectAnimator.ofFloat(this, "scaleX", pressedScale, 1.0f);
62 | ObjectAnimator nScaleY = ObjectAnimator.ofFloat(this, "scaleY", pressedScale, 1.0f);
63 | set.play(nScaleX).with(nScaleY);
64 | set.start();
65 | }
66 | }
67 |
68 | public void setPressedScale(float pressedScale) {
69 | this.pressedScale = pressedScale;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/ui/widget/PreviewRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.ui.widget;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import androidx.recyclerview.widget.RecyclerView;
7 | import android.util.AttributeSet;
8 | import android.view.MotionEvent;
9 |
10 | /**
11 | * 图片预览 RecyclerView
12 | * Create By lishilin On 2019/3/25
13 | */
14 | public class PreviewRecyclerView extends RecyclerView {
15 |
16 | private boolean isLock;// 是否锁住 RecyclerView ,避免和 PhotoView 双指放大缩小操作冲突
17 |
18 | public PreviewRecyclerView(@NonNull Context context) {
19 | super(context);
20 | }
21 |
22 | public PreviewRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | public PreviewRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
27 | super(context, attrs, defStyle);
28 | }
29 |
30 | @Override
31 | public boolean onInterceptTouchEvent(MotionEvent event) {
32 | switch (event.getActionMasked()) {
33 | case MotionEvent.ACTION_POINTER_DOWN:// 非第一个触点按下
34 | isLock = true;
35 | break;
36 | case MotionEvent.ACTION_UP:// 最后一个触点抬起
37 | isLock = false;
38 | break;
39 | }
40 | if (isLock) {
41 | return false;// 不拦截,交给子View处理
42 | }
43 | return super.onInterceptTouchEvent(event);
44 | }
45 |
46 | @Override
47 | public boolean dispatchTouchEvent(MotionEvent event) {
48 | switch (event.getActionMasked()) {
49 | case MotionEvent.ACTION_POINTER_DOWN:// 非第一个触点按下
50 | isLock = true;
51 | break;
52 | case MotionEvent.ACTION_UP:// 最后一个触点抬起
53 | isLock = false;
54 | break;
55 | }
56 | return super.dispatchTouchEvent(event);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/Color/ColorUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.Color;
2 |
3 | /**
4 | * Created by huan on 2018/1/9.
5 | */
6 |
7 | public class ColorUtils {
8 |
9 | /**
10 | * 判断颜色是否偏黑色
11 | *
12 | * @param color 颜色
13 | * @return
14 | */
15 | public static boolean isBlackColor(int color) {
16 | int grey = toGrey(color);
17 | return grey < 50;
18 | }
19 |
20 | /**
21 | * 颜色转换成灰度值
22 | *
23 | * @param rgb 颜色
24 | * @return 灰度值
25 | */
26 | public static int toGrey(int rgb) {
27 | int blue = rgb & 0x000000FF;
28 | int green = (rgb & 0x0000FF00) >> 8;
29 | int red = (rgb & 0x00FF0000) >> 16;
30 | return (red * 38 + green * 75 + blue * 15) >> 7;
31 | }
32 |
33 | public static boolean isWhiteColor(int color) {
34 | int grey = toGrey(color);
35 | return grey > 200;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/String/StringUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.String;
2 |
3 | /**
4 | * 字符串工具类
5 | * Created by huan on 2017/10/20.
6 | */
7 | public class StringUtils {
8 | public static String getLastPathSegment(String content) {
9 | if (content == null || content.length() == 0) {
10 | return "";
11 | }
12 | String[] segments = content.split("/");
13 | if (segments.length > 0) {
14 | return segments[segments.length - 1];
15 | }
16 | return "";
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/bitmap/SaveBitmapCallBack.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.bitmap;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | /**
7 | * 保存图片到本地的回调
8 | * Created by huan on 2017/12/6.
9 | */
10 |
11 | public interface SaveBitmapCallBack {
12 | void onSuccess(File file);
13 |
14 | void onIOFailed(IOException exception);
15 |
16 | void onCreateDirFailed();
17 | }
18 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/media/DurationUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.media;
2 |
3 | import android.media.MediaMetadataRetriever;
4 | import android.text.format.DateUtils;
5 |
6 | /**
7 | * DurationUtils
8 | * Create By lishilin On 2019/3/25
9 | */
10 | public class DurationUtils {
11 |
12 | /**
13 | * 获取时长
14 | *
15 | * @param path path
16 | * @return duration
17 | */
18 | public static long getDuration(String path) {
19 | MediaMetadataRetriever mmr = null;
20 | try {
21 | mmr = new MediaMetadataRetriever();
22 | mmr.setDataSource(path);
23 | return Long.parseLong(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
24 | } catch (Exception e) {
25 | // e.printStackTrace();
26 | } finally {
27 | if (mmr != null) {
28 | mmr.release();
29 | }
30 | }
31 | return 0;
32 | }
33 |
34 | /**
35 | * 格式化时长(不足一秒则显示为一秒)
36 | *
37 | * @param duration duration
38 | * @return "MM:SS" or "H:MM:SS"
39 | */
40 | public static String format(long duration) {
41 | long seconds = duration / 1000;
42 | if (seconds == 0) {
43 | seconds++;
44 | }
45 | return DateUtils.formatElapsedTime(seconds);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/media/MediaScannerConnectionUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.media;
2 |
3 | import android.content.Context;
4 | import android.media.MediaScannerConnection;
5 |
6 | import java.io.File;
7 | import java.util.List;
8 |
9 | /**
10 | * 更新媒体库
11 | * Created by huan on 2017/8/1.
12 | */
13 |
14 | public class MediaScannerConnectionUtils {
15 |
16 | public static void refresh(Context cxt, String... filePaths) {
17 | MediaScannerConnection.scanFile(cxt.getApplicationContext(),
18 | filePaths, null,
19 | null);
20 | }
21 |
22 |
23 | public static void refresh(Context cxt, File... files) {
24 | for (File file : files) {
25 | String filePath = file.getAbsolutePath();
26 | refresh(cxt, filePath);
27 | }
28 | }
29 |
30 | public static void refresh(Context cxt, List filePathList) {
31 | for (String filePath : filePathList) {
32 | refresh(cxt, filePath);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/permission/PermissionUtil.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.permission;
2 |
3 | import android.app.Activity;
4 | import android.content.pm.PackageManager;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.core.app.ActivityCompat;
8 | import androidx.core.content.PermissionChecker;
9 |
10 | import com.huantansheng.easyphotos.constant.Code;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * 运行时权限工具类
17 | * Created by huan on 2017/7/27.
18 | */
19 |
20 | public class PermissionUtil {
21 |
22 |
23 | public interface PermissionCallBack {
24 | void onSuccess();
25 |
26 | void onShouldShow();
27 |
28 | void onFailed();
29 | }
30 |
31 | public static boolean checkAndRequestPermissionsInActivity(Activity cxt,
32 | String... checkPermissions) {
33 | boolean isHas = true;
34 | List permissions = new ArrayList<>();
35 | int size = checkPermissions.length;
36 | for (int i = 0; i < size; i++) {
37 | String checkPermission = checkPermissions[i];
38 | if (PermissionChecker.checkSelfPermission(cxt, checkPermission) != PermissionChecker.PERMISSION_GRANTED) {
39 | isHas = false;
40 | permissions.add(checkPermission);
41 | }
42 | }
43 | if (!isHas) {
44 | String[] p = permissions.toArray(new String[permissions.size()]);
45 | requestPermissionsInActivity(cxt, Code.REQUEST_PERMISSION, p);
46 | }
47 | return isHas;
48 | }
49 |
50 | private static void requestPermissionsInActivity(Activity cxt, int requestCode,
51 | String... permissions) {
52 | ActivityCompat.requestPermissions(cxt, permissions, requestCode);
53 | }
54 |
55 | public static void onPermissionResult(Activity cxt, @NonNull String[] permissions,
56 | @NonNull int[] grantResults,
57 | PermissionCallBack listener) {
58 | int length = grantResults.length;
59 | List positions = new ArrayList<>();
60 | if (length > 0) {
61 | for (int i = 0; i < length; i++) {
62 | if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
63 | positions.add(i);
64 | }
65 | }
66 | }
67 | if (positions.size() == 0) {
68 | listener.onSuccess();
69 | return;
70 | }
71 | progressNoPermission(cxt, listener, permissions, positions, 0);
72 |
73 | }
74 |
75 | private static void progressNoPermission(Activity cxt, PermissionCallBack listener,
76 | String[] permissions, List positions, int i) {
77 | int index = positions.get(i);
78 | if (ActivityCompat.shouldShowRequestPermissionRationale(cxt, permissions[index])) {
79 | listener.onShouldShow();
80 | return;
81 | }
82 | if (i < positions.size() - 1) {
83 | i++;
84 | progressNoPermission(cxt, listener, permissions, positions, i);
85 | return;
86 | }
87 | listener.onFailed();
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/result/EasyResult.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.result;
2 |
3 | import androidx.fragment.app.Fragment;
4 | import androidx.fragment.app.FragmentActivity;
5 | import androidx.fragment.app.FragmentManager;
6 |
7 | /**
8 | * EasyResult
9 | *
10 | * @author joker
11 | * @date 2019/4/9.
12 | */
13 | public class EasyResult {
14 | private static final String TAG = "com.huantansheng.easyphotos";
15 |
16 | private EasyResult() {
17 |
18 | }
19 |
20 | public static HolderFragment get(FragmentActivity activity) {
21 | return new EasyResult().getHolderFragment(activity.getSupportFragmentManager());
22 | }
23 |
24 | public static HolderFragment get(Fragment fragment) {
25 | return new EasyResult().getHolderFragment(fragment.getChildFragmentManager());
26 | }
27 |
28 | private HolderFragment getHolderFragment(FragmentManager fragmentManager) {
29 | HolderFragment holderFragment = findHolderFragment(fragmentManager);
30 | if (holderFragment == null) {
31 | holderFragment = new HolderFragment();
32 | fragmentManager
33 | .beginTransaction()
34 | .add(holderFragment, TAG)
35 | .commitAllowingStateLoss();
36 | fragmentManager.executePendingTransactions();
37 | }
38 | return holderFragment;
39 | }
40 |
41 | private HolderFragment findHolderFragment(FragmentManager fragmentManager) {
42 | return (HolderFragment) fragmentManager.findFragmentByTag(TAG);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/result/HolderFragment.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.result;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import androidx.fragment.app.Fragment;
9 |
10 | import com.huantansheng.easyphotos.EasyPhotos;
11 | import com.huantansheng.easyphotos.callback.PuzzleCallback;
12 | import com.huantansheng.easyphotos.callback.SelectCallback;
13 | import com.huantansheng.easyphotos.engine.ImageEngine;
14 | import com.huantansheng.easyphotos.models.album.entity.Photo;
15 | import com.huantansheng.easyphotos.ui.EasyPhotosActivity;
16 | import com.huantansheng.easyphotos.ui.PuzzleActivity;
17 |
18 | import java.util.ArrayList;
19 |
20 | /**
21 | * HolderFragment
22 | *
23 | * @author joker
24 | * @date 2019/4/9.
25 | */
26 | public class HolderFragment extends Fragment {
27 |
28 | private static final int HOLDER_SELECT_REQUEST_CODE = 0x44;
29 | private static final int HOLDER_PUZZLE_REQUEST_CODE = 0x55;
30 | private SelectCallback mSelectCallback;
31 | private PuzzleCallback mPuzzleCallback;
32 |
33 | @Override
34 | public void onCreate(@Nullable Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setRetainInstance(true);
37 | }
38 |
39 | public void startEasyPhoto(SelectCallback callback) {
40 | mSelectCallback = callback;
41 | EasyPhotosActivity.start(this, HOLDER_SELECT_REQUEST_CODE);
42 | }
43 |
44 | public void startPuzzleWithPhotos(ArrayList photos, String puzzleSaveDirPath, String puzzleSaveNamePrefix, boolean replaceCustom, @NonNull ImageEngine imageEngine, PuzzleCallback callback) {
45 | mPuzzleCallback = callback;
46 | PuzzleActivity.startWithPhotos(this, photos, puzzleSaveDirPath, puzzleSaveNamePrefix, HOLDER_PUZZLE_REQUEST_CODE, replaceCustom, imageEngine);
47 | }
48 |
49 |
50 | @Override
51 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
52 | super.onActivityResult(requestCode, resultCode, data);
53 | if (Activity.RESULT_OK == resultCode) {
54 | switch (requestCode) {
55 | case HOLDER_SELECT_REQUEST_CODE:
56 | if (mSelectCallback != null) {
57 | ArrayList resultPhotos = data.getParcelableArrayListExtra(EasyPhotos.RESULT_PHOTOS);
58 | boolean selectedOriginal = data.getBooleanExtra(EasyPhotos.RESULT_SELECTED_ORIGINAL, false);
59 | mSelectCallback.onResult(resultPhotos, selectedOriginal);
60 | }
61 | break;
62 | case HOLDER_PUZZLE_REQUEST_CODE:
63 | if (mPuzzleCallback != null) {
64 | Photo puzzlePhoto = data.getParcelableExtra(EasyPhotos.RESULT_PHOTOS);
65 | mPuzzleCallback.onResult(puzzlePhoto);
66 | }
67 | break;
68 | }
69 | return;
70 | }
71 | if (Activity.RESULT_CANCELED == resultCode) {
72 | switch (requestCode) {
73 | case HOLDER_SELECT_REQUEST_CODE:
74 | if (mSelectCallback != null) {
75 | mSelectCallback.onCancel();
76 | }
77 | break;
78 | case HOLDER_PUZZLE_REQUEST_CODE:
79 | if (mPuzzleCallback != null) {
80 | mPuzzleCallback.onCancel();
81 | }
82 | break;
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/java/com/huantansheng/easyphotos/utils/settings/SettingsUtils.java:
--------------------------------------------------------------------------------
1 | package com.huantansheng.easyphotos.utils.settings;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.provider.Settings;
7 |
8 | import com.huantansheng.easyphotos.constant.Code;
9 |
10 | /**
11 | * 系统设置界面启动器
12 | * Created by huan on 2017/8/7.
13 | */
14 |
15 | public class SettingsUtils {
16 |
17 | /**
18 | * 启动应用详情界面
19 | * @param cxt 上下文
20 | * @param packageName 应用包名
21 | */
22 | public static void startMyApplicationDetailsForResult(Activity cxt, String packageName) {
23 | Uri packageUri = Uri.parse("package:" + packageName);
24 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri);
25 | cxt.startActivityForResult(intent, Code.REQUEST_SETTING_APP_DETAILS);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_dialog_album_items_background_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_dialog_loading_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_menu_done_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_second_level_menu_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_seek_bar_alpha_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_select_false_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_select_false_unable_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_select_true_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_selected_frame_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_selected_frame_puzzle_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/bg_text_sticker_editor_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_album_item_choose_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_album_items_name_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_arrow_back_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_arrow_down_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_arrow_up_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_black_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_blue_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_camera_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_clear_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_cyan_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_delete_easyy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_edit_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_gray_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_green_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_notifications_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_orange_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_play_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_purple_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_corner_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_flip_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_mirror_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_padding_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_replace_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
14 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_puzzle_rotate_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_red_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_selector_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_selector_true_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_settings_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_white_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/ic_yelow_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/progress_bar_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
19 |
20 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/drawable/thumb_seek_bar_alpha_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/dialog_loading_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
11 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/fragment_preview_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
17 |
18 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_ad_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_camera_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
18 |
19 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_dialog_album_items_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
28 |
29 |
40 |
41 |
52 |
53 |
63 |
64 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_preview_photo_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
25 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_preview_selected_photos_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
21 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_puzzle_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_puzzle_selector_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
20 |
43 |
44 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_puzzle_selector_preview_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
26 |
27 |
51 |
52 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_rv_photos_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
33 |
34 |
41 |
42 |
65 |
66 |
78 |
79 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/layout/item_text_sticker_easy_photos.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xhdpi/ic_controller_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xhdpi/ic_controller_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xhdpi/ic_delete_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xhdpi/ic_delete_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xhdpi/ic_editor_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xhdpi/ic_editor_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xhdpi/ic_mirror_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xhdpi/ic_mirror_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xhdpi/ic_rotate_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xhdpi/ic_rotate_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xxhdpi/ic_controller_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xxhdpi/ic_controller_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xxhdpi/ic_delete_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xxhdpi/ic_delete_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xxhdpi/ic_editor_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xxhdpi/ic_editor_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xxhdpi/ic_mirror_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xxhdpi/ic_mirror_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/mipmap-xxhdpi/ic_rotate_easy_photos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/easyPhotos/src/main/res/mipmap-xxhdpi/ic_rotate_easy_photos.png
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values-w480dp/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4
4 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values-w640dp/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 5
4 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #303135
4 | #00000000
5 | #FFFFFF
6 | #FFFFFF//按钮上的文字颜色,选择器上的文字颜色,选择器的边框颜色
7 |
8 |
9 | #FFFFFF//专辑项目列表的背景颜色
10 | #3e4145//专辑项目列表中专辑名称的字体颜色
11 | #4f5555//专辑项目列表中包含图片张数的字体颜色
12 |
13 |
14 | #33FFFFFF加载框背景颜色
15 |
16 |
17 | #d0021b//编辑字体颜色为红色
18 | #f5a623//编辑字体颜色为橙色
19 | #f8e71c//编辑字体颜色为黄色
20 | #7ed321//编辑字体颜色为绿色
21 | #50e3c2//编辑字体颜色为青色
22 | #4a90e2//编辑字体颜色为蓝色
23 | #9013fe//编辑字体颜色为紫色
24 | #000000//编辑字体颜色为黑色
25 | #4a4a4a//编辑字体颜色为灰色
26 | #ffffff//编辑字体颜色为白色
27 | #2c2e30//编辑界面背景色
28 | #393a3f//编辑界面操作栏颜色
29 |
30 |
31 | #ffffff//3e4145 前景主色,如字体颜色、icon颜色
32 | #9b9b9b//前景偏暗色,如不可用状态的字体颜色
33 | #00AA00//578fff 前景突出色,如发送按钮的背景色,选中状态的颜色
34 |
35 |
36 | #000000//f9f9f9 背景色,如每个activity的背景色,相册的图片间隔线颜色
37 |
38 |
39 | #393a3f//ffffff 操作栏主色,如相册页顶部和底部操作栏
40 | #303135//f9f9f9 操作栏偏暗色,操作栏间隔线颜色,如相册页返回按钮右边的竖线
41 | #eb212123//b4ffffff 操作栏带透明的色值,如预览页的底部操作栏颜色,相册页的相机按钮背景颜色。
42 |
43 |
44 | #393a3f
45 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16sp
3 | 42dp
4 |
5 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3
4 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyPhotos
3 |
4 | 所有图片
5 |
6 | 图片和视频
7 |
8 | 所有视频
9 |
10 | 选择
11 |
12 |
13 | 完成(%1$d/%2$d)
14 |
15 | 预览
16 |
17 | 超出最大选择数
18 |
19 | 最多只能选择%d张图片
20 |
21 | 最多只能选择%d个视频
22 |
23 | 需要选择同种类型的文件
24 |
25 | 无法启动相机!
26 |
27 | 图片错误
28 |
29 | 权限错误,无法正常工作!
30 |
31 | 图片的宽度必须大于%1$d,高度必须大于%2$d
32 |
33 | 不支持此图片格式
34 |
35 | 编辑
36 |
37 | 清空
38 |
39 | 没有符合要求的图片,拍一张吧
40 |
41 | 没有符合要求的视频
42 |
43 | 请点击并允许相关权限
44 |
45 | 请点击并在设置中允许相关权限
46 |
47 | 原图
48 |
49 | %1$d/%2$d
50 |
51 | 完成
52 |
53 | 取消
54 |
55 | 模板
56 |
57 | 文字
58 |
59 | 日期
60 |
61 | 双击编辑
62 |
63 | 自定义
64 |
65 | 图片选择
66 |
67 | 视频选择
68 |
69 | 拼一张
70 |
71 | 请选择2 \- 9张照片
72 |
73 | 动图
74 |
75 | 视频
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/easyPhotos/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 24 15:15:22 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/images/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/01.png
--------------------------------------------------------------------------------
/images/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/02.png
--------------------------------------------------------------------------------
/images/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/03.png
--------------------------------------------------------------------------------
/images/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/04.png
--------------------------------------------------------------------------------
/images/05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/05.png
--------------------------------------------------------------------------------
/images/06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/06.png
--------------------------------------------------------------------------------
/images/07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/07.png
--------------------------------------------------------------------------------
/images/08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/08.png
--------------------------------------------------------------------------------
/images/09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/09.png
--------------------------------------------------------------------------------
/images/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/10.png
--------------------------------------------------------------------------------
/images/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/11.png
--------------------------------------------------------------------------------
/images/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/12.png
--------------------------------------------------------------------------------
/images/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/13.png
--------------------------------------------------------------------------------
/images/14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/14.png
--------------------------------------------------------------------------------
/images/15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/15.png
--------------------------------------------------------------------------------
/images/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/16.png
--------------------------------------------------------------------------------
/images/17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/17.png
--------------------------------------------------------------------------------
/images/18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HuanTanSheng/EasyPhotos/d07e88b46932565a57c679c292193447be80b575/images/18.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':demo', ':easyPhotos'
2 |
--------------------------------------------------------------------------------