Skip to content
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 @@ -343,6 +343,10 @@ class AppConfig(ctx: Context) : ConfigStore {
get() = default_prefs.getBoolean(PREFS_KEY_USE_CAMERA, true)
set(value) = default_prefs.edit().putBoolean(PREFS_KEY_USE_CAMERA, value).apply()

var keepScreenOn: Boolean
get() = default_prefs.getBoolean(PREFS_KEY_SCREEN_ALWAYS_ON, true)
set(value) = default_prefs.edit().putBoolean(PREFS_KEY_SCREEN_ALWAYS_ON, value).apply()

val hideNames: Boolean
get() = default_prefs.getBoolean(PREFS_KEY_HIDE_NAMES, false)

Expand Down Expand Up @@ -452,5 +456,6 @@ class AppConfig(ctx: Context) : ConfigStore {
val PREFS_KEY_KIOSK_MODE = "pref_kiosk_mode"
val PREFS_KEY_MULTI_EVENT_MODE = "multi_event_mode"
private const val PREFS_KEY_KNOWN_LIVE_EVENT_SLUGS = "cache_known_live_event_slugs"
private const val PREFS_KEY_SCREEN_ALWAYS_ON = "pref_screen_always_on"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package eu.pretix.pretixscan.droid

import android.app.Activity
import android.app.Application
import android.database.sqlite.SQLiteException
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDexApplication
import androidx.preference.PreferenceManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import can be thrown out again - after that: Feel free to merge :-)

import app.cash.sqldelight.db.QueryResult
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
import eu.pretix.libpretixsync.check.AsyncCheckProvider
Expand All @@ -24,7 +29,7 @@ import net.zetetic.database.sqlcipher.SQLiteDatabaseHook
import java.util.concurrent.locks.ReentrantLock


class PretixScan : MultiDexApplication() {
class PretixScan : MultiDexApplication(), Application.ActivityLifecycleCallbacks {
val fileStorage = AndroidFileStorage(this)
val syncLock = ReentrantLock()
lateinit var connectivityHelper: ConnectivityHelper
Expand Down Expand Up @@ -111,7 +116,7 @@ class PretixScan : MultiDexApplication() {
}

// Uncomment LogSqliteDriver for verbose logging
val driver = if(BuildConfig.DEBUG) {
val driver = if (BuildConfig.DEBUG) {
// LogSqliteDriver(androidDriver) {
// Log.d("SQLDelight", it)
// }
Expand All @@ -135,6 +140,9 @@ class PretixScan : MultiDexApplication() {
}

connectivityHelper = ConnectivityHelper(AppConfig(this))


registerActivityLifecycleCallbacks(this)
}

fun getCheckProvider(conf: AppConfig): TicketCheckProvider {
Expand Down Expand Up @@ -162,6 +170,35 @@ class PretixScan : MultiDexApplication() {
}
}

override fun onActivityCreated(
activity: Activity,
savedInstanceState: Bundle?
) {
}

override fun onActivityDestroyed(activity: Activity) {}

override fun onActivityPaused(activity: Activity) {}

override fun onActivityResumed(activity: Activity) {

if (AppConfig(this).keepScreenOn) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}

override fun onActivitySaveInstanceState(
activity: Activity,
outState: Bundle
) {
}

override fun onActivityStarted(activity: Activity) {}

override fun onActivityStopped(activity: Activity) {}

companion object {
/*
* It is not a security problem that the keystore password is hardcoded in plain text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ fun wipeApp(ctx: Context, shouldRevoke: Boolean = false) {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:keepScreenOn="true"
tools:context=".ui.EventConfigActivity">

<com.google.android.material.appbar.AppBarLayout
Expand Down
3 changes: 1 addition & 2 deletions pretixscan/app/src/main/res/layout/activity_eventinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:keepScreenOn="true">
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:keepScreenOn="true">
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
Expand Down
2 changes: 0 additions & 2 deletions pretixscan/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
Expand Down Expand Up @@ -201,7 +200,6 @@
android:id="@+id/cl_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
tools:visibility="gone">

<ImageView
Expand Down
1 change: 1 addition & 0 deletions pretixscan/app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<string name="dismiss">Schließen</string>
<string name="settings_label_about">Über diese App</string>
<string name="settings_label_licenses">Autoren und Lizenzen</string>
<string name="settings_label_screen_always_on">Bildschirm wach halten</string>
<string name="settings_label_device_camera">Geräte-Kamera benutzen</string>
<string name="settings_label_scan_offline">Offline scannen</string>
<string name="settings_label_auto_offline">Offline-Modus automatisch steuern</string>
Expand Down
1 change: 1 addition & 0 deletions pretixscan/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<string name="settings_label_ui">User interface</string>
<string name="settings_label_about">About this app</string>
<string name="settings_label_licenses">Author and licenses</string>
<string name="settings_label_screen_always_on">Keep display awake</string>
<string name="settings_label_device_camera">Use device camera</string>
<string name="settings_label_scan_offline">Offline scanning</string>
<string name="settings_label_auto_offline">Automatically turn offline mode on and off</string>
Expand Down
5 changes: 5 additions & 0 deletions pretixscan/app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
android:title="@string/settings_label_auto_switch" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_label_ui">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_screen_always_on"
android:title="@string/settings_label_screen_always_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_use_camera"
Expand Down Expand Up @@ -68,6 +72,7 @@
android:dependency="pref_print_badges"
android:key="pref_print_badges_twice"
android:title="@string/preference_badges_twice" />

</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_label_details">
<CheckBoxPreference
Expand Down