code: работает сохранение
This commit is contained in:
parent
cf80c6b493
commit
f437e8a120
@ -9,7 +9,7 @@ class ListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|||||||
private val binding = ItemRecyclerViewEntrancedataBinding.bind(itemView)
|
private val binding = ItemRecyclerViewEntrancedataBinding.bind(itemView)
|
||||||
|
|
||||||
fun bind(item: ListInfo) {
|
fun bind(item: ListInfo) {
|
||||||
binding.text1.text = item.time
|
binding.text1.text = item.time.replace("T", " ")
|
||||||
binding.text2.text = item.value
|
binding.text2.text = item.value
|
||||||
binding.text3.text = item.type
|
binding.text3.text = item.type
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,9 @@ class ResultFragment : Fragment(R.layout.fragment_scan_result) {
|
|||||||
|
|
||||||
if (qrData != null) {
|
if (qrData != null) {
|
||||||
authPreferences.getLogin()?.let { login ->
|
authPreferences.getLogin()?.let { login ->
|
||||||
|
|
||||||
val currentTime = getCurrentTime()
|
val currentTime = getCurrentTime()
|
||||||
|
|
||||||
viewModel.open(login, CodeJson(
|
viewModel.open(login, CodeJson(
|
||||||
value = qrData.toString(),
|
value = qrData.toString(),
|
||||||
type = OpenType.QR_TYPE,
|
type = OpenType.QR_TYPE,
|
||||||
|
@ -22,7 +22,6 @@ import com.google.mlkit.vision.barcode.BarcodeScanning
|
|||||||
import com.google.mlkit.vision.barcode.common.Barcode
|
import com.google.mlkit.vision.barcode.common.Barcode
|
||||||
import ru.myitschool.work.R
|
import ru.myitschool.work.R
|
||||||
import ru.myitschool.work.databinding.FragmentQrScanBinding
|
import ru.myitschool.work.databinding.FragmentQrScanBinding
|
||||||
import ru.myitschool.work.ui.main.MainDestination
|
|
||||||
import ru.myitschool.work.ui.result.ResultDestination
|
import ru.myitschool.work.ui.result.ResultDestination
|
||||||
import ru.myitschool.work.utils.QrPreferences
|
import ru.myitschool.work.utils.QrPreferences
|
||||||
import ru.myitschool.work.utils.collectWhenStarted
|
import ru.myitschool.work.utils.collectWhenStarted
|
||||||
@ -41,10 +40,8 @@ class QrScanFragment : Fragment(R.layout.fragment_qr_scan) {
|
|||||||
private val viewModel: QrScanViewModel by viewModels()
|
private val viewModel: QrScanViewModel by viewModels()
|
||||||
private lateinit var qrPreferences: QrPreferences
|
private lateinit var qrPreferences: QrPreferences
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
qrPreferences = QrPreferences(requireContext())
|
qrPreferences = QrPreferences(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +74,7 @@ class QrScanFragment : Fragment(R.layout.fragment_qr_scan) {
|
|||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
is QrScanViewModel.Action.CloseWithResult -> {
|
is QrScanViewModel.Action.CloseWithResult -> {
|
||||||
sendResult(QrScanDestination.packToBundle(action.result))
|
// Удаляем этот блок, так как мы будем обрабатывать результат в другом месте
|
||||||
goResult()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,8 +104,12 @@ class QrScanFragment : Fragment(R.layout.fragment_qr_scan) {
|
|||||||
executor
|
executor
|
||||||
) { result ->
|
) { result ->
|
||||||
result?.getValue(barcodeScanner)?.firstOrNull()?.let { value ->
|
result?.getValue(barcodeScanner)?.firstOrNull()?.let { value ->
|
||||||
viewModel.findBarcode(value)
|
|
||||||
|
|
||||||
|
qrPreferences.saveQr(value.displayValue ?: value.rawValue ?: "")
|
||||||
|
|
||||||
|
sendResult(QrScanDestination.packToBundle(value.displayValue ?: value.rawValue ?: ""))
|
||||||
|
|
||||||
|
goResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -125,31 +125,17 @@ class QrScanFragment : Fragment(R.layout.fragment_qr_scan) {
|
|||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
|
||||||
val qrData = arguments?.let { QrScanDestination.getDataIfExist(it) }
|
|
||||||
qrPreferences.saveQr(qrData.toString())
|
|
||||||
|
|
||||||
findNavControllerOrNull()?.popBackStack()
|
|
||||||
?: requireActivity().onBackPressedDispatcher.onBackPressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun goResult() {
|
private fun goResult() {
|
||||||
try {
|
|
||||||
val qrData = arguments?.let { QrScanDestination.getDataIfExist(it) }
|
|
||||||
qrPreferences.saveQr(qrData.toString())
|
|
||||||
|
|
||||||
Log.i("ResultFragment", qrData.toString())
|
|
||||||
|
|
||||||
findNavController().apply {
|
findNavController().apply {
|
||||||
popBackStack(ResultDestination, false)
|
popBackStack(ResultDestination, false)
|
||||||
navigate(ResultDestination)
|
navigate(ResultDestination)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("ResultFragment", "Navigation error", e)
|
|
||||||
Toast.makeText(context, getText(R.string.errorGoText).toString(), Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun goBack() {
|
||||||
|
findNavControllerOrNull()?.popBackStack()
|
||||||
|
?: requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
private fun sendResult(bundle: Bundle) {
|
private fun sendResult(bundle: Bundle) {
|
||||||
setFragmentResult(
|
setFragmentResult(
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<solid android:color="@color/white" />
|
|
||||||
<stroke
|
|
||||||
android:width="2dp"
|
|
||||||
android:color="@color/beige" />
|
|
||||||
<corners android:radius="8dp"/>
|
|
||||||
</shape>
|
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="77.53dp"
|
|
||||||
android:height="115.35dp"
|
|
||||||
android:viewportWidth="77.53"
|
|
||||||
android:viewportHeight="115.35">
|
|
||||||
<path
|
|
||||||
android:pathData="M28.08,43.07h3.94v1h-3.94z"
|
|
||||||
android:fillColor="#E9D4C3"/>
|
|
||||||
<path
|
|
||||||
android:pathData="M36.1,43.07h12.85v1h-12.85z"
|
|
||||||
android:fillColor="#E9D4C3"/>
|
|
||||||
<path
|
|
||||||
android:pathData="M72.47,26l-2.49,28.5a5.18,5.18 0,0 1,-5.06 4.65,4.2 4.2,0 0,1 -4.25,-4.65L63.14,26a15.08,15.08 0,0 0,-15.24 -16.7L37.74,9.3A18.61,18.61 0,0 0,19.58 26l-1,11.64h-9.3l1,-11.64c1.25,-14.34 13.94,-26 28.27,-26h10.2A23.47,23.47 0,0 1,72.47 26Z"
|
|
||||||
android:fillColor="#E9D4C3"/>
|
|
||||||
<path
|
|
||||||
android:pathData="M72.47,26l-2.49,28.5a5.18,5.18 0,0 1,-5.06 4.65,4.2 4.2,0 0,1 -4.25,-4.65L63.14,26a15.08,15.08 0,0 0,-15.24 -16.7L37.74,9.3A18.61,18.61 0,0 0,19.58 26l-1,11.64h-9.3l1,-11.64c1.25,-14.34 13.94,-26 28.27,-26h10.2A23.47,23.47 0,0 1,72.47 26Z"
|
|
||||||
android:strokeAlpha="0.5"
|
|
||||||
android:fillColor="#fff"
|
|
||||||
android:fillAlpha="0.5"/>
|
|
||||||
<path
|
|
||||||
android:pathData="M73.14,53.46 L68.29,109a7.07,7.07 0,0 1,-6.92 6.35L5.83,115.35a5.73,5.73 0,0 1,-5.8 -6.35l4.86,-55.54a7.07,7.07 0,0 1,3.46 -5.39,6.8 6.8,0 0,1 3.46,-1L67.34,47.07a6,6 0,0 1,3.21 0.91A5.76,5.76 0,0 1,73.14 53.46Z"
|
|
||||||
android:fillColor="#E9D4C3"/>
|
|
||||||
<path
|
|
||||||
android:pathData="M15.39,77.72l14.43,22.21 47.59,-47.59a0.48,0.48 0,0 0,-0.63 -0.71l-45.35,35.55 -8.57,-13.81Z"
|
|
||||||
android:fillColor="#fff"/>
|
|
||||||
</vector>
|
|
9
app/src/main/res/drawable/res_success_ic.xml
Normal file
9
app/src/main/res/drawable/res_success_ic.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M17.5,12C20.538,12 23,14.462 23,17.5C23,20.537 20.538,23 17.5,23C14.463,23 12,20.537 12,17.5C12,14.462 14.463,12 17.5,12ZM14.854,17.146C14.658,16.951 14.342,16.951 14.147,17.146C13.951,17.341 13.951,17.658 14.147,17.853L16.147,19.853C16.342,20.049 16.658,20.049 16.854,19.853L20.854,15.853C21.049,15.658 21.049,15.342 20.854,15.146C20.658,14.951 20.342,14.951 20.147,15.146L16.5,18.793L14.854,17.146ZM12.022,13.999C11.726,14.462 11.486,14.966 11.314,15.499L4.253,15.5C3.839,15.5 3.504,15.835 3.504,16.249V16.826C3.504,17.362 3.695,17.88 4.043,18.287C5.296,19.755 7.262,20.501 10,20.501C10.597,20.501 11.156,20.465 11.68,20.395C11.925,20.89 12.233,21.348 12.592,21.761C11.796,21.921 10.932,22.001 10,22.001C6.854,22.001 4.468,21.096 2.902,19.261C2.322,18.583 2.004,17.719 2.004,16.826V16.249C2.004,15.007 3.011,14 4.253,14L12.022,13.999ZM10,2.004C12.762,2.004 15,4.243 15,7.004C15,9.766 12.762,12.004 10,12.004C7.239,12.004 5,9.766 5,7.004C5,4.243 7.239,2.004 10,2.004ZM10,3.504C8.067,3.504 6.5,5.071 6.5,7.004C6.5,8.937 8.067,10.504 10,10.504C11.933,10.504 13.5,8.937 13.5,7.004C13.5,5.071 11.933,3.504 10,3.504Z"
|
||||||
|
android:fillColor="#212121"/>
|
||||||
|
</vector>
|
@ -17,7 +17,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintGuide_percent="0.36" />
|
app:layout_constraintGuide_percent="0.4" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
@ -78,17 +78,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="@+id/input_field"
|
app:layout_constraintStart_toStartOf="@+id/input_field"
|
||||||
app:layout_constraintTop_toTopOf="@+id/input_field" />
|
app:layout_constraintTop_toTopOf="@+id/input_field" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/line"
|
|
||||||
android:layout_width="320dp"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:background="@drawable/ic_line"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/guideline2"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/username_field"
|
android:id="@+id/username_field"
|
||||||
@ -219,23 +208,16 @@
|
|||||||
app:layout_constraintEnd_toEndOf="@+id/block"
|
app:layout_constraintEnd_toEndOf="@+id/block"
|
||||||
app:layout_constraintTop_toTopOf="@+id/block" />
|
app:layout_constraintTop_toTopOf="@+id/block" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="320dp"
|
|
||||||
android:layout_height="140dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/block">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/entrance_data"
|
android:id="@+id/entrance_data"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.485"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/scan" />
|
app:layout_constraintTop_toBottomOf="@+id/block"
|
||||||
</LinearLayout>
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -10,7 +10,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintGuide_percent="0.31" />
|
app:layout_constraintGuide_percent="0.37" />
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintGuide_percent="0.21" />
|
app:layout_constraintGuide_percent="0.29" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/error"
|
android:id="@+id/error"
|
||||||
@ -28,7 +28,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/serverError"
|
android:text="@string/serverError"
|
||||||
android:visibility="gone"
|
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintGuide_percent="0.62" />
|
app:layout_constraintGuide_percent="0.58" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
@ -54,9 +54,9 @@
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/success_icon"
|
android:id="@+id/success_icon"
|
||||||
android:layout_width="190dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="250dp"
|
android:layout_height="150dp"
|
||||||
android:background="@drawable/res_success"
|
android:background="@drawable/res_success_ic"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/guideline_top" />
|
app:layout_constraintTop_toTopOf="@+id/guideline_top" />
|
||||||
@ -76,7 +76,7 @@
|
|||||||
android:layout_width="320dp"
|
android:layout_width="320dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@drawable/button_beige"
|
android:background="@drawable/button_grey"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/guideline_bottom" />
|
app:layout_constraintTop_toTopOf="@+id/guideline_bottom" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:background="@drawable/button_beigestroke_whitefill"
|
android:background="@drawable/button_grestroke_whiteback"
|
||||||
android:layout_width="320dp"
|
android:layout_width="320dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">NTO Pass</string>
|
<string name="app_name">DoorRock</string>
|
||||||
<string name="loginText">логин</string>
|
<string name="loginText">логин</string>
|
||||||
<string name="welcomeText">Добро пожаловать!</string>
|
<string name="welcomeText">Добро пожаловать!</string>
|
||||||
<string name="inputLoginText">Введите свой логин</string>
|
<string name="inputLoginText">Введите свой логин</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user