mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -04:00
Merge pull request #4421 from kiwix/Fixes#4420
Fixed: The `ActionMode` title and back button color did not match our pure white theme.
This commit is contained in:
commit
59030624b3
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2025 Kiwix <android.kiwix.org>
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.ui.components
|
|
||||||
|
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberUpdatedState
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.runtime.snapshotFlow
|
|
||||||
|
|
||||||
const val ONE_THOUSAND = 1000
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun rememberLazyListScrollListener(
|
|
||||||
lazyListState: LazyListState,
|
|
||||||
onScrollChanged: (ScrollDirection) -> Unit,
|
|
||||||
scrollThreshold: Int = 20
|
|
||||||
): LazyListState {
|
|
||||||
val updatedOnScrollChanged = rememberUpdatedState(onScrollChanged)
|
|
||||||
|
|
||||||
var previousScrollPosition by remember { mutableIntStateOf(0) }
|
|
||||||
var lastScrollDirection by remember { mutableStateOf(ScrollDirection.IDLE) }
|
|
||||||
|
|
||||||
LaunchedEffect(lazyListState) {
|
|
||||||
snapshotFlow {
|
|
||||||
lazyListState.firstVisibleItemIndex to lazyListState.firstVisibleItemScrollOffset
|
|
||||||
}.collect { (index, offset) ->
|
|
||||||
val currentScrollPosition = index * ONE_THOUSAND + offset
|
|
||||||
val scrollDelta = currentScrollPosition - previousScrollPosition
|
|
||||||
|
|
||||||
val scrollDirection = when {
|
|
||||||
scrollDelta > scrollThreshold -> ScrollDirection.SCROLL_DOWN
|
|
||||||
scrollDelta < -scrollThreshold -> ScrollDirection.SCROLL_UP
|
|
||||||
else -> lastScrollDirection
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollDirection != lastScrollDirection) {
|
|
||||||
lastScrollDirection = scrollDirection
|
|
||||||
updatedOnScrollChanged.value(scrollDirection)
|
|
||||||
}
|
|
||||||
|
|
||||||
previousScrollPosition = currentScrollPosition
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lazyListState
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class ScrollDirection {
|
|
||||||
SCROLL_UP,
|
|
||||||
SCROLL_DOWN,
|
|
||||||
IDLE
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<corners android:radius="3dp" />
|
|
||||||
<stroke android:color="@android:color/white" android:width="1.5dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
</selector>
|
|
@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="36dp"
|
|
||||||
android:viewportHeight="24.0"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:width="36dp">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FF000000"
|
|
||||||
android:pathData="M5,16h3v3h2v-5L5,14v2zM8,8L5,8v2h5L10,5L8,5v3zM14,19h2v-3h3v-2h-5v5zM16,8L16,5h-2v5h5L19,8h-3z" />
|
|
||||||
</vector>
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<!-- Background color -->
|
|
||||||
<item android:id="@android:id/background">
|
|
||||||
<shape>
|
|
||||||
<solid android:color="@color/mine_shaft_gray350" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<!-- Progress color -->
|
|
||||||
<item android:id="@android:id/progress">
|
|
||||||
<clip>
|
|
||||||
<shape>
|
|
||||||
<solid android:color="@color/denim_blue800" />
|
|
||||||
</shape>
|
|
||||||
</clip>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
</layer-list>
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<corners android:radius="3dip" />
|
|
||||||
<stroke
|
|
||||||
android:width="1.5dip"
|
|
||||||
android:color="@color/alabaster_white" />
|
|
||||||
<padding
|
|
||||||
android:bottom="0dip"
|
|
||||||
android:left="0dip"
|
|
||||||
android:right="0dip"
|
|
||||||
android:top="0dip" />
|
|
||||||
</shape>
|
|
33
core/src/main/res/layout/action_mode_back_button.xml
Normal file
33
core/src/main/res/layout/action_mode_back_button.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ Kiwix Android
|
||||||
|
~ Copyright (c) 2025 Kiwix <android.kiwix.org>
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
~
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/action_mode_close_button"
|
||||||
|
style="?attr/actionModeCloseButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginEnd="16dip"
|
||||||
|
android:clickable="true"
|
||||||
|
android:contentDescription="?attr/actionModeCloseContentDescription"
|
||||||
|
android:focusable="true"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
app:srcCompat="?attr/actionModeCloseDrawable"
|
||||||
|
app:tint="@color/white"
|
||||||
|
tools:ignore="RtlSymmetry" />
|
@ -83,7 +83,11 @@
|
|||||||
|
|
||||||
<style name="Base.MaterialThemeBuilder" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
<style name="Base.MaterialThemeBuilder" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
<item name="android:statusBarColor" tools:ignore="NewApi">@color/black</item>
|
<item name="android:statusBarColor" tools:ignore="NewApi">@color/black</item>
|
||||||
<item name="actionModeBackground">@color/cornflower_blue</item>
|
<!-- Increase the default action bar size so that ActionMode has more height.
|
||||||
|
Since we are now using Compose's TopAppBar, changing this will not affect the main UI. -->
|
||||||
|
<item name="actionBarSize">64dp</item>
|
||||||
|
<!-- Apply our custom ActionMode style -->
|
||||||
|
<item name="actionModeStyle">@style/Widget.KiwixTheme.ActionMode</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
|
|
||||||
<!--Remap legacy AppCompat attributes to MaterialComponent attributes-->
|
<!--Remap legacy AppCompat attributes to MaterialComponent attributes-->
|
||||||
@ -95,4 +99,15 @@
|
|||||||
<item name="android:windowLayoutInDisplayCutoutMode" tools:ignore="NewApi">never</item>
|
<item name="android:windowLayoutInDisplayCutoutMode" tools:ignore="NewApi">never</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Widget.KiwixTheme.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
|
||||||
|
<item name="background">@color/cornflower_blue</item>
|
||||||
|
<item name="titleTextStyle">@style/TextAppearance.KiwixTheme.ActionMode.Title</item>
|
||||||
|
<!-- Use a custom back button (white) so it matches our theme -->
|
||||||
|
<item name="closeItemLayout">@layout/action_mode_back_button</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.KiwixTheme.ActionMode.Title" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
|
||||||
|
<!-- Set the ActionMode title text color to white -->
|
||||||
|
<item name="android:textColor">@color/white</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user