Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #35 from MarcDonald/version/1.3.2
Browse files Browse the repository at this point in the history
Version 1.3.2
  • Loading branch information
MarcDonald committed Dec 19, 2019
2 parents f7253a4 + 621d932 commit 76fd344
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ android {
minSdkVersion 23
//noinspection OldTargetApi
targetSdkVersion 28
versionCode 33
versionName "1.3.1"
versionCode 34
versionName "1.3.2"
setProperty("archivesBaseName", "Hibi-v$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/marcdonald/hibi/data/database/DAO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ interface DAO {
fun getCountDays(): LiveData<Int>

@Suppress("SpellCheckingInspection")
@Query("SELECT COUNT(*) FROM (SELECT DISTINCT location COLLATE NOCASE FROM Entry )")
@Query("SELECT COUNT(*) FROM (SELECT DISTINCT location COLLATE NOCASE FROM Entry WHERE location != '')")
fun getCountLocations(): LiveData<Int>

@Query("SELECT MAX(numEntries) as number, year, month, day FROM (SELECT COUNT(*) as numEntries, year, month, day FROM Entry GROUP BY Entry.year, Entry.month, Entry.day)")
Expand Down Expand Up @@ -287,4 +287,4 @@ interface DAO {
}

data class NumberAndDateObject(val number: Int, val year: Int, val month: Int, val day: Int)
data class NumberAndIdObject(val number: Int, val id: Int)
data class NumberAndIdObject(val number: Int, val id: Int)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.marcdonald.hibi.uicomponents.views.TextStatisticDisplay
import org.kodein.di.KodeinAware
import org.kodein.di.android.x.closestKodein
import org.kodein.di.generic.instance
import timber.log.Timber

class StatisticsFragment : HibiFragment(), KodeinAware {

Expand Down Expand Up @@ -83,8 +82,11 @@ class StatisticsFragment : HibiFragment(), KodeinAware {
bookWithMostEntriesDisplay.show(false)
totalNewWordsDisplay = view.findViewById(R.id.stat_total_new_words)
mostNewWordsOneDayDisplay = view.findViewById(R.id.stat_most_new_words_one_day)
mostNewWordsOneDayDisplay.show(false)
mostNewWordsOneEntryDisplay = view.findViewById(R.id.stat_most_new_words_one_entry)
mostNewWordsOneEntryDisplay.show(false)
mostEntriesInOneDayDisplay = view.findViewById(R.id.stat_most_entries_one_day)
mostEntriesInOneDayDisplay.show(false)
}

private fun setupClickListeners(view: View) {
Expand Down Expand Up @@ -200,31 +202,38 @@ class StatisticsFragment : HibiFragment(), KodeinAware {
val mostNewWords = newValue.number
mostNewWordsOneDayDisplay.setMessage(resources.getQuantityString(R.plurals.stat_total_new_words, mostNewWords, mostNewWords))
if(newValue.number > 0) {
mostNewWordsOneDayDisplay.show(true)
val date = dateTimeUtils.formatDateForDisplay(newValue.day, newValue.month, newValue.year)
mostNewWordsOneDayDisplay.setSecondaryMessage(resources.getString(R.string.on_date, date))
} else {
mostNewWordsOneDayDisplay.show(false)
mostNewWordsOneDayDisplay.showSecondaryMessage(false)
}
}
})

viewModel.mostNewWordsInOneEntry.observe(this, Observer { value ->
value?.let { newValue ->
Timber.i("Log: setupObservers: $newValue")
val mostNewWords = newValue.number
mostNewWordsOneEntryDisplay.setMessage(resources.getQuantityString(R.plurals.stat_total_new_words, mostNewWords, mostNewWords))
if(newValue.number > 0) {
mostNewWordsOneEntryDisplay.show(true)
mostNewWordsOneEntryDisplay.setMessage(resources.getQuantityString(R.plurals.stat_total_new_words, mostNewWords, mostNewWords))
} else {
mostNewWordsOneEntryDisplay.show(false)
}
}
})

viewModel.mostEntriesInOneDay.observe(this, Observer { value ->
value?.let { newValue ->
val mostEntries = newValue.number
mostEntriesInOneDayDisplay.setMessage(resources.getQuantityString(R.plurals.stat_total_entries, mostEntries, mostEntries))
if(newValue.number > 0) {
if(newValue.number > 1) {
mostEntriesInOneDayDisplay.show(true)
val date = dateTimeUtils.formatDateForDisplay(newValue.day, newValue.month, newValue.year)
mostEntriesInOneDayDisplay.setSecondaryMessage(resources.getString(R.string.on_date, date))
} else {
mostEntriesInOneDayDisplay.showSecondaryMessage(false)
mostEntriesInOneDayDisplay.show(false)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ThrowbackFragmentViewModel(private val entryRepository: EntryRepository,
val lastMonth = today.clone() as Calendar
// Need to set day to 1 as if it's 31 and the last month has 30 days it doesn't behave as expected
lastMonth.set(Calendar.DAY_OF_MONTH, 1)
lastMonth.set(Calendar.MONTH, lastMonth.get(Calendar.MONTH - 1))
lastMonth.set(Calendar.MONTH, lastMonth.get(Calendar.MONTH) - 1)
return lastMonth.getActualMaximum(Calendar.DAY_OF_MONTH) == 30
}

Expand Down

0 comments on commit 76fd344

Please sign in to comment.