Skip to content

Commit

Permalink
Merge pull request #103 from pravinyo/my_books_ui_layout
Browse files Browse the repository at this point in the history
My books feature
  • Loading branch information
pravinyo authored May 21, 2020
2 parents 4ba47ba + c64839f commit 1c93121
Show file tree
Hide file tree
Showing 40 changed files with 1,066 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class MainActivity : BaseActivity() {
layoutParams = layout
}
}

}

private fun performAction(event: AudioPlayerEvent){
Expand Down Expand Up @@ -321,7 +320,6 @@ class MainActivity : BaseActivity() {
stopAudioService()
disposables.dispose()
downloader.Destroy()
AppModule.unloadModule()
}

private fun stopAudioService(){
Expand Down
5 changes: 4 additions & 1 deletion common/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@

<fragment
android:id="@+id/MyBooksFragment"
android:name="com.allsoftdroid.audiobook.feature_mybooks.MyBooksFragment"
android:name="com.allsoftdroid.audiobook.feature_mybooks.presentation.MyBooksFragment"
android:label="MyBooksFragment">
<action
android:id="@+id/action_MyBooksFragment_to_AudioBookDetailsFragment"
app:destination="@id/AudioBookDetailsFragment"/>
</fragment>

<fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ interface MetadataDao{
@Query("SELECT * FROM metadata_table where metadata_id=:bookId")
fun getMetadata( bookId : String):LiveData<DatabaseMetadataEntity>

@Query("SELECT * FROM metadata_table where metadata_id=:bookId")
fun getMetadataNonLive( bookId : String):DatabaseMetadataEntity

/**
* Get album details for the specified audio book
* @param metadata_id unique id given to audio book
Expand Down Expand Up @@ -50,6 +53,9 @@ interface MetadataDao{
@Query("SELECT * FROM MediaTrack_Table where track_album_id=:metadata_id and format like '%' || :formatContains || '%'")
fun getTrackDetails(metadata_id:String,formatContains:String):LiveData<List<DatabaseTrackEntity>>

@Query("SELECT * FROM MediaTrack_Table where track_album_id=:metadata_id and format like '%' || :formatContains || '%'")
fun getTrackDetailsNonLive(metadata_id:String,formatContains:String):List<DatabaseTrackEntity>

/**
* get list of media VBR track files for the given album id . here album id is same as metadata id so we will
* use complex sql queries to get VBR files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,4 @@ class AudioBookListFragment : BaseUIFragment(){
}
}
}

override fun onDestroy() {
super.onDestroy()
FeatureBookModule.unLoadModules()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ object BookDetailsModule {

factory {
MetadataRepositoryImpl(
metadataDao = get(),
metadataDao = get(named(name = METADATA_DAO)),
bookId = getProperty(PROPERTY_BOOK_ID),
metadataDataSource = get(),
saveInDatabase = get(named(name = METADATA_DATABASE))) as IMetadataRepository
}

factory {
TrackListRepositoryImpl(
metadataDao = get(),
metadataDao = get(named(name = METADATA_DAO)),
bookId = getProperty(PROPERTY_BOOK_ID)
) as ITrackListRepository
}
Expand Down Expand Up @@ -158,7 +158,7 @@ object BookDetailsModule {
AudioBookDatabase.getDatabase(get()).listenLaterDao()
}

single {
single(named(name = METADATA_DAO)) {
AudioBookDatabase.getDatabase(get()).metadataDao()
}

Expand All @@ -167,7 +167,7 @@ object BookDetailsModule {
}

single(named(name = METADATA_DATABASE)) {
SaveMetadataInDatabase.setup(metadataDao = get()) as SaveInDatabase<MetadataDao,SaveMetadataInDatabase>
SaveMetadataInDatabase.setup(metadataDao = get(named(name = METADATA_DAO))) as SaveInDatabase<MetadataDao,SaveMetadataInDatabase>
}

single {
Expand All @@ -185,4 +185,5 @@ object BookDetailsModule {

const val PROPERTY_BOOK_ID = "bookDetails_book_id"
private const val METADATA_DATABASE = "SaveMetadataInDatabase"
private const val METADATA_DAO ="MetadataDao_BookDetailsModule"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.allsoftdroid.feature.book_details.utils

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.allsoftdroid.common.test.getOrAwaitValue
import com.allsoftdroid.database.metadataCacheDB.MetadataDao
import com.allsoftdroid.database.metadataCacheDB.entity.DatabaseAlbumEntity
import com.allsoftdroid.database.metadataCacheDB.entity.DatabaseMetadataEntity
Expand All @@ -17,6 +18,10 @@ class FakeMetadataSource(private val _metadataLiveData: MutableLiveData<Database
return _metadataLiveData
}

override fun getMetadataNonLive(bookId: String): DatabaseMetadataEntity {
return _metadataLiveData.getOrAwaitValue()
}

override fun getAlbumDetails(metadata_id: String): LiveData<DatabaseAlbumEntity> {

return _albumEntity
Expand All @@ -34,6 +39,13 @@ class FakeMetadataSource(private val _metadataLiveData: MutableLiveData<Database
return _tracks
}

override fun getTrackDetailsNonLive(
metadata_id: String,
formatContains: String
): List<DatabaseTrackEntity> {
return _tracks.getOrAwaitValue()
}

override fun getTrackDetailsVBR(metadata_id: String): LiveData<List<DatabaseTrackEntity>> {
return _tracks
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#ffffff" android:pathData="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z" />
<path android:fillColor="#673AB7" android:pathData="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z" />
</vector>
2 changes: 1 addition & 1 deletion feature_downloader/src/main/res/drawable/ic_delete.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#ffffff" android:pathData="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
<path android:fillColor="#673AB7" android:pathData="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
</vector>
2 changes: 1 addition & 1 deletion feature_downloader/src/main/res/drawable/ic_file_music.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#ffffff" android:pathData="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M9,16A2,2 0 0,0 7,18A2,2 0 0,0 9,20A2,2 0 0,0 11,18V13H14V11H10V16.27C9.71,16.1 9.36,16 9,16Z" />
<path android:fillColor="#673AB7" android:pathData="M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M9,16A2,2 0 0,0 7,18A2,2 0 0,0 9,20A2,2 0 0,0 11,18V13H14V11H10V16.27C9.71,16.1 9.36,16 9,16Z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.DownloadManagementActivity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:text="@string/emptyView_download_message"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:textColor="@color/colorItem"
android:textColor="@color/colorPrimary"
android:layout_marginBottom="@dimen/margin_standard"
android:layout_height="wrap_content" />
</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
android:id="@+id/textView_download_file_name"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:layout_width="0dp"
android:textColor="@color/colorItem"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:layout_weight="1"
android:layout_height="wrap_content" />
<ImageView
Expand All @@ -33,7 +34,7 @@
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView_download_progress_details"
android:textColor="@color/colorItem"
android:textColor="@color/colorPrimary"
android:text="@string/calculating"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Expand All @@ -48,6 +49,7 @@
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="0dp"
android:paddingEnd="@dimen/padding_standard"
android:paddingStart="@dimen/standard_padding_min"
android:layout_weight="3"
android:layout_gravity="center"
android:layout_height="wrap_content" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.allsoftdroid.audiobook.feature_listen_later_ui.R
import com.allsoftdroid.audiobook.feature_listen_later_ui.data.model.ListenLaterItemDomainModel
import com.allsoftdroid.common.base.extension.CreateImageOverlay
import com.allsoftdroid.common.base.network.ArchiveUtils
import com.allsoftdroid.common.base.utils.BindingUtils.getNormalizedText
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
Expand Down Expand Up @@ -63,12 +64,4 @@ fun TextView.setBookDuration(item: ListenLaterItemDomainModel?){
item?.let {
text = it.duration
}
}

private fun getNormalizedText(text:String?,limit:Int):String{
if(text?.length?:0>limit){
return text?.substring(0,limit-3)+"..."
}

return text?:""
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
android:layout_height="?actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
android:background="@color/black"
android:padding="2dp"
android:padding="@dimen/padding_min"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/toolbar"
android:orientation="horizontal">

<ImageView
android:id="@+id/toolbar_back_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
android:clickable="true"
android:focusable="true"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/margin_normal"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_keyboard_arrow_left_black_24dp"
android:contentDescription="@string/toolbar_back_arrow" />
Expand All @@ -38,16 +38,17 @@
android:id="@+id/toolbar_title"
android:textColor="@color/white"
android:layout_width="0dp"
android:layout_marginStart="@dimen/margin_normal"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:gravity="center"
android:gravity="start|center_vertical"
android:text="@string/toolbar_title_text"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>


<LinearLayout
android:layout_marginTop="16dp"
android:layout_marginTop="@dimen/margin_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -59,7 +60,7 @@
<TextView
android:id="@+id/bookStats_count"
android:textColor="@color/black"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/margin_normal"
android:layout_width="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:gravity="center"
Expand All @@ -73,14 +74,14 @@
android:gravity="center"
android:clickable="true"
android:focusable="true"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/margin_normal"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/margin_normal"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_sort_black_24dp"
android:contentDescription="@string/sort" />
Expand Down
4 changes: 4 additions & 0 deletions feature_listen_later_ui/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
<dimen name="card_padding">24dp</dimen>
<dimen name="card_margin_top">16dp</dimen>
<dimen name="bookList_image_height">90dp</dimen>

<dimen name="padding_min">2dp</dimen>
<dimen name="icon_size">24dp</dimen>
<dimen name="margin_normal">16dp</dimen>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ class MiniPlayerFragment : BaseContainerFragment() {

override fun onDestroy() {
super.onDestroy()
FeatureMiniPlayerModule.unloadModule()
}
}
2 changes: 2 additions & 0 deletions feature_mybooks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ android {

dependencies {
implementation(project(path: ModuleDependency.LIBRARY_COMMON))
implementation(project(path: ModuleDependency.DATABASE))

implementation(LibraryDependency.GLIDE)
kapt(LibraryDependency.GLIDE_COMPILER)
implementation(LibraryDependency.KOIN_X_VIEWMODEL)
implementation(LibraryDependency.LOTTIE)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.allsoftdroid.audiobook.feature_mybooks.data.model

data class BookMetadata(
val title:String,
val author:String,
val totalTracks:Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.allsoftdroid.audiobook.feature_mybooks.data.model

data class LocalBookDomainModel (
val bookTitle:String,
val bookIdentifier:String,
val bookAuthor:String,
val bookChaptersDownloaded:Int,
val totalChapters:Int,
val fileNames:List<String>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.allsoftdroid.audiobook.feature_mybooks.data.model

data class LocalBookFiles(
val identifier:String,
val filePath:List<String>
)
Loading

0 comments on commit 1c93121

Please sign in to comment.