From a4ee53542933026b1aaa08ddf903391ee3320934 Mon Sep 17 00:00:00 2001 From: Fenimore Love Date: Thu, 25 Mar 2021 23:07:03 -0400 Subject: [PATCH] Empty cover and light mode button --- README.md | 1 + .../bookcase/BookViewActivity.kt | 2 +- .../timenotclocks/bookcase/MainActivity.kt | 17 ++++++++ .../bookcase/OpenLibrarySearchActivity.kt | 2 +- .../bookcase/SettingsActivity.kt | 20 +++++++++- .../ui/main/OpenLibrarySearchAdapter.kt | 16 +++++++- app/src/main/res/drawable/border.xml | 4 ++ app/src/main/res/layout/activity_main.xml | 13 ++++++- app/src/main/res/layout/book_view_content.xml | 39 +++++++++++++------ .../main/res/layout/book_view_list_item.xml | 17 ++++---- app/src/main/res/layout/fragment_main.xml | 2 +- app/src/main/res/menu/main_menu.xml | 16 +++++--- app/src/main/res/values-night/themes.xml | 4 ++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/themes.xml | 4 ++ app/src/main/res/xml/root_preferences.xml | 15 ++++++- 16 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/drawable/border.xml diff --git a/README.md b/README.md index 1925298..f98d055 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt index e8ea4bf..58bfc56 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt @@ -72,7 +72,7 @@ class BookViewActivity : AppCompatActivity() { current.isbn13?.let { findViewById(R.id.book_view_isbn13).text = "ISBN 13: $it" } current.numberPages?.let { findViewById(R.id.book_view_page_number).text = "Pages: $it" } current.yearString()?.let { findViewById(R.id.book_view_year).text = "$it" } - current.publisher?.let { findViewById(R.id.book_view_publisher).text = "From: $it" } + current.publisher?.let { findViewById(R.id.book_view_publisher).text = it } current.dateAdded?.let { findViewById(R.id.book_view_date_added).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) } current.dateStarted?.let { findViewById(R.id.book_view_date_started).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) } current.dateRead?.let { findViewById(R.id.book_view_date_shelved).text = LocalDate.ofEpochDay(it).format(csvDateFormatter) } diff --git a/app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt index 02c1b5a..19e8e32 100755 --- a/app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/MainActivity.kt @@ -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 @@ -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 { @@ -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) } diff --git a/app/src/main/java/com/timenotclocks/bookcase/OpenLibrarySearchActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/OpenLibrarySearchActivity.kt index bf12a6d..8de2d15 100755 --- a/app/src/main/java/com/timenotclocks/bookcase/OpenLibrarySearchActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/OpenLibrarySearchActivity.kt @@ -128,9 +128,9 @@ class OpenLibrarySearchActivity : AppCompatActivity() { val progressBar = findViewById(R.id.search_progress_bar) val numResultsView = findViewById(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) diff --git a/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt index eb91af4..a5487a2 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt @@ -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 { @@ -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 } } diff --git a/app/src/main/java/com/timenotclocks/bookcase/ui/main/OpenLibrarySearchAdapter.kt b/app/src/main/java/com/timenotclocks/bookcase/ui/main/OpenLibrarySearchAdapter.kt index 3b60e34..8691336 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/ui/main/OpenLibrarySearchAdapter.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/ui/main/OpenLibrarySearchAdapter.kt @@ -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 @@ -49,6 +50,7 @@ class OpenLibrarySearchAdapter() : ListAdapter(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) @@ -56,7 +58,19 @@ class OpenLibrarySearchAdapter() : ListAdapter(SEARCH_CO 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() diff --git a/app/src/main/res/drawable/border.xml b/app/src/main/res/drawable/border.xml new file mode 100644 index 0000000..718f3dc --- /dev/null +++ b/app/src/main/res/drawable/border.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ed8a70d..3019925 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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" /> @@ -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" /> + + + + + + + + + + + diff --git a/app/src/main/res/layout/book_view_content.xml b/app/src/main/res/layout/book_view_content.xml index 1523570..90444d6 100644 --- a/app/src/main/res/layout/book_view_content.xml +++ b/app/src/main/res/layout/book_view_content.xml @@ -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" @@ -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" @@ -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" /> @@ -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" + /> + + @@ -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" /> diff --git a/app/src/main/res/layout/book_view_list_item.xml b/app/src/main/res/layout/book_view_list_item.xml index 78f8e76..143b7e9 100644 --- a/app/src/main/res/layout/book_view_list_item.xml +++ b/app/src/main/res/layout/book_view_list_item.xml @@ -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" > 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" /> diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml index 40d70f4..c864aad 100644 --- a/app/src/main/res/menu/main_menu.xml +++ b/app/src/main/res/menu/main_menu.xml @@ -8,13 +8,8 @@ android:icon="@drawable/ic_add_circle_black" app:showAsAction="always" /> - - @@ -22,6 +17,11 @@ android:title="Manual Book Entry" app:showAsAction="never" /> + @@ -35,6 +35,10 @@ android:title="Delete All Data"/> + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1ea5ec7..8701bd2 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -39,6 +39,7 @@ limitations under the License. #00cbcc #000000 #000000 + #C1C1C1 #E0F7FA #B2EBF2 #80DEEA diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 9207bd7..3c4b3c8 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -63,5 +63,9 @@ + diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 2e4ee12..1b0b979 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -1,4 +1,5 @@ - + + + + + + \ No newline at end of file