diff --git a/README.md b/README.md index 8d0387d..f38b48a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt index e25d885..075f0a1 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/BookViewActivity.kt @@ -1,5 +1,6 @@ package com.timenotclocks.bookcase +import android.content.DialogInterface import android.content.Intent import android.net.Uri import android.os.Bundle @@ -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 @@ -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 } @@ -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 { @@ -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" @@ -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 { diff --git a/app/src/main/java/com/timenotclocks/bookcase/ChartActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/ChartActivity.kt index e953218..4254d55 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/ChartActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/ChartActivity.kt @@ -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 @@ -71,7 +72,10 @@ class ChartActivity : AppCompatActivity() { // Goals: Year to date read findViewById(R.id.chart_label_books_to_year).text = "Books ${LocalDate.now().year}:" findViewById(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(R.id.chart_donut_goal) goalDonut.donutColors = intArrayOf( Color.parseColor("#00cbcc"), diff --git a/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt b/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt index 0e3ebf0..9d358a8 100644 --- a/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt +++ b/app/src/main/java/com/timenotclocks/bookcase/SettingsActivity.kt @@ -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) @@ -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}" } } @@ -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])) { diff --git a/app/src/main/res/drawable-anydpi/ic_delete_black.xml b/app/src/main/res/drawable-anydpi/ic_delete_black.xml index debcb5f..688cc52 100644 --- a/app/src/main/res/drawable-anydpi/ic_delete_black.xml +++ b/app/src/main/res/drawable-anydpi/ic_delete_black.xml @@ -3,9 +3,14 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="#333333" - android:alpha="0.6"> - + android:tint="#000000" + android:alpha="0.8"> + + + diff --git a/app/src/main/res/drawable-anydpi/ic_edit_pencil.xml b/app/src/main/res/drawable-anydpi/ic_edit_pencil.xml index dccaf48..9c6819d 100644 --- a/app/src/main/res/drawable-anydpi/ic_edit_pencil.xml +++ b/app/src/main/res/drawable-anydpi/ic_edit_pencil.xml @@ -3,9 +3,14 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="#333333" - android:alpha="0.6"> - + android:tint="#000000" + android:alpha="0.8"> + + + diff --git a/app/src/main/res/drawable-anydpi/ic_library.xml b/app/src/main/res/drawable-anydpi/ic_library.xml index f8c9b12..57cae2f 100644 --- a/app/src/main/res/drawable-anydpi/ic_library.xml +++ b/app/src/main/res/drawable-anydpi/ic_library.xml @@ -3,12 +3,11 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="#333333" - android:alpha="0.6"> - + android:tint="#000000" + android:alpha="0.8"> + - + android:tint="#000000" + android:alpha="0.8"> + + + diff --git a/app/src/main/res/drawable-hdpi/ic_delete_black.png b/app/src/main/res/drawable-hdpi/ic_delete_black.png index a37cacc..2623a9d 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_delete_black.png and b/app/src/main/res/drawable-hdpi/ic_delete_black.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_edit_pencil.png b/app/src/main/res/drawable-hdpi/ic_edit_pencil.png index f93cc0d..00aca2c 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_edit_pencil.png and b/app/src/main/res/drawable-hdpi/ic_edit_pencil.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_library.png b/app/src/main/res/drawable-hdpi/ic_library.png index 529874b..6870439 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_library.png and b/app/src/main/res/drawable-hdpi/ic_library.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_save_disk.png b/app/src/main/res/drawable-hdpi/ic_save_disk.png index 75c05cb..e6ff298 100644 Binary files a/app/src/main/res/drawable-hdpi/ic_save_disk.png and b/app/src/main/res/drawable-hdpi/ic_save_disk.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete_black.png b/app/src/main/res/drawable-mdpi/ic_delete_black.png index 04e26b3..d44286f 100644 Binary files a/app/src/main/res/drawable-mdpi/ic_delete_black.png and b/app/src/main/res/drawable-mdpi/ic_delete_black.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_edit_pencil.png b/app/src/main/res/drawable-mdpi/ic_edit_pencil.png index aa7b716..6bce80d 100644 Binary files a/app/src/main/res/drawable-mdpi/ic_edit_pencil.png and b/app/src/main/res/drawable-mdpi/ic_edit_pencil.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_library.png b/app/src/main/res/drawable-mdpi/ic_library.png index f251d15..1ad3cce 100644 Binary files a/app/src/main/res/drawable-mdpi/ic_library.png and b/app/src/main/res/drawable-mdpi/ic_library.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_save_disk.png b/app/src/main/res/drawable-mdpi/ic_save_disk.png index 191f641..c1c77db 100644 Binary files a/app/src/main/res/drawable-mdpi/ic_save_disk.png and b/app/src/main/res/drawable-mdpi/ic_save_disk.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_black.png b/app/src/main/res/drawable-xhdpi/ic_delete_black.png index fb6c1b9..e6ec0ba 100644 Binary files a/app/src/main/res/drawable-xhdpi/ic_delete_black.png and b/app/src/main/res/drawable-xhdpi/ic_delete_black.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_edit_pencil.png b/app/src/main/res/drawable-xhdpi/ic_edit_pencil.png index a002ff0..7dd6781 100644 Binary files a/app/src/main/res/drawable-xhdpi/ic_edit_pencil.png and b/app/src/main/res/drawable-xhdpi/ic_edit_pencil.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_library.png b/app/src/main/res/drawable-xhdpi/ic_library.png index 753b61e..6ff60ef 100644 Binary files a/app/src/main/res/drawable-xhdpi/ic_library.png and b/app/src/main/res/drawable-xhdpi/ic_library.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_save_disk.png b/app/src/main/res/drawable-xhdpi/ic_save_disk.png index f5c595a..72f144f 100644 Binary files a/app/src/main/res/drawable-xhdpi/ic_save_disk.png and b/app/src/main/res/drawable-xhdpi/ic_save_disk.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_black.png b/app/src/main/res/drawable-xxhdpi/ic_delete_black.png index 75f41bb..1eff565 100644 Binary files a/app/src/main/res/drawable-xxhdpi/ic_delete_black.png and b/app/src/main/res/drawable-xxhdpi/ic_delete_black.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_edit_pencil.png b/app/src/main/res/drawable-xxhdpi/ic_edit_pencil.png index 25da310..2f68e19 100644 Binary files a/app/src/main/res/drawable-xxhdpi/ic_edit_pencil.png and b/app/src/main/res/drawable-xxhdpi/ic_edit_pencil.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_library.png b/app/src/main/res/drawable-xxhdpi/ic_library.png index 21a89ec..c99bd53 100644 Binary files a/app/src/main/res/drawable-xxhdpi/ic_library.png and b/app/src/main/res/drawable-xxhdpi/ic_library.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_save_disk.png b/app/src/main/res/drawable-xxhdpi/ic_save_disk.png index ea82d93..d683d8c 100644 Binary files a/app/src/main/res/drawable-xxhdpi/ic_save_disk.png and b/app/src/main/res/drawable-xxhdpi/ic_save_disk.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3019925..d250607 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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" diff --git a/app/src/main/res/layout/book_edit_content.xml b/app/src/main/res/layout/book_edit_content.xml index 20e8283..bc22532 100644 --- a/app/src/main/res/layout/book_edit_content.xml +++ b/app/src/main/res/layout/book_edit_content.xml @@ -335,13 +335,13 @@ card_view:layout_constraintStart_toStartOf="parent" card_view:layout_constraintTop_toBottomOf="@id/book_edit_shelf_dropdown" /> - + card_view:layout_constraintTop_toBottomOf="@+id/book_edit_rating_bar">--> - - - + card_view:layout_constraintTop_toBottomOf="@+id/book_edit_description_scroll">--> + card_view:layout_constraintTop_toBottomOf="@id/book_edit_description"> - - + card_view:layout_constraintTop_toBottomOf="@+id/book_edit_notes" /> diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index ab3da04..b3b8f8f 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -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" /> - + - + + + + - + - - - \ No newline at end of file diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index a118f5f..f7a8238 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -1,5 +1,16 @@ + + +