Skip to content

Commit

Permalink
Update icons and add setting for yearly goal
Browse files Browse the repository at this point in the history
  • Loading branch information
fenimore committed May 31, 2021
1 parent be2fba5 commit 88b28bd
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 81 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Copyright 2021 Fenimore Love
3. Add tag/star to books
5. Include numbers in bar charts
6. Make publishers fuzzy match duplicates in Summary of publishers
7. Import/Export Progress field
10. Batch Scan!
8. Version 2: Bookshelf view
9. Version 2: Login to OpenLibrary/sync shelves
Expand Down
38 changes: 25 additions & 13 deletions app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.timenotclocks.bookcase

import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand All @@ -11,6 +12,7 @@ import android.view.View
import android.widget.*
import androidx.activity.viewModels
import androidx.annotation.MenuRes
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.htmlEncode
import com.google.android.material.snackbar.Snackbar
Expand Down Expand Up @@ -67,13 +69,12 @@ class BookViewActivity : AppCompatActivity() {
Picasso.get().load(it).into(coverView, object : com.squareup.picasso.Callback {
override fun onSuccess() {
emptyCoverView.visibility = View.INVISIBLE
//coverView.visibility = View.VISIBLE
}

override fun onError(e: java.lang.Exception?) {}
})
}
emptyCoverView.text = current.titleString()
emptyCoverView?.text = current.titleString() + "\n\n" + current.authorString()
coverView.drawable ?: run {
emptyCoverView.visibility = View.VISIBLE
}
Expand Down Expand Up @@ -137,7 +138,7 @@ class BookViewActivity : AppCompatActivity() {
}
startActivity(intent)
}
R.id.menu_edit -> {
R.id.menu_edit, R.id.menu_edit_text -> {
Log.i(LOG_BOOK_VIEW, "Editing this book")
book?.let { it ->
val intent = Intent(applicationContext, BookEditActivity::class.java).apply {
Expand All @@ -146,16 +147,7 @@ class BookViewActivity : AppCompatActivity() {
startActivityForResult(intent, 100)
}
}
R.id.menu_bookshop -> {
book?.let { b ->
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)
startActivity(i)
}
}
R.id.menu_open_library -> {
R.id.menu_open_library, R.id.menu_open_library_text -> {
book?.let{ b ->
val term = b.isbn13 ?: b.titleString()
val url = "https://openlibrary.org/search?q=$term"
Expand All @@ -164,6 +156,26 @@ class BookViewActivity : AppCompatActivity() {
startActivity(i)
}
}
R.id.menu_delete -> {
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.apply {
setPositiveButton("OK",
DialogInterface.OnClickListener { dialog, id ->
// User clicked OK button
book?.let { bookViewModel.delete(it) }
val intent = Intent(applicationContext, BookViewActivity::class.java)
setResult(RESULT_DELETED, intent)
finish();
})
setNegativeButton("CANCEL",
DialogInterface.OnClickListener { dialog, id ->
// User cancelled the dialog
})
}
builder.setMessage("Delete this book?")
builder.create()
builder.show()
}
R.id.menu_greenlight -> {
book?.let { b ->
val url: String = b.isbn13?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.widget.ArrayAdapter
import android.widget.TextView
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -71,7 +72,10 @@ class ChartActivity : AppCompatActivity() {
// Goals: Year to date read
findViewById<TextView>(R.id.chart_label_books_to_year).text = "Books ${LocalDate.now().year}:"
findViewById<TextView>(R.id.chart_bar_years_subtitle).text = "${LocalDate.now().year - 1} - ${LocalDate.now().year}"
val yearlyGoal = 52.0.toFloat()
val yearlyGoal = (
PreferenceManager.getDefaultSharedPreferences(this).getString(
"yearly_goal", "52")?.toInt() ?: 52
).toFloat()
val goalDonut = findViewById<DonutChartView>(R.id.chart_donut_goal)
goalDonut.donutColors = intArrayOf(
Color.parseColor("#00cbcc"),
Expand Down
28 changes: 9 additions & 19 deletions app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,14 @@ 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.text.InputType
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 @@ -64,6 +46,12 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
dark?.summary = dark?.entry
val tab: ListPreference? = findPreference("landing_tab")
tab?.summary = tab?.entry

val yearlyGoal: EditTextPreference? = findPreference("yearly_goal")
yearlyGoal?.setOnBindEditTextListener { edit ->
edit.inputType = InputType.TYPE_CLASS_NUMBER
}
yearlyGoal?.summary = "Goal to read this year: ${yearlyGoal?.text}"
}
}

Expand All @@ -85,6 +73,8 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
if (key == null || sharedPreferences == null) return
val darkModeString = getString(R.string.dark_mode_prerence)
when (key) {
"landing_tab" -> {}
"yearly_goal" -> {}
darkModeString -> {
val darkModeValues = resources.getStringArray(R.array.dark_mode_values)
when (sharedPreferences.getString(darkModeString, darkModeValues[0])) {
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/res/drawable-anydpi/ic_delete_black.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
android:tint="#000000"
android:alpha="0.8">
<group android:scaleX="1.1111112"
android:scaleY="1.1111112"
android:translateX="-1.3333334"
android:translateY="-1.3333334">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</group>
</vector>
15 changes: 10 additions & 5 deletions app/src/main/res/drawable-anydpi/ic_edit_pencil.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
android:tint="#000000"
android:alpha="0.8">
<group android:scaleX="1.1111112"
android:scaleY="1.1111112"
android:translateX="-1.3333334"
android:translateY="-1.3333334">
<path
android:fillColor="@android:color/white"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</group>
</vector>
11 changes: 5 additions & 6 deletions app/src/main/res/drawable-anydpi/ic_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
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">
android:tint="#000000"
android:alpha="0.8">
<group android:scaleX="0.96"
android:scaleY="0.96"
android:translateY="-3">
<path
android:fillColor="#FF000000"
android:pathData="M23.3,8.252 L12.564,4.835 1.7,8.252L1.7,10.355h21.6z"
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/res/drawable-anydpi/ic_save_disk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
android:tint="#000000"
android:alpha="0.8">
<group android:scaleX="1.1111112"
android:scaleY="1.1111112"
android:translateX="-1.3333334"
android:translateY="-1.3333334">
<path
android:fillColor="@android:color/white"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</group>
</vector>
Binary file modified app/src/main/res/drawable-hdpi/ic_delete_black.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_edit_pencil.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_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_save_disk.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_delete_black.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_edit_pencil.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_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_save_disk.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_delete_black.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_edit_pencil.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_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_save_disk.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_delete_black.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_edit_pencil.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_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_save_disk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ So, we are leaving the template code in. -->
android:id="@+id/recyclerview"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="@dimen/big_padding"
android:paddingBottom="@dimen/big_padding"
android:paddingRight="@dimen/big_padding"
android:paddingLeft="@dimen/big_padding"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
Expand Down
23 changes: 12 additions & 11 deletions app/src/main/res/layout/book_edit_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@id/book_edit_shelf_dropdown" />

<androidx.core.widget.NestedScrollView
<!-- <androidx.core.widget.NestedScrollView
android:id="@+id/book_edit_description_scroll"
android:layout_width="0dp"
android:layout_height="180dp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_rating_bar">
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_rating_bar">-->

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/book_edit_description"
Expand All @@ -358,19 +358,20 @@
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="5"
android:nestedScrollingEnabled="true"
android:textAppearance="@style/TextAppearance.AppTheme.Body2"
android:inputType="textCapSentences|textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.core.widget.NestedScrollView>

<androidx.core.widget.NestedScrollView
<!-- <androidx.core.widget.NestedScrollView
android:id="@+id/book_edit_notes_scroll"
android:layout_width="0dp"
android:layout_height="180dp"
android:layout_height="wrap_content"
android:maxHeight="180dp"
android:scrollbars="vertical"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_description_scroll">
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_description_scroll">-->

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/book_edit_notes"
Expand All @@ -383,16 +384,16 @@
android:hint="Thoughts"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@id/book_edit_description_scroll">
card_view:layout_constraintTop_toBottomOf="@id/book_edit_description">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:lines="5"
android:nestedScrollingEnabled="true"
android:textAppearance="@style/TextAppearance.AppTheme.Body2"
android:inputType="textCapSentences|textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.core.widget.NestedScrollView>


<TextView
android:id="@+id/book_edit_date_added_label"
Expand All @@ -404,7 +405,7 @@
android:textAppearance="@style/TextAppearance.AppTheme.Subtitle1Bold"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_notes_scroll" />
card_view:layout_constraintTop_toBottomOf="@+id/book_edit_notes" />

<DatePicker
android:id="@+id/book_edit_date_added"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/book_view_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:textAlignment="center"
android:textSize="13dp"
android:ellipsize="end"
android:hint="Title"
android:textAppearance="@style/TextAppearance.AppTheme.Body1Bold"
android:textAppearance="@style/TextAppearance.AppTheme.Subtitle1"
android:visibility="visible"
/>
</RelativeLayout>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
android:id="@+id/recyclerview"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="@dimen/big_padding"
android:paddingBottom="@dimen/big_padding"
android:paddingRight="@dimen/big_padding"
android:paddingLeft="@dimen/big_padding"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/fragment_sort_button"
tools:listitem="@layout/book_view_list_item" />


<com.google.android.material.button.MaterialButton
android:layout_marginTop="50dp"
android:layout_marginStart="16dp"
Expand Down
Loading

0 comments on commit 88b28bd

Please sign in to comment.