mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Merge pull request #3444 from kiwix/Issue#3443
Fixes of Some deprecation warnings are showing in the logs but they are already fixed
This commit is contained in:
commit
79e43d8735
@ -212,6 +212,7 @@ class KiwixReaderFragment : CoreReaderFragment() {
|
||||
setBottomMarginToNavHostContainer(0)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, menuInflater)
|
||||
if (zimReaderContainer?.zimFileReader == null) {
|
||||
|
@ -32,6 +32,7 @@ class ConnectivityBroadcastReceiver @Inject constructor(
|
||||
) :
|
||||
BaseBroadcastReceiver() {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override val action: String = ConnectivityManager.CONNECTIVITY_ACTION
|
||||
|
||||
private val _networkStates = BehaviorProcessor.createDefault(connectivityManager.networkState)
|
||||
|
@ -63,6 +63,7 @@ class Fat32Checker constructor(
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun fileObserver(it: String): FileObserver {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return object : FileObserver(File(it), MOVED_FROM or DELETE) {
|
||||
|
@ -95,6 +95,8 @@ class ZimManageViewModelTest {
|
||||
private val defaultLanguageProvider: DefaultLanguageProvider = mockk()
|
||||
private val dataSource: DataSource = mockk()
|
||||
private val connectivityManager: ConnectivityManager = mockk()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private val networkInfo: NetworkInfo = mockk()
|
||||
private val sharedPreferenceUtil: SharedPreferenceUtil = mockk()
|
||||
lateinit var viewModel: ZimManageViewModel
|
||||
@ -119,6 +121,7 @@ class ZimManageViewModelTest {
|
||||
resetSchedulers()
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@BeforeEach
|
||||
fun init() {
|
||||
clearAllMocks()
|
||||
|
@ -35,6 +35,7 @@ interface KiwixService {
|
||||
|
||||
/******** Helper class that sets up new services */
|
||||
object ServiceCreator {
|
||||
@Suppress("DEPRECATION")
|
||||
fun newHackListService(okHttpClient: OkHttpClient, baseUrl: String): KiwixService {
|
||||
val retrofit = Retrofit.Builder()
|
||||
.baseUrl(baseUrl)
|
||||
|
@ -69,6 +69,7 @@ open class ErrorActivity : BaseActivity() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
extras.getSerializable(EXCEPTION_KEY, Throwable::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
extras.getSerializable(EXCEPTION_KEY) as Throwable
|
||||
}
|
||||
} else {
|
||||
|
@ -55,7 +55,9 @@ fun Context.registerReceiver(baseBroadcastReceiver: BaseBroadcastReceiver): Inte
|
||||
val Context.locale: Locale
|
||||
get() =
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.N) resources.configuration.locales.get(0)
|
||||
else resources.configuration.locale
|
||||
else
|
||||
@Suppress("DEPRECATION")
|
||||
resources.configuration.locale
|
||||
|
||||
fun Context.getAttribute(@AttrRes attributeRes: Int) = with(TypedValue()) {
|
||||
if (theme.resolveAttribute(attributeRes, this, true))
|
||||
|
@ -98,6 +98,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
activeFragments().iterator().forEach { it.onActivityResult(requestCode, resultCode, data) }
|
||||
|
@ -69,11 +69,14 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.MenuHost
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.widget.ContentLoadingProgressBar
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -387,7 +390,7 @@ abstract class CoreReaderFragment :
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
setupMenu()
|
||||
val activity = requireActivity() as AppCompatActivity?
|
||||
activity?.let {
|
||||
WebView(it).destroy() // Workaround for buggy webViews see #710
|
||||
@ -1173,8 +1176,21 @@ abstract class CoreReaderFragment :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
mainMenu?.onOptionsItemSelected(item) == true || super.onOptionsItemSelected(item)
|
||||
private fun setupMenu() {
|
||||
(requireActivity() as MenuHost).addMenuProvider(
|
||||
object : MenuProvider {
|
||||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||
menu.clear()
|
||||
mainMenu = createMainMenu(menu)
|
||||
}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
|
||||
mainMenu?.onOptionsItemSelected(menuItem) == true
|
||||
},
|
||||
viewLifecycleOwner,
|
||||
Lifecycle.State.RESUMED
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFullscreenMenuClicked() {
|
||||
if (isInFullScreenMode()) {
|
||||
@ -1747,12 +1763,6 @@ abstract class CoreReaderFragment :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super<BaseFragment>.onCreateOptionsMenu(menu, inflater)
|
||||
menu.clear()
|
||||
mainMenu = createMainMenu(menu)
|
||||
}
|
||||
|
||||
protected open fun createMainMenu(menu: Menu?): MainMenu? =
|
||||
menuFactory?.create(
|
||||
menu!!,
|
||||
|
@ -28,6 +28,7 @@ import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions.Super.ShouldCa
|
||||
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions.Super.ShouldNotCall
|
||||
|
||||
class NavigationHostFragment : NavHostFragment(), WebViewProvider, FragmentActivityExtensions {
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
childFragmentManager.fragments.iterator()
|
||||
|
@ -209,6 +209,7 @@ class SearchFragment : BaseFragment() {
|
||||
searchViewModel.actions.trySend(OnOpenInNewTabClick(it)).isSuccess
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
searchViewModel.actions.trySend(ActivityResultReceived(requestCode, resultCode, data)).isSuccess
|
||||
|
@ -82,6 +82,7 @@ class SearchViewModel @Inject constructor(
|
||||
viewModelScope.launch { actionMapper() }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private suspend fun reducer() {
|
||||
combine(
|
||||
filter.asFlow(),
|
||||
@ -97,6 +98,7 @@ class SearchViewModel @Inject constructor(
|
||||
.collect { state.value = it }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun searchResults() = filter.asFlow()
|
||||
.mapLatest {
|
||||
val zimFileReader = zimReaderContainer.copyReader()
|
||||
@ -122,6 +124,7 @@ class SearchViewModel @Inject constructor(
|
||||
actions
|
||||
)
|
||||
).isSuccess
|
||||
|
||||
ReceivedPromptForSpeechInput -> _effects.trySend(StartSpeechInput(actions)).isSuccess
|
||||
StartSpeechInputFailed -> _effects.trySend(ShowToast(R.string.speech_not_supported)).isSuccess
|
||||
is ActivityResultReceived ->
|
||||
@ -133,6 +136,7 @@ class SearchViewModel @Inject constructor(
|
||||
actions
|
||||
)
|
||||
).isSuccess
|
||||
|
||||
is ScreenWasStartedFrom -> searchOrigin.trySendBlocking(it.searchOrigin)
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.util.Locale
|
||||
|
||||
data class StartSpeechInput(private val actions: Channel<Action>) : SideEffect<Unit> {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun invokeWith(activity: AppCompatActivity) {
|
||||
try {
|
||||
activity.startActivityForResult(
|
||||
|
@ -156,6 +156,7 @@ class LanguageUtils(private val context: Context) {
|
||||
}
|
||||
|
||||
@SuppressLint("AppBundleLocaleChanges")
|
||||
@Suppress("DEPRECATION")
|
||||
@JvmStatic
|
||||
fun handleLocaleChange(
|
||||
activity: Activity,
|
||||
|
@ -37,6 +37,7 @@ internal class StartSpeechInputTest {
|
||||
|
||||
private val actions = mockk<Channel<Action>>(relaxed = true)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun `when invoke with throws exception offer StartSpeechInputFailed action`() {
|
||||
val activity = mockk<AppCompatActivity>(relaxed = true)
|
||||
@ -45,6 +46,7 @@ internal class StartSpeechInputTest {
|
||||
verify { actions.trySend(StartSpeechInputFailed).isSuccess }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun `invoke with starts an activity for speech recognition`() {
|
||||
val activity = mockk<AppCompatActivity>()
|
||||
|
@ -157,6 +157,7 @@ class CustomReaderFragment : CoreReaderFragment() {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.findItem(R.id.menu_help)?.isVisible = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user