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