Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My books ui layout #103

Merged
merged 62 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b12ab26
lottie dependency added
pravinyo May 18, 2020
ec082d8
dimen resource added
pravinyo May 18, 2020
f45d468
string resource added
pravinyo May 18, 2020
2fadcde
no book found layout added
pravinyo May 18, 2020
3fe2953
book item layout added
pravinyo May 18, 2020
67936f9
fragment UI layout added
pravinyo May 18, 2020
7eb7391
added action to navigate to Book Details screen
pravinyo May 19, 2020
25b7838
domain model added for local books
pravinyo May 19, 2020
9fb2439
implementation for local books repository
pravinyo May 19, 2020
5c83584
di module added for local books module
pravinyo May 19, 2020
3536340
local books repository contract added
pravinyo May 19, 2020
2a93e60
local books view model
pravinyo May 19, 2020
cb3099d
ui element listener added
pravinyo May 19, 2020
229f20f
local books list adapter added
pravinyo May 19, 2020
b21bbc3
local books list item view holder
pravinyo May 19, 2020
fbfc67b
request status model added
pravinyo May 19, 2020
6172648
id and layout renamed
pravinyo May 19, 2020
49bf0e3
renamed to fix layout bug
pravinyo May 19, 2020
2d57740
options menu
pravinyo May 19, 2020
1abb659
resource added for options menu
pravinyo May 19, 2020
019d492
data binding added and click listener added
pravinyo May 19, 2020
b29b59d
database dependency added
pravinyo May 19, 2020
4e8ea61
book metadata model
pravinyo May 19, 2020
6c0ee5a
added total chapter parameter
pravinyo May 19, 2020
c4ccb5b
local book file model added
pravinyo May 19, 2020
8777516
repository added for getting metadata
pravinyo May 19, 2020
3f66d97
implementation added for get all books
pravinyo May 19, 2020
2a7fa51
di added for local books module
pravinyo May 19, 2020
b69d338
contract for metadata repository
pravinyo May 19, 2020
474d342
contract for local books repository
pravinyo May 19, 2020
5ccc67e
instance is scoped
pravinyo May 19, 2020
e06a559
usecase added for book list
pravinyo May 19, 2020
9de487f
submit list to adapter on success
pravinyo May 19, 2020
a7e2113
load book list implemented
pravinyo May 19, 2020
c8ade62
added method to return nonLive data
pravinyo May 19, 2020
b44aef0
implementation changed to handle non live data
pravinyo May 19, 2020
d901ed7
comments removed
pravinyo May 19, 2020
75e1bf4
logging added
pravinyo May 19, 2020
208c198
logging added
pravinyo May 19, 2020
f255a4e
redundant code removed
pravinyo May 20, 2020
f062e13
binding adapter added for my books module
pravinyo May 20, 2020
226b722
dark background drawable added
pravinyo May 20, 2020
d2490cc
ui modified
pravinyo May 20, 2020
23ca2e5
resource updated
pravinyo May 20, 2020
c0e6e9d
added argument placeholder
pravinyo May 20, 2020
0fa481f
added argument placeholder
pravinyo May 20, 2020
1e08a99
added text in book counts
pravinyo May 20, 2020
7c4eea6
load from memory cache if available
pravinyo May 20, 2020
e1bf0f2
load data in resume
pravinyo May 20, 2020
ae1acc8
delete book and chapters implemented
pravinyo May 20, 2020
1c5abee
delete book and chapters implemented
pravinyo May 20, 2020
b731d30
delete book and chapters implemented
pravinyo May 20, 2020
f977191
toast removed and called book or chapters delete
pravinyo May 20, 2020
b0b8db1
dependency is injected via constructor
pravinyo May 20, 2020
47df2f4
module unloading removed
pravinyo May 20, 2020
df4ff9f
fixed bug
pravinyo May 20, 2020
f0376f3
toolbar title changed to begin from left
pravinyo May 21, 2020
5146572
toolbar title changed to begin from left
pravinyo May 21, 2020
c9c5dc6
color changed to purple
pravinyo May 21, 2020
900884a
text color and style changed
pravinyo May 21, 2020
2c5f156
text color changed
pravinyo May 21, 2020
c64839f
background color removed
pravinyo May 21, 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
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