mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Merge pull request #12044 from nextcloud/feature/use-m3-ChooseTemplateDialogFragment
Use Material Design 3 ChooseTemplateDialogFragment
This commit is contained in:
commit
0689f26e7d
1 changed files with 16 additions and 14 deletions
|
@ -32,10 +32,10 @@ import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.nextcloud.android.lib.resources.directediting.DirectEditingCreateFileRemoteOperation
|
import com.nextcloud.android.lib.resources.directediting.DirectEditingCreateFileRemoteOperation
|
||||||
import com.nextcloud.android.lib.resources.directediting.DirectEditingObtainListOfTemplatesRemoteOperation
|
import com.nextcloud.android.lib.resources.directediting.DirectEditingObtainListOfTemplatesRemoteOperation
|
||||||
|
@ -90,7 +90,7 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
||||||
private var adapter: TemplateAdapter? = null
|
private var adapter: TemplateAdapter? = null
|
||||||
private var parentFolder: OCFile? = null
|
private var parentFolder: OCFile? = null
|
||||||
private var title: String? = null
|
private var title: String? = null
|
||||||
private var positiveButton: Button? = null
|
private var positiveButton: MaterialButton? = null
|
||||||
private var creator: Creator? = null
|
private var creator: Creator? = null
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
|
@ -103,17 +103,18 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val alertDialog = dialog as AlertDialog
|
val alertDialog = dialog as AlertDialog
|
||||||
val button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
|
|
||||||
|
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
val positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE) as MaterialButton
|
||||||
button,
|
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(positiveButton)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
|
||||||
)
|
|
||||||
button.setOnClickListener(this)
|
|
||||||
button.isEnabled = false
|
|
||||||
button.isClickable = false
|
|
||||||
|
|
||||||
positiveButton = button
|
val negativeButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE) as MaterialButton
|
||||||
|
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(negativeButton)
|
||||||
|
|
||||||
|
positiveButton.setOnClickListener(this)
|
||||||
|
positiveButton.isEnabled = false
|
||||||
|
positiveButton.isClickable = false
|
||||||
|
|
||||||
|
this.positiveButton = positiveButton
|
||||||
checkEnablingCreateButton()
|
checkEnablingCreateButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
||||||
|
|
||||||
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER)
|
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER)
|
||||||
creator = arguments.getParcelable(ARG_CREATOR)
|
creator = arguments.getParcelable(ARG_CREATOR)
|
||||||
|
|
||||||
title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template))
|
title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template))
|
||||||
title = when (savedInstanceState) {
|
title = when (savedInstanceState) {
|
||||||
null -> arguments.getString(ARG_HEADLINE)
|
null -> arguments.getString(ARG_HEADLINE)
|
||||||
|
@ -175,7 +177,7 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
||||||
val builder = MaterialAlertDialogBuilder(activity)
|
val builder = MaterialAlertDialogBuilder(activity)
|
||||||
builder.setView(view)
|
builder.setView(view)
|
||||||
.setPositiveButton(R.string.create, null)
|
.setPositiveButton(R.string.create, null)
|
||||||
.setNeutralButton(R.string.common_cancel, null)
|
.setNegativeButton(R.string.common_cancel, null)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
|
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.list.context, builder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.list.context, builder)
|
||||||
|
@ -208,8 +210,8 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTemplateList(templateList: TemplateList?) {
|
fun setTemplateList(templateList: TemplateList?) {
|
||||||
adapter!!.setTemplateList(templateList)
|
adapter?.setTemplateList(templateList)
|
||||||
adapter!!.notifyDataSetChanged()
|
adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(template: Template) {
|
override fun onClick(template: Template) {
|
||||||
|
|
Loading…
Reference in a new issue