Skip to content

Commit

Permalink
Add a few design improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Dec 13, 2020
1 parent 944cba8 commit 8a4411c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/bookmarks/BookmarksFragmentModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class BookmarksFragmentModel(
)
},
cachedSupportingText = entriesSupportingTextRepository.getCachedSupportingText(this.id),
opened = opened,
opened = false,
)
}
}
32 changes: 9 additions & 23 deletions app/src/main/java/common/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,6 @@ class Preferences(
private val db: PreferenceQueries
) {

init {
val all = db.selectAll().executeAsList()

if (all.none { it.key == INITIAL_SYNC_COMPLETED }) {
putBooleanBlocking(INITIAL_SYNC_COMPLETED, false)
}

if (all.none { it.key == SHOW_OPENED_ENTRIES }) {
putBooleanBlocking(SHOW_OPENED_ENTRIES, false)
}

if (all.none { it.key == SHOW_PREVIEW_IMAGES }) {
putBooleanBlocking(SHOW_PREVIEW_IMAGES, true)
}

if (all.none { it.key == CROP_PREVIEW_IMAGES }) {
putBooleanBlocking(CROP_PREVIEW_IMAGES, true)
}
}

suspend fun getString(key: String) = withContext(Dispatchers.IO) {
db.selectByKey(key).asFlow().map { it.executeAsOneOrNull()?.value ?: "" }
}
Expand All @@ -51,7 +31,7 @@ class Preferences(
when (it) {
"true" -> true
"false" -> false
else -> throw Exception("Unsupported value: $it")
else -> getDefaultValue(key)
}
}

Expand All @@ -65,8 +45,14 @@ class Preferences(

fun putBooleanBlocking(key: String, value: Boolean) = runBlocking { putBoolean(key, value) }

suspend fun clear() = withContext(Dispatchers.IO) {
db.deleteAll()
private fun getDefaultValue(key: String): Boolean {
return when (key) {
INITIAL_SYNC_COMPLETED -> false
SHOW_OPENED_ENTRIES -> false
SHOW_PREVIEW_IMAGES -> true
CROP_PREVIEW_IMAGES -> true
else -> throw Exception("No defaults for key $key")
}
}

companion object {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/selector_bottom_navigation_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/bottom_navigation_item_active" android:state_checked="true" />
<item android:color="@color/bottom_navigation_item_inactive" />
</selector>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="4dp"
android:visibility="visible"
app:itemIconTint="@drawable/selector_bottom_navigation_item"
app:itemTextColor="@drawable/selector_bottom_navigation_item"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="@menu/menu_bottom_navigation" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_auth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_height="128dp"
android:contentDescription="@string/logo"
android:src="@drawable/ic_baseline_list_alt_24"
app:tint="@color/color_primary" />
app:tint="?colorPrimary" />

<TextView
android:id="@+id/title"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

<resources>
<color name="card_list_background">@android:color/transparent</color>

<color name="bottom_navigation_item_inactive">#66ffffff</color>
<color name="bottom_navigation_item_active">#ffffff</color>
</resources>
7 changes: 5 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<color name="color_primary">#e53935</color>
<color name="color_primary">#1976d2</color>
<color name="color_primary_dark">@color/color_primary</color>
<color name="color_secondary">@color/color_primary</color>
<color name="color_accent">@color/color_primary</color>

<color name="card_list_background">#fafafa</color>
<color name="card_list_background">#efefef</color>

<color name="bottom_navigation_item_inactive">#888888</color>
<color name="bottom_navigation_item_active">@color/color_primary</color>
</resources>

0 comments on commit 8a4411c

Please sign in to comment.