workaround for toasts not showing up on some android versions

This commit is contained in:
Helium314 2023-08-30 12:03:57 +02:00
parent 3758cfe403
commit 8916c67d15
2 changed files with 13 additions and 2 deletions

View file

@ -341,7 +341,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
final SuggestedWordInfo info = mSuggestedWords.getInfo(i);
if (info.getWord().equals(word)) {
final String text = info.mSourceDict.mDictType + ":" + info.mSourceDict.mLocale;
Toast.makeText(getContext(), text, Toast.LENGTH_LONG).show();
// apparently toast is not working on some Android versions, probably
// Android 13 with the notification permission
// Toast.makeText(getContext(), text, Toast.LENGTH_LONG).show();
final PopupMenu uglyWorkaround = new PopupMenu(DialogUtils.getPlatformDialogThemeContext(getContext()), wordView);
uglyWorkaround.getMenu().add(Menu.NONE, 1, Menu.NONE, text);
uglyWorkaround.show();
}
}
return true;

View file

@ -136,7 +136,13 @@ class NewDictionaryAdder(private val context: Context, private val onAdded: ((Bo
private fun onDictionaryLoadingError(messageId: Int) {
cachedDictionaryFile.delete()
Toast.makeText(context, messageId, Toast.LENGTH_LONG).show()
// Toast.makeText(context, messageId, Toast.LENGTH_LONG).show()
// show a dialog because toasts are not showing up on some Android versions
// possibly Android 13 because of notification permission
AlertDialog.Builder(context)
.setMessage(messageId)
.setNegativeButton(R.string.dialog_close, null)
.show()
}
}