Skip to content

Commit

Permalink
Empty cover and light mode button
Browse files Browse the repository at this point in the history
  • Loading branch information
fenimore committed Mar 26, 2021
1 parent 090fff1 commit a4ee535
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Copyright 2021 Fenimore Love
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?

## Known Bug:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BookViewActivity : AppCompatActivity() {
current.isbn13?.let { findViewById<TextView>(R.id.book_view_isbn13).text = "ISBN 13: $it" }
current.numberPages?.let { findViewById<TextView>(R.id.book_view_page_number).text = "Pages: $it" }
current.yearString()?.let { findViewById<TextView>(R.id.book_view_year).text = "$it" }
current.publisher?.let { findViewById<TextView>(R.id.book_view_publisher).text = "From: $it" }
current.publisher?.let { findViewById<TextView>(R.id.book_view_publisher).text = it }
current.dateAdded?.let { findViewById<TextView>(R.id.book_view_date_added).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) }
current.dateStarted?.let { findViewById<TextView>(R.id.book_view_date_started).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) }
current.dateRead?.let { findViewById<TextView>(R.id.book_view_date_shelved).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) }
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import android.util.Log
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.EditText
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
Expand Down Expand Up @@ -76,7 +77,21 @@ class MainActivity : AppCompatActivity() {
).getString("landing_tab", "0")?.toInt() ?: 0
viewPager.setCurrentItem(landingTab)



Log.d(LOG_TAG, "Created Main Activity")
/*
val fab: View = findViewById(R.id.fab)
fab.setOnClickListener { view ->
val intent = Intent(applicationContext, OpenLibrarySearchActivity::class.java)
startActivity(intent)
}
val intent = Intent(applicationContext, OpenLibrarySearchActivity::class.java).apply {
putExtra(EXTRA_SCAN, true)
}
startActivity(intent)
return true*/

/*val data = """{"author" : "Jane Mayer", "authorExtras" : "", "bookId" : 0, "dateAdded" : "2020-11-25", "dateStarted": null, "dateRead" : null, "isbn10" : "0307970655", "isbn13" : "9780385535595", "notes" : null, "numberPages" : null, "originalYear" : 2016, "publisher" : "Doubleday", "rating" : null, "shelf" : "to-read", "subtitle" : null, "title" : "Dark Money", "year" : 2016}"""
val intent = Intent(applicationContext, NewBookActivity::class.java).apply {
Expand Down Expand Up @@ -118,6 +133,8 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
*/

// val intent = Intent(applicationContext, SettingsActivity::class.java)
// startActivity(intent)
// val intent = Intent(applicationContext, OpenLibrarySearchActivity::class.java)
// startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class OpenLibrarySearchActivity : AppCompatActivity() {

val progressBar = findViewById<ProgressBar>(R.id.search_progress_bar)
val numResultsView = findViewById<TextView>(R.id.num_results_view)
numResultsView.text = "Search OpenLibrary.org for new books"

searchOpenLibrary(searchView, progressBar, numResultsView)
numResultsView.text = "Search OpenLibrary.org for new books"

if (intent.getBooleanExtra(EXTRA_SCAN, false)) {
val integrator = IntentIntegrator(this)
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.timenotclocks.bookcase

import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import androidx.preference.*

class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener {

Expand All @@ -28,6 +29,21 @@ class SettingsActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferen
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.root_preferences, rootKey)

val source: Preference? = findPreference("source")
source?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
val url = "https://github.com/fenimore/badreads"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
true
}
val version: Preference? = findPreference("version")
version?.summary = BuildConfig.VERSION_NAME
val dark: ListPreference? = findPreference("dark_mode")
dark?.summary = dark?.entry
val tab: ListPreference? = findPreference("landing_tab")
tab?.summary = tab?.entry
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.beust.klaxon.Klaxon
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import com.timenotclocks.bookcase.NewBookActivity
import com.timenotclocks.bookcase.R
Expand Down Expand Up @@ -49,14 +50,27 @@ class OpenLibrarySearchAdapter() : ListAdapter<Book, SearchViewHolder>(SEARCH_CO
private val captView1: TextView = itemView.findViewById(R.id.book_list_caption_view_1)
private val captView2: TextView = itemView.findViewById(R.id.book_list_caption_view_2)
private val captView3: TextView = itemView.findViewById(R.id.book_list_caption_view_3)
private val emptyCoverView: TextView = itemView.findViewById(R.id.book_list_empty_cover)
// private val captView4: TextView = itemView.findViewById(R.id.book_list_caption_view_4)
// private val captView5: TextView = itemView.findViewById(R.id.book_list_caption_view_5)
// private val captView6: TextView = itemView.findViewById(R.id.book_list_caption_view_6)

fun bindTo(book: Book?) {
book ?: return

book.cover("M").let{ Picasso.get().load(it).into(coverView)}
book.cover("M").let {
Picasso.get().load(it).into(coverView, object : Callback {
override fun onSuccess() {
emptyCoverView.visibility = View.INVISIBLE
}
override fun onError(e: Exception) {}
})
}
coverView.drawable ?: run {
emptyCoverView.visibility = View.VISIBLE
emptyCoverView.text = book.titleString()
}

mainView.text = book.titleString()
subView.text = book.authorString()

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/emptyBook" />
</shape>
13 changes: 12 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ So, we are leaving the template code in. -->
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/secondaryColor"
app:tabSelectedTextColor="@color/cyan"
app:tabSelectedTextColor="@color/primaryColor"
app:tabTextAppearance="@style/TextAppearance.MaterialComponents.Button"
/>
</com.google.android.material.appbar.AppBarLayout>
Expand All @@ -68,5 +68,16 @@ So, we are leaving the template code in. -->
app:layout_constraintTop_toBottomOf="@+id/toolbar"
tools:listitem="@layout/book_view_list_item" />

<!-- <com.google.android.material.floatingactionbutton.FloatingActionButton-->
<!-- android:id="@+id/fab"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="end|bottom"-->
<!-- android:src="@drawable/ic_plus"-->
<!-- android:contentDescription="Add book from OpenLibrary"-->
<!-- android:layout_marginEnd="40dp"-->
<!-- android:layout_marginBottom="70dp"-->
<!-- />-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

39 changes: 27 additions & 12 deletions app/src/main/res/layout/book_view_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:id="@+id/book_view_cover_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="300dp"
android:minHeight="250dp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
Expand Down Expand Up @@ -94,7 +94,7 @@
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:paddingTop="16dp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_isbn10"
Expand All @@ -107,7 +107,6 @@
android:layout_marginTop="10dp"
android:textIsSelectable="true"
android:textAppearance="@style/TextAppearance.AppTheme.Subtitle1"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_author" />

Expand All @@ -116,14 +115,14 @@
android:id="@+id/book_view_publisher"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:textIsSelectable="true"
android:textAppearance="@style/TextAppearance.AppTheme.Subtitle2"
android:textAppearance="@style/TextAppearance.AppTheme.Subtitle1"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_year" />
card_view:layout_constraintStart_toEndOf="@+id/book_view_year"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_author"
/>

<TextView
android:id="@+id/book_view_isbn13"
Expand Down Expand Up @@ -201,13 +200,29 @@
card_view:layout_constraintTop_toBottomOf="@+id/book_view_rating_bar"
/>

<ImageView
android:id="@+id/book_view_date_horizontal"
android:src="@android:drawable/divider_horizontal_dark"
android:layout_marginTop="20dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="2dp"
android:paddingTop="16dp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_notes"
/>

<TextView
android:id="@+id/book_view_date_added_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="Date Added"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_notes"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_date_horizontal"
card_view:layout_constraintEnd_toStartOf="@+id/book_view_date_started_label"
card_view:layout_constraintStart_toStartOf="parent"
android:textIsSelectable="true"
Expand All @@ -230,7 +245,7 @@
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="Date Started"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_notes"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_date_horizontal"
card_view:layout_constraintEnd_toStartOf="@+id/book_view_date_shelved_label"
card_view:layout_constraintStart_toEndOf="@id/book_view_date_added_label"
/>
Expand All @@ -251,7 +266,7 @@
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:text="Date Read"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_notes"
card_view:layout_constraintTop_toBottomOf="@+id/book_view_date_horizontal"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toEndOf="@id/book_view_date_started_label"
/>
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/res/layout/book_view_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ limitations under the License. -->
card_view:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/book_list_cover_wrapper"
android:minHeight="100dp"
android:minWidth="70dp"
android:minWidth="80dp"
>
<ImageView
android:id="@+id/book_list_cover_view"
Expand All @@ -52,21 +52,24 @@ limitations under the License. -->
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:minWidth="70dp"
android:minHeight="120dp"
android:minWidth="80dp"

/>
<TextView
android:id="@+id/book_list_empty_cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_margin="10dp"
android:width="80dp"
android:height="100dp"
android:height="120dp"
android:gravity="center"
android:background="@drawable/border"
android:textColor="@color/primaryTextColor"
android:textSize="13dp"

android:textAppearance="@style/TextAppearance.AppTheme.Body2Light"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.AppTheme.Body2"
android:visibility="gone"
/>
</RelativeLayout>
<TextView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:paddingRight="12dp"
android:minWidth="48dp"
android:minHeight="48dp"
app:iconTint="#FFF"
style="@style/TextAppearance.AppTheme.SortButton"
android:background="@color/zxing_transparent"
/>

Expand Down
16 changes: 10 additions & 6 deletions app/src/main/res/menu/main_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
android:icon="@drawable/ic_add_circle_black"
app:showAsAction="always"
/>
<item android:id="@+id/menu_main_barcode"
android:icon="@drawable/ic_barcode_black"
android:title="Scan Barcode"
app:showAsAction="always"
/>

<item android:title="Badreads Menu"
<item android:title="Manage Library"
android:enabled="false"
app:showAsAction="never"
/>
<item android:id="@+id/menu_main_add_manual"
android:title="Manual Book Entry"
app:showAsAction="never"
/>
<item android:id="@+id/menu_main_barcode"
android:icon="@drawable/ic_barcode_black"
android:title="Scan Barcode"
app:showAsAction="never"
/>
<item android:id="@+id/menu_export_import"
android:title="Library Export/Import"
>
Expand All @@ -35,6 +35,10 @@
android:title="Delete All Data"/>
</menu>
</item>
<item android:title="Badreads App"
android:enabled="false"
app:showAsAction="never"
/>
<item
android:id="@+id/menu_settings"
android:title="Settings"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Dark" >
</style>

<style name="TextAppearance.AppTheme.SortButton" parent="TextAppearance.AppCompat.Button">
<item name="iconTint">#FFF</item>
</style>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ limitations under the License.
<color name="dark_cyan">#00cbcc</color>
<color name="primaryTextColor">#000000</color>
<color name="secondaryTextColor">#000000</color>
<color name="emptyBook">#C1C1C1</color>
<color name="cyan50">#E0F7FA</color>
<color name="cyan100">#B2EBF2</color>
<color name="cyan200">#80DEEA</color>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="TextAppearance.AppTheme.SortButton" parent="TextAppearance.AppCompat.Button">
<item name="iconTint">#000</item>
</style>

</resources>

Loading

0 comments on commit a4ee535

Please sign in to comment.