mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Enabled EdgeToEdge mode in project to support latest windowInset API.
This commit is contained in:
parent
db41f1d876
commit
ccfc896f02
@ -21,8 +21,7 @@
|
||||
android:id="@+id/navigation_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/open_drawer"
|
||||
android:fitsSystemWindows="true">
|
||||
android:contentDescription="@string/open_drawer">
|
||||
|
||||
<org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -53,7 +52,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/nav_main"
|
||||
app:menu="@menu/menu_drawer_main" />
|
||||
|
||||
@ -62,7 +60,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/drawer_right" />
|
||||
|
||||
|
||||
|
@ -1,24 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/layout_standard_app_bar" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
tools:listitem="@layout/item_language"
|
||||
android:id="@+id/language_recycler_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
android:contentDescription="@string/pref_language_title"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_bar" />
|
||||
app:layout_constraintTop_toBottomOf="@id/app_bar"
|
||||
tools:listitem="@layout/item_language" />
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/language_progressbar"
|
||||
|
@ -22,7 +22,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="org.kiwix.kiwixmobile.webserver.ZimHostFragment">
|
||||
|
||||
<include layout="@layout/layout_toolbar" />
|
||||
|
@ -21,8 +21,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -5,7 +5,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="org.kiwix.kiwixmobile.localFileTransfer.LocalFileTransferFragment">
|
||||
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import io.opencensus.trace.Tracing
|
||||
|
||||
/**
|
||||
* Generated by https://github.com/jmfayard/buildSrcVersions
|
||||
*
|
||||
@ -308,6 +306,8 @@ object Libs {
|
||||
*/
|
||||
const val core_ktx: String = "androidx.core:core-ktx:" + Versions.core_ktx
|
||||
|
||||
const val androidx_activity: String = "androidx.activity:activity:" + Versions.androidx_activity
|
||||
|
||||
/**
|
||||
* https://github.com/kiwix/java-libkiwix
|
||||
*/
|
||||
|
@ -90,6 +90,8 @@ object Versions {
|
||||
|
||||
const val core_ktx: String = "1.15.0"
|
||||
|
||||
const val androidx_activity: String = "1.9.3"
|
||||
|
||||
const val libkiwix: String = "2.2.3"
|
||||
|
||||
const val material: String = "1.12.0"
|
||||
|
@ -233,6 +233,7 @@ class AllProjectConfigurer {
|
||||
kapt(Libs.roomCompiler)
|
||||
implementation(Libs.tracing)
|
||||
implementation(Libs.fetchOkhttp)
|
||||
implementation(Libs.androidx_activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,13 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.base
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.changeStatusBarAndNavigationBarColorInAndroid15AndAbove
|
||||
import org.kiwix.kiwixmobile.core.utils.LanguageUtils
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import javax.inject.Inject
|
||||
@ -29,7 +34,14 @@ open class BaseActivity : AppCompatActivity() {
|
||||
lateinit var sharedPreferenceUtil: SharedPreferenceUtil
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle = SystemBarStyle.dark(Color.BLACK),
|
||||
navigationBarStyle = SystemBarStyle.dark(Color.BLACK)
|
||||
)
|
||||
super.onCreate(savedInstanceState)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
changeStatusBarAndNavigationBarColorInAndroid15AndAbove()
|
||||
}
|
||||
LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil)
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,14 @@ package org.kiwix.kiwixmobile.core.base
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.extensions.enableEdgeToEdgeMode
|
||||
import org.kiwix.kiwixmobile.core.extensions.getToolbarNavigationIcon
|
||||
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
|
||||
|
||||
@ -46,7 +50,17 @@ abstract class BaseFragment : Fragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
enableEdgeToEdgeMode()
|
||||
setupToolbar()
|
||||
this.view?.let {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(it) { view, windowInsets ->
|
||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
val layoutParams = view.layoutParams as? ViewGroup.MarginLayoutParams
|
||||
layoutParams?.topMargin = insets.top
|
||||
view.layoutParams = layoutParams
|
||||
WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup toolbar to handle common back pressed event
|
||||
|
@ -29,6 +29,8 @@ import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.WindowInsetsController
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
@ -199,4 +201,21 @@ object ActivityExtensions {
|
||||
val isWideEnough = configuration.smallestScreenWidthDp >= 600
|
||||
return isLargeOrXLarge && isWideEnough
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for setting the statusBar color for Android 15 and above.
|
||||
* Since in Android 15 the setStatusBarColor method is deprecated and not works anymore.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
fun Activity.changeStatusBarAndNavigationBarColorInAndroid15AndAbove() {
|
||||
window?.apply {
|
||||
// Set the white color to icon since the statusBar color is black.
|
||||
decorView.windowInsetsController?.setSystemBarsAppearance(
|
||||
0,
|
||||
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
|
||||
)
|
||||
insetsController?.hide(android.view.WindowInsets.Type.statusBars())
|
||||
insetsController?.show(android.view.WindowInsets.Type.statusBars())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,12 @@
|
||||
package org.kiwix.kiwixmobile.core.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModel
|
||||
@ -55,3 +57,12 @@ fun View.closeKeyboard() {
|
||||
}
|
||||
|
||||
val Fragment.coreMainActivity get() = activity as CoreMainActivity
|
||||
|
||||
fun Fragment.enableEdgeToEdgeMode() {
|
||||
activity?.window?.let {
|
||||
WindowCompat.setDecorFitsSystemWindows(
|
||||
it,
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,4 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:focusable="true" />
|
||||
|
@ -4,7 +4,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".help.HelpFragment">
|
||||
|
||||
<include layout="@layout/layout_standard_app_bar" />
|
||||
|
@ -3,8 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
|
@ -20,8 +20,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/navigation_fragment_main_drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -4,7 +4,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
@ -24,7 +24,6 @@
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:ignore="ContentDescription"
|
||||
android:src="@drawable/ic_home_kiwix_banner" />
|
||||
</LinearLayout>
|
||||
|
@ -26,8 +26,7 @@
|
||||
|
||||
<org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/activity_main_content_frame"
|
||||
|
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -2,8 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/tab_switcher_recycler_view"
|
||||
|
@ -82,7 +82,6 @@
|
||||
</style>
|
||||
|
||||
<style name="Base.MaterialThemeBuilder" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
|
||||
<item name="android:statusBarColor" tools:ignore="NewApi">@color/black</item>
|
||||
<item name="actionModeBackground">@color/cornflower_blue</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
|
@ -22,7 +22,6 @@
|
||||
android:id="@+id/custom_drawer_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:ignore="UnusedIds">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
@ -38,7 +37,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/nav_main"
|
||||
app:menu="@menu/menu_drawer_main" />
|
||||
|
||||
@ -48,6 +46,5 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="24dp"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/drawer_right" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user