Dialogs and bottom sheet to Material 3 background

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-01 19:24:39 +02:00
parent 2f71a33c05
commit e3f305c804
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
9 changed files with 71 additions and 3 deletions

View file

@ -26,23 +26,36 @@ import android.app.Activity
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import autodagger.AutoInjector
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.ChatController
import com.nextcloud.talk.databinding.DialogAttachmentBinding
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class AttachmentDialog(val activity: Activity, var chatController: ChatController) : BottomSheetDialog(activity) {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var dialogAttachmentBinding: DialogAttachmentBinding
init {
NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dialogAttachmentBinding = DialogAttachmentBinding.inflate(layoutInflater)
setContentView(dialogAttachmentBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialog(dialogAttachmentBinding.root)
initItemsStrings()
initItemsVisibility()
initItemsClickListeners()

View file

@ -57,6 +57,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
setContentView(dialogAudioOutputBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialogDark(dialogAudioOutputBinding.root)
updateOutputDeviceList()
initClickListeners()
}

View file

@ -35,6 +35,8 @@ import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController
import com.nextcloud.talk.databinding.DialogBottomContactsBinding
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ContactsBottomDialog(
@ -42,6 +44,9 @@ class ContactsBottomDialog(
val bundle: Bundle
) : BottomSheetDialog(activity) {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private var dialogRouter: Router? = null
private lateinit var binding: DialogBottomContactsBinding
@ -56,6 +61,7 @@ class ContactsBottomDialog(
setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialog(binding.root)
executeEntryMenuController(bundle)
}

View file

@ -56,6 +56,7 @@ import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.DialogConversationOperationsBinding
import com.nextcloud.talk.jobs.LeaveConversationWorker
import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.Mimetype.TEXT_PLAIN
import com.nextcloud.talk.utils.ShareUtils
@ -82,6 +83,9 @@ class ConversationsListBottomDialog(
@Inject
lateinit var ncApi: NcApi
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@Inject
lateinit var userManager: UserManager
@ -95,6 +99,7 @@ class ConversationsListBottomDialog(
setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialog(binding.root)
initHeaderDescription()
initItemsVisibility()
initClickListeners()

View file

@ -32,17 +32,20 @@ import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.annotation.NonNull
import androidx.appcompat.content.res.AppCompatResources
import autodagger.AutoInjector
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.BuildConfig
import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.ChatController
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.DialogMessageActionsBinding
import com.nextcloud.talk.models.json.chat.ChatMessage
import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.vanniktech.emoji.EmojiPopup
@ -53,7 +56,9 @@ import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class MessageActionsDialog(
private val chatController: ChatController,
private val message: ChatMessage,
@ -64,16 +69,24 @@ class MessageActionsDialog(
private val ncApi: NcApi
) : BottomSheetDialog(chatController.activity!!) {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var dialogMessageActionsBinding: DialogMessageActionsBinding
private lateinit var popup: EmojiPopup
init {
NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dialogMessageActionsBinding = DialogMessageActionsBinding.inflate(layoutInflater)
setContentView(dialogMessageActionsBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialog(dialogMessageActionsBinding.root)
initEmojiBar(hasChatPermission)
initMenuItemCopy(!message.isDeleted)
initMenuReplyToMessage(message.replyable && hasChatPermission)

View file

@ -26,13 +26,18 @@ import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import autodagger.AutoInjector
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.controllers.ProfileController
import com.nextcloud.talk.databinding.DialogScopeBinding
import com.nextcloud.talk.models.json.userprofile.Scope
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ScopeDialog(
con: Context,
private val userInfoAdapter: ProfileController.UserInfoAdapter,
@ -40,8 +45,15 @@ class ScopeDialog(
private val position: Int
) : BottomSheetDialog(con) {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var dialogScopeBinding: DialogScopeBinding
init {
NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dialogScopeBinding = DialogScopeBinding.inflate(layoutInflater)
@ -49,6 +61,8 @@ class ScopeDialog(
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.themeDialog(dialogScopeBinding.root)
if (field == ProfileController.Field.DISPLAYNAME || field == ProfileController.Field.EMAIL) {
dialogScopeBinding.scopePrivate.visibility = View.GONE
}

View file

@ -120,6 +120,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
* find all relevant UI elements and set their values.
*/
private void setupDialogElements() {
viewThemeUtils.themeDialog(binding.root);
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.cancel);
taggedViews = new View[12];

View file

@ -73,11 +73,13 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
/**
* Scheme for painting elements
*/
fun getScheme(context: Context): Scheme = when {
private fun getScheme(context: Context): Scheme = when {
isDarkMode(context) -> theme.darkScheme
else -> theme.lightScheme
}
private fun getSchemeDark(): Scheme = theme.darkScheme
/**
* Color for painting elements
*/
@ -94,6 +96,10 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
block(getScheme(view.context))
}
private fun withSchemeDark(block: (Scheme) -> Unit) {
block(getSchemeDark())
}
fun themeToolbar(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.setBackgroundColor(scheme.surface)
@ -144,6 +150,12 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
}
fun themeDialogDark(view: View) {
withSchemeDark { scheme ->
view.setBackgroundColor(scheme.surface)
}
}
fun themeDialogDivider(view: View) {
withScheme(view) { scheme ->
view.setBackgroundColor(scheme.surfaceVariant)

View file

@ -293,9 +293,12 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">
android:gravity="end"
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.button.MaterialButton
android:id="@+id/cancel"
style="@style/Button.Borderless"
android:layout_width="wrap_content"