Add multi lines edit text

feature/top10
Aurelien Hubert 7 years ago
parent b44e7e21f4
commit 2473dbdd36
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  2. 56
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextMultiLinesFragment.kt
  3. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  4. 2
      app/src/main/java/net/pokeranalytics/android/ui/view/RowRepresentable.kt
  5. 28
      app/src/main/res/layout/bottom_sheet_edit_text_multi_lines.xml

@ -438,7 +438,7 @@ open class Session : RealmObject(), SessionInterface, Savable,
) )
} }
SessionRow.COMMENT -> { SessionRow.COMMENT -> {
data.add(RowRepresentableEditDescriptor(comment, R.string.comment, InputType.TYPE_CLASS_TEXT)) data.add(RowRepresentableEditDescriptor(comment, R.string.comment))
} }
SessionRow.GAME -> { SessionRow.GAME -> {
// Add current game & games list // Add current game & games list

@ -0,0 +1,56 @@
package net.pokeranalytics.android.ui.fragment.components.bottomsheet
import android.os.Bundle
import android.text.InputType
import android.view.LayoutInflater
import android.view.View
import androidx.core.widget.addTextChangedListener
import kotlinx.android.synthetic.main.bottom_sheet_edit_text_multi_lines.*
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.*
class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() {
private var value = ""
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
override fun onStart() {
super.onStart()
editText1.requestFocus()
}
override fun getValue(): Any? {
return value.trim()
}
/**
* Init data
*/
private fun initData() {
}
/**
* Init UI
*/
private fun initUI() {
setAddButtonVisible(false)
LayoutInflater.from(requireContext()).inflate(net.pokeranalytics.android.R.layout.bottom_sheet_edit_text_multi_lines, view?.bottomSheetContainer, true)
val data = getData()
if (data.size == 1) {
data[0].hint?.let { editText1.hint = getString(it) }
editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
editText1.addTextChangedListener { value = it?.toString() ?: "" }
editText1.setText((data[0].defaultValue ?: "").toString())
}
}
}

@ -22,6 +22,7 @@ enum class BottomSheetType {
DOUBLE_LIST, DOUBLE_LIST,
GRID, GRID,
EDIT_TEXT, EDIT_TEXT,
EDIT_TEXT_MULTI_LINES,
DOUBLE_EDIT_TEXT, DOUBLE_EDIT_TEXT,
SUM SUM
} }
@ -54,6 +55,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
BottomSheetType.GRID -> BottomSheetTableSizeGridFragment() BottomSheetType.GRID -> BottomSheetTableSizeGridFragment()
BottomSheetType.DOUBLE_LIST -> BottomSheetListGameFragment() BottomSheetType.DOUBLE_LIST -> BottomSheetListGameFragment()
BottomSheetType.EDIT_TEXT -> BottomSheetEditTextFragment() BottomSheetType.EDIT_TEXT -> BottomSheetEditTextFragment()
BottomSheetType.EDIT_TEXT_MULTI_LINES -> BottomSheetEditTextMultiLinesFragment()
BottomSheetType.DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment() BottomSheetType.DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment()
BottomSheetType.SUM -> BottomSheetSumFragment() BottomSheetType.SUM -> BottomSheetSumFragment()
else -> BottomSheetFragment() else -> BottomSheetFragment()

@ -206,7 +206,7 @@ enum class SessionRow : RowRepresentable {
GAME -> BottomSheetType.LIST_GAME GAME -> BottomSheetType.LIST_GAME
LOCATION, BANKROLL, TOURNAMENT_TYPE -> BottomSheetType.LIST LOCATION, BANKROLL, TOURNAMENT_TYPE -> BottomSheetType.LIST
TABLE_SIZE -> BottomSheetType.GRID TABLE_SIZE -> BottomSheetType.GRID
COMMENT -> BottomSheetType.EDIT_TEXT COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES
else -> BottomSheetType.NONE else -> BottomSheetType.NONE
} }
} }

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@color/gray_darker">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:gravity="top|start"
android:inputType="textMultiLine"
android:minLines="10"
android:maxLines="10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="10" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save