mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Merge pull request #3674 from nextcloud/file-attach-preview-handle-config
Fix: File Attachment Preview Dialog crashes ChatActivity
This commit is contained in:
commit
5a42341cf3
@ -2976,11 +2976,13 @@ class ChatActivity :
|
|||||||
filenamesWithLineBreaks.append(filename).append("\n")
|
filenamesWithLineBreaks.append(filename).append("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFragment: DialogFragment = FileAttachmentPreviewFragment.newInstance(
|
val newFragment = FileAttachmentPreviewFragment.newInstance(
|
||||||
filenamesWithLineBreaks.toString(),
|
filenamesWithLineBreaks.toString(),
|
||||||
filesToUpload,
|
filesToUpload
|
||||||
this::uploadFiles
|
|
||||||
)
|
)
|
||||||
|
newFragment.setListener { files, caption ->
|
||||||
|
uploadFiles(files, caption)
|
||||||
|
}
|
||||||
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
context.resources?.getString(R.string.nc_upload_failed)?.let {
|
context.resources?.getString(R.string.nc_upload_failed)?.let {
|
||||||
@ -3050,11 +3052,11 @@ class ChatActivity :
|
|||||||
filenamesWithLineBreaks.append(filename).append("\n")
|
filenamesWithLineBreaks.append(filename).append("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFragment: DialogFragment = FileAttachmentPreviewFragment.newInstance(
|
val newFragment = FileAttachmentPreviewFragment.newInstance(
|
||||||
filenamesWithLineBreaks.toString(),
|
filenamesWithLineBreaks.toString(),
|
||||||
filesToUpload,
|
filesToUpload
|
||||||
this::uploadFiles
|
|
||||||
)
|
)
|
||||||
|
newFragment.setListener { files, caption -> uploadFiles(files, caption) }
|
||||||
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
||||||
} else {
|
} else {
|
||||||
UploadAndShareFilesWorker.requestStoragePermission(this)
|
UploadAndShareFilesWorker.requestStoragePermission(this)
|
||||||
|
@ -36,14 +36,10 @@ import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
class FileAttachmentPreviewFragment(
|
class FileAttachmentPreviewFragment : DialogFragment() {
|
||||||
filenames: String,
|
private lateinit var files: String
|
||||||
filesToUpload: MutableList<String>,
|
private lateinit var filesList: ArrayList<String>
|
||||||
functionToCall: (files: MutableList<String>, caption: String) -> Unit
|
private var uploadFiles: (files: MutableList<String>, caption: String) -> Unit = { _, _ -> }
|
||||||
) : DialogFragment() {
|
|
||||||
private val files = filenames
|
|
||||||
private val filesList = filesToUpload
|
|
||||||
private val uploadFiles = functionToCall
|
|
||||||
lateinit var binding: DialogFileAttachmentPreviewBinding
|
lateinit var binding: DialogFileAttachmentPreviewBinding
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -51,7 +47,17 @@ class FileAttachmentPreviewFragment(
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var viewThemeUtils: ViewThemeUtils
|
lateinit var viewThemeUtils: ViewThemeUtils
|
||||||
|
|
||||||
|
fun setListener(uploadFiles: (files: MutableList<String>, caption: String) -> Unit) {
|
||||||
|
this.uploadFiles = uploadFiles
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
arguments?.let {
|
||||||
|
files = it.getString(FILE_NAMES_ARG, "")
|
||||||
|
filesList = it.getStringArrayList(FILES_TO_UPLOAD_ARG)!!
|
||||||
|
}
|
||||||
|
|
||||||
binding = DialogFileAttachmentPreviewBinding.inflate(LayoutInflater.from(context))
|
binding = DialogFileAttachmentPreviewBinding.inflate(LayoutInflater.from(context))
|
||||||
return MaterialAlertDialogBuilder(requireContext()).setView(binding.root).create()
|
return MaterialAlertDialogBuilder(requireContext()).setView(binding.root).create()
|
||||||
}
|
}
|
||||||
@ -88,12 +94,20 @@ class FileAttachmentPreviewFragment(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
private const val FILE_NAMES_ARG = "FILE_NAMES_ARG"
|
||||||
|
private const val FILES_TO_UPLOAD_ARG = "FILES_TO_UPLOAD_ARG"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newInstance(
|
fun newInstance(filenames: String, filesToUpload: MutableList<String>): FileAttachmentPreviewFragment {
|
||||||
filenames: String,
|
val fileAttachmentFragment = FileAttachmentPreviewFragment()
|
||||||
filesToUpload: MutableList<String>,
|
val args = Bundle()
|
||||||
functionToCall: (files: MutableList<String>, caption: String) -> Unit
|
args.putString(FILE_NAMES_ARG, filenames)
|
||||||
) = FileAttachmentPreviewFragment(filenames, filesToUpload, functionToCall)
|
args.putStringArrayList(FILES_TO_UPLOAD_ARG, ArrayList(filesToUpload))
|
||||||
|
fileAttachmentFragment.arguments = args
|
||||||
|
return fileAttachmentFragment
|
||||||
|
}
|
||||||
|
|
||||||
val TAG: String = FilterConversationFragment::class.java.simpleName
|
val TAG: String = FilterConversationFragment::class.java.simpleName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
<!--
|
|
||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Julius Linus
|
~ @author Julius Linus
|
||||||
@ -18,85 +17,92 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:background="@color/white"
|
tools:background="@color/white">
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/standard_margin"
|
|
||||||
android:text="@string/nc_add_file"
|
|
||||||
android:textSize="@dimen/md_title_textsize" />
|
|
||||||
|
|
||||||
<com.google.android.material.divider.MaterialDivider
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="100dp">
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/dialog_file_attachment_preview_filenames"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/standard_margin"
|
|
||||||
android:textSize="@dimen/headline_text_size"
|
|
||||||
tools:text="a.png\nb.png\nc.png"/>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:id="@+id/dialog_file_attachment_preview_layout"
|
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/standard_margin">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/dialog_file_attachment_preview_caption"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/nc_caption"
|
|
||||||
android:maxLines="3"
|
|
||||||
tools:text="a.png\nb.png\nc.png"/>
|
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.divider.MaterialDivider
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/standard_half_margin"
|
android:orientation="vertical">
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingStart="@dimen/dialog_padding"
|
|
||||||
android:paddingEnd="@dimen/dialog_padding"
|
|
||||||
android:paddingBottom="@dimen/dialog_padding_top_bottom">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/button_close"
|
android:layout_width="match_parent"
|
||||||
style="@style/Button.Borderless"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/min_size_clickable_area"
|
android:layout_margin="@dimen/standard_margin"
|
||||||
android:text="@string/nc_no" />
|
android:text="@string/nc_add_file"
|
||||||
|
android:textSize="@dimen/md_title_textsize" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.divider.MaterialDivider
|
||||||
android:id="@+id/button_send"
|
android:layout_width="match_parent"
|
||||||
style="@style/Button.Borderless"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="100dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/dialog_file_attachment_preview_filenames"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/standard_margin"
|
||||||
|
android:textSize="@dimen/headline_text_size"
|
||||||
|
tools:text="a.png\nb.png\nc.png" />
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/dialog_file_attachment_preview_layout"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/min_size_clickable_area"
|
android:layout_margin="@dimen/standard_margin">
|
||||||
android:text="@string/nc_yes" />
|
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/dialog_file_attachment_preview_caption"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/nc_caption"
|
||||||
|
android:maxLines="3"
|
||||||
|
tools:text="a.png\nb.png\nc.png" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.divider.MaterialDivider
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/standard_half_margin"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="@dimen/dialog_padding"
|
||||||
|
android:paddingEnd="@dimen/dialog_padding"
|
||||||
|
android:paddingBottom="@dimen/dialog_padding_top_bottom">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_close"
|
||||||
|
style="@style/Button.Borderless"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/min_size_clickable_area"
|
||||||
|
android:text="@string/nc_no" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_send"
|
||||||
|
style="@style/Button.Borderless"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/min_size_clickable_area"
|
||||||
|
android:text="@string/nc_yes" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
</ScrollView>
|
||||||
|
Loading…
Reference in New Issue
Block a user