Merge branch 'main' into feature/following-screen

This commit is contained in:
Jackson Harper
2024-04-28 22:47:41 -07:00
committed by GitHub
11 changed files with 73 additions and 7 deletions

View File

@ -43,6 +43,8 @@ fun ReaderPreferencesView(webReaderViewModel: WebReaderViewModel) {
val themeState = remember { mutableStateOf(currentWebPreferences.storedThemePreference) }
val volumeForScrollState = remember { mutableStateOf(currentWebPreferences.shouldUseVolumeRockerForScroll) }
OmnivoreTheme {
Column(
modifier = Modifier
@ -239,6 +241,24 @@ fun ReaderPreferencesView(webReaderViewModel: WebReaderViewModel) {
}
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
stringResource(R.string.reader_preferences_view_volume_scroll),
style = TextStyle(
fontSize = 15.sp,
fontWeight = FontWeight.Normal,
color = Color(red = 137, green = 137, blue = 137))
)
Spacer(modifier = Modifier.weight(1.0F))
Switch (
checked = volumeForScrollState.value,
onCheckedChange = {
volumeForScrollState.value = it
webReaderViewModel.updateVolumeRockerForScroll(it)
}
)
}
}
}
}
@ -285,5 +305,6 @@ data class WebPreferences(
val storedThemePreference: String,
val fontFamily: WebFont,
val prefersHighContrastText: Boolean,
val prefersJustifyText: Boolean
val prefersJustifyText: Boolean,
var shouldUseVolumeRockerForScroll: Boolean
)

View File

@ -170,11 +170,17 @@ fun WebReader(
if (event.action == KeyEvent.ACTION_DOWN) {
when (keyCode) {
KeyEvent.KEYCODE_VOLUME_UP -> {
if (!webReaderViewModel.shouldUseVolumeRockerForScroll) {
return@setOnKeyListener false
}
scrollVertically(OmnivoreWebView.Direction.UP)
return@setOnKeyListener true
}
KeyEvent.KEYCODE_VOLUME_DOWN -> {
if (!webReaderViewModel.shouldUseVolumeRockerForScroll) {
return@setOnKeyListener false
}
scrollVertically(OmnivoreWebView.Direction.DOWN)
return@setOnKeyListener true
}

View File

@ -111,6 +111,8 @@ class WebReaderViewModel @Inject constructor(
private val showHighlightColorPalette = MutableLiveData(false)
val highlightColor = MutableLiveData(HighlightColor())
var shouldUseVolumeRockerForScroll = true
fun loadItem(slug: String?, requestID: String?) {
this.slug = slug
if (isLoading || webReaderParamsLiveData.value != null) {
@ -474,7 +476,8 @@ class WebReaderViewModel @Inject constructor(
val prefersHighContrastFont =
datastoreRepo.getString(prefersWebHighContrastText) == "true"
val prefersJustifyText = datastoreRepo.getString(prefersJustifyText) == "true"
val prefersJustifyText = datastoreRepo.getString(DatastoreKeys.prefersJustifyText) == "true"
val shouldUseVolumeRockerForScroll = datastoreRepo.getString(DatastoreKeys.volumeForScroll) != "false"
WebPreferences(
textFontSize = storedFontSize ?: 12,
@ -484,7 +487,8 @@ class WebReaderViewModel @Inject constructor(
storedThemePreference = storedThemePreference,
fontFamily = storedWebFont,
prefersHighContrastText = prefersHighContrastFont,
prefersJustifyText = prefersJustifyText
prefersJustifyText = prefersJustifyText,
shouldUseVolumeRockerForScroll = shouldUseVolumeRockerForScroll
)
}
@ -560,6 +564,13 @@ class WebReaderViewModel @Inject constructor(
enqueueScript(script)
}
fun updateVolumeRockerForScroll(shouldUseVolumeRockerForScroll: Boolean) {
runBlocking {
datastoreRepo.putString(DatastoreKeys.volumeForScroll, shouldUseVolumeRockerForScroll.toString())
}
this.shouldUseVolumeRockerForScroll = shouldUseVolumeRockerForScroll
}
fun applyWebFont(font: WebFont) {
runBlocking {
datastoreRepo.putString(preferredWebFontFamily, font.rawValue)

View File

@ -3,8 +3,27 @@ package app.omnivore.omnivore.utils
import app.omnivore.omnivore.BuildConfig
object Constants {
const val apiURL = BuildConfig.OMNIVORE_API_URL
const val dataStoreName = "omnivore-datastore"
const val apiURL = BuildConfig.OMNIVORE_API_URL
const val dataStoreName = "omnivore-datastore"
}
object DatastoreKeys {
const val omnivoreSelfHostedAPIServer = "omnivoreSelfHostedAPIServer"
const val omnivoreSelfHostedWebServer = "omnivoreSelfHostedWebServer"
const val omnivoreAuthToken = "omnivoreAuthToken"
const val omnivoreAuthCookieString = "omnivoreAuthCookieString"
const val omnivorePendingUserToken = "omnivorePendingUserToken"
const val libraryLastSyncTimestamp = "libraryLastSyncTimestamp"
const val preferredWebFontSize = "preferredWebFontSize"
const val preferredWebLineHeight = "preferredWebLineHeight"
const val preferredWebMaxWidthPercentage = "preferredWebMaxWidthPercentage"
const val preferredWebFontFamily = "preferredWebFontFamily"
const val prefersWebHighContrastText = "prefersWebHighContrastText"
const val prefersJustifyText = "prefersJustifyText"
const val lastUsedSavedItemFilter = "lastUsedSavedItemFilter"
const val lastUsedSavedItemSortFilter = "lastUsedSavedItemSortFilter"
const val preferredTheme = "preferredTheme"
const val volumeForScroll = "volumeForScroll"
}
object AppleConstants {

View File

@ -148,6 +148,7 @@
<string name="reader_preferences_view_justify_text">Text ausrichten</string>
<!-- WebReaderLoadingContainer -->
<string name="reader_preferences_view_volume_scroll">Verwenden Sie die Lautstärketasten zum Scrollen</string>
<string name="web_reader_loading_container_error_msg">Wir konnten deinen Inhalt nicht abrufen.</string>
<string name="web_reader_loading_container_bottom_sheet_reader_preferences">Lese-Einstellungen</string>
<string name="web_reader_loading_container_bottom_sheet_notebook">Notizbuch</string>

View File

@ -149,6 +149,7 @@
<string name="reader_preferences_view_justify_text">对齐文字</string>
<!-- WebReaderLoadingContainer -->
<string name="reader_preferences_view_volume_scroll">使用音量按钮滚动</string>
<string name="web_reader_loading_container_error_msg">我们无法取得您的内容。</string>
<string name="web_reader_loading_container_bottom_sheet_reader_preferences">阅读器偏好设定</string>
<string name="web_reader_loading_container_bottom_sheet_notebook">笔记</string>

View File

@ -148,6 +148,7 @@
<string name="reader_preferences_view_justify_text">對齊文字</string>
<!-- WebReaderLoadingContainer -->
<string name="reader_preferences_view_volume_scroll">使用音量按鈕捲動</string>
<string name="web_reader_loading_container_error_msg">我們無法取得您的內容。</string>
<string name="web_reader_loading_container_bottom_sheet_reader_preferences">閱讀器偏好設定</string>
<string name="web_reader_loading_container_bottom_sheet_notebook">筆記本</string>

View File

@ -153,6 +153,7 @@
<string name="reader_preferences_view_auto">Auto</string>
<string name="reader_preferences_view_high_constrast_text">High Contrast Text</string>
<string name="reader_preferences_view_justify_text">Justify Text</string>
<string name="reader_preferences_view_volume_scroll">Use Volume Rocker to scroll</string>
<!-- WebReaderLoadingContainer -->
<string name="web_reader_loading_container_error_msg">We were unable to fetch your content.</string>

View File

@ -16,7 +16,6 @@ import {
generateUploadSignedUrl,
} from '../../utils/uploads'
const MAX_DAILY_UPLOADS = 1
const VALID_CONTENT_TYPES = ['text/csv', 'application/zip']
const extensionForContentType = (contentType: string) => {
@ -61,6 +60,7 @@ export const uploadImportFileResolver = authorized<
const dirPath = `imports/${uid}/${dateStr}/`
const fileCount = await countOfFilesWithPrefix(dirPath)
const MAX_DAILY_UPLOADS = env.fileUpload.dailyUploadLimit
if (fileCount >= MAX_DAILY_UPLOADS) {
return {
errorCodes: [UploadImportFileErrorCode.UploadDailyLimitExceeded],

View File

@ -81,6 +81,7 @@ export interface BackendEnv {
gcsUploadBucket: string
gcsUploadSAKeyFilePath: string
gcsUploadPrivateBucket: string
dailyUploadLimit: number
}
sender: {
message: string
@ -144,6 +145,7 @@ const nullableEnvVars = [
'POSTHOG_API_KEY',
'TWITTER_BEARER_TOKEN',
'GCS_UPLOAD_PRIVATE_BUCKET',
'GCS_UPLOAD_DAILY_LIMIT',
'SENDER_MESSAGE',
'SENDER_FEEDBACK',
'SENDER_GENERAL',
@ -275,6 +277,9 @@ export function getEnv(): BackendEnv {
gcsUploadBucket: parse('GCS_UPLOAD_BUCKET'),
gcsUploadSAKeyFilePath: parse('GCS_UPLOAD_SA_KEY_FILE_PATH'),
gcsUploadPrivateBucket: parse('GCS_UPLOAD_PRIVATE_BUCKET'),
dailyUploadLimit: parse('GCS_UPLOAD_DAILY_LIMIT')
? parseInt(parse('GCS_UPLOAD_DAILY_LIMIT'), 10)
: 5, // default to 5
}
const sender = {
message: parse('SENDER_MESSAGE'),

View File

@ -78,7 +78,7 @@ const ARTICLE_PREFIX = 'omnivore:'
export const FAKE_URL_PREFIX = 'https://omnivore.app/no_url?q='
export const RSS_PARSER_CONFIG = {
timeout: 5000, // 5 seconds
timeout: 20000, // 20 seconds
headers: {
// some rss feeds require user agent
'User-Agent':