Skip to content

Commit

Permalink
New icon
Browse files Browse the repository at this point in the history
  • Loading branch information
fenimore committed Mar 27, 2021
1 parent 829ec29 commit e97c456
Show file tree
Hide file tree
Showing 35 changed files with 258 additions and 100 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Badreads

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.timenotclocks.bookcase)


Badreads is a book tracking Android application for logging books
you're reading, read, and want to read. Your library "shelves" (reading, read, and to read)
are stored locally on your phone. Use the search or barcode reader to look up
Expand All @@ -18,25 +23,18 @@ GPLv3
Copyright 2021 Fenimore Love

## Todo:

1. Move export and import to settings
2. Fix settings action bar color
13. Empty library prompt
4. Custom Icons
5. Multiple Authors/DB Relation
9. OpenLibrary book details button?
8. Add tag/star to books
11. Fetch description **
1. Sort a - z
2. Sort z - a
3. Sort page numbers
1. Form fields must be numbers
1. Saving notes sometimes fails!?
9. Fix dark mode colors for light mode (white icon text for button)
10. Add Abe books?
1. Fix settings action bar color
2. Empty library prompt
3. Multiple Authors/DB Relation
4. Add tag/star to books
5. Sort a - z and z - a
6. Version 2: Bookshelf view
7. Version 2: Login to OpenLibrary/sync shelves

## Known Bug:

1. Deleting data directly after exporting, and then importing that same csv will break the CSV.
There seems to be an issue with the first line of the "rows" that are written (after the headers).
2. When writing a review, sometimes it doesn't save...
3. When moving export and import to settings, it doesn't succeed in creating new files
4. OpenLibrary doesn't provide descriptions
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.timenotclocks.bookcase"
minSdkVersion 29
targetSdkVersion 30
versionCode 4
versionName "0.0.4"
versionCode 5
versionName "0.0.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 48 additions & 14 deletions app/src/main/java/com/timenotclocks/bookcase/BookEditActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ package com.timenotclocks.bookcase
import android.annotation.SuppressLint
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.*
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
Expand All @@ -17,6 +19,7 @@ import androidx.core.widget.doAfterTextChanged
import com.beust.klaxon.Klaxon
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputLayout
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import com.timenotclocks.bookcase.api.OpenLibraryViewModel
import com.timenotclocks.bookcase.database.*
Expand Down Expand Up @@ -56,7 +59,6 @@ class BookEditActivity : AppCompatActivity() {
Log.i(LOG_EDIT, "Editing a book $it")
book = it
populateViews(it)
book?.isbn13?.let { openLibraryViewModel.getBookDetails(it) }
}
})
}
Expand All @@ -75,21 +77,50 @@ class BookEditActivity : AppCompatActivity() {
"New details added, click Save (disk) to save.",
Snackbar.LENGTH_INDEFINITE
).setAction("Ok", null).show()
book?.isbn13 = details.isbn13 ?: book?.isbn13
book?.isbn10 = details.isbn10 ?: book?.isbn10
book?.publisher = details.publisher ?: book?.publisher
book?.year = details.publishYear ?: book?.year
book?.numberPages = details.numberPages ?: book?.numberPages
book?.let { populateViews(it) }
} else {
Snackbar.make(
findViewById(R.id.book_edit_activity),
"No new details found.",
Snackbar.LENGTH_LONG
).setAction("Ok", null).show()
}


book?.isbn13 = details.isbn13 ?: book?.isbn13
book?.isbn10 = details.isbn10 ?: book?.isbn10
book?.publisher = details.publisher ?: book?.publisher
book?.year = details.publishYear ?: book?.year
book?.numberPages = details.numberPages ?: book?.numberPages
book?.let { populateViews(it) }
}
}
}

private fun populateViews(current: Book) {
current.cover("L").let { Picasso.get().load(it).into(findViewById<ImageView>(R.id.book_edit_cover_image)) }
val emptyCover = findViewById<TextView>(R.id.book_edit_empty_cover)
emptyCover?.text = current.titleString() + "\n\n" + current.authorString()
val coverView = findViewById<ImageView>(R.id.book_edit_cover_image)
current.cover("L").let {
Picasso.get().load(it).into(coverView, object : Callback {
override fun onSuccess() {
emptyCover.visibility = View.INVISIBLE
}
override fun onError(e: Exception) {}
})
}
coverView.drawable ?: run {
Log.i(LOG_TAG, "Check is it nulll?")
emptyCover.visibility = View.VISIBLE
}

current.cover("L").let {
Picasso.get().load(it).into(coverView)
}
findViewById<Button>(R.id.book_edit_image_edit).setOnClickListener { view ->
val term = current.isbn13 ?: current.titleString()
val url = "https://openlibrary.org/search?q=$term"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
}

val titleEdit = findViewById<TextInputLayout>(R.id.book_edit_title_layout)?.editText
titleEdit?.setText(current.title)
Expand Down Expand Up @@ -121,19 +152,19 @@ class BookEditActivity : AppCompatActivity() {

val yearEdit = findViewById<TextInputLayout>(R.id.book_edit_year).editText
current.year?.let { yearEdit?.setText(it.toString()) }
yearEdit?.doAfterTextChanged { editable -> editable.toString().toIntOrNull()?.let { year -> current.year = year } }
yearEdit?.doAfterTextChanged { editable -> editable.toString().toIntOrNull().let { year -> current.year = year } }

val originalYearEdit = findViewById<TextInputLayout>(R.id.book_edit_original_year).editText
current.originalYear?.let { originalYearEdit?.setText(it.toString()) }
originalYearEdit?.doAfterTextChanged { editable ->
editable.toString().toIntOrNull()?.let { year ->
editable.toString().toIntOrNull().let { year ->
current.originalYear = year
}
}
val pageNumbersEdit = findViewById<TextInputLayout>(R.id.book_edit_page_numbers).editText
current.numberPages?.let { pageNumbersEdit?.setText(it.toString()) }
pageNumbersEdit?.doAfterTextChanged { editable ->
editable.toString().toIntOrNull()?.let { pages ->
editable.toString().toIntOrNull().let { pages ->
current.numberPages = pages
}
}
Expand Down Expand Up @@ -162,7 +193,7 @@ class BookEditActivity : AppCompatActivity() {

val notesEdit = findViewById<EditText>(R.id.book_edit_notes)
current.notes?.let { notesEdit.setText(it) }
notesEdit.doAfterTextChanged { editable -> current.notes = editable.toString() }
notesEdit.doAfterTextChanged { editable -> current.notes = editable?.toString() }

val shelfDropdown = findViewById<Button>(R.id.book_edit_shelf_dropdown)
shelfDropdown.text = current.shelfString()
Expand Down Expand Up @@ -240,6 +271,9 @@ class BookEditActivity : AppCompatActivity() {
setResult(RESULT_OK, intent)
finish();
}
R.id.menu_meta -> {
book?.isbn13?.let { openLibraryViewModel.getBookDetails(it) }
}
}

return super.onOptionsItemSelected(item)
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.widget.*
import androidx.activity.viewModels
import androidx.annotation.MenuRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.htmlEncode
import com.google.android.material.snackbar.Snackbar
import com.squareup.picasso.Picasso
import com.timenotclocks.bookcase.database.*
Expand Down Expand Up @@ -48,6 +49,16 @@ class BookViewActivity : AppCompatActivity() {
}
}

override fun onResume() {
super.onResume()
intent.extras?.getLong(EXTRA_ID)?.let { id ->
bookViewModel.getBook(id).observe(this, { observable ->
book = observable
populateViews(observable)
})
}
}

private fun populateViews(current: Book) {
supportActionBar?.title = current.title
current.cover("L").let {
Expand Down Expand Up @@ -123,7 +134,7 @@ class BookViewActivity : AppCompatActivity() {
}
R.id.menu_bookshop -> {
book?.let { b ->
val term = b.isbn13 ?: b.title
val term = b.isbn13 ?: b.titleString()
val url = "https://bookshop.org/books?keywords=$term"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
Expand All @@ -132,7 +143,7 @@ class BookViewActivity : AppCompatActivity() {
}
R.id.menu_open_library -> {
book?.let{ b ->
val term = b.isbn13 ?: b.title
val term = b.isbn13 ?: b.titleString()
val url = "https://openlibrary.org/search?q=$term"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
Expand All @@ -145,7 +156,7 @@ class BookViewActivity : AppCompatActivity() {
"https://www.greenlightbookstore.com/book/$it"

} ?: run {
"https://www.greenlightbookstore.com/search/site/${b.title.replace(" ", "+")}"
"https://www.greenlightbookstore.com/search/site/${b.titleString().replace(" ", "+").replace(":", "")}"
}
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
*/

// val intent = Intent(applicationContext, SettingsActivity::class.java)
// startActivity(intent)
//val intent = Intent(applicationContext, SettingsActivity::class.java)
//startActivity(intent)
// val intent = Intent(applicationContext, OpenLibrarySearchActivity::class.java)
// startActivity(intent)
//val intent = Intent(applicationContext, BookViewActivity::class.java).apply {
//putExtra(EXTRA_ID, 2139.toLong())
//putExtra(EXTRA_ID, 2270.toLong())
//}
// startActivity(intent)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down
26 changes: 23 additions & 3 deletions app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,32 @@ import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle
import android.os.Environment
import android.os.storage.StorageManager
import android.provider.DocumentsContract
import android.util.Log
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.*
import com.google.android.material.snackbar.Snackbar
import com.timenotclocks.bookcase.api.Exporter
import com.timenotclocks.bookcase.api.GoodReadImport
import com.timenotclocks.bookcase.api.LOG_EXP
import com.timenotclocks.bookcase.database.BookViewModel
import com.timenotclocks.bookcase.database.BookViewModelFactory
import com.timenotclocks.bookcase.database.BooksApplication
import java.time.LocalDate

private const val exportRequest = 1
private const val importResult = 450
const val LOG_SET = "BookSettings"

class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
private val bookViewModel: BookViewModel by viewModels {
BookViewModelFactory((application as BooksApplication).repository)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -53,7 +73,7 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when(item.itemId) {
when (item.itemId) {
android.R.id.home -> {
finish()
}
Expand All @@ -64,7 +84,7 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == null || sharedPreferences == null) return
val darkModeString = "dark_mode" // todo put in string.xml I guess
when(key) {
when (key) {
darkModeString -> {
val darkModeValues = resources.getStringArray(R.array.dark_mode_values)
when (sharedPreferences.getString(darkModeString, darkModeValues[0])) {
Expand All @@ -76,4 +96,4 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
}
}
}
}
}
28 changes: 28 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_library.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<group android:scaleX="0.85333335"
android:scaleY="0.85333335"
android:translateX="1.3333334"
android:translateY="-1.3333334">
<path
android:fillColor="#FF000000"
android:pathData="M23.3,8.252 L12.564,4.835 1.7,8.252L1.7,10.355h21.6z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
<path
android:fillColor="#FF000000"
android:pathData="m22.152,22.115v1.44L2.472,23.555v-1.44h1.2L3.672,12.035h-1.2L2.472,11.075h19.68v0.96h-1.2L20.952,22.115ZM8.712,12.035h-2.88v10.08h2.88zM13.992,12.035h-3.12v10.08h3.12zM18.792,12.035h-2.64v10.08h2.64z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
<path
android:fillColor="#FF000000"
android:pathData="M1.7,24.275h21.6v2.16h-21.6z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
</group>
</vector>
27 changes: 22 additions & 5 deletions app/src/main/res/drawable-anydpi/ic_sort_white.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="@android:color/white"
android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"/>
android:tint="#333333"
android:alpha="0.6">
<group android:scaleX="0.85333335"
android:scaleY="0.85333335"
android:translateX="1.3333334"
android:translateY="-1.3333334">
<path
android:fillColor="#FF000000"
android:pathData="M23.3,8.252 L12.564,4.835 1.7,8.252L1.7,10.355h21.6z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
<path
android:fillColor="#FF000000"
android:pathData="m22.152,22.115v1.44L2.472,23.555v-1.44h1.2L3.672,12.035h-1.2L2.472,11.075h19.68v0.96h-1.2L20.952,22.115ZM8.712,12.035h-2.88v10.08h2.88zM13.992,12.035h-3.12v10.08h3.12zM18.792,12.035h-2.64v10.08h2.64z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
<path
android:fillColor="#FF000000"
android:pathData="M1.7,24.275h21.6v2.16h-21.6z"
android:strokeLineJoin="round"
android:fillType="evenOdd"/>
</group>
</vector>
Binary file added app/src/main/res/drawable-hdpi/ic_library.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/drawable-hdpi/ic_sort_white.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 added app/src/main/res/drawable-mdpi/ic_library.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/drawable-mdpi/ic_sort_white.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 added app/src/main/res/drawable-xhdpi/ic_library.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/drawable-xhdpi/ic_sort_white.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 added app/src/main/res/drawable-xxhdpi/ic_library.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/drawable-xxhdpi/ic_sort_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e97c456

Please sign in to comment.