├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── raw
│ │ │ │ └── tut2.gif
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimen.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── arrays.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ └── cpv_alpha.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── cpv_alpha.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── cpv_alpha.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ └── ic_launcher_foreground.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ └── ic_launcher_foreground.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ └── ic_launcher_foreground.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ └── ic_launcher_foreground.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ └── ic_launcher_foreground.webp
│ │ │ ├── drawable
│ │ │ │ ├── dot_drawable.xml
│ │ │ │ ├── cpv_ic_arrow_right_black_24dp.xml
│ │ │ │ ├── cpv_preset_checked.xml
│ │ │ │ ├── baseline_arrow_upward_24.xml
│ │ │ │ ├── sheet_top.xml
│ │ │ │ ├── cpv_btn_background_pressed.xml
│ │ │ │ ├── baseline_arrow_back_24.xml
│ │ │ │ ├── baseline_done_24.xml
│ │ │ │ ├── baseline_close_24.xml
│ │ │ │ ├── check_green.xml
│ │ │ │ ├── drag_shape.xml
│ │ │ │ ├── baseline_arrow_downward_24.xml
│ │ │ │ ├── discount_back.xml
│ │ │ │ ├── play_filled.xml
│ │ │ │ ├── picked_sub_item.xml
│ │ │ │ ├── baseline_info_outline_24.xml
│ │ │ │ ├── cpv_btn_background.xml
│ │ │ │ ├── baseline_brush_24.xml
│ │ │ │ ├── redo_line.xml
│ │ │ │ ├── undo_line.xml
│ │ │ │ ├── expand_left_right_line.xml
│ │ │ │ ├── delete_bin_line.xml
│ │ │ │ ├── save_3_line.xml
│ │ │ │ ├── baseline_auto_awesome_24.xml
│ │ │ │ ├── pencil_line.xml
│ │ │ │ ├── history_line.xml
│ │ │ │ ├── image_add_line.xml
│ │ │ │ ├── eraser_line.xml
│ │ │ │ ├── lock_2_line.xml
│ │ │ │ ├── paint_line.xml
│ │ │ │ ├── question_line.xml
│ │ │ │ ├── eye_close_line.xml
│ │ │ │ ├── eye_line.xml
│ │ │ │ ├── account_circle_line.xml
│ │ │ │ ├── equalizer_line.xml
│ │ │ │ ├── share_line.xml
│ │ │ │ ├── palette_line.xml
│ │ │ │ ├── hand.xml
│ │ │ │ ├── settings_line.xml
│ │ │ │ ├── premium_icon.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── history.xml
│ │ │ │ ├── gallery_fragment.xml
│ │ │ │ ├── info_layout.xml
│ │ │ │ ├── pref_activity.xml
│ │ │ │ ├── layout_image.xml
│ │ │ │ ├── input_dialog.xml
│ │ │ │ ├── gallery_item.xml
│ │ │ │ ├── progress_dialog.xml
│ │ │ │ ├── upscale_compare_dialog.xml
│ │ │ │ ├── gallery.xml
│ │ │ │ ├── crop_image.xml
│ │ │ │ ├── before_after_slider.xml
│ │ │ │ ├── save_image.xml
│ │ │ │ ├── fullscreen_image.xml
│ │ │ │ ├── upscale.xml
│ │ │ │ ├── drawing_activity.xml
│ │ │ │ └── settings.xml
│ │ │ ├── menu
│ │ │ │ ├── multi_select.xml
│ │ │ │ ├── bhmenu.xml
│ │ │ │ ├── bottom_nav_menu.xml
│ │ │ │ └── main_menu.xml
│ │ │ ├── xml
│ │ │ │ ├── provider_paths.xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ ├── data_extraction_rules.xml
│ │ │ │ └── preference.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── serhat
│ │ │ │ └── aieditor
│ │ │ │ ├── drawing
│ │ │ │ ├── Stroke.java
│ │ │ │ └── DrawView.java
│ │ │ │ ├── viewpager
│ │ │ │ ├── PagerItems.java
│ │ │ │ ├── PagerItem.java
│ │ │ │ ├── MainViewPager2Adapter.java
│ │ │ │ ├── FragmentPagerItem.java
│ │ │ │ └── FragmentPagerItems.java
│ │ │ │ ├── MainViewPager2Adapter.java
│ │ │ │ ├── model
│ │ │ │ └── GalleryModel.java
│ │ │ │ ├── AutoResetMode.java
│ │ │ │ ├── activity
│ │ │ │ └── PrefsActivity.java
│ │ │ │ ├── app
│ │ │ │ ├── ApplicationPath.java
│ │ │ │ └── App.java
│ │ │ │ ├── preference
│ │ │ │ └── Prefs.java
│ │ │ │ ├── Utils.java
│ │ │ │ ├── fragment
│ │ │ │ ├── SettingsFragment.java
│ │ │ │ ├── SavedFragment.java
│ │ │ │ ├── HistoryFragment.java
│ │ │ │ └── UpscaledFragment.java
│ │ │ │ ├── BeforeAfterSlider.java
│ │ │ │ └── adapter
│ │ │ │ └── HistoryAdapter.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── serhat
│ │ │ └── aieditor
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── serhat
│ │ └── aieditor
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .gitignore
├── compiler.xml
├── vcs.xml
├── migrations.xml
├── deploymentTargetSelector.xml
├── misc.xml
└── gradle.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
├── LICENSE
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/tut2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/raw/tut2.gif
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AI Image Editor
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/cpv_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/drawable-hdpi/cpv_alpha.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/cpv_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/drawable-xhdpi/cpv_alpha.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/cpv_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/drawable-xxhdpi/cpv_alpha.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serkali-sudo/ai-image-editor/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F8FAE5
4 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dot_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jan 04 22:29:42 TRT 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/history.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 | #5C6BC0
6 | #ffb0bec5
7 | #fff77c73
8 | #FF7043
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cpv_ic_arrow_right_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cpv_preset_checked.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_arrow_upward_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sheet_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "ai-image-editor"
17 | include ':app'
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/multi_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cpv_btn_background_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_arrow_back_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_done_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/drawing/Stroke.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.drawing;
2 |
3 | import android.graphics.Path;
4 |
5 | public class Stroke {
6 |
7 | public int colour;
8 | public float strokeWidth;
9 | public Path path;
10 |
11 | public Stroke(int colour, float width, Path path) {
12 | this.colour = colour;
13 | this.strokeWidth = width;
14 | this.path = path;
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_close_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/check_green.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/drag_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_arrow_downward_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/discount_back.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
12 |
15 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play_filled.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/serhat/aieditor/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/viewpager/PagerItems.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.viewpager;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 |
7 | public abstract class PagerItems extends ArrayList {
8 |
9 | private final Context context;
10 |
11 | protected PagerItems(Context context) {
12 | this.context = context;
13 | }
14 |
15 | public Context getContext() {
16 | return context;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/picked_sub_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
10 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_info_outline_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gallery_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cpv_btn_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_brush_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 6dp
4 | 66dp
5 | 34dp
6 | 58dp
7 | 50dp
8 | 8dp
9 | 28dp
10 | 40dp
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/redo_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/undo_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/expand_left_right_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/delete_bin_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/save_3_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/info_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bhmenu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/viewpager/PagerItem.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.viewpager;
2 |
3 | public abstract class PagerItem {
4 |
5 | protected static final float DEFAULT_WIDTH = 1.f;
6 |
7 | private final CharSequence title;
8 | private final float width;
9 |
10 | protected PagerItem(CharSequence title,float width){
11 | this.title = title;
12 | this.width = width;
13 | }
14 |
15 | public CharSequence getTitle(){
16 | return title;
17 | }
18 |
19 | public float getWidth(){
20 | return width;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/baseline_auto_awesome_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pencil_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/history_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pref_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_add_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/eraser_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/lock_2_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/input_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/paint_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gallery_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
14 |
15 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/question_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/eye_close_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/eye_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | -keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | -renamesourcefileattribute SourceFile
22 | -dontwarn javax.annotation.Nullable
--------------------------------------------------------------------------------
/app/src/main/res/layout/progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
16 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/upscale_compare_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/serhat/aieditor/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.serhat.aieditor", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/account_circle_line.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preference.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/equalizer_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Serhat İbin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/share_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/palette_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/hand.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/viewpager/MainViewPager2Adapter.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.viewpager;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.collection.SparseArrayCompat;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.fragment.app.FragmentActivity;
7 | import androidx.viewpager2.adapter.FragmentStateAdapter;
8 |
9 | import java.lang.ref.WeakReference;
10 |
11 | public class MainViewPager2Adapter extends FragmentStateAdapter {
12 |
13 | private final FragmentPagerItems pages;
14 |
15 | private final SparseArrayCompat> holder;
16 |
17 | public MainViewPager2Adapter(FragmentActivity fm, FragmentPagerItems pages) {
18 | super(fm);
19 | this.pages = pages;
20 | this.holder = new SparseArrayCompat<>(pages.size());
21 | }
22 |
23 | @NonNull
24 | @Override
25 | public Fragment createFragment(int position) {
26 | return getPagerItem(position).instantiate(pages.getContext(), position);
27 | }
28 |
29 | @Override
30 | public int getItemCount() {
31 | return pages.size();
32 | }
33 |
34 | protected FragmentPagerItem getPagerItem(int position) {
35 | return pages.get(position);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/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 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/MainViewPager2Adapter.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.collection.SparseArrayCompat;
5 | import androidx.fragment.app.Fragment;
6 | import androidx.fragment.app.FragmentActivity;
7 | import androidx.viewpager2.adapter.FragmentStateAdapter;
8 |
9 | import com.serhat.aieditor.viewpager.FragmentPagerItem;
10 | import com.serhat.aieditor.viewpager.FragmentPagerItems;
11 |
12 | import java.lang.ref.WeakReference;
13 |
14 | public class MainViewPager2Adapter extends FragmentStateAdapter {
15 |
16 | private final FragmentPagerItems pages;
17 |
18 | private final SparseArrayCompat> holder;
19 |
20 | public MainViewPager2Adapter(FragmentActivity fm, FragmentPagerItems pages) {
21 | super(fm);
22 | this.pages = pages;
23 | this.holder = new SparseArrayCompat<>(pages.size());
24 | }
25 |
26 | @NonNull
27 | @Override
28 | public Fragment createFragment(int position) {
29 | return getPagerItem(position).instantiate(pages.getContext(), position);
30 | }
31 |
32 | @Override
33 | public int getItemCount() {
34 | return pages.size();
35 | }
36 |
37 | protected FragmentPagerItem getPagerItem(int position) {
38 | return pages.get(position);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/settings_line.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
15 | #83FFFFFF
16 |
17 |
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AI Image Editor
2 |
3 | A simple client app that demonstrates how to create a mask of drawing on an image and use it as a input for Stable Diffusion AI inpainting models via API.
4 |
5 | 
6 |
7 | ## Requirements
8 | * An API key from [fal.ai](https://fal.ai/)
9 | * Minimum API: Android 5.1 (21)
10 |
11 | ## Features
12 | * Edit images using ai inpaint models like **Stable Diffusion XL Lightning**
13 | * Auto crop images that are not right size for the ai model
14 | * Downscale or upscale image resolution if it is too small or too big for the ai model
15 | * Auto save every image generated
16 | * Upscale images using ai models like: **RealESRGAN**
17 |
18 | ## How to use
19 | * Get an API key from [fal.ai](https://fal.ai/)
20 | * Enter the API key to the app from settings or it will prompt when you try to run or at start of the app if you havent entered an api key
21 | * Add an image you want to edit then paint the parts you want to edit
22 | * Write a prompt to tell ai to how it should edit
23 | * Then hit run and wait the result will appear on the top
24 |
25 | https://github.com/Serkali-sudo/ai-image-editor/assets/59535990/b105992f-3761-4e12-a675-a388731e74a4
26 |
27 | ## Screenshots
28 | 
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/model/GalleryModel.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.model;
2 |
3 | import com.serhat.aieditor.Utils;
4 |
5 | import java.io.File;
6 |
7 | public class GalleryModel {
8 |
9 | public String prompt;
10 | public String negative_prompt;
11 | public int width;
12 | public int height;
13 | public String path;
14 | public String originalPath;
15 | public String seed;
16 | public long id;
17 | public String addedDate;
18 | public boolean isSelected = false;
19 |
20 | public GalleryModel() {
21 |
22 | }
23 |
24 |
25 | public GalleryModel(long id, String prompt, String negative_prompt,
26 | int width, int height, String path, String originalPath, String seed, String addedDate) {
27 | this.id = id;
28 | this.prompt = prompt;
29 | this.negative_prompt = negative_prompt;
30 | this.width = width;
31 | this.height = height;
32 | this.path = path;
33 | this.originalPath = originalPath;
34 | this.seed = seed;
35 | this.addedDate = addedDate;
36 | }
37 |
38 | public void deleteFromDisk() {
39 | try {
40 | File file = new File(path);
41 | if (file.exists()) {
42 | file.delete();
43 | }
44 | } catch (Exception e) {
45 | Utils.e("GalleryModel", e.getMessage());
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
17 |
18 |
19 |
20 | #83000000
21 |
22 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/AutoResetMode.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import androidx.annotation.IntDef;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | /**
9 | * Describes how the {@link ZoomageView} will reset to its original size
10 | * once interaction with it stops. {@link #UNDER} will reset when the image is smaller
11 | * than or equal to its starting size, {@link #OVER} when it's larger than or equal to its starting size,
12 | * {@link #ALWAYS} in both situations,
13 | * and {@link #NEVER} causes no reset. Note that when using {@link #NEVER}, the image will still animate
14 | * to within the screen bounds in certain situations.
15 | */
16 | @Retention(RetentionPolicy.SOURCE)
17 | @IntDef({AutoResetMode.NEVER, AutoResetMode.UNDER, AutoResetMode.OVER, AutoResetMode.ALWAYS})
18 | public @interface AutoResetMode {
19 |
20 | int UNDER = 0;
21 | int OVER = 1;
22 | int ALWAYS = 2;
23 | int NEVER = 3;
24 |
25 | class Parser {
26 |
27 | @AutoResetMode
28 | public static int fromInt(final int value) {
29 | switch (value) {
30 | case OVER:
31 | return OVER;
32 | case ALWAYS:
33 | return ALWAYS;
34 | case NEVER:
35 | return NEVER;
36 | default:
37 | return UNDER;
38 | }
39 | }
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/activity/PrefsActivity.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.activity;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 |
8 | import android.view.MenuItem;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 | import androidx.appcompat.widget.Toolbar;
12 |
13 |
14 | import com.serhat.aieditor.R;
15 | import com.serhat.aieditor.fragment.SettingsFragment;
16 |
17 | import java.util.Objects;
18 |
19 | public class PrefsActivity extends AppCompatActivity {
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.pref_activity);
24 | Toolbar toolbar = findViewById(R.id.toolbar);
25 | getSupportFragmentManager()
26 | .beginTransaction()
27 | .replace(R.id.settings_container, new SettingsFragment())
28 | .commit();
29 | setSupportActionBar(toolbar);
30 | Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
31 | }
32 |
33 | @Override
34 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
35 | int id = item.getItemId();
36 | if (id == android.R.id.home) {
37 | finish();
38 | setResult(RESULT_OK);
39 | return true;
40 | }
41 | return super.onOptionsItemSelected(item);
42 |
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | namespace 'com.serhat.aieditor'
7 | compileSdk 34
8 |
9 | defaultConfig {
10 | applicationId "com.serhat.aieditor"
11 | minSdk 21
12 | targetSdk 34
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation 'androidx.appcompat:appcompat:1.6.1'
32 | implementation 'com.google.android.material:material:1.11.0'
33 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
34 | testImplementation 'junit:junit:4.13.2'
35 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
37 | implementation 'com.android.volley:volley:1.2.1'
38 | implementation 'com.github.bumptech.glide:glide:4.16.0'
39 | implementation 'com.google.android.flexbox:flexbox:3.0.0'
40 | implementation "androidx.preference:preference:1.2.1"
41 | implementation 'com.airbnb.android:lottie:5.2.0'
42 | implementation "com.vanniktech:android-image-cropper:4.5.0"
43 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - Landscape (16:9)
6 | - Landscape (4:3)
7 | - Square (1:1)
8 | - Portrait (9:16)
9 | - Portrait (3:4)
10 |
11 |
12 |
13 | - Light
14 | - Dark
15 | - Auto (By Time)
16 | - Auto (By Battery)
17 | - Auto (Follow System)
18 |
19 |
20 |
21 |
22 | - 0
23 | - 1
24 | - 2
25 | - 3
26 | - 4
27 |
28 |
29 |
30 | - 0
31 | - 1
32 | - 2
33 | - 3
34 | - 4
35 |
36 |
37 |
38 |
39 | - RealESRGAN_x4plus
40 | - RealESRGAN_x2plus
41 | - RealESRGAN_x4plus_anime_6B
42 | - RealESRGAN_x4_v3
43 | - RealESRGAN_x4_wdn_v3
44 | - RealESRGAN_x4_anime_v3
45 |
46 |
47 |
48 | - 1
49 | - 2
50 | - 3
51 | - 4
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
19 |
20 |
21 |
26 |
27 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/app/ApplicationPath.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.app;
2 |
3 | import android.os.Build;
4 | import android.os.Environment;
5 |
6 | import java.io.File;
7 |
8 | public class ApplicationPath {
9 |
10 | public static String savePath() {
11 | return getQuantumPath("AI Editor Saved", Environment.DIRECTORY_PICTURES);
12 | }
13 |
14 | public static String upscalePath() {
15 | return getQuantumPath("AI Editor Upscaled", Environment.DIRECTORY_PICTURES);
16 | }
17 |
18 |
19 | public static String getQuantumPath(String folderName, String dir) {
20 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
21 | File result = new File(Environment.getExternalStoragePublicDirectory(dir),
22 | folderName);
23 | if (result.isDirectory() || result.mkdirs()) {
24 | return result.getPath();
25 | }
26 | else {
27 | return (Environment.getExternalStoragePublicDirectory(dir).getPath());
28 | }
29 | } else {
30 | if (App.getInstance().isStoragePermissionGranted()) {
31 | File result = new File(Environment.getExternalStoragePublicDirectory(dir),
32 | folderName);
33 | if (result.isDirectory() || result.mkdirs()) {
34 | return result.getPath();
35 | } else {
36 | return (Environment.getExternalStoragePublicDirectory(dir).getPath());
37 | }
38 | } else {
39 | return App.getInstance().getExternalFilesDir(folderName).getPath();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/app/App.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.app;
2 |
3 | import android.Manifest;
4 | import android.app.Application;
5 | import android.content.pm.PackageManager;
6 |
7 | import androidx.appcompat.app.AppCompatDelegate;
8 | import androidx.core.app.ActivityCompat;
9 |
10 |
11 | import com.serhat.aieditor.preference.Prefs;
12 |
13 | public class App extends Application {
14 |
15 | public static App SELF_INSTANCE;
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | SELF_INSTANCE = this;
21 | Prefs prefs = Prefs.getInstance(getApplicationContext());
22 |
23 | switch (prefs.getString("themeChoice", "4")) {
24 | case "0":
25 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
26 | break;
27 | case "1":
28 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
29 | break;
30 | case "2":
31 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_TIME);
32 | break;
33 | case "3":
34 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
35 | break;
36 | case "4":
37 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
38 | break;
39 | }
40 | }
41 |
42 |
43 | public static App getInstance() {
44 | return SELF_INSTANCE;
45 | }
46 |
47 | public boolean isStoragePermissionGranted() {
48 | return ActivityCompat.checkSelfPermission(App.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/viewpager/FragmentPagerItem.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.viewpager;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 |
6 | import androidx.fragment.app.Fragment;
7 |
8 | public class FragmentPagerItem extends PagerItem {
9 |
10 | private static final String TAG = FragmentPagerItem.class.getSimpleName();
11 | private static final String KEY_POSITION = TAG + ":Position";
12 |
13 | private final String className;
14 | private final Bundle args;
15 |
16 |
17 | protected FragmentPagerItem(CharSequence title, float width, String className, Bundle args) {
18 | super(title, width);
19 | this.className = className;
20 | this.args = args;
21 | }
22 |
23 | public static FragmentPagerItem of(CharSequence title, Class extends Fragment> clazz) {
24 | return of(title, DEFAULT_WIDTH, clazz);
25 | }
26 |
27 | public static FragmentPagerItem of(CharSequence title, Class extends Fragment> clazz, Bundle args) {
28 | return of(title, DEFAULT_WIDTH, clazz, args);
29 | }
30 |
31 | public static FragmentPagerItem of(CharSequence title, float width,
32 | Class extends Fragment> clazz) {
33 | return of(title, width, clazz, new Bundle());
34 | }
35 |
36 | public static FragmentPagerItem of(CharSequence title, float width,
37 | Class extends Fragment> clazz, Bundle args) {
38 | return new FragmentPagerItem(title, width, clazz.getName(), args);
39 | }
40 |
41 | public static boolean hasPosition(Bundle args) {
42 | return args != null && args.containsKey(KEY_POSITION);
43 | }
44 |
45 | public static int getPosition(Bundle args) {
46 | return (hasPosition(args)) ? args.getInt(KEY_POSITION) : 0;
47 | }
48 |
49 | static void setPosition(Bundle args, int position) {
50 | args.putInt(KEY_POSITION, position);
51 | }
52 |
53 | public Fragment instantiate(Context context, int position) {
54 | setPosition(args, position);
55 | return Fragment.instantiate(context,className,args);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/viewpager/FragmentPagerItems.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.viewpager;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.StringRes;
7 | import androidx.fragment.app.Fragment;
8 |
9 | public class FragmentPagerItems extends PagerItems {
10 |
11 | public FragmentPagerItems(Context context) {
12 | super(context);
13 | }
14 |
15 | public static Creator with(Context context) {
16 | return new Creator(context);
17 | }
18 |
19 | public static class Creator {
20 |
21 | private final FragmentPagerItems items;
22 |
23 | public Creator(Context context) {
24 | items = new FragmentPagerItems(context);
25 | }
26 |
27 | public Creator add(@StringRes int title, Class extends Fragment> clazz) {
28 | return add(FragmentPagerItem.of(items.getContext().getString(title), clazz));
29 | }
30 |
31 | public Creator add(@StringRes int title, Class extends Fragment> clazz, Bundle args) {
32 | return add(FragmentPagerItem.of(items.getContext().getString(title), clazz, args));
33 | }
34 |
35 | public Creator add(@StringRes int title, float width, Class extends Fragment> clazz) {
36 | return add(FragmentPagerItem.of(items.getContext().getString(title), width, clazz));
37 | }
38 |
39 | public Creator add(@StringRes int title, float width, Class extends Fragment> clazz,
40 | Bundle args) {
41 | return add(FragmentPagerItem.of(items.getContext().getString(title), width, clazz, args));
42 | }
43 |
44 | public Creator add(CharSequence title, Class extends Fragment> clazz) {
45 | return add(FragmentPagerItem.of(title, clazz));
46 | }
47 |
48 | public Creator add(CharSequence title, Class extends Fragment> clazz, Bundle args) {
49 | return add(FragmentPagerItem.of(title, clazz, args));
50 | }
51 |
52 | public Creator add(FragmentPagerItem item) {
53 | items.add(item);
54 | return this;
55 | }
56 |
57 | public FragmentPagerItems create() {
58 | return items;
59 | }
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
10 |
11 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
46 |
47 |
52 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/preference/Prefs.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.preference;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import androidx.preference.PreferenceManager;
7 |
8 | public class Prefs {
9 |
10 | private final SharedPreferences sharedPreferences;
11 | private final SharedPreferences.Editor editor;
12 |
13 | private static Prefs instance;
14 |
15 | private Prefs(Context context) {
16 | sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
17 | editor = sharedPreferences.edit();
18 | }
19 |
20 | public static Prefs getInstance(Context context) {
21 | if (instance == null) {
22 | instance = new Prefs(context);
23 | }
24 | return instance;
25 | }
26 |
27 | public void setInt(String key, int value) {
28 | editor.putInt(key, value);
29 | editor.apply();
30 | }
31 |
32 |
33 | public void setLong(String key, long value) {
34 | editor.putLong(key, value);
35 | editor.apply();
36 | }
37 |
38 |
39 | public void setString(String key, String value) {
40 | editor.putString(key, value);
41 | editor.apply();
42 | }
43 |
44 |
45 | public void setBoolean(String key, boolean value) {
46 | editor.putBoolean(key, value);
47 | editor.apply();
48 | }
49 |
50 | public void setFloat(String key, float value) {
51 | editor.putFloat(key, value).apply();
52 | }
53 |
54 | public void removeKey(String key) {
55 | editor.remove(key);
56 | editor.apply();
57 | }
58 |
59 | public boolean getBoolean(String key, boolean def) {
60 | return sharedPreferences.getBoolean(key, def);
61 | }
62 |
63 | public int getInt(String key, int def) {
64 | return sharedPreferences.getInt(key, def);
65 | }
66 |
67 | public float getFloat(String key, float def) {
68 | return sharedPreferences.getFloat(key, def);
69 | }
70 |
71 |
72 | public long getLong(String key, long def) {
73 | return sharedPreferences.getLong(key, def);
74 | }
75 |
76 |
77 | public String getString(String key, String def) {
78 | return sharedPreferences.getString(key, def);
79 | }
80 |
81 | public SharedPreferences getSharedPreferences() {
82 | return sharedPreferences;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/Utils.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.view.inputmethod.InputMethodManager;
9 | import android.widget.EditText;
10 |
11 | public class Utils {
12 | public static boolean DEBUG = true;
13 |
14 | public static void hideKeyboard(Activity appCompatActivity) {
15 | View view = appCompatActivity.getCurrentFocus();
16 | if (view != null) {
17 | InputMethodManager imm = (InputMethodManager)
18 | appCompatActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
19 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
20 | }
21 | }
22 |
23 | public static int pxToDp(Context context, int px) {
24 | DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
25 | float density = displayMetrics.density;
26 | return Math.round(px / density);
27 | }
28 |
29 | // public static int px2dp(Context context, int px) {
30 | // Resources r = context.getResources();
31 | // DisplayMetrics metrics = r.getDisplayMetrics();
32 | // float dp = TypedValue.applyDimension(
33 | // TypedValue.COMPLEX_UNIT_PX,
34 | // px,
35 | // metrics
36 | // );
37 | // return (int) dp;
38 | // }
39 |
40 | public static void hideKeyboard(Activity appCompatActivity, EditText editText) {
41 | InputMethodManager imm = (InputMethodManager)
42 | appCompatActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
43 | imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
44 |
45 | }
46 |
47 |
48 | public static void d(String tag, String message) {
49 | if (DEBUG) {
50 | Log.d(tag, message);
51 | }
52 | }
53 |
54 | public static void e(String tag, String message) {
55 | if (DEBUG) {
56 | Log.e(tag, message);
57 | }
58 | }
59 |
60 | public static void i(String tag, String message) {
61 | if (DEBUG) {
62 | Log.i(tag, message);
63 | }
64 | }
65 |
66 | public static void w(String tag, String message) {
67 | if (DEBUG) {
68 | Log.w(tag, message);
69 | }
70 | }
71 |
72 | public static void v(String tag, String message) {
73 | if (DEBUG) {
74 | Log.v(tag, message);
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/crop_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
22 |
23 |
31 |
32 |
40 |
41 |
42 |
43 |
47 |
48 |
56 |
57 |
60 |
61 |
65 |
66 |
67 |
68 |
69 |
73 |
74 |
75 |
76 |
77 |
78 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/premium_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/fragment/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.fragment;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.annotation.Nullable;
11 | import androidx.appcompat.app.AppCompatDelegate;
12 | import androidx.fragment.app.FragmentActivity;
13 | import androidx.preference.ListPreference;
14 | import androidx.preference.Preference;
15 | import androidx.preference.PreferenceFragmentCompat;
16 |
17 | import com.serhat.aieditor.R;
18 | import com.serhat.aieditor.preference.Prefs;
19 |
20 | public class SettingsFragment extends PreferenceFragmentCompat {
21 |
22 | private ListPreference mThemeList;
23 |
24 | private Preference github_key;
25 |
26 | private FragmentActivity activity;
27 |
28 | private Context context;
29 |
30 | private Prefs prefs;
31 |
32 |
33 | SharedPreferences.OnSharedPreferenceChangeListener prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
34 | @Override
35 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Nullable String key) {
36 | assert key != null;
37 | if (key.equals("themeChoice")) {
38 | setSummaryTheme(sharedPreferences.getString("themeChoice", "4"));
39 | }
40 | }
41 | };
42 |
43 | @Override
44 | public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
45 | context = getContext();
46 | activity = getActivity();
47 | prefs = Prefs.getInstance(activity.getApplicationContext());
48 | setPreferencesFromResource(R.xml.preference, rootKey);
49 | mThemeList = (ListPreference) findPreference("themeChoice");
50 |
51 | github_key = findPreference("github_key");
52 |
53 | github_key.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
54 | @Override
55 | public boolean onPreferenceClick(@NonNull Preference preference) {
56 | try {
57 | Intent intent = new Intent(Intent.ACTION_VIEW);
58 | intent.setData(Uri.parse("https://github.com/Serkali-sudo/AI-Image-Editor"));
59 | startActivity(intent);
60 | } catch (Exception ignored) {
61 | }
62 | return false;
63 | }
64 | });
65 |
66 | setSummaryTheme(prefs.getString("themeChoice", "4"));
67 | prefs.getSharedPreferences().registerOnSharedPreferenceChangeListener(prefListener);
68 | }
69 |
70 | private void setSummaryTheme(String theme) {
71 | switch (theme) {
72 | case "0":
73 | mThemeList.setSummary("Light");
74 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
75 | break;
76 | case "1":
77 | mThemeList.setSummary("Dark");
78 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
79 | break;
80 | case "2":
81 | mThemeList.setSummary("Auto (By Time)");
82 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_TIME);
83 | break;
84 | case "3":
85 | mThemeList.setSummary("Auto (By Battery)");
86 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
87 | break;
88 | case "4":
89 | mThemeList.setSummary("Auto (Follow System)");
90 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
91 | break;
92 | }
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/before_after_slider.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
27 |
28 |
35 |
36 |
42 |
43 |
51 |
52 |
53 |
54 |
55 |
64 |
65 |
74 |
75 |
91 |
92 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/save_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
36 |
37 |
42 |
43 |
47 |
48 |
55 |
56 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
76 |
77 |
82 |
83 |
88 |
89 |
96 |
97 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fullscreen_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
23 |
29 |
30 |
38 |
39 |
40 |
41 |
42 |
49 |
50 |
55 |
56 |
64 |
65 |
66 |
67 |
74 |
75 |
83 |
84 |
85 |
86 |
90 |
91 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/fragment/SavedFragment.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.fragment;
2 |
3 | import static android.app.Activity.RESULT_OK;
4 |
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.Menu;
9 | import android.view.MenuInflater;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.annotation.Nullable;
16 | import androidx.fragment.app.Fragment;
17 | import androidx.recyclerview.widget.RecyclerView;
18 |
19 | import com.google.android.flexbox.AlignItems;
20 | import com.google.android.flexbox.FlexDirection;
21 | import com.google.android.flexbox.FlexWrap;
22 | import com.google.android.flexbox.FlexboxLayoutManager;
23 | import com.google.android.material.dialog.MaterialAlertDialogBuilder;
24 | import com.serhat.aieditor.GalleryActivity;
25 | import com.serhat.aieditor.R;
26 | import com.serhat.aieditor.adapter.HistoryAdapter;
27 | import com.serhat.aieditor.app.ApplicationPath;
28 | import com.serhat.aieditor.model.GalleryModel;
29 |
30 |
31 | import java.io.File;
32 | import java.util.List;
33 |
34 | public class SavedFragment extends Fragment {
35 |
36 | private RecyclerView recyclerView;
37 | public GalleryActivity activity;
38 | private HistoryAdapter historyAdapter;
39 |
40 | @Override
41 | public void onCreate(@Nullable Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | activity = (GalleryActivity) getActivity();
44 | setHasOptionsMenu(true);
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
50 | View layout = inflater.inflate(R.layout.gallery_fragment, container, false);
51 | recyclerView = layout.findViewById(R.id.bookmark_RV);
52 | FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(activity);
53 | flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
54 | flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
55 | flexboxLayoutManager.setAlignItems(AlignItems.STRETCH);
56 | recyclerView.setLayoutManager(flexboxLayoutManager);
57 | return layout;
58 | }
59 |
60 | @Override
61 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
62 | super.onViewCreated(view, savedInstanceState);
63 | List bookmark_list = activity.databaseHelper.getAllSaved();
64 | if (bookmark_list != null) {
65 | historyAdapter = new HistoryAdapter(activity, bookmark_list, HistoryAdapter.CurrTab.SAVED);
66 | recyclerView.setAdapter(historyAdapter);
67 | }
68 | }
69 |
70 | @Override
71 | public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
72 | super.onCreateOptionsMenu(menu, inflater);
73 | inflater.inflate(R.menu.bhmenu, menu);
74 | }
75 |
76 | @Override
77 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
78 | int id = item.getItemId();
79 | if (id == android.R.id.home) {
80 | activity.finish();
81 | activity.setResult(RESULT_OK);
82 | return true;
83 | } else if (id == R.id.remove_all_bh) {
84 | if (activity.databaseHelper != null) {
85 | new MaterialAlertDialogBuilder(activity)
86 | .setTitle("Delete All Saved?")
87 | .setMessage("Are you sure that you want to delete all saved images?")
88 | .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
89 | @Override
90 | public void onClick(DialogInterface dialog, int which) {
91 | new Thread(new Runnable() {
92 | @Override
93 | public void run() {
94 | File result = new File(ApplicationPath.savePath());
95 | if (result.exists()) {
96 | result.delete();
97 | }
98 | }
99 | }).start();
100 |
101 | activity.databaseHelper.deleteAllBookmarks();
102 | historyAdapter.clearList();
103 | }
104 | })
105 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
106 | @Override
107 | public void onClick(DialogInterface dialog, int which) {
108 | dialog.dismiss();
109 | }
110 | }).show();
111 |
112 |
113 | }
114 | } else if (id == R.id.multi_select_menu) {
115 | enableMultiMode();
116 | }
117 | return super.onOptionsItemSelected(item);
118 | }
119 | public void enableMultiMode() {
120 | if (historyAdapter != null) {
121 | historyAdapter.enableActionMode();
122 | }
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/fragment/HistoryFragment.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.fragment;
2 |
3 | import static android.app.Activity.RESULT_OK;
4 |
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.Menu;
9 | import android.view.MenuInflater;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.annotation.Nullable;
16 | import androidx.fragment.app.Fragment;
17 | import androidx.recyclerview.widget.RecyclerView;
18 |
19 | import com.google.android.flexbox.AlignItems;
20 | import com.google.android.flexbox.FlexDirection;
21 | import com.google.android.flexbox.FlexWrap;
22 | import com.google.android.flexbox.FlexboxLayoutManager;
23 | import com.google.android.material.dialog.MaterialAlertDialogBuilder;
24 | import com.serhat.aieditor.GalleryActivity;
25 | import com.serhat.aieditor.R;
26 | import com.serhat.aieditor.adapter.HistoryAdapter;
27 | import com.serhat.aieditor.model.GalleryModel;
28 |
29 |
30 | import java.io.File;
31 | import java.util.List;
32 |
33 | public class HistoryFragment extends Fragment {
34 |
35 | private RecyclerView recyclerView;
36 | public GalleryActivity activity;
37 | private HistoryAdapter historyAdapter;
38 |
39 | @Override
40 | public void onCreate(@Nullable Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | activity = (GalleryActivity) getActivity();
43 | setHasOptionsMenu(true);
44 |
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
50 | View layout = inflater.inflate(R.layout.gallery_fragment, container, false);
51 | recyclerView = layout.findViewById(R.id.bookmark_RV);
52 | FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(activity);
53 | flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
54 | flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
55 | flexboxLayoutManager.setAlignItems(AlignItems.STRETCH);
56 | recyclerView.setLayoutManager(flexboxLayoutManager);
57 |
58 |
59 | return layout;
60 | }
61 |
62 |
63 | public void enableMultiMode() {
64 | if (historyAdapter != null) {
65 | historyAdapter.enableActionMode();
66 | }
67 | }
68 |
69 | @Override
70 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
71 | super.onViewCreated(view, savedInstanceState);
72 | List historyList = activity.databaseHelper.getAllHistory();
73 | historyAdapter = new HistoryAdapter(activity, historyList, HistoryAdapter.CurrTab.HISTORY);
74 | if (historyList != null) {
75 | recyclerView.setAdapter(historyAdapter);
76 | }
77 |
78 |
79 | }
80 |
81 |
82 | @Override
83 | public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
84 | super.onCreateOptionsMenu(menu, inflater);
85 | inflater.inflate(R.menu.bhmenu, menu);
86 | }
87 |
88 | @Override
89 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
90 | int id = item.getItemId();
91 | if (id == android.R.id.home) {
92 | activity.finish();
93 | activity.setResult(RESULT_OK);
94 | return true;
95 | } else if (id == R.id.remove_all_bh) {
96 | if (activity.databaseHelper != null) {
97 | new MaterialAlertDialogBuilder(activity)
98 | .setTitle("Delete All History?")
99 | .setMessage("Are you sure that you want to delete all history?")
100 | .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
101 | @Override
102 | public void onClick(DialogInterface dialog, int which) {
103 | new Thread(new Runnable() {
104 | @Override
105 | public void run() {
106 | File result = new File(activity.getExternalFilesDir("history"), "generation_history");
107 | if (result.exists()) {
108 | result.delete();
109 | }
110 | }
111 | }).start();
112 |
113 | activity.databaseHelper.deleteAllHistory();
114 | historyAdapter.clearList();
115 | }
116 | })
117 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
118 | @Override
119 | public void onClick(DialogInterface dialog, int which) {
120 | dialog.dismiss();
121 | }
122 | }).show();
123 |
124 |
125 | }
126 | } else if (id == R.id.multi_select_menu) {
127 | enableMultiMode();
128 | }
129 | return super.onOptionsItemSelected(item);
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/fragment/UpscaledFragment.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.fragment;
2 |
3 | import static android.app.Activity.RESULT_OK;
4 |
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.Menu;
9 | import android.view.MenuInflater;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.annotation.Nullable;
16 | import androidx.fragment.app.Fragment;
17 | import androidx.recyclerview.widget.RecyclerView;
18 |
19 | import com.google.android.flexbox.AlignItems;
20 | import com.google.android.flexbox.FlexDirection;
21 | import com.google.android.flexbox.FlexWrap;
22 | import com.google.android.flexbox.FlexboxLayoutManager;
23 | import com.google.android.material.dialog.MaterialAlertDialogBuilder;
24 | import com.serhat.aieditor.GalleryActivity;
25 | import com.serhat.aieditor.R;
26 | import com.serhat.aieditor.adapter.HistoryAdapter;
27 | import com.serhat.aieditor.app.ApplicationPath;
28 | import com.serhat.aieditor.model.GalleryModel;
29 |
30 |
31 | import java.io.File;
32 | import java.util.List;
33 |
34 | public class UpscaledFragment extends Fragment {
35 |
36 | private RecyclerView recyclerView;
37 | public GalleryActivity activity;
38 | private HistoryAdapter historyAdapter;
39 | @Override
40 | public void onCreate(@Nullable Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | activity = (GalleryActivity) getActivity();
43 | setHasOptionsMenu(true);
44 | }
45 |
46 | @Nullable
47 | @Override
48 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
49 | View layout = inflater.inflate(R.layout.gallery_fragment, container, false);
50 | recyclerView = layout.findViewById(R.id.bookmark_RV);
51 | FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(activity);
52 | flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
53 | flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
54 | flexboxLayoutManager.setAlignItems(AlignItems.STRETCH);
55 | recyclerView.setLayoutManager(flexboxLayoutManager);
56 | return layout;
57 | }
58 |
59 | @Override
60 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
61 | super.onViewCreated(view, savedInstanceState);
62 | List bookmark_list = activity.databaseHelper.getAllUpscaled();
63 | if (bookmark_list != null) {
64 | HistoryAdapter historyAdapter = new HistoryAdapter(activity, bookmark_list, HistoryAdapter.CurrTab.UPSCALED);
65 | recyclerView.setAdapter(historyAdapter);
66 |
67 | }
68 | }
69 |
70 | @Override
71 | public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
72 | super.onCreateOptionsMenu(menu, inflater);
73 | inflater.inflate(R.menu.bhmenu, menu);
74 | }
75 |
76 | @Override
77 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
78 | int id = item.getItemId();
79 | if (id == android.R.id.home) {
80 | activity.finish();
81 | activity.setResult(RESULT_OK);
82 | return true;
83 | } else if (id == R.id.remove_all_bh) {
84 | if (activity.databaseHelper != null) {
85 | new MaterialAlertDialogBuilder(activity)
86 | .setTitle("Delete All Upscaled?")
87 | .setMessage("Are you sure that you want to delete all upscaled images?")
88 | .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
89 | @Override
90 | public void onClick(DialogInterface dialog, int which) {
91 | new Thread(new Runnable() {
92 | @Override
93 | public void run() {
94 | File result = new File(ApplicationPath.upscalePath());
95 | if (result.exists()) {
96 | result.delete();
97 | }
98 | }
99 | }).start();
100 |
101 | activity.databaseHelper.deleteAllUpscaled();
102 | historyAdapter.clearList();
103 | }
104 | })
105 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
106 | @Override
107 | public void onClick(DialogInterface dialog, int which) {
108 | dialog.dismiss();
109 | }
110 | }).show();
111 |
112 |
113 | }
114 | } else if (id == R.id.multi_select_menu) {
115 | enableMultiMode();
116 | }
117 | return super.onOptionsItemSelected(item);
118 | }
119 | public void enableMultiMode() {
120 | if (historyAdapter != null) {
121 | historyAdapter.enableActionMode();
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/BeforeAfterSlider.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Bitmap;
6 | import android.graphics.drawable.Drawable;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.SeekBar;
12 |
13 | import androidx.annotation.Nullable;
14 | import androidx.appcompat.content.res.AppCompatResources;
15 | import androidx.constraintlayout.widget.ConstraintLayout;
16 |
17 | public class BeforeAfterSlider extends ConstraintLayout {
18 | public BeforeAfterSlider(Context context) {
19 | super(context);
20 | init(null);
21 | }
22 |
23 | public BeforeAfterSlider(Context context, @Nullable AttributeSet attrs) {
24 | super(context, attrs);
25 | init(attrs);
26 | }
27 |
28 | public BeforeAfterSlider(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
29 | super(context, attrs, defStyleAttr);
30 | init(attrs);
31 | }
32 |
33 | public void setFore(Bitmap bitmap) {
34 | ImageView foreground_image = findViewById(R.id.foreground_image);
35 | foreground_image.setImageBitmap(bitmap);
36 | }
37 |
38 | public void setBack(Bitmap bitmap) {
39 | ImageView background_image = findViewById(R.id.background_image);
40 | background_image.setImageBitmap(bitmap);
41 | }
42 |
43 |
44 | // public void setTestImages() {
45 | // ImageView foreground_image = findViewById(R.id.foreground_image);
46 | // foreground_image.setImageResource(R.drawable.test1);
47 | // ImageView background_image = findViewById(R.id.background_image);
48 | // background_image.setImageResource(R.drawable.test2);
49 | // }
50 |
51 |
52 |
53 | private void init(AttributeSet attrs) {
54 | View.inflate(getContext(), R.layout.before_after_slider, this);
55 |
56 | TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.BeforeAfterSlider);
57 | try {
58 | // int drawableBackground = ta.getResourceId(R.styleable.ImageCompareSlider_background_image, 0);
59 | // if (drawableBackground != 0) {
60 | // Drawable drawable = AppCompatResources.getDrawable(getContext(), drawableBackground);
61 | // ImageView background_image = findViewById(R.id.background_image);
62 | // background_image.setImageDrawable(drawable);
63 | // }
64 | // int drawableForeground = ta.getResourceId(R.styleable.ImageCompareSlider_foreground_image, 0);
65 | // if (drawableForeground != 0) {
66 | // Drawable drawable = AppCompatResources.getDrawable(getContext(), drawableForeground);
67 | // ImageView foreground_image = findViewById(R.id.foreground_image);
68 | // foreground_image.setImageDrawable(drawable);
69 | // }
70 | int drawableSliderIcon = ta.getResourceId(R.styleable.BeforeAfterSlider_slider_icon, 0);
71 | if (drawableSliderIcon != 0) {
72 | Drawable drawable = AppCompatResources.getDrawable(getContext(), drawableSliderIcon);
73 | ImageView slider_image = findViewById(R.id.slider_image);
74 | slider_image.setImageDrawable(drawable);
75 | slider_image.setBackgroundResource(R.drawable.drag_shape);
76 | }
77 | } finally {
78 | ta.recycle();
79 | }
80 |
81 | SeekBar sbImageSeek = findViewById(R.id.sbImageSeek);
82 | sbImageSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
83 | @Override
84 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
85 | setImageWidth(i);
86 | }
87 |
88 | @Override
89 | public void onStartTrackingTouch(SeekBar seekBar) {
90 | }
91 |
92 | @Override
93 | public void onStopTrackingTouch(SeekBar seekBar) {
94 | }
95 | });
96 |
97 | View background_image = findViewById(R.id.background_image);
98 | View foreground_image = findViewById(R.id.foreground_image);
99 | View slider_bar = findViewById(R.id.slider_bar);
100 |
101 | background_image.post(new Runnable() {
102 | @Override
103 | public void run() {
104 | ViewGroup.LayoutParams layoutParams = foreground_image.getLayoutParams();
105 | layoutParams.height = background_image.getHeight();
106 | layoutParams.width = background_image.getWidth();
107 | foreground_image.setLayoutParams(layoutParams);
108 |
109 | sbImageSeek.setMax(background_image.getWidth());
110 | sbImageSeek.setProgress((sbImageSeek.getMax() / 2));
111 |
112 | ViewGroup.LayoutParams sliderBarLayoutParams = slider_bar.getLayoutParams();
113 | sliderBarLayoutParams.height = background_image.getHeight();
114 | slider_bar.setLayoutParams(sliderBarLayoutParams);
115 | }
116 | });
117 | }
118 |
119 | private void setImageWidth(int progress) {
120 | if (progress <= 0)
121 | return;
122 |
123 | View target = findViewById(R.id.target);
124 | ViewGroup.LayoutParams lp = target.getLayoutParams();
125 | lp.width = progress;
126 | target.setLayoutParams(lp);
127 | }
128 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/upscale.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
31 |
32 |
41 |
42 |
47 |
48 |
56 |
57 |
63 |
64 |
69 |
70 |
71 |
72 |
73 |
74 |
83 |
84 |
89 |
90 |
98 |
99 |
105 |
106 |
111 |
112 |
113 |
114 |
115 |
116 |
125 |
126 |
131 |
139 |
146 |
147 |
151 |
152 |
153 |
154 |
155 |
156 |
166 |
167 |
172 |
173 |
177 |
178 |
185 |
186 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/drawing/DrawView.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.drawing;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Matrix;
9 | import android.graphics.Paint;
10 | import android.graphics.Path;
11 | import android.graphics.PointF;
12 | import android.graphics.PorterDuff;
13 | import android.graphics.Rect;
14 | import android.os.Handler;
15 | import android.util.AttributeSet;
16 | import android.util.Base64;
17 | import android.view.GestureDetector;
18 | import android.view.MotionEvent;
19 | import android.view.View;
20 | import android.widget.Toast;
21 |
22 |
23 | import androidx.core.content.ContextCompat;
24 |
25 | import com.serhat.aieditor.R;
26 | import com.serhat.aieditor.Utils;
27 |
28 | import java.io.ByteArrayOutputStream;
29 | import java.util.ArrayList;
30 |
31 |
32 | public class DrawView extends View {
33 |
34 | private static final float TOUCH_TOLERANCE = 4;
35 | private float mX;
36 | private float mY;
37 | private Path mPath;
38 | private Paint mPaint;
39 |
40 | private final ArrayList paths = new ArrayList<>();
41 | private final ArrayList undonePaths = new ArrayList<>();
42 | public int currentColour;
43 | public float strokeWidth;
44 | private Bitmap mBitmap;
45 | private Canvas mCanvas;
46 | Paint background;
47 | public int backgroundColour;
48 |
49 | private int containerWidth;
50 | private int containerHeight;
51 | float[] mv = new float[9];
52 | Matrix matrix = new Matrix();
53 | float currentScale;
54 | float curX;
55 | float curY;
56 | float minScale;
57 | Rect clipBounds;
58 |
59 |
60 | public DrawView(Context context) {
61 | super(context);
62 | setFocusable(true);
63 | setFocusableInTouchMode(true);
64 | initPaints();
65 | }
66 |
67 |
68 | public String captureCanvasAsBase64() {
69 | if (mBitmap != null) {
70 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
71 | save().compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
72 | byte[] byteArray = byteArrayOutputStream.toByteArray();
73 | return "data:image/png;base64," + Base64.encodeToString(byteArray,
74 | Base64.DEFAULT);
75 | }
76 | return null;
77 | }
78 |
79 | public DrawView(Context context, AttributeSet attributes) {
80 | super(context, attributes);
81 | initPaints();
82 | }
83 |
84 | public void setUpDrawing() {
85 | mPath = new Path();
86 | mPaint = new Paint();
87 | mPaint.setAntiAlias(true);
88 | mPaint.setDither(true);
89 | mPaint.setColor(Color.BLACK);
90 | mPaint.setStyle(Paint.Style.STROKE);
91 | mPaint.setStrokeJoin(Paint.Join.ROUND);
92 | mPaint.setStrokeCap(Paint.Cap.ROUND);
93 | backgroundColour = Color.TRANSPARENT;
94 | }
95 |
96 |
97 | private void initPaints() {
98 | background = new Paint();
99 | setUpDrawing();
100 | }
101 |
102 |
103 | @Override
104 | protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
105 | super.onSizeChanged(width, height, oldWidth, oldHeight);
106 | Utils.d("DrawingView", "Changed");
107 | strokeWidth = 50f;
108 | fitScaleInitial();
109 | invalidate();
110 |
111 | }
112 |
113 | public void setUpCanvas(int width, int height) {
114 | mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
115 | mCanvas = new Canvas(mBitmap);
116 | if (currentColour == 0) {
117 | currentColour = ContextCompat.getColor(getContext(), R.color.paint_color);
118 | }
119 | strokeWidth = 50f;
120 | Utils.d("DrawingView", "Called Setup:" + width + "x" + height);
121 | fitScaleInitial();
122 | }
123 |
124 | private void fitScaleInitial() {
125 | containerWidth = getWidth();
126 | containerHeight = getHeight();
127 | if (mBitmap != null && containerWidth > 0 && containerHeight > 0) {
128 | mCanvas = new Canvas(mBitmap);
129 | int imgHeight = mBitmap.getHeight();
130 | int imgWidth = mBitmap.getWidth();
131 | float scale;
132 | int initX = 0;
133 | int initY = 0;
134 |
135 | float scaleX = (float) containerWidth / imgWidth;
136 | float scaleY = (float) containerHeight / imgHeight;
137 | scale = Math.min(scaleX, scaleY);
138 |
139 | float minScaleFactor = 0.5f;
140 | if (scale < minScaleFactor) {
141 | scale = minScaleFactor;
142 | }
143 |
144 | float newWidth = imgWidth * scale;
145 | float newHeight = imgHeight * scale;
146 |
147 | initX = (int) ((containerWidth - newWidth) / 2);
148 | initY = (int) ((containerHeight - newHeight) / 2);
149 |
150 | strokeWidth /= scale;
151 | matrix.setScale(scale, scale);
152 | matrix.postTranslate(initX, initY);
153 |
154 | curX = initX;
155 | curY = initY;
156 | currentScale = scale;
157 | minScale = scale;
158 |
159 |
160 | }
161 |
162 | }
163 |
164 | @SuppressLint("DrawAllocation")
165 | @Override
166 | protected void onDraw(Canvas canvas) {
167 | super.onDraw(canvas);
168 |
169 | canvas.save();
170 | if (mBitmap != null) {
171 | if (mCanvas == null) {
172 | mCanvas = new Canvas(mBitmap);
173 | }
174 | }
175 | clipBounds = canvas.getClipBounds();
176 | canvas.drawBitmap(mBitmap, matrix, background);
177 | canvas.concat(matrix);
178 |
179 | mCanvas.drawColor(backgroundColour);
180 | for (Stroke currentPath : paths) {
181 | mPaint.setColor(currentPath.colour);
182 | mPaint.setStrokeWidth(currentPath.strokeWidth);
183 | mCanvas.drawPath(currentPath.path, mPaint);
184 | invalidate();
185 | }
186 |
187 | canvas.restore();
188 | invalidate();
189 | }
190 |
191 |
192 | private void touchStart(float x, float y) {
193 | undonePaths.clear();
194 | mPath = new Path();
195 |
196 | Stroke currentPath = new Stroke(currentColour, strokeWidth, mPath);
197 | paths.add(currentPath);
198 |
199 | mPath.reset();
200 | mPath.moveTo(x, y);
201 | mX = x;
202 | mY = y;
203 | }
204 |
205 | private void touchMove(float x, float y) {
206 | float dx = Math.abs(x - mX);
207 | float dy = Math.abs(y - mY);
208 |
209 | if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
210 | mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
211 | mX = x;
212 | mY = y;
213 | }
214 | }
215 |
216 | private void touchUp() {
217 | mPath.lineTo(mX, mY);
218 | }
219 |
220 | @SuppressLint("ClickableViewAccessibility")
221 | @Override
222 | public boolean onTouchEvent(MotionEvent event) {
223 | matrix.getValues(mv);
224 | float touchX = (event.getX() * (1 / mv[4]) - (mv[2] / mv[4]));
225 | float touchY = (event.getY() * (1 / mv[4]) - (mv[5] / mv[4]));
226 | switch (event.getAction()) {
227 | case MotionEvent.ACTION_DOWN:
228 | touchStart(touchX, touchY);
229 | break;
230 | case MotionEvent.ACTION_MOVE:
231 | touchMove(touchX, touchY);
232 | break;
233 | case MotionEvent.ACTION_UP:
234 | touchUp();
235 | break;
236 | case MotionEvent.ACTION_POINTER_DOWN:
237 | break;
238 | default:
239 | return false;
240 | }
241 | invalidate();
242 | return true;
243 | }
244 |
245 |
246 | public void clearCanvas() {
247 | if (!paths.isEmpty()) {
248 | paths.clear();
249 | mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
250 | }
251 | invalidate();
252 | }
253 |
254 | public boolean isCanvasClear() {
255 | return paths.isEmpty();
256 | }
257 |
258 |
259 | public void undo() {
260 | if (!paths.isEmpty()) {
261 | undonePaths.add(paths.remove(paths.size() - 1));
262 | mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
263 | } else {
264 | Toast.makeText(getContext(), "Cant Undo", Toast.LENGTH_SHORT).show();
265 | }
266 | invalidate();
267 | }
268 |
269 | public void redo() {
270 | if (!undonePaths.isEmpty()) {
271 | paths.add(undonePaths.remove(undonePaths.size() - 1));
272 | mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
273 | } else {
274 | Toast.makeText(getContext(), "Cant Redo", Toast.LENGTH_SHORT).show();
275 | }
276 | invalidate();
277 | }
278 |
279 | public Bitmap save() {
280 | Bitmap blackBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
281 | Canvas canvas = new Canvas(blackBitmap);
282 | canvas.drawBitmap(mBitmap, 0f, 0f, null);
283 | canvas.drawColor(Color.BLACK);
284 | for (Stroke currentPath : paths) {
285 | mPaint.setColor(Color.WHITE);
286 | mPaint.setStrokeWidth(currentPath.strokeWidth);
287 | canvas.drawPath(currentPath.path, mPaint);
288 | }
289 | return blackBitmap;
290 | }
291 |
292 |
293 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/drawing_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
53 |
54 |
55 |
63 |
64 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
94 |
95 |
99 |
100 |
104 |
105 |
110 |
111 |
112 |
121 |
122 |
123 |
130 |
131 |
134 |
135 |
144 |
145 |
146 |
147 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
163 |
164 |
165 |
169 |
170 |
176 |
177 |
183 |
184 |
185 |
186 |
187 |
192 |
193 |
199 |
200 |
201 |
202 |
203 |
208 |
209 |
215 |
216 |
217 |
222 |
223 |
229 |
230 |
231 |
232 |
233 |
234 |
240 |
241 |
248 |
249 |
254 |
255 |
256 |
257 |
263 |
264 |
267 |
268 |
274 |
275 |
280 |
281 |
282 |
283 |
284 |
285 |
291 |
292 |
293 |
--------------------------------------------------------------------------------
/app/src/main/java/com/serhat/aieditor/adapter/HistoryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.serhat.aieditor.adapter;
2 |
3 | import android.content.DialogInterface;
4 |
5 | import android.view.LayoutInflater;
6 | import android.view.Menu;
7 | import android.view.MenuInflater;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.appcompat.view.ActionMode;
15 | import androidx.recyclerview.widget.RecyclerView;
16 |
17 |
18 | import com.bumptech.glide.Glide;
19 | import com.google.android.flexbox.FlexboxLayoutManager;
20 | import com.google.android.material.dialog.MaterialAlertDialogBuilder;
21 | import com.serhat.aieditor.GalleryActivity;
22 | import com.serhat.aieditor.R;
23 | import com.serhat.aieditor.Utils;
24 | import com.serhat.aieditor.model.GalleryModel;
25 |
26 | import java.io.File;
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | public class HistoryAdapter extends RecyclerView.Adapter {
31 |
32 | private ActionMode mActionMode;
33 |
34 | private List listData = new ArrayList<>();
35 |
36 | private List tempListData = new ArrayList<>();
37 |
38 | private GalleryActivity activity;
39 |
40 | private CurrTab currTab = CurrTab.HISTORY;
41 |
42 | public enum CurrTab {
43 | HISTORY, SAVED, UPSCALED
44 | }
45 |
46 |
47 | private boolean isMultiSelectMode = false;
48 |
49 |
50 | public HistoryAdapter(GalleryActivity activity, List listData, CurrTab currTab) {
51 | this.activity = activity;
52 | this.listData = listData;
53 | this.currTab = currTab;
54 | }
55 |
56 |
57 | @NonNull
58 | @Override
59 | public HistoryAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
60 | return new HistoryAdapterViewHolder(LayoutInflater.from(parent.getContext())
61 | .inflate(R.layout.gallery_item, parent, false));
62 | }
63 |
64 | @Override
65 | public void onBindViewHolder(@NonNull HistoryAdapterViewHolder holder, int position) {
66 | holder.onBind(listData.get(position));
67 | }
68 |
69 | public boolean isListEmpty() {
70 | return listData == null || listData.size() == 0;
71 | }
72 |
73 | public void deleteItem(int pos) {
74 | this.listData.remove(pos);
75 | notifyItemRemoved(pos);
76 | }
77 |
78 |
79 | public void clearList() {
80 | this.listData.clear();
81 | notifyDataSetChanged();
82 | }
83 |
84 | @Override
85 | public int getItemCount() {
86 | return listData.size();
87 | }
88 |
89 |
90 | public class HistoryAdapterViewHolder extends RecyclerView.ViewHolder {
91 |
92 | private ImageView imageView, selected_IV;
93 | private View view;
94 |
95 |
96 | public HistoryAdapterViewHolder(@NonNull View itemView) {
97 | super(itemView);
98 | imageView = itemView.findViewById(R.id.galleryImage);
99 | selected_IV = itemView.findViewById(R.id.selected_IV);
100 | view = itemView;
101 | }
102 |
103 |
104 | public void onBind(GalleryModel galleryModel) {
105 | // imageView.setImageURI(Uri.parse(galleryModel.path));
106 |
107 |
108 | if (galleryModel.path != null) {
109 | File file = new File(galleryModel.path);
110 | if (file.exists()) {
111 | // BitmapFactory.Options options = new BitmapFactory.Options();
112 | // options.inJustDecodeBounds = true;
113 | // BitmapFactory.decodeFile(galleryModel.path, options);
114 | // int imageWidth = options.outWidth;
115 | // int imageHeight = options.outHeight;
116 | view.getLayoutParams().width = Utils.pxToDp(activity, galleryModel.width);
117 | view.getLayoutParams().height = Utils.pxToDp(activity, galleryModel.height);
118 | Glide.with(itemView.getContext()).load(file)
119 | .into(imageView);
120 | // imageView.setImageURI(Uri.parse(galleryModel.path));
121 | }
122 | }
123 | if (galleryModel.isSelected) {
124 | selected_IV.setVisibility(View.VISIBLE);
125 | } else {
126 | selected_IV.setVisibility(View.GONE);
127 | }
128 |
129 |
130 | ViewGroup.LayoutParams lp = view.getLayoutParams();
131 | if (lp instanceof FlexboxLayoutManager.LayoutParams) {
132 | ((FlexboxLayoutManager.LayoutParams) lp).setFlexGrow(1f);
133 | }
134 |
135 |
136 | view.setOnClickListener(new View.OnClickListener() {
137 | @Override
138 | public void onClick(View v) {
139 | if (isMultiSelectMode) {
140 | if (galleryModel.isSelected) {
141 | galleryModel.isSelected = false;
142 | selected_IV.setVisibility(View.GONE);
143 | tempListData.remove(galleryModel);
144 | if (tempListData.size() == 0) {
145 | isMultiSelectMode = false;
146 | if (mActionMode != null) {
147 | mActionMode.finish();
148 | }
149 | } else {
150 | if (mActionMode != null) {
151 | mActionMode.setTitle("Selected: " + tempListData.size() + "/" + getItemCount());
152 | }
153 | }
154 | } else {
155 | galleryModel.isSelected = true;
156 | selected_IV.setVisibility(View.VISIBLE);
157 | tempListData.add(galleryModel);
158 | if (mActionMode != null) {
159 | mActionMode.setTitle("Selected: " + tempListData.size() + "/" + getItemCount());
160 | }
161 | }
162 | } else {
163 | activity.openImageFullscreen(galleryModel);
164 | }
165 | }
166 | });
167 |
168 | view.setOnLongClickListener(new View.OnLongClickListener() {
169 | @Override
170 | public boolean onLongClick(View v) {
171 | if (galleryModel.isSelected) {
172 | galleryModel.isSelected = false;
173 | selected_IV.setVisibility(View.GONE);
174 | tempListData.remove(galleryModel);
175 | if (tempListData.size() == 0) {
176 | isMultiSelectMode = false;
177 | if (mActionMode != null) {
178 | mActionMode.finish();
179 | }
180 | } else {
181 | if (mActionMode != null) {
182 | mActionMode.setTitle("Selected: " + tempListData.size() + "/" + getItemCount());
183 | }
184 | }
185 |
186 | } else {
187 | galleryModel.isSelected = true;
188 | selected_IV.setVisibility(View.VISIBLE);
189 | tempListData.add(galleryModel);
190 | isMultiSelectMode = true;
191 | if (mActionMode == null) {
192 | mActionMode = activity.startSupportActionMode(mActionModeCallback);
193 | mActionMode.setTitle("Selected: " + tempListData.size() + "/" + getItemCount());
194 | }
195 |
196 | }
197 |
198 |
199 | // historyClick.onHistoryLongClick(galleryModel, getAdapterPosition());
200 | return true;
201 | }
202 | });
203 |
204 | }
205 | }
206 |
207 | public void enableActionMode() {
208 | if (mActionMode == null) {
209 | mActionMode = activity.startSupportActionMode(mActionModeCallback);
210 | mActionMode.setTitle("Selected: " + tempListData.size() + "/" + getItemCount());
211 | isMultiSelectMode = true;
212 | }
213 | }
214 |
215 | private void showSelectedRemoveDialog() {
216 | new MaterialAlertDialogBuilder(activity)
217 | .setTitle("Delete Selected Images?")
218 | .setMessage("Are you sure you want yo delete all of the selected images?")
219 | .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
220 | @Override
221 | public void onClick(DialogInterface dialog, int which) {
222 | removeItems();
223 | }
224 | }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
225 | @Override
226 | public void onClick(DialogInterface dialog, int which) {
227 | dialog.dismiss();
228 | }
229 | }).show();
230 | }
231 |
232 | public ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
233 |
234 | @Override
235 | public boolean onCreateActionMode(ActionMode mode, Menu menu) {
236 | MenuInflater inflater = mode.getMenuInflater();
237 | inflater.inflate(R.menu.multi_select, menu);
238 | return true;
239 | }
240 |
241 | @Override
242 | public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
243 | return false;
244 | }
245 |
246 | @Override
247 | public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
248 | int id = item.getItemId();
249 | if (id == R.id.delete_multi) {
250 | showSelectedRemoveDialog();
251 | return true;
252 | }
253 | return false;
254 | }
255 |
256 |
257 | @Override
258 | public void onDestroyActionMode(ActionMode mode) {
259 | mActionMode = null;
260 | isMultiSelectMode = false;
261 | removeTicks();
262 | }
263 | };
264 |
265 |
266 | private void removeItems() {
267 | if (tempListData.size() > 0) {
268 | for (GalleryModel item : tempListData) {
269 | int index = listData.indexOf(item);
270 | if (index != -1) {
271 | item.deleteFromDisk();
272 | if (currTab == CurrTab.HISTORY) {
273 | activity.databaseHelper.deleteHistoryByID(item.id);
274 | } else if (currTab == CurrTab.SAVED) {
275 | activity.databaseHelper.deleteSavedByID(item.id);
276 | } else if (currTab == CurrTab.UPSCALED) {
277 | activity.databaseHelper.deleteUpscaledByID(item.id);
278 | }
279 | listData.remove(item);
280 | notifyItemRemoved(index);
281 | }
282 | }
283 | tempListData.clear();
284 | if (mActionMode != null) {
285 | mActionMode.finish();
286 | }
287 | }
288 | }
289 |
290 | private void removeTicks() {
291 | if (tempListData.size() > 0) {
292 | for (GalleryModel item : tempListData) {
293 | int index = listData.indexOf(item);
294 | if (index != -1) {
295 | listData.get(index).isSelected = false;
296 | notifyItemChanged(index);
297 | }
298 | }
299 | tempListData.clear();
300 | }
301 | }
302 |
303 |
304 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
13 |
14 |
21 |
22 |
30 |
31 |
40 |
41 |
48 |
49 |
53 |
54 |
62 |
63 |
70 |
71 |
72 |
73 |
74 |
78 |
79 |
85 |
86 |
91 |
92 |
93 |
94 |
95 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
120 |
121 |
128 |
129 |
133 |
134 |
142 |
143 |
150 |
151 |
155 |
156 |
157 |
158 |
159 |
160 |
166 |
167 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
189 |
190 |
197 |
198 |
202 |
203 |
211 |
212 |
219 |
220 |
225 |
226 |
227 |
228 |
229 |
230 |
236 |
237 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
259 |
260 |
267 |
268 |
272 |
273 |
281 |
282 |
289 |
290 |
291 |
292 |
293 |
300 |
301 |
302 |
307 |
308 |
313 |
314 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
341 |
342 |
347 |
348 |
356 |
357 |
364 |
365 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
--------------------------------------------------------------------------------