Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to keep screen on while viewing photos (#365) #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class SettingsActivity : SimpleActivity() {
setupAppPasswordProtection()
setupFileDeletionPasswordProtection()
setupDeleteEmptyFolders()
setupKeepScreenOn()
setupAllowPhotoGestures()
setupAllowVideoGestures()
setupAllowDownGesture()
Expand Down Expand Up @@ -446,6 +447,14 @@ class SettingsActivity : SimpleActivity() {
}
}

private fun setupKeepScreenOn() {
binding.settingsKeepScreenOnFullscreenPhotos.isChecked = config.keepScreenOn
binding.settingsKeepScreenOnFullscreenPhotosHolder.setOnClickListener {
binding.settingsKeepScreenOnFullscreenPhotos.toggle()
config.keepScreenOn = binding.settingsKeepScreenOnFullscreenPhotos.isChecked
}
}

private fun setupAllowPhotoGestures() {
binding.settingsAllowPhotoGestures.isChecked = config.allowPhotoGestures
binding.settingsAllowPhotoGesturesHolder.setOnClickListener {
Expand Down Expand Up @@ -884,6 +893,7 @@ class SettingsActivity : SimpleActivity() {
put(BLACK_BACKGROUND, config.blackBackground)
put(HIDE_SYSTEM_UI, config.hideSystemUI)
put(ALLOW_INSTANT_CHANGE, config.allowInstantChange)
put(KEEP_SCREEN_ON, config.keepScreenOn)
put(ALLOW_PHOTO_GESTURES, config.allowPhotoGestures)
put(ALLOW_DOWN_GESTURE, config.allowDownGesture)
put(ALLOW_ROTATING_WITH_GESTURES, config.allowRotatingWithGestures)
Expand Down Expand Up @@ -1027,6 +1037,7 @@ class SettingsActivity : SimpleActivity() {
BLACK_BACKGROUND -> config.blackBackground = value.toBoolean()
HIDE_SYSTEM_UI -> config.hideSystemUI = value.toBoolean()
ALLOW_INSTANT_CHANGE -> config.allowInstantChange = value.toBoolean()
KEEP_SCREEN_ON -> config.keepScreenOn = value.toBoolean()
ALLOW_PHOTO_GESTURES -> config.allowPhotoGestures = value.toBoolean()
ALLOW_DOWN_GESTURE -> config.allowDownGesture = value.toBoolean()
ALLOW_ROTATING_WITH_GESTURES -> config.allowRotatingWithGestures = value.toBoolean()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.RelativeLayout
import androidx.exifinterface.media.ExifInterface.*
import com.alexvasilkov.gestures.GestureController
Expand Down Expand Up @@ -220,6 +221,7 @@ class PhotoFragment : ViewPagerFragment() {

override fun onPause() {
super.onPause()
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
storeStateVariables()
}

Expand All @@ -245,6 +247,7 @@ class PhotoFragment : ViewPagerFragment() {
mShouldResetImage = false
}

val keepScreenOn = config.keepScreenOn
val allowPhotoGestures = config.allowPhotoGestures
val allowInstantChange = config.allowInstantChange

Expand All @@ -254,6 +257,10 @@ class PhotoFragment : ViewPagerFragment() {
instantNextItem.beVisibleIf(allowInstantChange)
}

if (keepScreenOn) {
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}

storeStateVariables()
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/kotlin/org/fossify/gallery/helpers/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(DELETE_EMPTY_FOLDERS, false)
set(deleteEmptyFolders) = prefs.edit().putBoolean(DELETE_EMPTY_FOLDERS, deleteEmptyFolders).apply()

var keepScreenOn: Boolean
get() = prefs.getBoolean(KEEP_SCREEN_ON, true)
set(keepScreenOn) = prefs.edit().putBoolean(KEEP_SCREEN_ON, keepScreenOn).apply()

var allowPhotoGestures: Boolean
get() = prefs.getBoolean(ALLOW_PHOTO_GESTURES, false)
set(allowPhotoGestures) = prefs.edit().putBoolean(ALLOW_PHOTO_GESTURES, allowPhotoGestures).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const val INCLUDED_FOLDERS = "included_folders"
const val ALBUM_COVERS = "album_covers"
const val HIDE_SYSTEM_UI = "hide_system_ui"
const val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
const val KEEP_SCREEN_ON = "keep_screen_on"
const val ALLOW_PHOTO_GESTURES = "allow_photo_gestures"
const val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
const val TEMP_FOLDER_PATH = "temp_folder_path"
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,21 @@

</RelativeLayout>

<RelativeLayout
android:id="@+id/settings_keep_screen_on_fullscreen_photos_holder"
style="@style/SettingsHolderSwitchStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<org.fossify.commons.views.MyMaterialSwitch
android:id="@+id/settings_keep_screen_on_fullscreen_photos"
style="@style/SettingsSwitchStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keep_screen_on_fullscreen_photos" />

</RelativeLayout>

<RelativeLayout
android:id="@+id/settings_allow_photo_gestures_holder"
style="@style/SettingsHolderSwitchStyle"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
<string name="scroll_thumbnails_horizontally">Przewijaj miniaturki w poziomie</string>
<string name="hide_system_ui_at_fullscreen">Automatycznie ukrywaj interfejs systemu dla multimediów na pełnym ekranie</string>
<string name="delete_empty_folders">Usuwaj puste foldery po usunięciu ich zawartości</string>
<string name="keep_screen_on_fullscreen_photos">Pozostawiaj ekran włączony podczas oglądania obrazów na pełnym ekranie</string>
<string name="allow_photo_gestures">Zezwalaj na kontrolowanie jasności obrazów pionowymi gestami</string>
<string name="allow_video_gestures">Zezwalaj na kontrolowanie głośności i jasności wideo pionowymi gestami</string>
<string name="show_media_count">Pokazuj liczbę multimediów w folderze w widoku głównym</string>
Expand Down Expand Up @@ -259,4 +260,4 @@
<string name="media_exceeds_device_capabilities">Plik przekracza możliwości urządzenia.</string>
<string name="unsupported_format">Nieobsługiwany format.</string>
<string name="file_is_malformed_or_corrupted">Plik jest wadliwy lub uszkodzony.</string>
</resources>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<string name="scroll_thumbnails_horizontally">Scroll thumbnails horizontally</string>
<string name="hide_system_ui_at_fullscreen">Automatically hide system UI at fullscreen media</string>
<string name="delete_empty_folders">Delete empty folders after deleting their content</string>
<string name="keep_screen_on_fullscreen_photos">Keep the screen on while viewing fullscreen photos</string>
<string name="allow_photo_gestures">Allow controlling photo brightness with vertical gestures</string>
<string name="allow_video_gestures">Allow controlling video volume and brightness with vertical gestures</string>
<string name="playback_speed">Playback speed</string>
Expand Down
Loading