1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 04:49:08 -05:00

Fix restoring state in exposed dropdown menu (#569)

This commit is contained in:
Rafał Borcz 2019-10-24 22:56:49 +02:00 committed by Mikołaj Pich
parent 5c5993cc2a
commit 125a010f03
4 changed files with 33 additions and 20 deletions

View File

@ -9,7 +9,6 @@ import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
import android.view.inputmethod.EditorInfo.IME_NULL
import android.widget.ArrayAdapter
import androidx.core.widget.doOnTextChanged
import io.github.wulkanowy.R
import io.github.wulkanowy.data.db.entities.Student
@ -17,11 +16,11 @@ import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.login.LoginActivity
import io.github.wulkanowy.utils.AppInfo
import io.github.wulkanowy.utils.hideSoftInput
import io.github.wulkanowy.utils.openEmail
import io.github.wulkanowy.utils.openInternetBrowser
import io.github.wulkanowy.utils.showSoftInput
import kotlinx.android.synthetic.main.fragment_login_form.*
import javax.inject.Inject
import io.github.wulkanowy.utils.openEmail
class LoginFormFragment : BaseFragment(), LoginFormView {
@ -71,12 +70,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
}
with(loginFormHost) {
//Bug with filter in ExposedDropdownMenu on restoring state
isSaveEnabled = false
setText(hostKeys.getOrElse(0) { "" })
setAdapter(ArrayAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
keyListener = null
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
}
}

View File

@ -0,0 +1,16 @@
package io.github.wulkanowy.ui.modules.login.form
import android.content.Context
import android.widget.ArrayAdapter
import android.widget.Filter
class LoginSymbolAdapter(context: Context, resource: Int, objects: Array<out String>) :
ArrayAdapter<String>(context, resource, objects) {
override fun getFilter() = object : Filter() {
override fun performFiltering(constraint: CharSequence?) = null
override fun publishResults(constraint: CharSequence?, results: FilterResults?) {}
}
}

View File

@ -143,7 +143,7 @@ class MessagePreviewFragment : BaseFragment(), MessagePreviewView, MainView.Titl
}
override fun notifyParentMessageDeleted(message: Message) {
fragmentManager?.fragments?.forEach { if (it is MessageFragment) it.onDeleteMessage(message) }
parentFragmentManager.fragments.forEach { if (it is MessageFragment) it.onDeleteMessage(message) }
}
override fun onSaveInstanceState(outState: Bundle) {

View File

@ -30,10 +30,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"
tools:visibility="visible">
<TextView
@ -42,9 +42,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:gravity="center_horizontal"
android:text="@string/login_contact_header"
@ -55,28 +55,29 @@
android:id="@+id/loginFormContactButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
android:layout_marginRight="16dp"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:id="@+id/loginFormContactEmail"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/login_contact_email"
app:icon="@drawable/ic_more_messages" />
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:id="@+id/loginFormContactDiscord"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:text="@string/login_contact_discord"
app:icon="@drawable/ic_about_discord" />
</LinearLayout>
@ -95,9 +96,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="48dp"
android:gravity="center_horizontal"
android:text="@string/login_header_default"
android:textSize="16sp"
@ -191,7 +192,8 @@
android:id="@+id/loginFormHost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="LabelFor" />
android:editable="false"
tools:ignore="Deprecated,LabelFor" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton