Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2615c7a
icon updated
pravinyo Jun 1, 2020
f626630
Merge pull request #136 from pravinyo/launcher_update
pravinyo Jun 1, 2020
03c5731
player state enum added
pravinyo Jun 1, 2020
4d7e07f
3 variable is reduced to single player state variable
pravinyo Jun 1, 2020
02988ba
3 variable is reduced to single player state variable
pravinyo Jun 1, 2020
5e441e3
player state is observed to manage state
pravinyo Jun 1, 2020
175c5e0
launcher updated
pravinyo Jun 1, 2020
bed3677
finished event added
pravinyo Jun 1, 2020
3639136
implemented finished event
pravinyo Jun 1, 2020
53eb7f5
added method for UI reset
pravinyo Jun 1, 2020
3658358
implementation added for finish event
pravinyo Jun 1, 2020
ee12131
track multi icon play bug fixed
pravinyo Jun 1, 2020
d4cf7ec
bug fixed for replaying the track again
pravinyo Jun 1, 2020
8a03938
Merge pull request #138 from pravinyo/bookDetails_UI_bug
pravinyo Jun 1, 2020
ae23955
vibration removed
pravinyo Jun 2, 2020
8f2ec00
bug fixed for looping after track finished
pravinyo Jun 2, 2020
e686ca8
don't open mini player when tracks are finished playing
pravinyo Jun 2, 2020
9108665
finished event handling added
pravinyo Jun 2, 2020
369f2a9
ignore setting background color
pravinyo Jun 2, 2020
27f8634
method renamed
pravinyo Jun 2, 2020
b7beb68
Merge pull request #139 from pravinyo/bookDetails_UI_bug
pravinyo Jun 2, 2020
25c0056
code cleanup
pravinyo Jun 2, 2020
11b7e21
added extra field added date
pravinyo Jun 2, 2020
ee14dcb
date diff method is enhanced to provide better time difference
pravinyo Jun 2, 2020
5fee28a
added extra field added date
pravinyo Jun 2, 2020
dc2f36e
db version incremented
pravinyo Jun 2, 2020
71f407d
date variable is replaced with added_date param for better time diffe…
pravinyo Jun 2, 2020
d69c9cd
test fixed
pravinyo Jun 2, 2020
543019e
Merge pull request #140 from pravinyo/fix_time_bug
pravinyo Jun 2, 2020
ddbdc3c
url opening bug fixed
pravinyo Jun 3, 2020
336492a
Merge pull request #141 from pravinyo/fix_read_link
pravinyo Jun 3, 2020
b1604c0
swipe listener added
pravinyo Jun 3, 2020
c86305d
swipe listener added to the mini player container
pravinyo Jun 3, 2020
83da232
open main player method removed
pravinyo Jun 3, 2020
8d282fa
tooltip code removed
pravinyo Jun 3, 2020
9cc7239
tooltip dependency added
pravinyo Jun 3, 2020
6c40a4f
tool tip for mini player added
pravinyo Jun 3, 2020
6031f07
unused import removed
pravinyo Jun 3, 2020
d3494b6
tooltip dependency removed
pravinyo Jun 3, 2020
3f3b68b
display message updated
pravinyo Jun 3, 2020
8e2efa9
tool top string message moved to app module
pravinyo Jun 3, 2020
759428a
open player test removed
pravinyo Jun 3, 2020
baab248
Merge pull request #142 from pravinyo/miniplayer_swipe_feature
pravinyo Jun 4, 2020
2b0c02c
ui layout created for settings screen
pravinyo Jun 4, 2020
c400e00
dimen added for button and margin
pravinyo Jun 4, 2020
d48a75c
updated
pravinyo Jun 4, 2020
7a379a1
UI fragment created for settings and back button implemented
pravinyo Jun 4, 2020
2909e0f
settings code moved to settings pref fragment
pravinyo Jun 4, 2020
9816dd3
Merge pull request #147 from pravinyo/fix_setting_screen_bug
pravinyo Jun 4, 2020
e2bd98c
fixed multiple download screen bug
pravinyo Jun 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ dependencies {
debugImplementation(LibraryDependency.LEAKY_CANARY)
implementation(LibraryDependency.SUPPORT_V13)
implementation(LibraryDependency.OSS_LICENSES)
implementation(LibraryDependency.TOOL_TIP)

//crash analytics report
implementation(LibraryDependency.FIREBASE_ANALYTICS)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
</intent-filter>
</activity>

<activity android:name=".feature_downloader.presentation.DownloadManagementActivity" />
<activity
android:launchMode= "singleTop"
android:name=".feature_downloader.presentation.DownloadManagementActivity" />

<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.allsoftdroid.audiobook.feature_downloader.presentation.DownloadManage
import com.allsoftdroid.audiobook.feature_mini_player.presentation.MiniPlayerFragment
import com.allsoftdroid.audiobook.presentation.viewModel.MainActivityViewModel
import com.allsoftdroid.audiobook.utility.MovableFrameLayout
import com.allsoftdroid.common.base.utils.StoragePermissionHandler
import com.allsoftdroid.audiobook.utility.OnSwipeTouchListener
import com.allsoftdroid.common.base.activity.BaseActivity
import com.allsoftdroid.common.base.extension.Event
import com.allsoftdroid.common.base.network.ConnectionLiveData
Expand All @@ -27,12 +27,14 @@ import com.allsoftdroid.common.base.store.downloader.DownloadEvent
import com.allsoftdroid.common.base.store.downloader.DownloadEventStore
import com.allsoftdroid.common.base.store.downloader.DownloadNothing
import com.allsoftdroid.common.base.store.userAction.*
import com.allsoftdroid.common.base.utils.StoragePermissionHandler
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import it.sephiroth.android.library.xtooltip.Tooltip
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
Expand All @@ -55,6 +57,7 @@ class MainActivity : BaseActivity() {
private val downloader: IDownloaderCore by inject{parametersOf(this)}
private val userActionEventStore:UserActionEventStore by inject()
private val disposables = CompositeDisposable()
private var isShownTooltip = false


private val snackBar by lazy {
Expand Down Expand Up @@ -233,7 +236,19 @@ class MainActivity : BaseActivity() {
.commit()
}

findViewById<MovableFrameLayout>(R.id.miniPlayerContainer).visibility = View.VISIBLE
findViewById<MovableFrameLayout>(R.id.miniPlayerContainer).apply {
visibility = View.VISIBLE
setOnTouchListener(object : OnSwipeTouchListener(context) {

override fun onSwipeTop() {
super.onSwipeTop()
Timber.d("Event sent for opening main player event")
userActionEventStore.publish(Event(OpenMainPlayerUI(this::class.java.simpleName)))
}
})
}.post {
if(!isShownTooltip) showToolTipForMiniPlayer()
}

findViewById<View>(R.id.navHostFragment).apply {

Expand All @@ -243,6 +258,8 @@ class MainActivity : BaseActivity() {
layoutParams = layout
}



}else{
val fragment = supportFragmentManager.findFragmentByTag(MINI_PLAYER_TAG)

Expand Down Expand Up @@ -301,6 +318,10 @@ class MainActivity : BaseActivity() {
}
}

is Finished -> {
mainActivityViewModel.playerStatus(showPlayer = false)
}

else -> {
Timber.d("Unknown event received")
Timber.d("Unknown Event has message of type TrackDetails: ${event is TrackDetails}")
Expand Down Expand Up @@ -364,4 +385,28 @@ class MainActivity : BaseActivity() {
}

}

private fun showToolTipForMiniPlayer(){
val containerView:View = findViewById<MovableFrameLayout>(R.id.miniPlayerContainer)

val metrics = resources.displayMetrics
val gravity = Tooltip.Gravity.TOP

var tooltip:Tooltip? = Tooltip.Builder(containerView.context)
.anchor(containerView,100,70,false)
.text(getString(R.string.tooltip_open_player_message))
.maxWidth(metrics.widthPixels / 2)
.arrow(false)
.floatingAnimation(Tooltip.Animation.DEFAULT)
.showDuration(3000)
.overlay(true)
.create()

tooltip
?.doOnHidden {
tooltip = null
isShownTooltip = true
}
?.show(containerView.rootView, gravity, true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.allsoftdroid.audiobook.utility

import android.annotation.SuppressLint
import android.content.Context
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import kotlin.math.abs

open class OnSwipeTouchListener(ctx: Context) : View.OnTouchListener {

private val gestureDetector: GestureDetector

companion object {

private const val SWIPE_THRESHOLD = 100
private const val SWIPE_VELOCITY_THRESHOLD = 100
}

init {
gestureDetector = GestureDetector(ctx, GestureListener())
}

@SuppressLint("ClickableViewAccessibility")
override fun onTouch(v: View, event: MotionEvent): Boolean {
return gestureDetector.onTouchEvent(event)
}

private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {


override fun onDown(e: MotionEvent): Boolean {
return true
}

override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
var result = false
try {
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
if (abs(diffX) > abs(diffY)) {
if (abs(diffX) > SWIPE_THRESHOLD && abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
if (diffX > 0) {
onSwipeRight()
} else {
onSwipeLeft()
}
result = true
}
} else if (abs(diffY) > SWIPE_THRESHOLD && abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
if (diffY > 0) {
onSwipeBottom()
} else {
onSwipeTop()
}
result = true
}
} catch (exception: Exception) {
exception.printStackTrace()
}

return result
}


}

open fun onSwipeRight() {}

open fun onSwipeLeft() {}

open fun onSwipeTop() {}

open fun onSwipeBottom() {}
}
Binary file modified app/src/main/res/drawable/launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">AudioBook</string>
<string name="title_feature_book">Feature Book</string>
<string name="title_feature_downloader">Download Feature</string>
<string name="tooltip_open_player_message">Swipe up to open player</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class Pause(val result: AudioPlayerEventState) : AudioPlayerEvent()
data class EmptyEvent(val default: AudioPlayerEventState):AudioPlayerEvent()
object Rewind : AudioPlayerEvent()
object Forward : AudioPlayerEvent()
object Finished : AudioPlayerEvent()

//Details or information event for the player and UI
data class PlaySelectedTrack(val trackList : List<AudioPlayListItem>,val bookId:String,val bookName:String, val position:Int) : AudioPlayerEvent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object BindingUtils {
}

private fun getCurrentDate():String{
val format = SimpleDateFormat("yyyy.MM.dd")
val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
return format.format(date)
}

Expand Down Expand Up @@ -57,8 +57,10 @@ object BindingUtils {
"${result.year - 70}y"
} else if (result.month > 0) {
"${1 + result.month}m"
} else {
"${result.date}d"
} else if (result.date>1){
"${result.date-1}d"
}else {
"${result.hours}hr"
}

} catch (e: Exception) {
Expand Down
Binary file modified common/src/main/res/mipmap/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ data class DatabaseAudioBook(
var creator : String?,

@ColumnInfo(name = "published_date")
var date: String?
var date: String?,

@ColumnInfo(name = "added_date")
var addeddate: String?
){
constructor() : this("","","","")
constructor() : this("","","","","")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.allsoftdroid.database.networkCacheDB.NetworkCacheDao
DatabaseNetworkResponseEntity::class,
DatabaseListenLaterEntity::class
],
version = 7 ,
version = 8 ,
exportSchema = false)
abstract class AudioBookDatabase : RoomDatabase(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fun List<DatabaseAudioBook>.asBookDomainModel():List<AudioBookDomainModel>{
mId = it.identifier,
title = it.title,
creator = it.creator,
date = it.date
date = it.date,
addeddate = it.addeddate?:""
)
}
}
Expand All @@ -23,6 +24,7 @@ fun DatabaseAudioBook.toBookDomainModel():AudioBookDomainModel{
mId = identifier,
title = title,
creator = creator,
date = date
date = date,
addeddate = addeddate?:""
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ internal data class AudioBookDataModel(
val identifier: String,
val title: String,
val creator: Any?,
val date: String
val date: String,
val addeddate:String
)

internal fun AudioBookDataModel.toDomainModel(): AudioBookDomainModel {
Expand All @@ -16,7 +17,8 @@ internal fun AudioBookDataModel.toDomainModel(): AudioBookDomainModel {
mId = this.identifier,
title = this.title,
creator = this.creator?.toString()?:"N/A",
date = this.date
date = this.date,
addeddate = this.addeddate
)
}

Expand All @@ -27,6 +29,7 @@ internal fun AudioBookDataModel.toDatabaseModel(): DatabaseAudioBook {
identifier = this.identifier,
title = this.title,
creator = this.creator?.toString()?:"N/A",
date = this.date
date = this.date,
addeddate = this.addeddate
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.allsoftdroid.feature_book.data.network
class Utils {
object Books{
private const val BASE_URL = "https://archive.org/"
private const val FILTER_MOST_RECENT = "+AND+mediatype%3A(audio)&fl[]=creator,date,identifier,title&sort[]=-date&output=json"
private const val FILTER_MOST_RECENT = "+AND+mediatype%3A(audio)&fl[]=creator,date,identifier,title,addeddate&sort[]=-date&output=json"
private const val QUERY="librivox"
private const val COLLECTIONS="librivoxaudio"
private const val OUTPUT_FIELDS = "fl[]=creator,date,identifier,title&sort[]=-date&output=json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ data class AudioBookDomainModel(
val mId: String,
val title: String,
val creator: String?,
val date: String?
val date: String?,
val addeddate:String
)
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun TextView.setBookDescription(item: AudioBookDomainModel?){
item?.let {
text = getNormalizedText(
"- by ${formattedCreators(it.creator)}, ${convertDateToTime(
it.date,
it.addeddate?:it.date,
this.context
)}", 70
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FakeAudioDataSource(var bookList: MutableList<DatabaseAudioBook> = mutable
if(it.identifier == identifier) return it
}

return DatabaseAudioBook(identifier="",title = "",creator = "",date = "")
return DatabaseAudioBook(identifier="",title = "",creator = "",date = "",addeddate = "")
}

override fun insert(book: DatabaseAudioBook) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FakeAudioBookRepository(private val manualFailure:Boolean = false) : Audio
override suspend fun fetchBookList(page: Int) {
if(!manualFailure){
val list = ArrayList<AudioBookDomainModel>()
list.add(AudioBookDomainModel("1","Title","creator","2019"))
list.add(AudioBookDomainModel("1","Title","creator","2019","2020-06-01T11:22:00"))

audioBooks.value = list

Expand Down
Loading