Icon update; re-wrote text font dropdown so it looks a bit better

This commit is contained in:
denizk0461
2023-05-17 09:54:15 +02:00
parent c9c325ddf0
commit 5636f1e679
18 changed files with 25 additions and 51 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -8,8 +8,8 @@ import android.os.Bundle
import android.util.TypedValue
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageButton
import android.widget.PopupMenu
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.annotation.StringRes
@@ -41,58 +41,22 @@ class SettingsNewFragment : BaseFragment(R.layout.fragment_settings_new) {
storage = QuoteStorage.getInstance(context)
// --- text font --- //
// binding.autoCompleteFont.setOnClickListener {
// // Create menu for selecting a new canteen
// PopupMenu(binding.root.context, binding.textLayoutFont).apply {
// setOnMenuItemClickListener { item ->
// item?.itemId?.let { id ->
// storage.setTypefaceStyle(id)
// }
//
// // Update the preview
// updatePreview()
// true
// }
// menu.add(0, 0, 0, getString(R.string.sansserif))
// menu.add(1, 1, 1, getString(R.string.serif))
// menu.add(2, 2, 2, getString(R.string.monospace))
// show()
// }
// }
val fontAdapter = ArrayAdapter.createFromResource(
context,
R.array.text_fonts,
R.layout.item_dropdown,
)
// val fontAdapter = ArrayAdapter(
// context,
// R.layout.item_dropdown_menu,
// resources.getStringArray(R.array.text_fonts),
// )
//
// binding.autoCompleteFont.setAdapter(fontAdapter)
binding.autoCompleteFont.setAdapter(fontAdapter)
binding.autoCompleteFont.setText(
fontAdapter.getItem(storage.getTypefaceIndex()).toString(),
false,
)
binding.autoCompleteFont
.setText(context.resources.getStringArray(R.array.text_fonts)[storage.getTypefaceIndex()])
binding.autoCompleteFont.setOnClickListener {
PopupMenu(binding.root.context, binding.autoCompleteFont).apply {
setOnMenuItemClickListener { item ->
item?.itemId?.let { id ->
val index = when (id) {
R.id.serif -> 1
R.id.monospace -> 2
else -> 0 // sans-serif
}
storage.setTypefaceIndex(index)
binding.autoCompleteFont
.setText(context.resources.getStringArray(R.array.text_fonts)[index])
}
// Refresh the canteen menu for the newly selected canteen
updatePreview()
true
}
inflate(R.menu.list_fonts)
show()
}
binding.autoCompleteFont.setOnItemClickListener { _, _, position, _ ->
storage.setTypefaceIndex(position)
binding.autoCompleteFont.setText(fontAdapter.getItem(position), false)
updatePreview()
}
// --- font style --- //
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
xmlns:android="http://schemas.android.com/apk/res/android" />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB