Skip to content

Commit

Permalink
fix: crashes without sound yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
tumuyan committed Dec 25, 2021
1 parent 9e4fc05 commit a6e4a1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/osfans/trime/ime/core/Trime.java
Expand Up @@ -683,7 +683,7 @@ public void setShowComment(boolean show_comment) {
@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
Sound.get().resetProgress();
Sound.resetProgress();
for (EventListener listener : eventListeners) {
if (listener != null) listener.onStartInputView(activeEditorInstance, restarting);
}
Expand Down
Expand Up @@ -91,7 +91,7 @@ class InputFeedbackManager(
fun keyPressSound(keyCode: Int? = null) {
if (prefs.keyboard.soundEnabled) {
val soundVolume = prefs.keyboard.soundVolume
if (Sound.get().isEnable)
if (Sound.isEnable())
Sound.get().play(keyCode, soundVolume)
else {
if (soundVolume > 0) {
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/com/osfans/trime/ime/keyboard/Sound.java
Expand Up @@ -33,12 +33,13 @@ public static Sound get(String soundPackageName) {
return self;
}

public boolean isEnable() {
return enable;
public static boolean isEnable() {
if (self == null) return false;
return self.enable;
}

public void resetProgress() {
progress = 0;
public static void resetProgress() {
if (self != null) self.progress = 0;
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit a6e4a1d

Please sign in to comment.