#2159 navigation works but no navigation fragments are implemented

This commit is contained in:
HissPirat 2020-06-22 13:44:42 +02:00
parent bc532d7abf
commit 560614a292
7 changed files with 45 additions and 8 deletions

View File

@ -63,11 +63,12 @@ class KiwixMainActivity : CoreMainActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kiwix_new_navigation)
if (savedInstanceState != null) {
return
}
supportFragmentManager.beginTransaction()
.add(R.id.fragment_custom_app_container, KiwixMainFragment()).commit()
.add(R.id.kiwix_fragment_containter, KiwixMainFragment()).commit()
}
}

View File

@ -87,7 +87,7 @@ class KiwixMainFragment : CoreReaderFragment() {
) = KiwixWebViewClient(webViewCallback, zimReaderContainer)
override fun onNewNavigationMenuClicked() {
// do nothing
startActivity(Intent(activity, KiwixNewNavigationActivity::class.java))
}
private fun manageExternalLaunchAndRestoringViewState() {

View File

@ -42,7 +42,6 @@ class KiwixNewNavigationActivity : CoreNewNavigationActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_new_navigation)
val navView: BottomNavigationView = findViewById(R.id.nav_view)
navController = findNavController(R.id.nav_host_fragment)

View File

@ -18,8 +18,12 @@
package org.kiwix.kiwixmobile.main
import androidx.fragment.app.Fragment
class NavigationHostFragment : Fragment() {
import android.content.Intent
import androidx.navigation.fragment.NavHostFragment
class NavigationHostFragment : NavHostFragment() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
childFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
}
}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 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/>.
~
-->
<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">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/kiwix_fragment_containter"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -23,7 +23,7 @@
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_custom_app_container"
android:id="@+id/fragment_containter"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -71,6 +71,6 @@ class CustomMainActivity : CoreMainActivity() {
return
}
supportFragmentManager.beginTransaction()
.add(R.id.fragment_custom_app_container, CustomReaderFragment()).commit()
.add(R.id.fragment_containter, CustomReaderFragment()).commit()
}
}