diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java deleted file mode 100644 index f49e3f3c7..000000000 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Kiwix Android - * Copyright (c) 2019 Kiwix - * 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 . - * - */ - -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); - setContentView(R.layout.activity_new_navigation); - } - - @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; - } -} diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt new file mode 100644 index 000000000..cb742d60e --- /dev/null +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreMainActivity.kt @@ -0,0 +1,51 @@ +/* + * Kiwix Android + * Copyright (c) 2019 Kiwix + * 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 . + * + */ +package org.kiwix.kiwixmobile.core.main + +import android.content.Intent +import android.os.Bundle +import org.kiwix.kiwixmobile.core.R +import org.kiwix.kiwixmobile.core.base.BaseActivity + +abstract class CoreMainActivity : BaseActivity(), WebViewProvider { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_new_navigation) + } + + 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, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + supportFragmentManager.fragments.forEach { + it.onRequestPermissionsResult(requestCode, permissions, grantResults) + } + } + + override fun getCurrentWebView(): KiwixWebView? { + return supportFragmentManager.fragments.filterIsInstance().first() + .getCurrentWebView() + } +}