Skip to content

Commit 60cd802

Browse files
sanjay-miakashmi
andauthored
Develop (#98)
- Added Hotfix branch file as faced conflict file issue while taking merge from develop - Resolved media sort issue - Provided sort options for other media also * View binding implemented removed kotlin synthetic * Gradle version updated to 8.0.1 instead of 7.4.2 --------- Co-authored-by: AKASH PATEL <[email protected]>
1 parent 200db7f commit 60cd802

File tree

95 files changed

+8552
-8863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+8552
-8863
lines changed

app/build.gradle

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
4-
apply plugin: 'kotlin-kapt'
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
id 'kotlin-kapt'
5+
id 'kotlin-parcelize'
6+
id 'org.jetbrains.kotlin.android'
7+
}
58

69

710
android {
8-
compileSdkVersion 33
11+
namespace 'com.lassi.app'
12+
compileSdk 33
913
defaultConfig {
1014
applicationId "com.lassi.app"
11-
minSdkVersion 19
12-
targetSdkVersion 33
15+
minSdk 21
16+
targetSdk 33
1317
versionCode 1
1418
versionName "1.0"
1519
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1620
multiDexEnabled true
1721
}
1822
buildTypes {
19-
debug{
23+
debug {
2024
debuggable true
2125
minifyEnabled false
2226
shrinkResources false
@@ -28,25 +32,33 @@ android {
2832
}
2933

3034
compileOptions {
31-
sourceCompatibility JavaVersion.VERSION_1_8
32-
targetCompatibility JavaVersion.VERSION_1_8
35+
sourceCompatibility JavaVersion.VERSION_17
36+
targetCompatibility JavaVersion.VERSION_17
37+
}
38+
39+
kotlinOptions {
40+
jvmTarget = '17'
41+
}
42+
43+
buildFeatures {
44+
viewBinding = true
3345
}
3446
}
3547

3648
dependencies {
3749
implementation fileTree(dir: 'libs', include: ['*.jar'])
38-
implementation 'androidx.appcompat:appcompat:1.4.1'
39-
implementation 'androidx.core:core-ktx:1.7.0'
40-
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
50+
implementation 'androidx.appcompat:appcompat:1.6.1'
51+
implementation 'androidx.core:core-ktx:1.10.0'
52+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
4153
testImplementation 'junit:junit:4.13.2'
42-
androidTestImplementation 'androidx.test:runner:1.4.0'
43-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
54+
androidTestImplementation 'androidx.test:runner:1.5.2'
55+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
4456
implementation project(path: ':lassi')
45-
implementation 'androidx.recyclerview:recyclerview:1.2.1'
57+
implementation 'androidx.recyclerview:recyclerview:1.3.0'
4658
implementation 'androidx.cardview:cardview:1.0.0'
4759

48-
implementation 'com.github.bumptech.glide:glide:4.13.2'
49-
kapt 'com.github.bumptech.glide:compiler:4.13.2'
60+
implementation 'com.github.bumptech.glide:glide:4.14.2'
61+
kapt 'com.github.bumptech.glide:compiler:4.14.2'
5062

5163
implementation "androidx.multidex:multidex:2.0.1"
5264

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.lassi.app">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<!-- This permission require only for document picker feature and if Android device SDK is >= 30-->
65
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

app/src/main/java/com/lassi/app/MainActivity.kt

Lines changed: 96 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,55 @@ import androidx.appcompat.app.AppCompatActivity
1515
import androidx.core.content.FileProvider
1616
import androidx.core.view.isVisible
1717
import com.lassi.app.adapter.SelectedMediaAdapter
18+
import com.lassi.app.databinding.ActivityMainBinding
1819
import com.lassi.common.utils.KeyUtils
1920
import com.lassi.data.media.MiMedia
2021
import com.lassi.domain.media.LassiOption
2122
import com.lassi.domain.media.MediaType
2223
import com.lassi.presentation.builder.Lassi
2324
import com.lassi.presentation.common.decoration.GridSpacingItemDecoration
2425
import com.lassi.presentation.cropper.CropImageView
25-
import kotlinx.android.synthetic.main.activity_main.*
2626
import java.io.File
27-
import java.util.*
27+
import java.util.Locale
2828

2929
class MainActivity : AppCompatActivity(), View.OnClickListener {
30+
private var _binding: ActivityMainBinding? = null
31+
protected val binding get() = _binding!!
3032

3133
private val selectedMediaAdapter by lazy { SelectedMediaAdapter(this::onItemClicked) }
3234

3335
override fun onCreate(savedInstanceState: Bundle?) {
3436
super.onCreate(savedInstanceState)
35-
setContentView(R.layout.activity_main)
36-
btnImagePicker.setOnClickListener(this)
37-
btnVideoPicker.setOnClickListener(this)
38-
btnAudioPicker.setOnClickListener(this)
39-
btnDocPicker.setOnClickListener(this)
40-
btnImageCapture.setOnClickListener(this)
41-
btnVideoCapture.setOnClickListener(this)
42-
btnDocumentSystemIntent.setOnClickListener(this)
43-
rvSelectedMedia.adapter = selectedMediaAdapter
44-
rvSelectedMedia.addItemDecoration(GridSpacingItemDecoration(2, 10))
37+
_binding = ActivityMainBinding.inflate(layoutInflater)
38+
binding.also {
39+
setContentView(it.root)
40+
it.btnImagePicker.setOnClickListener(this)
41+
it.btnVideoPicker.setOnClickListener(this)
42+
it.btnAudioPicker.setOnClickListener(this)
43+
it.btnDocPicker.setOnClickListener(this)
44+
it.btnImageCapture.setOnClickListener(this)
45+
it.btnVideoCapture.setOnClickListener(this)
46+
it.btnDocumentSystemIntent.setOnClickListener(this)
47+
it.rvSelectedMedia.adapter = selectedMediaAdapter
48+
it.rvSelectedMedia.addItemDecoration(GridSpacingItemDecoration(2, 10))
49+
}
4550
}
4651

4752
override fun onClick(v: View?) {
4853
when (v?.id) {
4954
R.id.btnImagePicker -> {
5055
val intent = Lassi(this)
5156
.with(LassiOption.CAMERA_AND_GALLERY)
52-
.setMaxCount(4)
57+
.setMaxCount(1)
5358
.setGridSize(2)
5459
.setPlaceHolder(R.drawable.ic_image_placeholder)
5560
.setErrorDrawable(R.drawable.ic_image_placeholder)
5661
.setSelectionDrawable(R.drawable.ic_checked_media)
5762
.setStatusBarColor(R.color.colorPrimaryDark)
5863
.setToolbarColor(R.color.colorPrimary)
5964
.setToolbarResourceColor(android.R.color.white)
65+
.setAlertDialogNegativeButtonColor(R.color.cherry_red)
66+
.setAlertDialogPositiveButtonColor(R.color.emerald_green)
6067
.setProgressBarColor(R.color.colorAccent)
6168
.setGalleryBackgroundColor(R.color.colorGrey)
6269
.setCropType(CropImageView.CropShape.OVAL)
@@ -72,19 +79,22 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
7279
receiveData.launch(intent)
7380

7481
}
82+
7583
R.id.btnVideoPicker -> {
7684
val intent = Lassi(this)
7785
.with(LassiOption.CAMERA_AND_GALLERY)
78-
.setMaxCount(1)
86+
.setMaxCount(4)
7987
.setGridSize(3)
8088
.setMinTime(5)
8189
.setMaxTime(30)
8290
.setMinFileSize(0)
83-
.setMaxFileSize(2000)
91+
.setMaxFileSize(20000)
8492
.setMediaType(MediaType.VIDEO)
8593
.setStatusBarColor(R.color.colorPrimaryDark)
8694
.setToolbarColor(R.color.colorPrimary)
8795
.setToolbarResourceColor(android.R.color.white)
96+
.setAlertDialogNegativeButtonColor(R.color.cherry_red)
97+
.setAlertDialogPositiveButtonColor(R.color.emerald_green)
8898
.setProgressBarColor(R.color.colorAccent)
8999
.setGalleryBackgroundColor(R.color.colorGrey)
90100
.setPlaceHolder(R.drawable.ic_video_placeholder)
@@ -111,9 +121,11 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
111121
.build()
112122
receiveData.launch(intent)
113123
}
124+
114125
R.id.btnDocPicker -> {
115126
requestPermissionForDocument()
116127
}
128+
117129
R.id.btnDocumentSystemIntent -> {
118130
val intent = Lassi(this)
119131
.setMediaType(MediaType.FILE_TYPE_WITH_SYSTEM_VIEW)
@@ -141,6 +153,70 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
141153
"xlsx",
142154
"xls"
143155
)
156+
.setMaxCount(3)
157+
.setCustomLimitExceedingErrorMessage(R.string.error_exceed_msg)
158+
.build()
159+
receiveData.launch(intent)
160+
}
161+
162+
R.id.btnImageCapture -> {
163+
val intent = Lassi(this)
164+
.with(LassiOption.CAMERA)
165+
.setMaxCount(1)
166+
.setGridSize(2)
167+
.setPlaceHolder(R.drawable.ic_image_placeholder)
168+
.setErrorDrawable(R.drawable.ic_image_placeholder)
169+
.setSelectionDrawable(R.drawable.ic_checked_media)
170+
.setStatusBarColor(R.color.colorPrimaryDark)
171+
.setToolbarColor(R.color.colorPrimary)
172+
.setToolbarResourceColor(android.R.color.white)
173+
.setProgressBarColor(R.color.colorAccent)
174+
.setGalleryBackgroundColor(R.color.colorGrey)
175+
.setAlertDialogNegativeButtonColor(R.color.cherry_red)
176+
.setAlertDialogPositiveButtonColor(R.color.emerald_green)
177+
.setMediaType(MediaType.IMAGE)
178+
.setCropType(CropImageView.CropShape.OVAL)
179+
.setCropAspectRatio(1, 1)
180+
.setCompressionRation(0)
181+
.setMinFileSize(0)
182+
.setMaxFileSize(1000000)
183+
.enableActualCircleCrop()
184+
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
185+
.enableFlip()
186+
.enableRotate()
187+
.build()
188+
receiveData.launch(intent)
189+
}
190+
191+
R.id.btnVideoCapture -> {
192+
val intent = Lassi(this)
193+
.with(LassiOption.CAMERA)
194+
.setMaxCount(1)
195+
.setGridSize(3)
196+
.setMinTime(5)
197+
.setMaxTime(30)
198+
.setMinFileSize(0)
199+
.setMaxFileSize(2000)
200+
.setPlaceHolder(R.drawable.ic_image_placeholder)
201+
.setErrorDrawable(R.drawable.ic_image_placeholder)
202+
.setSelectionDrawable(R.drawable.ic_checked_media)
203+
.setStatusBarColor(R.color.colorPrimaryDark)
204+
.setToolbarColor(R.color.colorPrimary)
205+
.setMediaType(MediaType.VIDEO)
206+
.setToolbarResourceColor(android.R.color.white)
207+
.setAlertDialogNegativeButtonColor(R.color.cherry_red)
208+
.setAlertDialogPositiveButtonColor(R.color.emerald_green)
209+
.setProgressBarColor(R.color.colorAccent)
210+
.setGalleryBackgroundColor(R.color.colorGrey)
211+
.setCropType(CropImageView.CropShape.OVAL)
212+
.setCropAspectRatio(1, 1)
213+
.setCompressionRation(0)
214+
.setMinFileSize(0)
215+
.setMaxFileSize(10000)
216+
.enableActualCircleCrop()
217+
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
218+
.enableFlip()
219+
.enableRotate()
144220
.build()
145221
receiveData.launch(intent)
146222
}
@@ -216,6 +292,8 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
216292
.setStatusBarColor(R.color.colorPrimaryDark)
217293
.setToolbarColor(R.color.colorPrimary)
218294
.setToolbarResourceColor(android.R.color.white)
295+
.setAlertDialogNegativeButtonColor(R.color.cherry_red)
296+
.setAlertDialogPositiveButtonColor(R.color.emerald_green)
219297
.setGalleryBackgroundColor(R.color.colorGrey)
220298
.setSupportedFileTypes(
221299
"pdf",
@@ -240,8 +318,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
240318
if (it.resultCode == Activity.RESULT_OK) {
241319
val selectedMedia =
242320
it.data?.getSerializableExtra(KeyUtils.SELECTED_MEDIA) as ArrayList<MiMedia>
321+
243322
if (selectedMedia.isNotEmpty()) {
244-
ivEmpty.isVisible = selectedMedia.isEmpty()
323+
binding.ivEmpty.isVisible = selectedMedia.isEmpty()
245324
selectedMediaAdapter.setList(selectedMedia)
246325
}
247326
}
@@ -301,6 +380,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
301380
}
302381
}
303382
}
383+
304384
else -> {
305385
launchDocPicker()
306386
}

app/src/main/java/com/lassi/app/adapter/SelectedMediaAdapter.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.lassi.app.adapter
22

3-
import android.view.View
43
import android.view.ViewGroup
54
import androidx.recyclerview.widget.RecyclerView
6-
import com.lassi.app.R
7-
import com.lassi.common.extenstions.inflate
5+
import com.lassi.app.databinding.RowSelectedMediaBinding
86
import com.lassi.common.extenstions.loadImage
7+
import com.lassi.common.extenstions.toBinding
98
import com.lassi.common.utils.ImageUtils
109
import com.lassi.data.media.MiMedia
11-
import kotlinx.android.synthetic.main.row_selected_media.view.*
1210

1311
class SelectedMediaAdapter(private val onItemClicked: (miMedia: MiMedia) -> Unit) :
1412
RecyclerView.Adapter<SelectedMediaAdapter.MediaViewHolder>() {
@@ -24,7 +22,7 @@ class SelectedMediaAdapter(private val onItemClicked: (miMedia: MiMedia) -> Unit
2422
}
2523

2624
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaViewHolder {
27-
return MediaViewHolder(parent.inflate(R.layout.row_selected_media))
25+
return MediaViewHolder(parent.toBinding())
2826
}
2927

3028
override fun getItemCount() = this.selectedMedias.size
@@ -33,10 +31,11 @@ class SelectedMediaAdapter(private val onItemClicked: (miMedia: MiMedia) -> Unit
3331
holder.bind(this.selectedMedias[position])
3432
}
3533

36-
inner class MediaViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
34+
inner class MediaViewHolder(private val binding: RowSelectedMediaBinding) :
35+
RecyclerView.ViewHolder(binding.root) {
3736
fun bind(miMedia: MiMedia) {
38-
itemView.ivSelectedMediaThumbnail.loadImage(ImageUtils.getThumb(miMedia))
39-
itemView.setOnClickListener {
37+
binding.ivSelectedMediaThumbnail.loadImage(ImageUtils.getThumb(miMedia))
38+
binding.root.setOnClickListener {
4039
onItemClicked(miMedia)
4140
}
4241
}

app/src/main/res/values/colors.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
<color name="colorPrimaryDark">#FFA000</color>
55
<color name="colorAccent">#FFC107</color>
66
<color name="colorGrey">#E3E3E3</color>
7+
8+
<color name="cherry_red">#E9333C</color>
9+
<color name="chartreuse">#DFFF00</color>
10+
<color name="emerald_green">#50C878</color>
711
</resources>

build.gradle

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.7.10'
4+
ext.kotlin_version = '1.8.20'
55
repositories {
66
google()
77
mavenCentral()
88
maven { url "https://jitpack.io" }
9+
maven {
10+
url "https://plugins.gradle.org/m2/"
11+
}
912
}
1013
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.2.2'
14+
classpath 'com.android.tools.build:gradle:8.0.1'
1215
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1316
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1417
// NOTE: Do not place your application dependencies here; they belong
1518
// in the individual module build.gradle files
1619
}
1720
}
1821

19-
allprojects {
20-
repositories {
21-
google()
22-
mavenCentral()
23-
maven { url "https://jitpack.io" }
24-
}
25-
}
26-
2722
task clean(type: Delete) {
2823
delete rootProject.buildDir
2924
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ android.useAndroidX=true
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
22+
android.defaults.buildfeatures.buildconfig=true
23+
android.nonTransitiveRClass=false
24+
android.nonFinalResIds=false
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Apr 30 18:22:17 IST 2021
1+
#Mon May 15 16:07:45 IST 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 commit comments

Comments
 (0)