Skip to content

Commit

Permalink
add wake lock
Browse files Browse the repository at this point in the history
  • Loading branch information
maxitemis authored and Max Starikov committed Jan 10, 2025
1 parent dbad859 commit 876dd6b
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ protected void onResume() {
startActivity(intent);
}

ServiceLocator.getInstance().getWakeLockService().acquireLock(this.getApplicationContext());
if (settingsService.useWakeLock()) {
ServiceLocator.getInstance().getWakeLockService().acquireLock(this.getApplicationContext());
}
}

protected void onPause() {
Expand All @@ -282,7 +284,9 @@ protected void onPause() {

mText.removeTextChangedListener(textWatcher);
selectionStart = mText.getSelectionStart();
ServiceLocator.getInstance().getWakeLockService().releaseLock();
if (settingsService.useWakeLock()) {
ServiceLocator.getInstance().getWakeLockService().releaseLock();
}
super.onPause();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class SettingsService {
public static final String SETTING_ALTERNATIVE_FILE_ACCESS = "use_alternative_file_access";
public static final String SETTING_SHOW_LAST_EDITED_FILES = "show_last_edited_files";

private static final String SETTING_USE_WAKE_LOCK = "use_wake_lock";

public static final String SETTING_MEDIUM = "Medium";
public static final String SETTING_EXTRA_SMALL = "Extra Small";
Expand Down Expand Up @@ -71,6 +72,8 @@ public class SettingsService {
private int searchSelectionColor;
private int textSelectionColor;

private boolean useWakeLock = false;


private static boolean languageWasChanged = false;

Expand All @@ -82,6 +85,7 @@ public void loadSettings(Context context) {
open_last_file = sharedPref.getBoolean(SETTING_OPEN_LAST_FILE, false);
show_last_edited_files = sharedPref.getBoolean(SETTING_SHOW_LAST_EDITED_FILES, true);
legacy_file_picker = sharedPref.getBoolean(SETTING_LEGASY_FILE_PICKER, false);
useWakeLock= sharedPref.getBoolean(SETTING_USE_WAKE_LOCK, false);
alternative_file_access = sharedPref.getBoolean(SETTING_ALTERNATIVE_FILE_ACCESS, true);
last_filename = sharedPref.getString(SETTING_LAST_FILENAME, TPStrings.EMPTY);
file_encoding = sharedPref.getString(SETTING_FILE_ENCODING, TPStrings.UTF_8);
Expand Down Expand Up @@ -261,4 +265,8 @@ public boolean isCustomTheme() {
public String getColorThemeType() {
return this.colorThemeType;
}

public boolean useWakeLock() {
return this.useWakeLock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,5 @@ public void releaseLock() {
} catch (Exception e) {
Log.e("ERROR", e.toString());
}

}


}
3 changes: 3 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,8 @@
<string name="preference_color_theme_dark">مظلم</string>
<string name="preference_color_theme_custom">مخصص</string>

<string name="preferenceUseWakeLockTitle">استخدم ويكلوك</string>
<string name="preferenceUseWakeLockDescription">منع الجهاز من الدخول في وضع السكون</string>


</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-cn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,8 @@
<string name="preference_color_theme_dark">黑暗的</string>
<string name="preference_color_theme_custom">风俗</string>

<string name="preferenceUseWakeLockTitle">使用唤醒锁</string>
<string name="preferenceUseWakeLockDescription">防止设备进入睡眠模式</string>


</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,8 @@
<string name="preference_color_theme_dark">Dunkel</string>
<string name="preference_color_theme_custom">Brauch</string>

<string name="preferenceUseWakeLockTitle">Verwenden WakeLock</string>
<string name="preferenceUseWakeLockDescription">Verhindern, dass das Gerät in den Ruhemodus wechselt</string>


</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Oscura</string>
<string name="preference_color_theme_custom">Costumbre</string>

<string name="preferenceUseWakeLockTitle">Usar WakeLock</string>
<string name="preferenceUseWakeLockDescription">Evitar que el dispositivo entre en modo de suspensión</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Sombre</string>
<string name="preference_color_theme_custom">Coutume</string>

<string name="preferenceUseWakeLockTitle">Utiliser WakeLock</string>
<string name="preferenceUseWakeLockDescription">Empêcher l\'appareil de passer en mode veille</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Buia</string>
<string name="preference_color_theme_custom">Costume</string>

<string name="preferenceUseWakeLockTitle">Usa WakeLock</string>
<string name="preferenceUseWakeLockDescription">Impedisce al dispositivo di entrare in modalità sospensione</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">暗い</string>
<string name="preference_color_theme_custom">カスタム</string>

<string name="preferenceUseWakeLockTitle">ウェイクロックを使用する</string>
<string name="preferenceUseWakeLockDescription">デバイスがスリープモードになるのを防ぐ</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Ciemny</string>
<string name="preference_color_theme_custom">Zwyczaj</string>

<string name="preferenceUseWakeLockTitle">Użyj funkcji WakeLock</string>
<string name="preferenceUseWakeLockDescription">Zapobiegaj przejściu urządzenia w tryb uśpienia</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Escura</string>
<string name="preference_color_theme_custom">Personalizada</string>

<string name="preferenceUseWakeLockTitle">Usar WakeLock</string>
<string name="preferenceUseWakeLockDescription">Impedir que o dispositivo entre no modo de suspensão</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@
<string name="preference_color_theme_dark">Темная</string>
<string name="preference_color_theme_custom">Пользовательская</string>

<string name="preferenceUseWakeLockTitle">Использовать WakeLock</string>
<string name="preferenceUseWakeLockDescription">Запретить переход устройства в спящий режим</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,7 @@
<string name="preference_color_theme_dark">Karanlık</string>
<string name="preference_color_theme_custom">Gelenek</string>

<string name="preferenceUseWakeLockTitle">WakeLock\'u kullanın</string>
<string name="preferenceUseWakeLockDescription">Cihazın uyku moduna geçmesini önleyin</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
<string name="preference_color_theme_light">Light</string>
<string name="preference_color_theme_dark">Dark</string>
<string name="preference_color_theme_custom">Custom</string>
<string name="preferenceUseWakeLockTitle">Use WakeLock</string>
<string name="preferenceUseWakeLockDescription">Prevent device going to sleep mode</string>


</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
android:summary="@string/preferenceAutoSaveCurrentFileDescription"
android:defaultValue="false" />

<CheckBoxPreference
android:key="use_wake_lock"
android:title="@string/preferenceUseWakeLockTitle"
android:summary="@string/preferenceUseWakeLockDescription"
android:defaultValue="false" />

<ListPreference
android:key="encoding"
android:summary="@string/Click_to_change_encoding"
Expand Down

0 comments on commit 876dd6b

Please sign in to comment.