diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png index 9059700..11a56a4 100644 Binary files a/app/src/main/ic_launcher-playstore.png and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/denizd/textbasic/fragment/SettingsNewFragment.kt b/app/src/main/java/com/denizd/textbasic/fragment/SettingsNewFragment.kt index 4cdf346..e6ea15b 100644 --- a/app/src/main/java/com/denizd/textbasic/fragment/SettingsNewFragment.kt +++ b/app/src/main/java/com/denizd/textbasic/fragment/SettingsNewFragment.kt @@ -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 --- // diff --git a/app/src/main/res/layout/item_dropdown.xml b/app/src/main/res/layout/item_dropdown.xml new file mode 100644 index 0000000..e430a66 --- /dev/null +++ b/app/src/main/res/layout/item_dropdown.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 71a4539..0940768 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index eab9d9d..5b11ee9 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index 71a4539..0940768 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 101f87e..2af11ab 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 739715b..2af319c 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index 101f87e..2af11ab 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index a630ec2..939849e 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index e4027ee..6b84305 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index a630ec2..939849e 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 8d5da5e..485ba4d 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index f9432d5..030c6f6 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index 8d5da5e..485ba4d 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index e8ab68d..d988414 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 98ae5c7..0c1536d 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index e8ab68d..d988414 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ