Skip to content

Commit

Permalink
[sample-gallery-core][INIT]: module initialization fro sample gallery…
Browse files Browse the repository at this point in the history
… core;

[sample-gallery][DEV]: code refactor to adapt to latest project structure;
  • Loading branch information
dailystudio committed Jul 3, 2023
1 parent 1b422e8 commit 4000679
Show file tree
Hide file tree
Showing 60 changed files with 357 additions and 104 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions sample-gallery-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
apikey.unsplash
66 changes: 66 additions & 0 deletions sample-gallery-core/build.gradle
Original file line number Diff line number Diff line change
@@ -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}"
}
Empty file.
2 changes: 2 additions & 0 deletions sample-gallery-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kdispatcherVersion = 1.1.92
coilVersion = 2.2.2
21 changes: 21 additions & 0 deletions sample-gallery-core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 2 additions & 0 deletions sample-gallery-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest/>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -218,7 +217,7 @@ object UnsplashApi: AuthenticatedNetworkApi<UnsplashApiInterface>() {
override val defaultAuthInfo: Map<String, String>
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions sample-gallery-core/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_in_left.xml
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-50%p" android:toXDelta="0"
android:duration="@integer/animLength"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@integer/animLength" />
</set>
26 changes: 26 additions & 0 deletions sample-gallery-core/src/main/res/anim/slide_in_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_in_left.xml
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="150%p" android:toXDelta="0"
android:duration="@integer/animLength"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@integer/animLength" />
</set>
26 changes: 26 additions & 0 deletions sample-gallery-core/src/main/res/anim/slide_out_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_in_left.xml
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-50%p"
android:duration="@integer/animLength"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@integer/animLength" />
</set>
26 changes: 26 additions & 0 deletions sample-gallery-core/src/main/res/anim/slide_out_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_in_left.xml
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="150%p"
android:duration="@integer/animLength"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="@integer/animLength" />
</set>
11 changes: 11 additions & 0 deletions sample-gallery-core/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--?xml version="1.0" encoding="UTF-8"?-->
<resources>
<color name="primaryColor">#d32f2f</color>
<color name="primaryLightColor">#ff6659</color>
<color name="primaryDarkColor">#9a0007</color>
<color name="secondaryColor">#3949ab</color>
<color name="secondaryLightColor">#6f74dd</color>
<color name="secondaryDarkColor">#00227b</color>
<color name="primaryTextColor">#ffffff</color>
<color name="secondaryTextColor">#ffffff</color>
</resources>
5 changes: 5 additions & 0 deletions sample-gallery-core/src/main/res/values/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="animLength">400</integer>
</resources>

19 changes: 19 additions & 0 deletions sample-gallery-core/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>

<dimen name="photo_item_padding_h">0dp</dimen>
<dimen name="photo_item_padding_v">0dp</dimen>

<dimen name="photo_item_title_font_size">12dp</dimen>
<dimen name="photo_item_title_height">150dp</dimen>
<dimen name="photo_item_title_padding_h">6dp</dimen>
<dimen name="photo_item_title_padding_v">6dp</dimen>
<dimen name="photo_item_supporting_font_size">10dp</dimen>
<dimen name="photo_item_supporting_height">80dp</dimen>

<dimen name="photo_user_name_font_size">18dp</dimen>
<dimen name="photo_source_font_size">14dp</dimen>
<dimen name="photo_download_icon_size">32dp</dimen>

</resources>
15 changes: 15 additions & 0 deletions sample-gallery-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<resources>
<string name="app_name">Gallery</string>
<string name="app_desc">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</string>

<string name="label_author">by %1$s\u00A0</string>
<string name="label_website">unsplash.com\u00A0</string>

<string name="menu_search">Search</string>
<string name="menu_clear_search">Clear search</string>
<string name="menu_about">About</string>

<string name="source_unsplash">Unsplash.com</string>


</resources>
51 changes: 51 additions & 0 deletions sample-gallery-core/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="PhotoItemText">
<item name="android:textStyle">italic</item>
<item name="android:maxLines">1</item>
<item name="android:ellipsize">marquee</item>
</style>

<style name="PhotoItemTitle" parent="PhotoItemText">
<item name="android:textSize">@dimen/photo_item_title_font_size</item>
<item name="android:textColor">@color/light_white</item>
<item name="android:gravity">end|bottom</item>
<item name="android:background">@drawable/photo_item_title_background</item>
<item name="android:paddingStart">@dimen/photo_item_title_padding_h</item>
<item name="android:paddingEnd">@dimen/photo_item_title_padding_h</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">@dimen/photo_item_title_padding_v</item>
</style>

<style name="PhotoItemSupportingText" parent="PhotoItemText">
<item name="android:textStyle">italic|bold</item>
<item name="android:textSize">@dimen/photo_item_supporting_font_size</item>
<item name="android:textColor">@color/primaryColor</item>
<item name="android:gravity">start|top</item>
<item name="android:background">@drawable/photo_item_supporting_background</item>
<item name="android:paddingStart">@dimen/photo_item_title_padding_h</item>
<item name="android:paddingEnd">@dimen/photo_item_title_padding_h</item>
<item name="android:paddingTop">@dimen/photo_item_title_padding_v</item>
<item name="android:paddingBottom">0dp</item>
</style>

<style name="UserName">
<item name="android:gravity">left|center_vertical</item>
<item name="android:textColor">@color/light_black</item>
<item name="android:textSize">@dimen/photo_user_name_font_size</item>
<item name="android:paddingStart">@dimen/default_label_padding</item>
<item name="android:paddingEnd">@dimen/default_label_padding</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>

<style name="ImageSource">
<item name="android:gravity">left|center_vertical</item>
<item name="android:textColor">@color/light_gray</item>
<item name="android:textSize">@dimen/photo_source_font_size</item>
<item name="android:textStyle">italic</item>
<item name="android:paddingStart">@dimen/default_label_padding</item>
<item name="android:paddingEnd">@dimen/default_label_padding</item>
</style>

</resources>
Loading

0 comments on commit 4000679

Please sign in to comment.