From 789b53335878484dd39ed8b3da085cae1a904cf9 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Sat, 18 Jan 2025 12:45:26 +0100 Subject: [PATCH] set custom typeface also in clipboard suggestion view and rename read method to get --- .../main/java/helium314/keyboard/keyboard/KeyboardView.java | 2 +- .../keyboard/keyboard/clipboard/ClipboardHistoryView.kt | 2 +- .../helium314/keyboard/keyboard/internal/KeyPreviewView.java | 2 +- .../java/helium314/keyboard/latin/ClipboardHistoryManager.kt | 1 + .../java/helium314/keyboard/latin/settings/Settings.java | 5 +---- .../keyboard/latin/suggestions/SuggestionStripView.java | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/KeyboardView.java b/app/src/main/java/helium314/keyboard/keyboard/KeyboardView.java index b1fc5aba8..5e39d1665 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/KeyboardView.java +++ b/app/src/main/java/helium314/keyboard/keyboard/KeyboardView.java @@ -145,7 +145,7 @@ public class KeyboardView extends View { keyAttr.recycle(); mPaint.setAntiAlias(true); - mTypeface = Settings.getInstance().readCustomTypeface(); + mTypeface = Settings.getInstance().getCustomTypeface(); } @Nullable diff --git a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt index 1f55d191f..188ed3c5e 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt @@ -156,7 +156,7 @@ class ClipboardHistoryView @JvmOverloads constructor( val params = KeyDrawParams() params.updateParams(clipboardLayoutParams.bottomRowKeyboardHeight, keyVisualAttr) - Settings.getInstance().readCustomTypeface()?.let { params.mTypeface = it } + Settings.getInstance().getCustomTypeface()?.let { params.mTypeface = it } setupClipKey(params) setupBottomRowKeyboard(editorInfo, keyboardActionListener) diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyPreviewView.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyPreviewView.java index 56a1d53d9..f1d75986d 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyPreviewView.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyPreviewView.java @@ -44,7 +44,7 @@ public class KeyPreviewView extends AppCompatTextView { public KeyPreviewView(final Context context, final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); setGravity(Gravity.CENTER); - mTypeface = Settings.getInstance().readCustomTypeface(); + mTypeface = Settings.getInstance().getCustomTypeface(); } public void setPreviewVisual(final Key key, final KeyboardIconsSet iconsSet, final KeyDrawParams drawParams) { diff --git a/app/src/main/java/helium314/keyboard/latin/ClipboardHistoryManager.kt b/app/src/main/java/helium314/keyboard/latin/ClipboardHistoryManager.kt index 09bba931a..88a9923f0 100644 --- a/app/src/main/java/helium314/keyboard/latin/ClipboardHistoryManager.kt +++ b/app/src/main/java/helium314/keyboard/latin/ClipboardHistoryManager.kt @@ -198,6 +198,7 @@ class ClipboardHistoryManager( // create the view val binding = ClipboardSuggestionBinding.inflate(LayoutInflater.from(latinIME), parent, false) val textView = binding.clipboardSuggestionText + latinIME.mSettings.getCustomTypeface()?.let { textView.typeface = it } textView.text = (if (isClipSensitive(inputType)) "*".repeat(content.length) else content) .take(200) // truncate displayed text for performance reasons val clipIcon = latinIME.mKeyboardSwitcher.keyboard.mIconsSet.getIconDrawable(ToolbarKey.PASTE.name.lowercase()) diff --git a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java index da3efd11d..fea784f0f 100644 --- a/app/src/main/java/helium314/keyboard/latin/settings/Settings.java +++ b/app/src/main/java/helium314/keyboard/latin/settings/Settings.java @@ -737,10 +737,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang } @Nullable - public Typeface readCustomTypeface() { - // dammit, dann würde wenns keins gibt bei jedem zugriff gesucht -> 2 variablen nehmen? custom und hasCustom? - // ein clear brauchen wir sowieso on theme changed (und auch triggern wenn man ne font setzt/löscht) - // try/catch! + public Typeface getCustomTypeface() { if (sCachedTypeface == null) { try { sCachedTypeface = Typeface.createFromFile(getCustomFontFile(mContext)); diff --git a/app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.java b/app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.java index 3503cfbf0..04cc9c4e3 100644 --- a/app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.java +++ b/app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.java @@ -156,7 +156,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mToolbar = findViewById(R.id.toolbar); mToolbarContainer = findViewById(R.id.toolbar_container); - final Typeface customTypeface = Settings.getInstance().readCustomTypeface(); + final Typeface customTypeface = Settings.getInstance().getCustomTypeface(); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));