mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
#2159 merge with 2147 and implementation of BaseFragmentActivityExtensions in NavHostFragment
This commit is contained in:
commit
71e6bbcb6e
@ -5,7 +5,7 @@
|
|||||||
<ID>EmptyFunctionBlock:None.kt$None${ }</ID>
|
<ID>EmptyFunctionBlock:None.kt$None${ }</ID>
|
||||||
<ID>EmptyFunctionBlock:SimplePageChangeListener.kt$SimplePageChangeListener${ }</ID>
|
<ID>EmptyFunctionBlock:SimplePageChangeListener.kt$SimplePageChangeListener${ }</ID>
|
||||||
<ID>EmptyFunctionBlock:ZimHostActivity.kt$ZimHostActivity.<no name provided>${}</ID>
|
<ID>EmptyFunctionBlock:ZimHostActivity.kt$ZimHostActivity.<no name provided>${}</ID>
|
||||||
<ID>ForbiddenComment:KiwixMainFragment.kt$KiwixMainFragment$// TODO: Show to user</ID>
|
<ID>ForbiddenComment:KiwixReaderFragment.kt$KiwixReaderFragment$// TODO: Show to user</ID>
|
||||||
<ID>ForbiddenComment:ReaderFragment.kt$ReaderFragment$// TODO: Show to user</ID>
|
<ID>ForbiddenComment:ReaderFragment.kt$ReaderFragment$// TODO: Show to user</ID>
|
||||||
<ID>LongParameterList:ZimManageViewModel.kt$ZimManageViewModel$( booksOnFileSystem: List<BookOnDisk>, activeDownloads: List<DownloadModel>, allLanguages: List<Language>, libraryNetworkEntity: LibraryNetworkEntity, filter: String, fileSystemState: FileSystemState )</ID>
|
<ID>LongParameterList:ZimManageViewModel.kt$ZimManageViewModel$( booksOnFileSystem: List<BookOnDisk>, activeDownloads: List<DownloadModel>, allLanguages: List<Language>, libraryNetworkEntity: LibraryNetworkEntity, filter: String, fileSystemState: FileSystemState )</ID>
|
||||||
<ID>MagicNumber:LibraryListItem.kt$LibraryListItem.LibraryDownloadItem$1000L</ID>
|
<ID>MagicNumber:LibraryListItem.kt$LibraryListItem.LibraryDownloadItem$1000L</ID>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
<ID>ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean</ID>
|
<ID>ReturnCount:Fat32Checker.kt$Fat32Checker$private fun canCreate4GbFile(storage: String): Boolean</ID>
|
||||||
<ID>ReturnCount:LanguageActivity.kt$LanguageActivity$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
|
<ID>ReturnCount:LanguageActivity.kt$LanguageActivity$override fun onOptionsItemSelected(item: MenuItem): Boolean</ID>
|
||||||
<ID>TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception</ID>
|
<ID>TooGenericExceptionCaught:FileWritingFileSystemChecker.kt$FileWritingFileSystemChecker$e: Exception</ID>
|
||||||
<ID>TooGenericExceptionCaught:KiwixMainFragment.kt$KiwixMainFragment$e: Exception</ID>
|
<ID>TooGenericExceptionCaught:KiwixReaderFragment.kt$KiwixReaderFragment$e: Exception</ID>
|
||||||
<ID>TooGenericExceptionCaught:ReaderFragment.kt$ReaderFragment$e: Exception</ID>
|
<ID>TooGenericExceptionCaught:ReaderFragment.kt$ReaderFragment$e: Exception</ID>
|
||||||
<ID>TooGenericExceptionThrown:ActivityExtensions.kt$throw RuntimeException( """ applicationContext is ${applicationContext::class.java.simpleName} application is ${application::class.java.simpleName} """.trimIndent() )</ID>
|
<ID>TooGenericExceptionThrown:ActivityExtensions.kt$throw RuntimeException( """ applicationContext is ${applicationContext::class.java.simpleName} application is ${application::class.java.simpleName} """.trimIndent() )</ID>
|
||||||
<ID>TooGenericExceptionThrown:LibraryViewHolder.kt$LibraryViewHolder.LibraryBookViewHolder$throw RuntimeException("impossible invalid state: ${item.fileSystemState}")</ID>
|
<ID>TooGenericExceptionThrown:LibraryViewHolder.kt$LibraryViewHolder.LibraryBookViewHolder$throw RuntimeException("impossible invalid state: ${item.fileSystemState}")</ID>
|
||||||
|
@ -27,10 +27,10 @@ import org.kiwix.kiwixmobile.intro.IntroModule
|
|||||||
import org.kiwix.kiwixmobile.language.LanguageActivity
|
import org.kiwix.kiwixmobile.language.LanguageActivity
|
||||||
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
|
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainFragment
|
|
||||||
import org.kiwix.kiwixmobile.main.KiwixNewNavigationActivity
|
import org.kiwix.kiwixmobile.main.KiwixNewNavigationActivity
|
||||||
import org.kiwix.kiwixmobile.nav.destination.library.OnlineLibraryFragment
|
import org.kiwix.kiwixmobile.main.KiwixReaderFragment
|
||||||
import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragment
|
import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragment
|
||||||
|
import org.kiwix.kiwixmobile.nav.destination.library.OnlineLibraryFragment
|
||||||
import org.kiwix.kiwixmobile.nav.destination.reader.ReaderFragment
|
import org.kiwix.kiwixmobile.nav.destination.reader.ReaderFragment
|
||||||
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
|
import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity
|
||||||
import org.kiwix.kiwixmobile.splash.KiwixSplashActivity
|
import org.kiwix.kiwixmobile.splash.KiwixSplashActivity
|
||||||
@ -63,9 +63,9 @@ interface KiwixActivityComponent {
|
|||||||
fun inject(zimHostActivity: ZimHostActivity)
|
fun inject(zimHostActivity: ZimHostActivity)
|
||||||
fun inject(introActivity: IntroActivity)
|
fun inject(introActivity: IntroActivity)
|
||||||
fun inject(kiwixSplashActivity: KiwixSplashActivity)
|
fun inject(kiwixSplashActivity: KiwixSplashActivity)
|
||||||
fun inject(kiwixMainFragment: KiwixMainFragment)
|
|
||||||
fun inject(kiwixNewNavigationActivity: KiwixNewNavigationActivity)
|
fun inject(kiwixNewNavigationActivity: KiwixNewNavigationActivity)
|
||||||
fun inject(onlineLibraryFragment: OnlineLibraryFragment)
|
fun inject(onlineLibraryFragment: OnlineLibraryFragment)
|
||||||
|
fun inject(kiwixMainFragment: KiwixReaderFragment)
|
||||||
|
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
@ -18,11 +18,8 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.main
|
package org.kiwix.kiwixmobile.main
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.ActionMode
|
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
||||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||||
@ -32,35 +29,6 @@ class KiwixMainActivity : CoreMainActivity() {
|
|||||||
kiwixActivityComponent.inject(this)
|
kiwixActivityComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionModeStarted(mode: ActionMode) {
|
|
||||||
super.onActionModeStarted(mode)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onActionModeStarted(mode, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActionModeFinished(mode: ActionMode) {
|
|
||||||
super.onActionModeFinished(mode)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onActionModeFinished(mode, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
if (it.onBackPressed(this) == BaseFragmentActivityExtensions.Super.ShouldCall) {
|
|
||||||
super.onBackPressed()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
|
||||||
super.onNewIntent(intent)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onNewIntent(intent, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_kiwix_new_navigation)
|
setContentView(R.layout.activity_kiwix_new_navigation)
|
||||||
@ -69,6 +37,6 @@ class KiwixMainActivity : CoreMainActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.add(R.id.kiwix_fragment_containter, KiwixMainFragment()).commit()
|
.add(R.id.kiwix_fragment_containter, KiwixReaderFragment()).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,10 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
|
|||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
||||||
import org.kiwix.kiwixmobile.core.main.CoreNewNavigationActivity
|
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||||
|
|
||||||
class KiwixNewNavigationActivity : CoreNewNavigationActivity() {
|
class KiwixNewNavigationActivity : CoreMainActivity() {
|
||||||
private lateinit var navController: NavController
|
private lateinit var navController: NavController
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
override fun injection(coreComponent: CoreComponent) {
|
override fun injection(coreComponent: CoreComponent) {
|
||||||
|
@ -53,7 +53,7 @@ import org.kiwix.kiwixmobile.webserver.ZimHostActivity
|
|||||||
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class KiwixMainFragment : CoreReaderFragment() {
|
class KiwixReaderFragment : CoreReaderFragment() {
|
||||||
|
|
||||||
override fun inject(baseActivity: BaseActivity) {
|
override fun inject(baseActivity: BaseActivity) {
|
||||||
baseActivity.kiwixActivityComponent.inject(this)
|
baseActivity.kiwixActivityComponent.inject(this)
|
@ -19,11 +19,87 @@
|
|||||||
package org.kiwix.kiwixmobile.main
|
package org.kiwix.kiwixmobile.main
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.view.ActionMode
|
||||||
|
import android.view.Menu
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
|
||||||
|
import org.kiwix.kiwixmobile.core.main.KiwixWebView
|
||||||
|
import org.kiwix.kiwixmobile.core.main.WebViewProvider
|
||||||
|
|
||||||
class NavigationHostFragment : NavHostFragment() {
|
class NavigationHostFragment : NavHostFragment(), WebViewProvider, BaseFragmentActivityExtensions {
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
childFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
|
childFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCurrentWebView(): KiwixWebView? {
|
||||||
|
return childFragmentManager.fragments.filterIsInstance<WebViewProvider>().firstOrNull()
|
||||||
|
?.getCurrentWebView()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<out String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
childFragmentManager.fragments.forEach {
|
||||||
|
it.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionModeStarted(
|
||||||
|
actionMode: ActionMode,
|
||||||
|
activity: AppCompatActivity
|
||||||
|
): Super {
|
||||||
|
var result = ShouldCall
|
||||||
|
childFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
result = it.onActionModeStarted(actionMode, activity)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionModeFinished(
|
||||||
|
actionMode: ActionMode,
|
||||||
|
activity: AppCompatActivity
|
||||||
|
): Super {
|
||||||
|
var result = ShouldCall
|
||||||
|
childFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
result = it.onActionModeFinished(actionMode, activity)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(activity: AppCompatActivity): Super {
|
||||||
|
var result = ShouldCall
|
||||||
|
childFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
result = it.onBackPressed(activity)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNewIntent(
|
||||||
|
intent: Intent,
|
||||||
|
activity: AppCompatActivity
|
||||||
|
): Super {
|
||||||
|
var result = ShouldCall
|
||||||
|
childFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
result = it.onNewIntent(intent, activity)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(
|
||||||
|
menu: Menu,
|
||||||
|
activity: AppCompatActivity
|
||||||
|
): Super {
|
||||||
|
var result = ShouldCall
|
||||||
|
childFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
result = it.onCreateOptionsMenu(menu, activity)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,17 @@ import android.content.Intent
|
|||||||
import android.view.ActionMode
|
import android.view.ActionMode
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
|
||||||
|
|
||||||
interface BaseFragmentActivityExtensions {
|
interface BaseFragmentActivityExtensions {
|
||||||
enum class Super {
|
enum class Super {
|
||||||
ShouldCall,
|
ShouldCall,
|
||||||
DontCall
|
ShouldNotCall
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onActionModeStarted(actionMode: ActionMode, activity: AppCompatActivity): Super
|
fun onActionModeStarted(actionMode: ActionMode, activity: AppCompatActivity): Super = ShouldCall
|
||||||
fun onActionModeFinished(actionMode: ActionMode, activity: AppCompatActivity): Super
|
fun onActionModeFinished(actionMode: ActionMode, activity: AppCompatActivity): Super = ShouldCall
|
||||||
fun onBackPressed(activity: AppCompatActivity): Super
|
fun onBackPressed(activity: AppCompatActivity): Super = ShouldCall
|
||||||
fun onNewIntent(intent: Intent, activity: AppCompatActivity): Super
|
fun onNewIntent(intent: Intent, activity: AppCompatActivity): Super = ShouldCall
|
||||||
fun onCreateOptionsMenu(menu: Menu, activity: AppCompatActivity): Super
|
fun onCreateOptionsMenu(menu: Menu, activity: AppCompatActivity): Super = ShouldCall
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Kiwix Android
|
|
||||||
* Copyright (c) 2019 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.main;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.kiwix.kiwixmobile.core.R;
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
|
||||||
|
|
||||||
public abstract class CoreMainActivity extends BaseActivity implements WebViewProvider {
|
|
||||||
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void onActivityResult(int requestCode, int resultCode,
|
|
||||||
@androidx.annotation.Nullable Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
for (Fragment it : getSupportFragmentManager().getFragments()) {
|
|
||||||
it.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@androidx.annotation.Nullable @Override public KiwixWebView getCurrentWebView() {
|
|
||||||
for (Fragment frag : getSupportFragmentManager().getFragments()) {
|
|
||||||
if (frag instanceof WebViewProvider) {
|
|
||||||
return ((WebViewProvider) frag).getCurrentWebView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Kiwix Android
|
||||||
|
* Copyright (c) 2019 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.main
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.ActionMode
|
||||||
|
import org.kiwix.kiwixmobile.core.R
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
|
||||||
|
|
||||||
|
abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_main)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
supportFragmentManager.fragments.forEach { it.onActivityResult(requestCode, resultCode, data) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<out String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
supportFragmentManager.fragments.forEach {
|
||||||
|
it.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionModeStarted(mode: ActionMode) {
|
||||||
|
super.onActionModeStarted(mode)
|
||||||
|
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
it.onActionModeStarted(mode, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionModeFinished(mode: ActionMode) {
|
||||||
|
super.onActionModeFinished(mode)
|
||||||
|
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
it.onActionModeFinished(mode, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
if (it.onBackPressed(this) == ShouldCall) {
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNewIntent(intent: Intent) {
|
||||||
|
super.onNewIntent(intent)
|
||||||
|
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
||||||
|
it.onNewIntent(intent, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCurrentWebView(): KiwixWebView? {
|
||||||
|
return supportFragmentManager.fragments.filterIsInstance<WebViewProvider>().firstOrNull()
|
||||||
|
?.getCurrentWebView()
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.kiwix.kiwixmobile.core.main;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity;
|
|
||||||
|
|
||||||
public abstract class CoreNewNavigationActivity extends BaseActivity {
|
|
||||||
|
|
||||||
@Override protected void onActivityResult(int requestCode, int resultCode,
|
|
||||||
@androidx.annotation.Nullable Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
for (Fragment it : getSupportFragmentManager().getFragments()) {
|
|
||||||
it.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setContentView(int layoutResID) {
|
|
||||||
super.setContentView(layoutResID);
|
|
||||||
}
|
|
||||||
}
|
|
@ -300,13 +300,12 @@ public abstract class CoreReaderFragment extends BaseFragment
|
|||||||
getActivity().getMenuInflater().inflate(R.menu.menu_webview_action, menu);
|
getActivity().getMenuInflater().inflate(R.menu.menu_webview_action, menu);
|
||||||
configureWebViewSelectionHandler(menu);
|
configureWebViewSelectionHandler(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Super.ShouldCall;
|
return Super.ShouldCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public Super onActionModeFinished(@NotNull ActionMode actionMode,
|
@NotNull @Override public Super onActionModeFinished(@NotNull ActionMode actionMode,
|
||||||
@NotNull AppCompatActivity activity) {
|
@NotNull AppCompatActivity activity) {
|
||||||
actionMode = null;
|
this.actionMode = null;
|
||||||
return Super.ShouldCall;
|
return Super.ShouldCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +653,7 @@ public abstract class CoreReaderFragment extends BaseFragment
|
|||||||
} else {
|
} else {
|
||||||
return Super.ShouldCall;
|
return Super.ShouldCall;
|
||||||
}
|
}
|
||||||
return Super.DontCall;
|
return Super.ShouldNotCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForRateDialog() {
|
private void checkForRateDialog() {
|
||||||
|
@ -23,6 +23,7 @@ import android.view.Menu
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import org.kiwix.kiwixmobile.core.BuildConfig
|
||||||
import org.kiwix.kiwixmobile.core.Intents.internal
|
import org.kiwix.kiwixmobile.core.Intents.internal
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.intent
|
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.intent
|
||||||
@ -108,6 +109,9 @@ class MainMenu(
|
|||||||
tabSwitcher = null
|
tabSwitcher = null
|
||||||
tabSwitcherTextView = null
|
tabSwitcherTextView = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newNavigation.isVisible = BuildConfig.DEBUG
|
||||||
|
|
||||||
randomArticle.setShowAsAction(
|
randomArticle.setShowAsAction(
|
||||||
if (activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
|
if (activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM
|
MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.custom.main
|
package org.kiwix.kiwixmobile.custom.main
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.ActionMode
|
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
|
||||||
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
|
||||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||||
import org.kiwix.kiwixmobile.custom.R
|
import org.kiwix.kiwixmobile.custom.R
|
||||||
@ -35,35 +32,6 @@ class CustomMainActivity : CoreMainActivity() {
|
|||||||
customActivityComponent.inject(this)
|
customActivityComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionModeStarted(mode: ActionMode) {
|
|
||||||
super.onActionModeStarted(mode)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onActionModeStarted(mode, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActionModeFinished(mode: ActionMode) {
|
|
||||||
super.onActionModeFinished(mode)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onActionModeFinished(mode, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
if (it.onBackPressed(this) == BaseFragmentActivityExtensions.Super.ShouldCall) {
|
|
||||||
super.onBackPressed()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
|
||||||
super.onNewIntent(intent)
|
|
||||||
supportFragmentManager.fragments.filterIsInstance<BaseFragmentActivityExtensions>().forEach {
|
|
||||||
it.onNewIntent(intent, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
@ -40,11 +40,13 @@ import androidx.core.app.ActivityCompat
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||||
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseFragmentActivityExtensions.Super.ShouldCall
|
||||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
|
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.start
|
||||||
import org.kiwix.kiwixmobile.core.main.CoreReaderFragment
|
import org.kiwix.kiwixmobile.core.main.CoreReaderFragment
|
||||||
import org.kiwix.kiwixmobile.core.main.MainMenu
|
import org.kiwix.kiwixmobile.core.main.MainMenu
|
||||||
import org.kiwix.kiwixmobile.core.main.WebViewCallback
|
import org.kiwix.kiwixmobile.core.main.WebViewCallback
|
||||||
|
import org.kiwix.kiwixmobile.core.reader.ZimFileReader.Companion.CONTENT_PREFIX
|
||||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog
|
import org.kiwix.kiwixmobile.core.utils.KiwixDialog
|
||||||
@ -120,6 +122,14 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed(activity: AppCompatActivity): Super {
|
||||||
|
val result = super.onBackPressed(activity)
|
||||||
|
if (zimReaderContainer.mainPage == getCurrentWebView().url.substringAfter(CONTENT_PREFIX)) {
|
||||||
|
return ShouldCall
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(
|
override fun onRequestPermissionsResult(
|
||||||
requestCode: Int,
|
requestCode: Int,
|
||||||
permissions: Array<out String>,
|
permissions: Array<out String>,
|
||||||
@ -151,18 +161,12 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
val onCreateOptionsMenu = super.onCreateOptionsMenu(menu, requireActivity().menuInflater)
|
|
||||||
menu.findItem(R.id.menu_help)?.isVisible = false
|
menu.findItem(R.id.menu_help)?.isVisible = false
|
||||||
menu.findItem(R.id.menu_new_navigation)?.isVisible = false
|
menu.findItem(R.id.menu_new_navigation)?.isVisible = false
|
||||||
menu.findItem(R.id.menu_openfile)?.isVisible = false
|
menu.findItem(R.id.menu_openfile)?.isVisible = false
|
||||||
menu.findItem(R.id.menu_host_books)?.isVisible = false
|
menu.findItem(R.id.menu_host_books)?.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(
|
|
||||||
menu: Menu,
|
|
||||||
activity: AppCompatActivity
|
|
||||||
): BaseFragmentActivityExtensions.Super = BaseFragmentActivityExtensions.Super.ShouldCall
|
|
||||||
|
|
||||||
override fun getIconResId() = R.mipmap.ic_launcher
|
override fun getIconResId() = R.mipmap.ic_launcher
|
||||||
|
|
||||||
override fun createWebClient(
|
override fun createWebClient(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user