Skip to content

Commit

Permalink
Merge branch 'release/0.2.0-alpha' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
ayayk committed Oct 23, 2017
2 parents c422bb0 + 38167c9 commit c2bb1ce
Show file tree
Hide file tree
Showing 66 changed files with 279 additions and 25 deletions.
14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'io.fabric'

def APP_NAME = "biblio"
def VERSION = "0.1.1-alpha"
def VERSION = "0.2.0-alpha"
def PACKAGE_NAME = "com.ayatk.biblio"

// for debug info
Expand Down Expand Up @@ -125,6 +125,18 @@ android {
}
}

variantFilter { variant ->
def names = variant.flavors*.name

def nightlyDebug = names.contains("nightly") && variant.buildType.name == "debug"
def productionDebug = names.contains("production") && variant.buildType.name == "debug"
// To check for a certain build type, use variant.buildType.name == "<buildType>"
if (nightlyDebug || productionDebug) {
// Gradle ignores any variants that satisfy the conditions above.
setIgnore(true)
}
}

flavorDimensions 'tier'

sourceSets {
Expand Down
9 changes: 6 additions & 3 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
package="com.ayatk.biblio">

<application
android:name="com.ayatk.biblio.DebugApp"
android:name=".DebugApp"
android:allowBackup="false"
tools:replace="android:name, android:allowBackup"/>
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
tools:replace="android:name, android:allowBackup,android:icon,android:roundIcon"/>
</manifest>
Binary file removed app/src/debug/assets/ic_launcher.png
Binary file not shown.
22 changes: 22 additions & 0 deletions app/src/debug/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="131.0"
android:viewportWidth="130.0"
android:width="24dp">
<path
android:fillColor="#F86C6B"
android:fillType="evenOdd"
android:pathData="M0,1h130v130h-130z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
<path
android:fillColor="#FF7473"
android:fillType="evenOdd"
android:pathData="M130,0.95l-130,0l0,130z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">

<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

</adaptive-icon>
10 changes: 10 additions & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file modified app/src/debug/res/mipmap-hdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/debug/res/mipmap-mdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/debug/res/mipmap-xhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/debug/res/mipmap-xxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/debug/res/mipmap-xxxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
android:fullBackupContent="@xml/backup"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
*/

package com.ayatk.biblio.view.helper

import android.databinding.BindingConversion
import android.graphics.drawable.ColorDrawable

object DataBindingHelper {

@JvmStatic
@BindingConversion
fun convertColorToDrawable(color: Int): ColorDrawable = ColorDrawable(color)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,56 @@
package com.ayatk.biblio.viewmodel

import android.databinding.BaseObservable
import android.databinding.Bindable
import android.view.View
import com.ayatk.biblio.BR
import com.ayatk.biblio.model.Library
import com.ayatk.biblio.model.Novel
import com.ayatk.biblio.model.enums.NovelState
import com.ayatk.biblio.repository.library.LibraryRepository
import com.ayatk.biblio.util.FORMAT_yyyyMMdd_kkmm
import io.reactivex.rxkotlin.subscribeBy
import timber.log.Timber


class SearchResultItemViewModel(
libraries: List<Library>,
val novel: Novel,
val libraryRepository: LibraryRepository) : BaseObservable(), ViewModel {

@Bindable
var downloadVisibility: Int = View.VISIBLE

@Bindable
var downloadedVisibility: Int = View.GONE

val lastUpdate: String = FORMAT_yyyyMMdd_kkmm.format(novel.lastUpdateDate)

val isShortStory = novel.novelState == NovelState.SHORT_STORY

init {
if (novel in libraries.map { library -> library.novel }) {
downloadVisibility = View.GONE
notifyPropertyChanged(BR.downloadVisibility)
downloadedVisibility = View.VISIBLE
notifyPropertyChanged(BR.downloadedVisibility)
}
}

fun View.onClickAddLibrary() {
libraryRepository.save(Library(novel = novel, tag = listOf())).subscribe(
{ },
{ throwable ->
Timber.tag("SearchResultItemViewModel").e(throwable, "Failed to save libraries.")
libraryRepository.save(Library(novel = novel, tag = listOf()))
.doOnSubscribe {
downloadVisibility = View.GONE
notifyPropertyChanged(BR.downloadVisibility)
}
)
.subscribeBy(
onComplete = {
downloadedVisibility = View.VISIBLE
notifyPropertyChanged(BR.downloadedVisibility)
},
onError = { throwable ->
Timber.tag("SearchResultItemViewModel").e(throwable, "Failed to save libraries.")
}
)
}

override fun destroy() {
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/kotlin/com/ayatk/biblio/viewmodel/SearchViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
package com.ayatk.biblio.viewmodel

import android.databinding.ObservableArrayList
import android.util.Log
import android.view.View
import com.ayatk.biblio.data.narou.NarouClient
import com.ayatk.biblio.data.narou.util.QueryBuilder
import com.ayatk.biblio.model.Library
import com.ayatk.biblio.model.Novel
import com.ayatk.biblio.repository.library.LibraryRepository
import io.reactivex.android.schedulers.AndroidSchedulers
Expand All @@ -20,12 +22,23 @@ class SearchViewModel @Inject constructor(
private val narouClient: NarouClient,
private val libraryRepository: LibraryRepository) : ViewModel {

init {
libraryRepository.findAll()
.subscribeOn(Schedulers.io())
.subscribe(
{ libraries -> this.libraries = libraries },
{ t -> Log.e("SearchViewModel", t.toString()) }
)
}

private val compositeDisposable = CompositeDisposable()

val searchResult = ObservableArrayList<SearchResultItemViewModel>()

val searchResultVisibility: BehaviorSubject<Int> = BehaviorSubject.createDefault(View.GONE)

var libraries = listOf<Library>()

override fun destroy() {
searchResultVisibility.onComplete()
compositeDisposable.clear()
Expand All @@ -37,7 +50,8 @@ class SearchViewModel @Inject constructor(
searchResultVisibility.onNext(View.VISIBLE)
val builtQuery = QueryBuilder().searchWords(query).size(100).build()
compositeDisposable.clear()
compositeDisposable.add(narouClient.getNovel(builtQuery).subscribeOn(Schedulers.io())
compositeDisposable.add(narouClient.getNovel(builtQuery)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map({ novels -> convertToViewModel(novels) })
.subscribe(
Expand All @@ -56,6 +70,6 @@ class SearchViewModel @Inject constructor(
}

private fun convertToViewModel(novels: List<Novel>): List<SearchResultItemViewModel> {
return novels.map { novel -> SearchResultItemViewModel(novel, libraryRepository) }
return novels.map { novel -> SearchResultItemViewModel(libraries, novel, libraryRepository) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
android:viewportWidth="24"
android:width="24dp">
<path
android:fillColor="#000"
android:fillColor="@color/grey600"
android:pathData="M18,22H6A2,2 0 0,1 4,20V4C4,2.89 4.9,2 6,2H7V9L9.5,7.5L12,9V2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22M14,20H16V18H18V16H16V14H14V16H12V18H14V20Z"/>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_check_green_24_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp">
<path
android:fillColor="@color/dark_light_green"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>
22 changes: 22 additions & 0 deletions app/src/main/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="131.0"
android:viewportWidth="130.0"
android:width="24dp">
<path
android:fillColor="#39B0DA"
android:fillType="evenOdd"
android:pathData="M0,1h130v130h-130z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
<path
android:fillColor="#47B8E0"
android:fillType="evenOdd"
android:pathData="M130,0.95l-130,0l0,130z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>
28 changes: 23 additions & 5 deletions app/src/main/res/layout/view_search_result_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<data>

<import type="android.view.View"/>

<variable
name="viewModel"
type="com.ayatk.biblio.viewmodel.SearchResultItemViewModel"/>
Expand Down Expand Up @@ -96,14 +98,30 @@
app:layout_constraintStart_toEndOf="@+id/read_progress"
tools:text="連載中"/>

<android.support.v7.widget.AppCompatImageView
android:id="@+id/add_library"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{viewModel::onClickAddLibrary}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_book_plus_black_24_vector"/>
app:layout_constraintEnd_toEndOf="parent">

<android.support.v7.widget.AppCompatImageView
android:id="@+id/add_library"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{viewModel::onClickAddLibrary}"
android:visibility="@{viewModel.downloadVisibility}"
app:srcCompat="@drawable/ic_book_plus_gray600_24_vector"
tools:visibility="visible"/>

<android.support.v7.widget.AppCompatImageView
android:id="@+id/download_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{viewModel.downloadedVisibility}"
app:srcCompat="@drawable/ic_check_green_24_vector"
tools:visibility="visible"/>

</FrameLayout>

</android.support.constraint.ConstraintLayout>

Expand Down
23 changes: 16 additions & 7 deletions app/src/main/res/layout/view_table_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
xmlns:tools="http://schemas.android.com/tools">

<data>

<import type="android.R"/>

<variable
name="viewModel"
type="com.ayatk.biblio.viewmodel.NovelTableItemViewModel"/>
Expand All @@ -17,31 +20,37 @@
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:background="@{viewModel.novelTable.isChapter ? @color/grey300 : 0}"
android:clickable="@{!viewModel.novelTable.isChapter}"
android:focusable="@{!viewModel.novelTable.isChapter}"
android:foreground="?attr/selectableItemBackground"
android:onClick="@{viewModel::onItemClick}"
android:padding="@dimen/space_16dp">

<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="1"
android:text="@{viewModel.novelTable.title}"
android:textSize="@dimen/text_14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/publish_date"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="01.自業自得な令嬢の後釜"/>
tools:text="長いたいとるだよおおおおおおおおおおおお"/>

<TextView
android:id="@+id/publish_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginRight="0dp"
android:layout_marginEnd="0dp"
android:layout_marginTop="0dp"
android:text="@{viewModel.lastUpdate}"
android:textSize="@dimen/text_14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
10 changes: 10 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016-2017. Aya Tokikaze. All Rights Reserved.
-->

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
100755 → 100644
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100755 → 100644
Loading

0 comments on commit c2bb1ce

Please sign in to comment.