migrate scope dialog to native view binding

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-11-10 23:06:56 +01:00
parent c680888dba
commit fd754f582b
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 15 additions and 8 deletions

View File

@ -2,7 +2,9 @@
* Nextcloud Talk application * Nextcloud Talk application
* *
* @author Marcel Hibbe * @author Marcel Hibbe
* @author Andy Scherzinger
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de> * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -2,7 +2,9 @@
* Nextcloud Talk application * Nextcloud Talk application
* *
* @author Tobias Kaminsky * @author Tobias Kaminsky
* @author Andy Scherzinger
* Copyright (C) 2021 Tobias Kaminsky <tobias.kaminsky@nextcloud.com> * Copyright (C) 2021 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,11 +26,11 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.controllers.ProfileController import com.nextcloud.talk.controllers.ProfileController
import com.nextcloud.talk.databinding.DialogScopeBinding
import com.nextcloud.talk.models.json.userprofile.Scope import com.nextcloud.talk.models.json.userprofile.Scope
class ScopeDialog( class ScopeDialog(
@ -38,33 +40,36 @@ class ScopeDialog(
private val position: Int private val position: Int
) : ) :
BottomSheetDialog(con) { BottomSheetDialog(con) {
private lateinit var dialogScopeBinding: DialogScopeBinding
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val view = layoutInflater.inflate(R.layout.dialog_scope, null) dialogScopeBinding = DialogScopeBinding.inflate(layoutInflater)
setContentView(view) setContentView(dialogScopeBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
if (field == ProfileController.Field.DISPLAYNAME || field == ProfileController.Field.EMAIL) { if (field == ProfileController.Field.DISPLAYNAME || field == ProfileController.Field.EMAIL) {
findViewById<LinearLayout>(R.id.scope_private)?.visibility = View.GONE dialogScopeBinding.scopePrivate.visibility = View.GONE
} }
findViewById<LinearLayout>(R.id.scope_private)?.setOnClickListener { dialogScopeBinding.scopePrivate.setOnClickListener {
userInfoAdapter.updateScope(position, Scope.PRIVATE) userInfoAdapter.updateScope(position, Scope.PRIVATE)
dismiss() dismiss()
} }
findViewById<LinearLayout>(R.id.scope_local)?.setOnClickListener { dialogScopeBinding.scopeLocal.setOnClickListener {
userInfoAdapter.updateScope(position, Scope.LOCAL) userInfoAdapter.updateScope(position, Scope.LOCAL)
dismiss() dismiss()
} }
findViewById<LinearLayout>(R.id.scope_federated)?.setOnClickListener { dialogScopeBinding.scopeFederated.setOnClickListener {
userInfoAdapter.updateScope(position, Scope.FEDERATED) userInfoAdapter.updateScope(position, Scope.FEDERATED)
dismiss() dismiss()
} }
findViewById<LinearLayout>(R.id.scope_published)?.setOnClickListener { dialogScopeBinding.scopePublished.setOnClickListener {
userInfoAdapter.updateScope(position, Scope.PUBLISHED) userInfoAdapter.updateScope(position, Scope.PUBLISHED)
dismiss() dismiss()
} }