mirror of
https://github.com/nextcloud/android.git
synced 2024-11-21 20:55:31 +03:00
Improve export type selection dialog
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
cd51c4f5df
commit
9478fb15e9
3 changed files with 83 additions and 11 deletions
|
@ -26,6 +26,7 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
|
@ -35,6 +36,7 @@ import com.nextcloud.client.di.ViewModelFactory
|
|||
import com.nextcloud.client.logger.Logger
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.ActivityDocumentScanBinding
|
||||
import com.owncloud.android.databinding.DialogScanExportTypeBinding
|
||||
import com.owncloud.android.ui.activity.ToolbarActivity
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import com.zynksoftware.documentscanner.ui.DocumentScanner
|
||||
|
@ -153,19 +155,38 @@ class DocumentScanActivity : ToolbarActivity(), Injectable {
|
|||
}
|
||||
|
||||
private fun showExportDialog() {
|
||||
// TODO better dialog
|
||||
MaterialAlertDialogBuilder(this)
|
||||
val dialogBinding = DialogScanExportTypeBinding.inflate(layoutInflater)
|
||||
|
||||
val dialog = MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.document_scan_export_dialog_title)
|
||||
.setPositiveButton(R.string.document_scan_export_dialog_pdf) { _, _ ->
|
||||
viewModel.onExportTypeSelected(DocumentScanViewModel.ExportType.PDF)
|
||||
}
|
||||
.setNeutralButton(R.string.document_scan_export_dialog_images) { _, _ ->
|
||||
viewModel.onExportTypeSelected(DocumentScanViewModel.ExportType.IMAGES)
|
||||
}
|
||||
.setCancelable(true)
|
||||
.setView(dialogBinding.root)
|
||||
.setNegativeButton(R.string.common_cancel) { _, _ ->
|
||||
viewModel.onExportCanceled()
|
||||
}
|
||||
.show()
|
||||
.setOnCancelListener { viewModel.onExportCanceled() }
|
||||
.also {
|
||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this@DocumentScanActivity, it)
|
||||
}
|
||||
.create()
|
||||
|
||||
viewThemeUtils.platform.colorTextButtons(dialogBinding.btnPdf, dialogBinding.btnImages)
|
||||
|
||||
dialogBinding.btnPdf.setOnClickListener {
|
||||
viewModel.onExportTypeSelected(DocumentScanViewModel.ExportType.PDF)
|
||||
dialog.dismiss()
|
||||
}
|
||||
dialogBinding.btnImages.setOnClickListener {
|
||||
viewModel.onExportTypeSelected(DocumentScanViewModel.ExportType.IMAGES)
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
dialog.setOnShowListener {
|
||||
val alertDialog = it as AlertDialog
|
||||
viewThemeUtils.platform.colorTextButtons(alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE))
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun updateRecycler(pageList: List<String>) {
|
||||
|
|
51
app/src/main/res/layout/dialog_scan_export_type.xml
Normal file
51
app/src/main/res/layout/dialog_scan_export_type.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Nextcloud Android client application
|
||||
~
|
||||
~ @author Álvaro Brey Vilas
|
||||
~ Copyright (C) 2022 Álvaro Brey Vilas
|
||||
~ Copyright (C) 2022 Nextcloud GmbH
|
||||
~
|
||||
~ 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 <https://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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="?dialogPreferredPadding">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_pdf"
|
||||
style="@style/OutlinedButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/standard_padding"
|
||||
android:text="@string/document_scan_export_dialog_pdf"
|
||||
app:cornerRadius="@dimen/button_corner_radius"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_images"
|
||||
style="@style/OutlinedButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/document_scan_export_dialog_images"
|
||||
app:cornerRadius="@dimen/button_corner_radius"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_pdf" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1068,10 +1068,10 @@
|
|||
<string name="prefs_keys_exist">Add end-to-end encryption to this client</string>
|
||||
<string name="scan_page">Scan page</string>
|
||||
<string name="done">Done</string>
|
||||
<string name="document_scan_pdf_generation_in_progress">Generating PDF...</string>
|
||||
<string name="document_scan_pdf_generation_in_progress">Generating PDF…</string>
|
||||
<string name="error_starting_doc_scan">Error starting document scan</string>
|
||||
<string name="document_scan_pdf_generation_failed">PDF generation failed</string>
|
||||
<string name="document_scan_export_dialog_title">Choose export type</string>
|
||||
<string name="document_scan_export_dialog_pdf">PDF</string>
|
||||
<string name="document_scan_export_dialog_pdf">PDF file</string>
|
||||
<string name="document_scan_export_dialog_images">Multiple images</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue