mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-10 16:02:05 -04:00
Merge pull request #3417 from kiwix/Issue#3336
Fixes of ProgressDialog is deprecated
This commit is contained in:
commit
b00c3ecc9e
@ -20,7 +20,8 @@ package org.kiwix.kiwixmobile.webserver
|
|||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.Manifest.permission.POST_NOTIFICATIONS
|
import android.Manifest.permission.POST_NOTIFICATIONS
|
||||||
import android.app.ProgressDialog
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Dialog
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@ -54,6 +55,7 @@ import org.kiwix.kiwixmobile.core.utils.ServerUtils
|
|||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
|
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
|
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog.StartServer
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter
|
||||||
@ -85,7 +87,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
private var hotspotService: HotspotService? = null
|
private var hotspotService: HotspotService? = null
|
||||||
private var ip: String? = null
|
private var ip: String? = null
|
||||||
private lateinit var serviceConnection: ServiceConnection
|
private lateinit var serviceConnection: ServiceConnection
|
||||||
private var progressDialog: ProgressDialog? = null
|
private var dialog: Dialog? = null
|
||||||
private var activityZimHostBinding: ActivityZimHostBinding? = null
|
private var activityZimHostBinding: ActivityZimHostBinding? = null
|
||||||
private val selectedBooksPath: ArrayList<String>
|
private val selectedBooksPath: ArrayList<String>
|
||||||
get() {
|
get() {
|
||||||
@ -271,12 +273,14 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("InflateParams")
|
||||||
private fun startKiwixHotspot() {
|
private fun startKiwixHotspot() {
|
||||||
progressDialog = ProgressDialog.show(
|
if (dialog == null) {
|
||||||
requireActivity(),
|
val dialogView: View =
|
||||||
getString(R.string.progress_dialog_starting_server), "",
|
layoutInflater.inflate(R.layout.item_custom_spinner, null)
|
||||||
true
|
dialog = alertDialogShower.create(StartServer { dialogView })
|
||||||
)
|
}
|
||||||
|
dialog?.show()
|
||||||
requireActivity().startService(createHotspotIntent(ACTION_CHECK_IP_ADDRESS))
|
requireActivity().startService(createHotspotIntent(ACTION_CHECK_IP_ADDRESS))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +454,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onIpAddressValid() {
|
override fun onIpAddressValid() {
|
||||||
progressDialog?.dismiss()
|
dialog?.dismiss()
|
||||||
requireActivity().startService(
|
requireActivity().startService(
|
||||||
createHotspotIntent(ACTION_START_SERVER).putStringArrayListExtra(
|
createHotspotIntent(ACTION_START_SERVER).putStringArrayListExtra(
|
||||||
SELECTED_ZIM_PATHS_KEY, selectedBooksPath
|
SELECTED_ZIM_PATHS_KEY, selectedBooksPath
|
||||||
@ -459,7 +463,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onIpAddressInvalid() {
|
override fun onIpAddressInvalid() {
|
||||||
progressDialog?.dismiss()
|
dialog?.dismiss()
|
||||||
toast(R.string.server_failed_message, Toast.LENGTH_SHORT)
|
toast(R.string.server_failed_message, Toast.LENGTH_SHORT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
app/src/main/res/layout/item_custom_spinner.xml
Normal file
34
app/src/main/res/layout/item_custom_spinner.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ Kiwix Android
|
||||||
|
~ Copyright (c) 2023 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="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:indeterminate="true"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -22,6 +22,7 @@ import android.app.Activity
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
sealed class KiwixDialog(
|
sealed class KiwixDialog(
|
||||||
val title: Int?,
|
val title: Int?,
|
||||||
val message: Int?,
|
val message: Int?,
|
||||||
@ -227,6 +228,14 @@ sealed class KiwixDialog(
|
|||||||
getView = customGetView
|
getView = customGetView
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class StartServer(val customGetView: (() -> View)?) : KiwixDialog(
|
||||||
|
R.string.progress_dialog_starting_server,
|
||||||
|
null,
|
||||||
|
R.string.empty_string,
|
||||||
|
null,
|
||||||
|
getView = customGetView
|
||||||
|
)
|
||||||
|
|
||||||
object NotesDiscardConfirmation : KiwixDialog(
|
object NotesDiscardConfirmation : KiwixDialog(
|
||||||
null,
|
null,
|
||||||
R.string.confirmation_alert_dialog_message,
|
R.string.confirmation_alert_dialog_message,
|
||||||
|
@ -338,4 +338,5 @@
|
|||||||
<string name="navigation_history_cleared">Navigation History Cleared</string>
|
<string name="navigation_history_cleared">Navigation History Cleared</string>
|
||||||
<string name="go_to_settings_label">Go to Settings</string>
|
<string name="go_to_settings_label">Go to Settings</string>
|
||||||
<string name="request_notification_permission_message">To perform this action, please grant notification access</string>
|
<string name="request_notification_permission_message">To perform this action, please grant notification access</string>
|
||||||
|
<string name="empty_string" />
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user