[Android] Migrate the add server dialog to bottomsheet
Nicolas Pomepuy
git at videolan.org
Thu Apr 15 07:48:33 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 13 10:22:59 2021 +0200| [f27a53d5e3095a5b900d6ad7349d32888d073940] | committer: Nicolas Pomepuy
Migrate the add server dialog to bottomsheet
> https://code.videolan.org/videolan/vlc-android/commit/f27a53d5e3095a5b900d6ad7349d32888d073940
---
.../videolan/vlc/gui/dialogs/NetworkServerDialog.kt | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
index 7e228719d..e78b08616 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
@@ -14,6 +14,7 @@ import android.widget.*
import androidx.appcompat.app.AppCompatDialog
import androidx.core.net.toUri
import androidx.fragment.app.DialogFragment
+import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.textfield.TextInputLayout
import kotlinx.coroutines.launch
import org.videolan.medialibrary.interfaces.media.MediaWrapper
@@ -23,7 +24,7 @@ import org.videolan.vlc.gui.DialogActivity
import org.videolan.vlc.gui.MainActivity
import org.videolan.vlc.repository.BrowserFavRepository
-class NetworkServerDialog : DialogFragment(), AdapterView.OnItemSelectedListener, TextWatcher, View.OnClickListener {
+class NetworkServerDialog : VLCBottomSheetDialogFragment(), AdapterView.OnItemSelectedListener, TextWatcher, View.OnClickListener {
private lateinit var browserFavRepository: BrowserFavRepository
@@ -45,22 +46,17 @@ class NetworkServerDialog : DialogFragment(), AdapterView.OnItemSelectedListener
//Dummy hack because spinner callback is called right on registration
var ignoreFirstSpinnerCb = false
- override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
- val activity = activity
- val dialog = AppCompatDialog(activity, theme)
- dialog.setTitle(R.string.server_add_title)
-
- dialog.setCancelable(true)
- dialog.setCanceledOnTouchOutside(true)
- dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
- return dialog
- }
-
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
(activity as? MainActivity)?.forceRefresh()
}
+ override fun getDefaultState(): Int = BottomSheetBehavior.STATE_EXPANDED
+
+ override fun needToManageOrientation(): Boolean = false
+
+ override fun initialFocusedView(): View = spinnerProtocol
+
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
More information about the Android
mailing list