forked from akai/readest
android: dismiss the splash screen and change icon background color in task list (#1450)
* layout: various layout fix on iPad * android: dismiss the splash screen and change icon background color in task list, closes #1424
This commit is contained in:
+38
@@ -1,10 +1,14 @@
|
||||
package com.bilingify.readest
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import android.view.KeyEvent
|
||||
import android.webkit.WebView
|
||||
import android.util.Log
|
||||
import android.graphics.Color
|
||||
import android.app.ActivityManager
|
||||
import android.content.res.Configuration
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -77,5 +81,39 @@ class MainActivity : TauriActivity(), KeyDownInterceptor {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
updateTaskDescription()
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
updateTaskDescription()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateTaskDescription()
|
||||
}
|
||||
|
||||
private fun updateTaskDescription() {
|
||||
val backgroundColor = if (isDarkTheme()) {
|
||||
Color.parseColor("#2D2D2D")
|
||||
} else {
|
||||
Color.parseColor("#FFFFFF")
|
||||
}
|
||||
|
||||
setTaskDescription(
|
||||
ActivityManager.TaskDescription(
|
||||
"Readest",
|
||||
null,
|
||||
backgroundColor
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun isDarkTheme(): Boolean {
|
||||
return when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
||||
Configuration.UI_MODE_NIGHT_YES -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.readest" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="android:windowSplashScreenBackground">@android:color/transparent</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="31">@null</item>
|
||||
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowTranslucentStatus">false</item>
|
||||
|
||||
@@ -163,6 +163,8 @@ const FooterBar: React.FC<FooterBarProps> = ({
|
||||
? (progressInfo!.current + 1) / progressInfo!.total || 0
|
||||
: 0;
|
||||
|
||||
const isMobile = window.innerWidth < 640 || window.innerHeight < 640;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -202,7 +204,7 @@ const FooterBar: React.FC<FooterBarProps> = ({
|
||||
: 'pointer-events-none invisible translate-y-full overflow-hidden pb-0 pt-0 ease-in',
|
||||
)}
|
||||
style={{
|
||||
bottom: appService?.hasSafeAreaInset ? `${gridInsets.bottom + 64}px` : '64px',
|
||||
bottom: isMobile ? `${gridInsets.bottom + 64}px` : '64px',
|
||||
}}
|
||||
>
|
||||
<div className='flex w-full items-center justify-between gap-x-6'>
|
||||
@@ -256,7 +258,7 @@ const FooterBar: React.FC<FooterBarProps> = ({
|
||||
: 'pointer-events-none invisible translate-y-full overflow-hidden pb-0 pt-0 ease-in',
|
||||
)}
|
||||
style={{
|
||||
bottom: appService?.hasSafeAreaInset ? `${gridInsets.bottom + 64}px` : '64px',
|
||||
bottom: isMobile ? `${gridInsets.bottom + 64}px` : '64px',
|
||||
}}
|
||||
>
|
||||
<Slider
|
||||
@@ -298,7 +300,7 @@ const FooterBar: React.FC<FooterBarProps> = ({
|
||||
'bg-base-200 z-50 mt-auto flex w-full justify-between px-8 py-4 sm:hidden',
|
||||
)}
|
||||
style={{
|
||||
paddingBottom: appService?.hasSafeAreaInset ? `${gridInsets.bottom + 16}px` : '0px',
|
||||
paddingBottom: isMobile ? `${gridInsets.bottom + 16}px` : '0px',
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
@@ -328,7 +330,7 @@ const FooterBar: React.FC<FooterBarProps> = ({
|
||||
<div
|
||||
className='absolute hidden h-full w-full items-center gap-x-4 px-4 sm:flex'
|
||||
style={{
|
||||
bottom: appService?.hasSafeAreaInset ? `${gridInsets.bottom / 2}px` : '0px',
|
||||
bottom: isMobile ? `${gridInsets.bottom / 2}px` : '0px',
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
|
||||
@@ -31,7 +31,8 @@ export interface TextSelection {
|
||||
annotated?: boolean;
|
||||
}
|
||||
|
||||
const frameRect = (frame: Frame, rect: Rect, sx = 1, sy = 1) => {
|
||||
const frameRect = (frame: Frame, rect?: Rect, sx = 1, sy = 1) => {
|
||||
if (!rect) return { left: 0, right: 0, top: 0, bottom: 0 };
|
||||
const left = sx * rect.left + frame.left;
|
||||
const right = sx * rect.right + frame.left;
|
||||
const top = sy * rect.top + frame.top;
|
||||
@@ -84,8 +85,8 @@ export const getPosition = (
|
||||
|
||||
const frame = frameElement?.getBoundingClientRect() ?? { top: 0, left: 0 };
|
||||
const rects = Array.from(target.getClientRects());
|
||||
const first = frameRect(frame, rects[0] as Rect, sx, sy);
|
||||
const last = frameRect(frame, rects.at(-1) as Rect, sx, sy);
|
||||
const first = frameRect(frame, rects[0], sx, sy);
|
||||
const last = frameRect(frame, rects.at(-1), sx, sy);
|
||||
|
||||
if (isVertical) {
|
||||
const leftSpace = first.left - rect.left;
|
||||
|
||||
Reference in New Issue
Block a user