From 40006794ecca2d5c45d40644ae2f512b6fdae41c Mon Sep 17 00:00:00 2001 From: Nan YE Date: Mon, 3 Jul 2023 15:16:02 +0800 Subject: [PATCH] [sample-gallery-core][INIT]: module initialization fro sample gallery core; [sample-gallery][DEV]: code refactor to adapt to latest project structure; --- build.gradle | 4 +- sample-gallery-core/.gitignore | 2 + sample-gallery-core/build.gradle | 66 ++++++++++++++++++ sample-gallery-core/consumer-rules.pro | 0 sample-gallery-core/gradle.properties | 2 + sample-gallery-core/proguard-rules.pro | 21 ++++++ .../gallery/core/ExampleInstrumentedTest.kt | 24 +++++++ .../src/main/AndroidManifest.xml | 2 + .../devbricksx/gallery/Constants.kt | 0 .../devbricksx/gallery/Directories.kt | 0 .../devbricksx/gallery/GalleryApplication.kt | 1 + .../devbricksx/gallery/api/UnsplashApi.kt | 3 +- .../devbricksx/gallery/api/data/Exif.kt | 0 .../devbricksx/gallery/api/data/Links.kt | 0 .../devbricksx/gallery/api/data/Photo.kt | 0 .../devbricksx/gallery/api/data/Urls.kt | 0 .../devbricksx/gallery/api/data/User.kt | 0 .../devbricksx/gallery/db/PhotoItem.kt | 2 +- .../gallery/db/PhotoItemMediator.kt | 0 .../devbricksx/gallery/db/UserItem.kt | 0 .../gallery/model/PhotoItemViewModel.kt | 0 .../gallery/model/UserItemViewModelExt.kt | 0 .../src/main/res/anim/slide_in_left.xml | 26 +++++++ .../src/main/res/anim/slide_in_right.xml | 26 +++++++ .../src/main/res/anim/slide_out_left.xml | 26 +++++++ .../src/main/res/anim/slide_out_right.xml | 26 +++++++ .../res/drawable-anydpi/ic_action_search.xml | 0 .../ic_action_search_clear.xml | 0 .../drawable-hdpi/ic_action_search_clear.png | Bin .../drawable-mdpi/ic_action_search_clear.png | Bin .../src/main/res/drawable-nodpi/app_thumb.jpg | Bin .../drawable-xhdpi/ic_action_search_clear.png | Bin .../ic_action_search_clear.png | Bin .../main/res/drawable/ic_action_download.xml | 0 .../res/drawable/ic_launcher_foreground.xml | 0 .../src/main/res/drawable/photo_badge.xml | 0 .../photo_item_supporting_background.xml | 0 .../drawable/photo_item_title_background.xml | 0 .../src/main/res/layout/layout_photo_item.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../src/main/res/values/colors.xml | 11 +++ .../src/main/res/values/config.xml | 5 ++ .../src/main/res/values/dimens.xml | 19 +++++ .../res/values/ic_launcher_background.xml | 0 .../src/main/res/values/strings.xml | 15 ++++ .../src/main/res/values/themes.xml | 51 ++++++++++++++ .../gallery/core/ExampleUnitTest.kt | 17 +++++ sample-gallery/.gitignore | 3 +- sample-gallery/build.gradle | 5 +- sample-gallery/gradle.properties | 2 +- .../gallery/fragment/AboutFragment.kt | 2 +- .../fragment/PhotoItemsListFragmentExt.kt | 7 +- .../gallery/fragment/PhotoViewFragment.kt | 7 +- sample-gallery/src/main/res/values/colors.xml | 8 --- sample-gallery/src/main/res/values/config.xml | 1 - sample-gallery/src/main/res/values/dimens.xml | 15 ---- .../src/main/res/values/strings.xml | 13 ---- sample-gallery/src/main/res/values/themes.xml | 48 ------------- settings.gradle | 1 + 60 files changed, 357 insertions(+), 104 deletions(-) create mode 100644 sample-gallery-core/.gitignore create mode 100644 sample-gallery-core/build.gradle create mode 100644 sample-gallery-core/consumer-rules.pro create mode 100644 sample-gallery-core/gradle.properties create mode 100644 sample-gallery-core/proguard-rules.pro create mode 100644 sample-gallery-core/src/androidTest/java/com/dailystudio/devbricksx/gallery/core/ExampleInstrumentedTest.kt create mode 100644 sample-gallery-core/src/main/AndroidManifest.xml rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/Constants.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/Directories.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt (95%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt (98%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Exif.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Links.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Photo.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Urls.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/api/data/User.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt (99%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItemMediator.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/db/UserItem.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/model/PhotoItemViewModel.kt (100%) rename {sample-gallery => sample-gallery-core}/src/main/java/com/dailystudio/devbricksx/gallery/model/UserItemViewModelExt.kt (100%) create mode 100644 sample-gallery-core/src/main/res/anim/slide_in_left.xml create mode 100644 sample-gallery-core/src/main/res/anim/slide_in_right.xml create mode 100644 sample-gallery-core/src/main/res/anim/slide_out_left.xml create mode 100644 sample-gallery-core/src/main/res/anim/slide_out_right.xml rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-anydpi/ic_action_search.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-anydpi/ic_action_search_clear.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-hdpi/ic_action_search_clear.png (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-mdpi/ic_action_search_clear.png (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-nodpi/app_thumb.jpg (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-xhdpi/ic_action_search_clear.png (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable-xxhdpi/ic_action_search_clear.png (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable/ic_action_download.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable/ic_launcher_foreground.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable/photo_badge.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable/photo_item_supporting_background.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/drawable/photo_item_title_background.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/layout/layout_photo_item.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename {sample-gallery => sample-gallery-core}/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) create mode 100644 sample-gallery-core/src/main/res/values/colors.xml create mode 100644 sample-gallery-core/src/main/res/values/config.xml create mode 100644 sample-gallery-core/src/main/res/values/dimens.xml rename {sample-gallery => sample-gallery-core}/src/main/res/values/ic_launcher_background.xml (100%) create mode 100644 sample-gallery-core/src/main/res/values/strings.xml create mode 100644 sample-gallery-core/src/main/res/values/themes.xml create mode 100644 sample-gallery-core/src/test/java/com/dailystudio/devbricksx/gallery/core/ExampleUnitTest.kt diff --git a/build.gradle b/build.gradle index 1cf0db53..46bff9d4 100644 --- a/build.gradle +++ b/build.gradle @@ -64,9 +64,9 @@ ext { } // Unsplash.com API - if (file("sample-gallery/apikey.unsplash").exists()) { + if (file("sample-gallery-core/apikey.unsplash").exists()) { Properties props = new Properties() - props.load(new FileInputStream(file("sample-gallery/apikey.unsplash"))) + props.load(new FileInputStream(file("sample-gallery-core/apikey.unsplash"))) UNSPLASH_API_KEY = props.getProperty('API_KEY') } else { diff --git a/sample-gallery-core/.gitignore b/sample-gallery-core/.gitignore new file mode 100644 index 00000000..bad70197 --- /dev/null +++ b/sample-gallery-core/.gitignore @@ -0,0 +1,2 @@ +/build +apikey.unsplash \ No newline at end of file diff --git a/sample-gallery-core/build.gradle b/sample-gallery-core/build.gradle new file mode 100644 index 00000000..12bd505f --- /dev/null +++ b/sample-gallery-core/build.gradle @@ -0,0 +1,66 @@ +plugins { + id 'com.android.library' + id 'kotlin-android' + + id("cn.dailystudio.devbricksx.devkit") version "$devkit_version" +} + +android { + compileSdkVersion COMPILE_SDK + buildToolsVersion BUILD_TOOLS + + defaultConfig { + namespace "com.dailystudio.devbricksx.gallery.core" + + minSdkVersion 21 + targetSdkVersion TARGET_SDK + versionCode VERSION_CODE + versionName VERSION_NAME + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + vectorDrawables { + useSupportLibrary = true + } + + resValue "string", "api_key", "${project.UNSPLASH_API_KEY}" + + multiDexEnabled true + } + + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + buildFeatures { + buildConfig true + } + + compileOptions { + sourceCompatibility JAVA_VERSION + targetCompatibility JAVA_VERSION + } + + kotlinOptions { + jvmTarget = JVM_TARGET + } +} + +devKit { + compileType = "Project" + devKitComps = [ "Network"] +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + api("io.coil-kt:coil:${project.ext.coilVersion}") + api "com.github.Rasalexman:KDispatcher:${project.ext.kdispatcherVersion}" +} diff --git a/sample-gallery-core/consumer-rules.pro b/sample-gallery-core/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/sample-gallery-core/gradle.properties b/sample-gallery-core/gradle.properties new file mode 100644 index 00000000..5760a47d --- /dev/null +++ b/sample-gallery-core/gradle.properties @@ -0,0 +1,2 @@ +kdispatcherVersion = 1.1.92 +coilVersion = 2.2.2 diff --git a/sample-gallery-core/proguard-rules.pro b/sample-gallery-core/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/sample-gallery-core/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/sample-gallery-core/src/androidTest/java/com/dailystudio/devbricksx/gallery/core/ExampleInstrumentedTest.kt b/sample-gallery-core/src/androidTest/java/com/dailystudio/devbricksx/gallery/core/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..28e36f02 --- /dev/null +++ b/sample-gallery-core/src/androidTest/java/com/dailystudio/devbricksx/gallery/core/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.dailystudio.devbricks.gallery.core + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.dailystudio.devbricks.gallery.core.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/sample-gallery-core/src/main/AndroidManifest.xml b/sample-gallery-core/src/main/AndroidManifest.xml new file mode 100644 index 00000000..1d26c87a --- /dev/null +++ b/sample-gallery-core/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/Constants.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/Constants.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/Constants.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/Constants.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/Directories.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/Directories.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/Directories.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/Directories.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt similarity index 95% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt index 7aa60afe..3d5f8089 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt +++ b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/GalleryApplication.kt @@ -6,6 +6,7 @@ import coil.Coil import coil.ImageLoader import com.dailystudio.devbricksx.app.DevBricksMultiDexApplication import com.dailystudio.devbricksx.development.Logger +import com.dailystudio.devbricksx.gallery.core.BuildConfig class CustomizedLogger: coil.util.Logger { diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt similarity index 98% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt index 18b4565c..c52a93bb 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt +++ b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/UnsplashApi.kt @@ -3,7 +3,6 @@ package com.dailystudio.devbricksx.gallery.api import android.net.Uri import com.dailystudio.devbricksx.GlobalContextWrapper import com.dailystudio.devbricksx.development.Logger -import com.dailystudio.devbricksx.gallery.R import com.dailystudio.devbricksx.gallery.api.data.Links import com.dailystudio.devbricksx.gallery.api.data.PageResults import com.dailystudio.devbricksx.gallery.api.data.Photo @@ -218,7 +217,7 @@ object UnsplashApi: AuthenticatedNetworkApi() { override val defaultAuthInfo: Map get() { val apiKey = GlobalContextWrapper.context?.let { - it.getString(R.string.api_key) + it.getString(com.dailystudio.devbricksx.gallery.core.R.string.api_key) } return mutableMapOf( diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Exif.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Exif.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Exif.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Exif.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Links.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Links.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Links.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Links.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Photo.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Photo.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Photo.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Photo.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Urls.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Urls.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Urls.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/Urls.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/User.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/User.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/api/data/User.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/api/data/User.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt similarity index 99% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt index 02523071..836a9a05 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt +++ b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItem.kt @@ -17,9 +17,9 @@ import com.dailystudio.devbricksx.annotations.viewmodel.ViewModel import com.dailystudio.devbricksx.database.DateConverter import com.dailystudio.devbricksx.database.StringIdRecord import com.dailystudio.devbricksx.development.Logger -import com.dailystudio.devbricksx.gallery.R import com.dailystudio.devbricksx.gallery.api.data.Links import com.dailystudio.devbricksx.gallery.api.data.Photo +import com.dailystudio.devbricksx.gallery.core.R import com.dailystudio.devbricksx.ui.AbsCardViewHolder import java.lang.IllegalArgumentException import java.text.DateFormat diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItemMediator.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItemMediator.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItemMediator.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/PhotoItemMediator.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/UserItem.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/UserItem.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/db/UserItem.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/db/UserItem.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/model/PhotoItemViewModel.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/model/PhotoItemViewModel.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/model/PhotoItemViewModel.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/model/PhotoItemViewModel.kt diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/model/UserItemViewModelExt.kt b/sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/model/UserItemViewModelExt.kt similarity index 100% rename from sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/model/UserItemViewModelExt.kt rename to sample-gallery-core/src/main/java/com/dailystudio/devbricksx/gallery/model/UserItemViewModelExt.kt diff --git a/sample-gallery-core/src/main/res/anim/slide_in_left.xml b/sample-gallery-core/src/main/res/anim/slide_in_left.xml new file mode 100644 index 00000000..f6aaba96 --- /dev/null +++ b/sample-gallery-core/src/main/res/anim/slide_in_left.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sample-gallery-core/src/main/res/anim/slide_in_right.xml b/sample-gallery-core/src/main/res/anim/slide_in_right.xml new file mode 100644 index 00000000..3bbb214c --- /dev/null +++ b/sample-gallery-core/src/main/res/anim/slide_in_right.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sample-gallery-core/src/main/res/anim/slide_out_left.xml b/sample-gallery-core/src/main/res/anim/slide_out_left.xml new file mode 100644 index 00000000..8b0da00a --- /dev/null +++ b/sample-gallery-core/src/main/res/anim/slide_out_left.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sample-gallery-core/src/main/res/anim/slide_out_right.xml b/sample-gallery-core/src/main/res/anim/slide_out_right.xml new file mode 100644 index 00000000..64871dc8 --- /dev/null +++ b/sample-gallery-core/src/main/res/anim/slide_out_right.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sample-gallery/src/main/res/drawable-anydpi/ic_action_search.xml b/sample-gallery-core/src/main/res/drawable-anydpi/ic_action_search.xml similarity index 100% rename from sample-gallery/src/main/res/drawable-anydpi/ic_action_search.xml rename to sample-gallery-core/src/main/res/drawable-anydpi/ic_action_search.xml diff --git a/sample-gallery/src/main/res/drawable-anydpi/ic_action_search_clear.xml b/sample-gallery-core/src/main/res/drawable-anydpi/ic_action_search_clear.xml similarity index 100% rename from sample-gallery/src/main/res/drawable-anydpi/ic_action_search_clear.xml rename to sample-gallery-core/src/main/res/drawable-anydpi/ic_action_search_clear.xml diff --git a/sample-gallery/src/main/res/drawable-hdpi/ic_action_search_clear.png b/sample-gallery-core/src/main/res/drawable-hdpi/ic_action_search_clear.png similarity index 100% rename from sample-gallery/src/main/res/drawable-hdpi/ic_action_search_clear.png rename to sample-gallery-core/src/main/res/drawable-hdpi/ic_action_search_clear.png diff --git a/sample-gallery/src/main/res/drawable-mdpi/ic_action_search_clear.png b/sample-gallery-core/src/main/res/drawable-mdpi/ic_action_search_clear.png similarity index 100% rename from sample-gallery/src/main/res/drawable-mdpi/ic_action_search_clear.png rename to sample-gallery-core/src/main/res/drawable-mdpi/ic_action_search_clear.png diff --git a/sample-gallery/src/main/res/drawable-nodpi/app_thumb.jpg b/sample-gallery-core/src/main/res/drawable-nodpi/app_thumb.jpg similarity index 100% rename from sample-gallery/src/main/res/drawable-nodpi/app_thumb.jpg rename to sample-gallery-core/src/main/res/drawable-nodpi/app_thumb.jpg diff --git a/sample-gallery/src/main/res/drawable-xhdpi/ic_action_search_clear.png b/sample-gallery-core/src/main/res/drawable-xhdpi/ic_action_search_clear.png similarity index 100% rename from sample-gallery/src/main/res/drawable-xhdpi/ic_action_search_clear.png rename to sample-gallery-core/src/main/res/drawable-xhdpi/ic_action_search_clear.png diff --git a/sample-gallery/src/main/res/drawable-xxhdpi/ic_action_search_clear.png b/sample-gallery-core/src/main/res/drawable-xxhdpi/ic_action_search_clear.png similarity index 100% rename from sample-gallery/src/main/res/drawable-xxhdpi/ic_action_search_clear.png rename to sample-gallery-core/src/main/res/drawable-xxhdpi/ic_action_search_clear.png diff --git a/sample-gallery/src/main/res/drawable/ic_action_download.xml b/sample-gallery-core/src/main/res/drawable/ic_action_download.xml similarity index 100% rename from sample-gallery/src/main/res/drawable/ic_action_download.xml rename to sample-gallery-core/src/main/res/drawable/ic_action_download.xml diff --git a/sample-gallery/src/main/res/drawable/ic_launcher_foreground.xml b/sample-gallery-core/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from sample-gallery/src/main/res/drawable/ic_launcher_foreground.xml rename to sample-gallery-core/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/sample-gallery/src/main/res/drawable/photo_badge.xml b/sample-gallery-core/src/main/res/drawable/photo_badge.xml similarity index 100% rename from sample-gallery/src/main/res/drawable/photo_badge.xml rename to sample-gallery-core/src/main/res/drawable/photo_badge.xml diff --git a/sample-gallery/src/main/res/drawable/photo_item_supporting_background.xml b/sample-gallery-core/src/main/res/drawable/photo_item_supporting_background.xml similarity index 100% rename from sample-gallery/src/main/res/drawable/photo_item_supporting_background.xml rename to sample-gallery-core/src/main/res/drawable/photo_item_supporting_background.xml diff --git a/sample-gallery/src/main/res/drawable/photo_item_title_background.xml b/sample-gallery-core/src/main/res/drawable/photo_item_title_background.xml similarity index 100% rename from sample-gallery/src/main/res/drawable/photo_item_title_background.xml rename to sample-gallery-core/src/main/res/drawable/photo_item_title_background.xml diff --git a/sample-gallery/src/main/res/layout/layout_photo_item.xml b/sample-gallery-core/src/main/res/layout/layout_photo_item.xml similarity index 100% rename from sample-gallery/src/main/res/layout/layout_photo_item.xml rename to sample-gallery-core/src/main/res/layout/layout_photo_item.xml diff --git a/sample-gallery/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/sample-gallery-core/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from sample-gallery/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to sample-gallery-core/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/sample-gallery/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/sample-gallery-core/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from sample-gallery/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to sample-gallery-core/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/sample-gallery-core/src/main/res/values/colors.xml b/sample-gallery-core/src/main/res/values/colors.xml new file mode 100644 index 00000000..8843170e --- /dev/null +++ b/sample-gallery-core/src/main/res/values/colors.xml @@ -0,0 +1,11 @@ + + + #d32f2f + #ff6659 + #9a0007 + #3949ab + #6f74dd + #00227b + #ffffff + #ffffff + \ No newline at end of file diff --git a/sample-gallery-core/src/main/res/values/config.xml b/sample-gallery-core/src/main/res/values/config.xml new file mode 100644 index 00000000..8064c6c8 --- /dev/null +++ b/sample-gallery-core/src/main/res/values/config.xml @@ -0,0 +1,5 @@ + + + 400 + + diff --git a/sample-gallery-core/src/main/res/values/dimens.xml b/sample-gallery-core/src/main/res/values/dimens.xml new file mode 100644 index 00000000..dcb9b40c --- /dev/null +++ b/sample-gallery-core/src/main/res/values/dimens.xml @@ -0,0 +1,19 @@ + + + + + 0dp + 0dp + + 12dp + 150dp + 6dp + 6dp + 10dp + 80dp + + 18dp + 14dp + 32dp + + diff --git a/sample-gallery/src/main/res/values/ic_launcher_background.xml b/sample-gallery-core/src/main/res/values/ic_launcher_background.xml similarity index 100% rename from sample-gallery/src/main/res/values/ic_launcher_background.xml rename to sample-gallery-core/src/main/res/values/ic_launcher_background.xml diff --git a/sample-gallery-core/src/main/res/values/strings.xml b/sample-gallery-core/src/main/res/values/strings.xml new file mode 100644 index 00000000..fb9cab5d --- /dev/null +++ b/sample-gallery-core/src/main/res/values/strings.xml @@ -0,0 +1,15 @@ + + Gallery + This is a sample application written with DevbricksX library. It illustrates how to use the library to compose a gallery app in the most efficient way.\n\nIt shows numerous high-quality images from Unsplash.com. Plus, you can search images on that website with your keywords.\n\nIf you have any problem, please feel free to contact me:\n\n\t\t\tdailystudio2010@gmail.com\n + + by %1$s\u00A0 + unsplash.com\u00A0 + + Search + Clear search + About + + Unsplash.com + + + \ No newline at end of file diff --git a/sample-gallery-core/src/main/res/values/themes.xml b/sample-gallery-core/src/main/res/values/themes.xml new file mode 100644 index 00000000..d389fdd6 --- /dev/null +++ b/sample-gallery-core/src/main/res/values/themes.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sample-gallery-core/src/test/java/com/dailystudio/devbricksx/gallery/core/ExampleUnitTest.kt b/sample-gallery-core/src/test/java/com/dailystudio/devbricksx/gallery/core/ExampleUnitTest.kt new file mode 100644 index 00000000..392a5499 --- /dev/null +++ b/sample-gallery-core/src/test/java/com/dailystudio/devbricksx/gallery/core/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.dailystudio.devbricks.gallery.core + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/sample-gallery/.gitignore b/sample-gallery/.gitignore index bad70197..42afabfd 100644 --- a/sample-gallery/.gitignore +++ b/sample-gallery/.gitignore @@ -1,2 +1 @@ -/build -apikey.unsplash \ No newline at end of file +/build \ No newline at end of file diff --git a/sample-gallery/build.gradle b/sample-gallery/build.gradle index ef7bd812..0d249f5f 100644 --- a/sample-gallery/build.gradle +++ b/sample-gallery/build.gradle @@ -25,8 +25,6 @@ android { useSupportLibrary = true } - resValue "string", "api_key", "${project.UNSPLASH_API_KEY}" - multiDexEnabled true } @@ -65,9 +63,8 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation("io.coil-kt:coil:${project.ext.coilVersion}") + implementation(project(":sample-gallery-core")) implementation "androidx.navigation:navigation-fragment-ktx:${project.ext.navigationVersion}" implementation "androidx.navigation:navigation-ui-ktx:${project.ext.navigationVersion}" - implementation "com.github.Rasalexman:KDispatcher:${project.ext.kdispatcherVersion}" } diff --git a/sample-gallery/gradle.properties b/sample-gallery/gradle.properties index f48a1e8f..ec19b8c9 100644 --- a/sample-gallery/gradle.properties +++ b/sample-gallery/gradle.properties @@ -1,5 +1,5 @@ multidex = 1.0.3 -navigationVersion = 2.5.3 +navigationVersion = 2.6.0 kdispatcherVersion = 1.1.92 retrofitVersion = 2.9.0 coilVersion = 2.2.2 diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/AboutFragment.kt b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/AboutFragment.kt index 2cc466a0..5b436faf 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/AboutFragment.kt +++ b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/AboutFragment.kt @@ -1,7 +1,7 @@ package com.dailystudio.devbricksx.gallery.fragment import com.dailystudio.devbricksx.fragment.AbsAboutFragment -import com.dailystudio.devbricksx.gallery.R +import com.dailystudio.devbricksx.gallery.core.R class AboutFragment: AbsAboutFragment() { override val appName: CharSequence? diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoItemsListFragmentExt.kt b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoItemsListFragmentExt.kt index b0e6e686..fc31886a 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoItemsListFragmentExt.kt +++ b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoItemsListFragmentExt.kt @@ -14,7 +14,6 @@ import androidx.paging.* import androidx.recyclerview.widget.RecyclerView import com.dailystudio.devbricksx.development.Logger import com.dailystudio.devbricksx.gallery.Constants -import com.dailystudio.devbricksx.gallery.R import com.dailystudio.devbricksx.gallery.api.UnsplashApiInterface import com.dailystudio.devbricksx.gallery.db.PhotoItem import com.dailystudio.devbricksx.gallery.db.PhotoItemMediator @@ -25,6 +24,8 @@ import com.google.android.material.appbar.MaterialToolbar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn +import com.dailystudio.devbricksx.gallery.R as R +import com.dailystudio.devbricksx.gallery.core.R as coreR class PhotoItemsListFragmentExt: PhotoItemsListFragment() { @@ -56,11 +57,11 @@ class PhotoItemsListFragmentExt: PhotoItemsListFragment() { setHasOptionsMenu(true) SystemBarsUtils.statusBarColor( requireActivity(), - ResourcesCompatUtils.getColor(requireContext(), R.color.primaryColor) + ResourcesCompatUtils.getColor(requireContext(), coreR.color.primaryColor) ) topBar = fragmentView.findViewById(R.id.topAppBar) - topBar?.setTitle(R.string.app_name) + topBar?.setTitle(coreR.string.app_name) disableItemChangeDuration() } diff --git a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoViewFragment.kt b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoViewFragment.kt index 1a5e7f58..837e8fe4 100644 --- a/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoViewFragment.kt +++ b/sample-gallery/src/main/java/com/dailystudio/devbricksx/gallery/fragment/PhotoViewFragment.kt @@ -25,7 +25,8 @@ import coil.transform.CircleCropTransformation import com.dailystudio.devbricksx.development.Logger import com.dailystudio.devbricksx.fragment.AbsPermissionsFragment import com.dailystudio.devbricksx.gallery.Directories -import com.dailystudio.devbricksx.gallery.R +import com.dailystudio.devbricksx.gallery.R as R +import com.dailystudio.devbricksx.gallery.core.R as coreR import com.dailystudio.devbricksx.gallery.api.ImageApi import com.dailystudio.devbricksx.gallery.model.UserItemViewModelExt import com.dailystudio.devbricksx.utils.FileUtils @@ -81,7 +82,7 @@ class PhotoViewFragment: AbsPermissionsFragment() { /* * Improve Status Bar transformation during navigation animation */ - delay(resources.getInteger(R.integer.animLength)/ 2L) + delay(resources.getInteger(coreR.integer.animLength)/ 2L) withContext(Dispatchers.Main) { SystemBarsUtils.statusBarColor(requireActivity(), Color.TRANSPARENT @@ -120,7 +121,7 @@ class PhotoViewFragment: AbsPermissionsFragment() { iconView?.backgroundTintList = (ColorStateList.valueOf(Color.parseColor(args.color))) sourceView = view.findViewById(R.id.image_source) - sourceView?.text = getString(R.string.source_unsplash) + sourceView?.text = getString(coreR.string.source_unsplash) saveButton = view.findViewById(R.id.download) saveButton?.setOnClickListener { diff --git a/sample-gallery/src/main/res/values/colors.xml b/sample-gallery/src/main/res/values/colors.xml index 8843170e..93cecdd6 100644 --- a/sample-gallery/src/main/res/values/colors.xml +++ b/sample-gallery/src/main/res/values/colors.xml @@ -1,11 +1,3 @@ - #d32f2f - #ff6659 - #9a0007 - #3949ab - #6f74dd - #00227b - #ffffff - #ffffff \ No newline at end of file diff --git a/sample-gallery/src/main/res/values/config.xml b/sample-gallery/src/main/res/values/config.xml index 8064c6c8..0e8722a4 100644 --- a/sample-gallery/src/main/res/values/config.xml +++ b/sample-gallery/src/main/res/values/config.xml @@ -1,5 +1,4 @@ - 400 diff --git a/sample-gallery/src/main/res/values/dimens.xml b/sample-gallery/src/main/res/values/dimens.xml index dcb9b40c..1a0eb548 100644 --- a/sample-gallery/src/main/res/values/dimens.xml +++ b/sample-gallery/src/main/res/values/dimens.xml @@ -1,19 +1,4 @@ - - 0dp - 0dp - - 12dp - 150dp - 6dp - 6dp - 10dp - 80dp - - 18dp - 14dp - 32dp - diff --git a/sample-gallery/src/main/res/values/strings.xml b/sample-gallery/src/main/res/values/strings.xml index fb9cab5d..e5f8fdc2 100644 --- a/sample-gallery/src/main/res/values/strings.xml +++ b/sample-gallery/src/main/res/values/strings.xml @@ -1,15 +1,2 @@ - Gallery - This is a sample application written with DevbricksX library. It illustrates how to use the library to compose a gallery app in the most efficient way.\n\nIt shows numerous high-quality images from Unsplash.com. Plus, you can search images on that website with your keywords.\n\nIf you have any problem, please feel free to contact me:\n\n\t\t\tdailystudio2010@gmail.com\n - - by %1$s\u00A0 - unsplash.com\u00A0 - - Search - Clear search - About - - Unsplash.com - - \ No newline at end of file diff --git a/sample-gallery/src/main/res/values/themes.xml b/sample-gallery/src/main/res/values/themes.xml index 1b038e22..893eb682 100644 --- a/sample-gallery/src/main/res/values/themes.xml +++ b/sample-gallery/src/main/res/values/themes.xml @@ -37,54 +37,6 @@ @color/white - - - - - - - - - -