mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-03 01:57:40 +01:00
fixed nullability crash in keyboard shortcut settings
This commit is contained in:
parent
54fcde9270
commit
6da2717a3b
@ -307,11 +307,12 @@ public class KeyboardShortcutsHandler implements KeyboardShortcutConstants {
|
||||
public static final class KeyboardShortcutSpec {
|
||||
|
||||
private String action;
|
||||
@Nullable
|
||||
private String contextTag;
|
||||
private int keyMeta;
|
||||
private String keyName;
|
||||
|
||||
public KeyboardShortcutSpec(String contextTag, int keyMeta, String keyName, String action) {
|
||||
public KeyboardShortcutSpec(@Nullable String contextTag, int keyMeta, String keyName, String action) {
|
||||
this.contextTag = contextTag;
|
||||
this.keyMeta = keyMeta;
|
||||
this.keyName = keyName;
|
||||
@ -340,11 +341,12 @@ public class KeyboardShortcutsHandler implements KeyboardShortcutConstants {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getContextTag() {
|
||||
return contextTag;
|
||||
}
|
||||
|
||||
public void setContextTag(String contextTag) {
|
||||
public void setContextTag(@Nullable String contextTag) {
|
||||
this.contextTag = contextTag;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class KeyboardShortcutPreference(context: Context, attrs: AttributeSet? = null)
|
||||
|
||||
private val preferencesChangeListener: SharedPreferences.OnSharedPreferenceChangeListener
|
||||
|
||||
val contextTag: String
|
||||
val contextTag: String?
|
||||
val action: String
|
||||
|
||||
@Inject
|
||||
@ -42,7 +42,6 @@ class KeyboardShortcutPreference(context: Context, attrs: AttributeSet? = null)
|
||||
val a = context.obtainStyledAttributes(attrs, R.styleable.KeyboardShortcutPreference)
|
||||
contextTag = a.getString(R.styleable.KeyboardShortcutPreference_android_tag)
|
||||
action = a.getString(R.styleable.KeyboardShortcutPreference_android_action)
|
||||
.takeUnless(String::isNullOrEmpty) ?: throw IllegalArgumentException("android:action required")
|
||||
a.recycle()
|
||||
|
||||
key = action
|
||||
|
Loading…
x
Reference in New Issue
Block a user